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

Unified Diff: src/builtins/builtins-array.cc

Issue 2756663002: [csa] Bailout to the runtime for ToInteger conversion in Array.p.indexOf. (Closed)
Patch Set: Also fix FastDoubleElementsAccessor::IndexOfValueImpl 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 | src/elements.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-array.cc
diff --git a/src/builtins/builtins-array.cc b/src/builtins/builtins-array.cc
index 3537b4243572f1805de8d7c5197d88ac6c2ff084..fd2f2d835e2b8708e01408ee1c26bae56df4d4c8 100644
--- a/src/builtins/builtins-array.cc
+++ b/src/builtins/builtins-array.cc
@@ -2048,33 +2048,28 @@ TF_BUILTIN(ArrayIndexOf, CodeStubAssembler) {
Bind(&init_k);
{
- Label done(this), init_k_smi(this), init_k_heap_num(this),
- init_k_zero(this), init_k_n(this);
- Node* tagged_n = ToInteger(context, start_from);
-
- Branch(TaggedIsSmi(tagged_n), &init_k_smi, &init_k_heap_num);
+ // For now only deal with undefined and Smis here; we must be really careful
+ // with side-effects from the ToInteger conversion as the side-effects might
+ // render our assumptions about the receiver being a fast JSArray and the
+ // length invalid.
+ Label done(this), init_k_smi(this), init_k_other(this), init_k_zero(this),
+ init_k_n(this);
+ Branch(TaggedIsSmi(start_from), &init_k_smi, &init_k_other);
Bind(&init_k_smi);
{
- start_from_var.Bind(SmiUntag(tagged_n));
+ // The fromIndex is a Smi.
+ start_from_var.Bind(SmiUntag(start_from));
Goto(&init_k_n);
}
- Bind(&init_k_heap_num);
+ Bind(&init_k_other);
{
- Label do_return_not_found(this);
- // This round is lossless for all valid lengths.
- Node* fp_len = RoundIntPtrToFloat64(len_var.value());
- Node* fp_n = LoadHeapNumberValue(tagged_n);
- GotoIf(Float64GreaterThanOrEqual(fp_n, fp_len), &do_return_not_found);
- start_from_var.Bind(ChangeInt32ToIntPtr(TruncateFloat64ToWord32(fp_n)));
+ // The fromIndex must be undefined then, otherwise bailout and let the
+ // runtime deal with the full ToInteger conversion.
+ GotoIfNot(IsUndefined(start_from), &call_runtime);
+ start_from_var.Bind(intptr_zero);
Goto(&init_k_n);
-
- Bind(&do_return_not_found);
- {
- index_var.Bind(intptr_zero);
- Goto(&return_not_found);
- }
}
Bind(&init_k_n);
« no previous file with comments | « no previous file | src/elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698