OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 static_cast<int64_t>(pattern_len)) * | 424 static_cast<int64_t>(pattern_len)) * |
425 static_cast<int64_t>(matches) + | 425 static_cast<int64_t>(matches) + |
426 static_cast<int64_t>(subject_len); | 426 static_cast<int64_t>(subject_len); |
427 int result_len; | 427 int result_len; |
428 if (result_len_64 > static_cast<int64_t>(String::kMaxLength)) { | 428 if (result_len_64 > static_cast<int64_t>(String::kMaxLength)) { |
429 STATIC_ASSERT(String::kMaxLength < kMaxInt); | 429 STATIC_ASSERT(String::kMaxLength < kMaxInt); |
430 result_len = kMaxInt; // Provoke exception. | 430 result_len = kMaxInt; // Provoke exception. |
431 } else { | 431 } else { |
432 result_len = static_cast<int>(result_len_64); | 432 result_len = static_cast<int>(result_len_64); |
433 } | 433 } |
434 if (result_len == 0) { | |
435 return isolate->heap()->empty_string(); | |
436 } | |
437 | 434 |
438 int subject_pos = 0; | 435 int subject_pos = 0; |
439 int result_pos = 0; | 436 int result_pos = 0; |
440 | 437 |
441 MaybeHandle<SeqString> maybe_res; | 438 MaybeHandle<SeqString> maybe_res; |
442 if (ResultSeqString::kHasOneByteEncoding) { | 439 if (ResultSeqString::kHasOneByteEncoding) { |
443 maybe_res = isolate->factory()->NewRawOneByteString(result_len); | 440 maybe_res = isolate->factory()->NewRawOneByteString(result_len); |
444 } else { | 441 } else { |
445 maybe_res = isolate->factory()->NewRawTwoByteString(result_len); | 442 maybe_res = isolate->factory()->NewRawTwoByteString(result_len); |
446 } | 443 } |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 | 1678 |
1682 RUNTIME_FUNCTION(Runtime_IsRegExp) { | 1679 RUNTIME_FUNCTION(Runtime_IsRegExp) { |
1683 SealHandleScope shs(isolate); | 1680 SealHandleScope shs(isolate); |
1684 DCHECK_EQ(1, args.length()); | 1681 DCHECK_EQ(1, args.length()); |
1685 CONVERT_ARG_CHECKED(Object, obj, 0); | 1682 CONVERT_ARG_CHECKED(Object, obj, 0); |
1686 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1683 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
1687 } | 1684 } |
1688 | 1685 |
1689 } // namespace internal | 1686 } // namespace internal |
1690 } // namespace v8 | 1687 } // namespace v8 |
OLD | NEW |