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

Unified Diff: src/elements.cc

Issue 2769673002: Move Oddball/String to %Typearray%.prototype.fill fast path (Closed)
Patch Set: Oddball and String 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/typedarray-fill.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index a72158f7d2884584ef4ff50a23c49c193774c4f3..6258da399c6c7d1983e71a4e4cee87745b055353 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -2863,16 +2863,23 @@ class TypedElementsAccessor
Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
DCHECK(!array->WasNeutered());
- if (!obj_value->IsNumber()) {
- return FillNumberSlowPath(isolate, array, obj_value, start, end);
- }
-
- ctype value = 0;
+ ctype value;
if (obj_value->IsSmi()) {
value = BackingStore::from_int(Smi::cast(*obj_value)->value());
} else {
- DCHECK(obj_value->IsHeapNumber());
- value = BackingStore::from_double(HeapNumber::cast(*obj_value)->value());
+ Handle<HeapObject> heap_obj_value = Handle<HeapObject>::cast(obj_value);
+ if (heap_obj_value->IsHeapNumber()) {
+ value = BackingStore::from_double(
+ HeapNumber::cast(*heap_obj_value)->value());
+ } else if (heap_obj_value->IsOddball()) {
+ value = BackingStore::from_double(
+ Oddball::ToNumber(Handle<Oddball>::cast(heap_obj_value))->Number());
+ } else if (heap_obj_value->IsString()) {
+ value = BackingStore::from_double(
+ String::ToNumber(Handle<String>::cast(heap_obj_value))->Number());
+ } else {
+ return FillNumberSlowPath(isolate, array, obj_value, start, end);
+ }
}
// Ensure indexes are within array bounds
« 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