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

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

Issue 2679173002: [builtins] fix String.prototype.indexOf with negative indices (Closed)
Patch Set: fix accidental change Created 3 years, 10 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/string-indexof-1.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-string.cc
diff --git a/src/builtins/builtins-string.cc b/src/builtins/builtins-string.cc
index 9ebd7cf0a79b3d5559407adf336ba6ae2de0905b..20ad423b144a5e0a12db3d9dc71a35d7cba2a547 100644
--- a/src/builtins/builtins-string.cc
+++ b/src/builtins/builtins-string.cc
@@ -832,7 +832,7 @@ void StringBuiltinsAssembler::StringIndexOf(
GotoIf(IntPtrLessThan(IntPtrConstant(1), needle_length),
&call_runtime_unchecked);
Node* string_length = SmiUntag(LoadStringLength(receiver));
- Node* start_position = SmiUntag(position);
+ Node* start_position = IntPtrMax(SmiUntag(position), IntPtrConstant(0));
GotoIf(IntPtrEqual(IntPtrConstant(0), needle_length), &zero_length_needle);
// Check that the needle fits in the start position.
@@ -940,7 +940,6 @@ TF_BUILTIN(StringPrototypeIndexOf, StringBuiltinsAssembler) {
search_string.Bind(arguments.AtIndex(0));
position.Bind(arguments.AtIndex(1));
GotoUnless(TaggedIsSmi(position.value()), &call_runtime);
- position.Bind(SmiMax(position.value(), SmiConstant(0)));
Goto(&fast_path);
}
« no previous file with comments | « no previous file | test/mjsunit/string-indexof-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698