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

Unified Diff: src/code-stub-assembler.cc

Issue 2496323002: [builtins] Take fast path in Array.prototype.keys() only if length is an Smi (Closed)
Patch Set: Created 4 years, 1 month 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/regress/regress-660925.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 766d331333bd837b614f0a7429fadb990985d08e..66354e6e9641f191b9cf1ecacac0de1ab8f4e20e 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -8850,20 +8850,31 @@ compiler::Node* CodeStubAssembler::CreateArrayIterator(
// There are only two key iterator maps, branch depending on whether or not
// the receiver is a TypedArray or not.
- Label if_isarray(this), if_istypedarray(this), if_isgeneric(this);
- Label* kInstanceTypeHandlers[] = {&if_isarray, &if_istypedarray};
-
- static int32_t kInstanceType[] = {JS_ARRAY_TYPE, JS_TYPED_ARRAY_TYPE};
+ Label if_istypedarray(this), if_isgeneric(this);
- Switch(array_type, &if_isgeneric, kInstanceType, kInstanceTypeHandlers,
- arraysize(kInstanceType));
+ Branch(Word32Equal(array_type, Int32Constant(JS_TYPED_ARRAY_TYPE)),
+ &if_istypedarray, &if_isgeneric);
- Bind(&if_isarray);
+ Bind(&if_isgeneric);
{
- var_map_index.Bind(
- IntPtrConstant(Context::FAST_ARRAY_KEY_ITERATOR_MAP_INDEX));
- var_array_map.Bind(array_map);
- Goto(&allocate_iterator);
+ Label if_isfast(this), if_isslow(this);
+ BranchIfFastJSArray(array, context, &if_isfast, &if_isslow);
+
+ Bind(&if_isfast);
+ {
+ var_map_index.Bind(
+ IntPtrConstant(Context::FAST_ARRAY_KEY_ITERATOR_MAP_INDEX));
+ var_array_map.Bind(array_map);
+ Goto(&allocate_iterator);
+ }
+
+ Bind(&if_isslow);
+ {
+ var_map_index.Bind(
+ IntPtrConstant(Context::GENERIC_ARRAY_KEY_ITERATOR_MAP_INDEX));
+ var_array_map.Bind(UndefinedConstant());
+ Goto(&allocate_iterator);
+ }
}
Bind(&if_istypedarray);
@@ -8873,14 +8884,6 @@ compiler::Node* CodeStubAssembler::CreateArrayIterator(
var_array_map.Bind(UndefinedConstant());
Goto(&allocate_iterator);
}
-
- Bind(&if_isgeneric);
- {
- var_map_index.Bind(
- IntPtrConstant(Context::GENERIC_ARRAY_KEY_ITERATOR_MAP_INDEX));
- var_array_map.Bind(UndefinedConstant());
- Goto(&allocate_iterator);
- }
} else {
Label if_istypedarray(this), if_isgeneric(this);
Branch(Word32Equal(array_type, Int32Constant(JS_TYPED_ARRAY_TYPE)),
« no previous file with comments | « no previous file | test/mjsunit/es6/regress/regress-660925.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698