Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: src/elements.cc

Issue 2769673002: Move Oddball/String to %Typearray%.prototype.fill fast path (Closed)
Patch Set: beautify test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/typedarray-fill.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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->IsUndefined(isolate)) {
2875 value =
2876 BackingStore::from_double(std::numeric_limits<double>::quiet_NaN());
Camillo Bruni 2017/03/23 10:56:43 I just realized that we do already have a number c
rongjie 2017/03/23 12:39:14 Done.
2877 } else if (heap_obj_value->IsNull(isolate)) {
2878 value = static_cast<ctype>(+0.0);
2879 } else if (heap_obj_value->IsBoolean()) {
2880 value = static_cast<ctype>(heap_obj_value->IsTrue(isolate));
2881 } else {
2882 return FillNumberSlowPath(isolate, array, obj_value, start, end);
2883 }
2876 } 2884 }
2877 2885
2878 // Ensure indexes are within array bounds 2886 // Ensure indexes are within array bounds
2879 DCHECK_LE(0, start); 2887 DCHECK_LE(0, start);
2880 DCHECK_LE(start, end); 2888 DCHECK_LE(start, end);
2881 DCHECK_LE(end, array->length_value()); 2889 DCHECK_LE(end, array->length_value());
2882 2890
2883 DisallowHeapAllocation no_gc; 2891 DisallowHeapAllocation no_gc;
2884 BackingStore* elements = BackingStore::cast(receiver->elements()); 2892 BackingStore* elements = BackingStore::cast(receiver->elements());
2885 ctype* data = static_cast<ctype*>(elements->DataPtr()); 2893 ctype* data = static_cast<ctype*>(elements->DataPtr());
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 insertion_index += len; 3984 insertion_index += len;
3977 } 3985 }
3978 3986
3979 DCHECK_EQ(insertion_index, result_len); 3987 DCHECK_EQ(insertion_index, result_len);
3980 return result_array; 3988 return result_array;
3981 } 3989 }
3982 3990
3983 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3991 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3984 } // namespace internal 3992 } // namespace internal
3985 } // namespace v8 3993 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/typedarray-fill.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698