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/regexp/jsregexp-inl.h" | 8 #include "src/regexp/jsregexp-inl.h" |
9 #include "src/string-builder.h" | 9 #include "src/string-builder.h" |
10 #include "src/string-search.h" | 10 #include "src/string-search.h" |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 | 718 |
719 | 719 |
720 // Copies Latin1 characters to the given fixed array looking up | 720 // Copies Latin1 characters to the given fixed array looking up |
721 // one-char strings in the cache. Gives up on the first char that is | 721 // one-char strings in the cache. Gives up on the first char that is |
722 // not in the cache and fills the remainder with smi zeros. Returns | 722 // not in the cache and fills the remainder with smi zeros. Returns |
723 // the length of the successfully copied prefix. | 723 // the length of the successfully copied prefix. |
724 static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars, | 724 static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars, |
725 FixedArray* elements, int length) { | 725 FixedArray* elements, int length) { |
726 DisallowHeapAllocation no_gc; | 726 DisallowHeapAllocation no_gc; |
727 FixedArray* one_byte_cache = heap->single_character_string_cache(); | 727 FixedArray* one_byte_cache = heap->single_character_string_cache(); |
728 Object* undefined = heap->undefined_value(); | |
729 int i; | 728 int i; |
730 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); | 729 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); |
731 for (i = 0; i < length; ++i) { | 730 for (i = 0; i < length; ++i) { |
732 Object* value = one_byte_cache->get(chars[i]); | 731 Object* value = one_byte_cache->get(chars[i]); |
733 if (value == undefined) break; | 732 if (value->IsUndefined(heap->isolate())) break; |
734 elements->set(i, value, mode); | 733 elements->set(i, value, mode); |
735 } | 734 } |
736 if (i < length) { | 735 if (i < length) { |
737 DCHECK(Smi::FromInt(0) == 0); | 736 DCHECK(Smi::FromInt(0) == 0); |
738 memset(elements->data_start() + i, 0, kPointerSize * (length - i)); | 737 memset(elements->data_start() + i, 0, kPointerSize * (length - i)); |
739 } | 738 } |
740 #ifdef DEBUG | 739 #ifdef DEBUG |
741 for (int j = 0; j < length; ++j) { | 740 for (int j = 0; j < length; ++j) { |
742 Object* element = elements->get(j); | 741 Object* element = elements->get(j); |
743 DCHECK(element == Smi::FromInt(0) || | 742 DCHECK(element == Smi::FromInt(0) || |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 SealHandleScope shs(isolate); | 1206 SealHandleScope shs(isolate); |
1208 DCHECK(args.length() == 2); | 1207 DCHECK(args.length() == 2); |
1209 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1208 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
1210 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1209 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
1211 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1210 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
1212 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1211 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
1213 } | 1212 } |
1214 | 1213 |
1215 } // namespace internal | 1214 } // namespace internal |
1216 } // namespace v8 | 1215 } // namespace v8 |
OLD | NEW |