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/regexp/jsregexp-inl.h" | 10 #include "src/regexp/jsregexp-inl.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 RUNTIME_ASSERT(array_length > 0); | 635 RUNTIME_ASSERT(array_length > 0); |
636 | 636 |
637 // Find total length of join result. | 637 // Find total length of join result. |
638 int string_length = 0; | 638 int string_length = 0; |
639 bool is_one_byte = separator->IsOneByteRepresentation(); | 639 bool is_one_byte = separator->IsOneByteRepresentation(); |
640 bool overflow = false; | 640 bool overflow = false; |
641 CONVERT_NUMBER_CHECKED(int, elements_length, Int32, elements_array->length()); | 641 CONVERT_NUMBER_CHECKED(int, elements_length, Int32, elements_array->length()); |
642 RUNTIME_ASSERT(elements_length <= elements_array->elements()->length()); | 642 RUNTIME_ASSERT(elements_length <= elements_array->elements()->length()); |
643 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. | 643 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. |
644 FixedArray* elements = FixedArray::cast(elements_array->elements()); | 644 FixedArray* elements = FixedArray::cast(elements_array->elements()); |
645 for (int i = 0; i < elements_length; i += 2) { | |
646 RUNTIME_ASSERT(elements->get(i)->IsNumber()); | |
647 CONVERT_NUMBER_CHECKED(uint32_t, position, Uint32, elements->get(i)); | |
648 RUNTIME_ASSERT(position < array_length); | |
649 RUNTIME_ASSERT(elements->get(i + 1)->IsString()); | |
650 } | |
651 | |
652 { | 645 { |
653 DisallowHeapAllocation no_gc; | 646 DisallowHeapAllocation no_gc; |
654 for (int i = 0; i < elements_length; i += 2) { | 647 for (int i = 0; i < elements_length; i += 2) { |
655 String* string = String::cast(elements->get(i + 1)); | 648 String* string = String::cast(elements->get(i + 1)); |
656 int length = string->length(); | 649 int length = string->length(); |
657 if (is_one_byte && !string->IsOneByteRepresentation()) { | 650 if (is_one_byte && !string->IsOneByteRepresentation()) { |
658 is_one_byte = false; | 651 is_one_byte = false; |
659 } | 652 } |
660 if (length > String::kMaxLength || | 653 if (length > String::kMaxLength || |
661 String::kMaxLength - length < string_length) { | 654 String::kMaxLength - length < string_length) { |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 SealHandleScope shs(isolate); | 1302 SealHandleScope shs(isolate); |
1310 DCHECK(args.length() == 2); | 1303 DCHECK(args.length() == 2); |
1311 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1304 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
1312 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1305 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
1313 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1306 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
1314 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1307 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
1315 } | 1308 } |
1316 | 1309 |
1317 } // namespace internal | 1310 } // namespace internal |
1318 } // namespace v8 | 1311 } // namespace v8 |
OLD | NEW |