OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/elements.h" | 5 #include "src/elements.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 2845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 *nof_items = count; | 2856 *nof_items = count; |
2857 return Just(true); | 2857 return Just(true); |
2858 } | 2858 } |
2859 | 2859 |
2860 static Object* FillImpl(Isolate* isolate, Handle<JSObject> receiver, | 2860 static Object* FillImpl(Isolate* isolate, Handle<JSObject> receiver, |
2861 Handle<Object> obj_value, uint32_t start, | 2861 Handle<Object> obj_value, uint32_t start, |
2862 uint32_t end) { | 2862 uint32_t end) { |
2863 Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver); | 2863 Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver); |
2864 DCHECK(!array->WasNeutered()); | 2864 DCHECK(!array->WasNeutered()); |
2865 | 2865 |
2866 if (!obj_value->IsNumber()) { | 2866 ctype value; |
2867 return FillNumberSlowPath(isolate, array, obj_value, start, end); | |
2868 } | |
2869 | |
2870 ctype value = 0; | |
2871 if (obj_value->IsSmi()) { | 2867 if (obj_value->IsSmi()) { |
2872 value = BackingStore::from_int(Smi::cast(*obj_value)->value()); | 2868 value = BackingStore::from_int(Smi::cast(*obj_value)->value()); |
2873 } else { | 2869 } else { |
2874 DCHECK(obj_value->IsHeapNumber()); | 2870 Handle<HeapObject> heap_obj_value = Handle<HeapObject>::cast(obj_value); |
2875 value = BackingStore::from_double(HeapNumber::cast(*obj_value)->value()); | 2871 if (heap_obj_value->IsHeapNumber()) { |
| 2872 value = BackingStore::from_double( |
| 2873 HeapNumber::cast(*heap_obj_value)->value()); |
| 2874 } else if (heap_obj_value->IsOddball()) { |
| 2875 value = BackingStore::from_double( |
| 2876 Oddball::ToNumber(Handle<Oddball>::cast(heap_obj_value))->Number()); |
| 2877 } else if (heap_obj_value->IsString()) { |
| 2878 value = BackingStore::from_double( |
| 2879 String::ToNumber(Handle<String>::cast(heap_obj_value))->Number()); |
| 2880 } else { |
| 2881 return FillNumberSlowPath(isolate, array, obj_value, start, end); |
| 2882 } |
2876 } | 2883 } |
2877 | 2884 |
2878 // Ensure indexes are within array bounds | 2885 // Ensure indexes are within array bounds |
2879 DCHECK_LE(0, start); | 2886 DCHECK_LE(0, start); |
2880 DCHECK_LE(start, end); | 2887 DCHECK_LE(start, end); |
2881 DCHECK_LE(end, array->length_value()); | 2888 DCHECK_LE(end, array->length_value()); |
2882 | 2889 |
2883 DisallowHeapAllocation no_gc; | 2890 DisallowHeapAllocation no_gc; |
2884 BackingStore* elements = BackingStore::cast(receiver->elements()); | 2891 BackingStore* elements = BackingStore::cast(receiver->elements()); |
2885 ctype* data = static_cast<ctype*>(elements->DataPtr()); | 2892 ctype* data = static_cast<ctype*>(elements->DataPtr()); |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3976 insertion_index += len; | 3983 insertion_index += len; |
3977 } | 3984 } |
3978 | 3985 |
3979 DCHECK_EQ(insertion_index, result_len); | 3986 DCHECK_EQ(insertion_index, result_len); |
3980 return result_array; | 3987 return result_array; |
3981 } | 3988 } |
3982 | 3989 |
3983 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3990 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3984 } // namespace internal | 3991 } // namespace internal |
3985 } // namespace v8 | 3992 } // namespace v8 |
OLD | NEW |