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

Side by Side Diff: src/elements.cc

Issue 2769673002: Move Oddball/String to %Typearray%.prototype.fill fast path (Closed)
Patch Set: 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') | test/mjsunit/es6/typedarray-fill.js » ('J')
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()) {
2867 return FillNumberSlowPath(isolate, array, obj_value, start, end);
2868 }
2869
2870 ctype value = 0; 2866 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());
2869 } else if (obj_value->IsHeapNumber()) {
caitp 2017/03/22 13:11:42 Oh nvm, I thought we had a fast path in CSA. This
Camillo Bruni 2017/03/22 21:26:50 Given that we now perform additional checks, let's
rongjie 2017/03/23 00:01:49 Done.
2870 value = BackingStore::from_double(HeapNumber::cast(*obj_value)->value());
2871 } else if (obj_value->IsUndefined(isolate)) {
2872 value =
2873 BackingStore::from_double(std::numeric_limits<double>::quiet_NaN());
2874 } else if (obj_value->IsNull(isolate)) {
2875 value = static_cast<ctype>(+0.0);
2876 } else if (obj_value->IsBoolean()) {
2877 value = static_cast<ctype>(obj_value->IsTrue(isolate));
2873 } else { 2878 } else {
2874 DCHECK(obj_value->IsHeapNumber()); 2879 return FillNumberSlowPath(isolate, array, obj_value, start, end);
2875 value = BackingStore::from_double(HeapNumber::cast(*obj_value)->value());
2876 } 2880 }
2877 2881
2878 // Ensure indexes are within array bounds 2882 // Ensure indexes are within array bounds
2879 DCHECK_LE(0, start); 2883 DCHECK_LE(0, start);
2880 DCHECK_LE(start, end); 2884 DCHECK_LE(start, end);
2881 DCHECK_LE(end, array->length_value()); 2885 DCHECK_LE(end, array->length_value());
2882 2886
2883 DisallowHeapAllocation no_gc; 2887 DisallowHeapAllocation no_gc;
2884 BackingStore* elements = BackingStore::cast(receiver->elements()); 2888 BackingStore* elements = BackingStore::cast(receiver->elements());
2885 ctype* data = static_cast<ctype*>(elements->DataPtr()); 2889 ctype* data = static_cast<ctype*>(elements->DataPtr());
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 insertion_index += len; 3980 insertion_index += len;
3977 } 3981 }
3978 3982
3979 DCHECK_EQ(insertion_index, result_len); 3983 DCHECK_EQ(insertion_index, result_len);
3980 return result_array; 3984 return result_array;
3981 } 3985 }
3982 3986
3983 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3987 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3984 } // namespace internal 3988 } // namespace internal
3985 } // namespace v8 3989 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/typedarray-fill.js » ('j') | test/mjsunit/es6/typedarray-fill.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698