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

Side by Side Diff: src/builtins/builtins-string.cc

Issue 2593593002: [builtins] Fix String.prototype.indexOf with negative positions (Closed)
Patch Set: Created 3 years, 12 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/string-indexof-1.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 #include "src/regexp/regexp-utils.h" 9 #include "src/regexp/regexp-utils.h"
10 10
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 search_string.Bind(arguments.AtIndex(0)); 899 search_string.Bind(arguments.AtIndex(0));
900 position.Bind(SmiConstant(0)); 900 position.Bind(SmiConstant(0));
901 Goto(&fast_path); 901 Goto(&fast_path);
902 } 902 }
903 Bind(&argc_2); 903 Bind(&argc_2);
904 { 904 {
905 Comment("2 Argument case"); 905 Comment("2 Argument case");
906 search_string.Bind(arguments.AtIndex(0)); 906 search_string.Bind(arguments.AtIndex(0));
907 position.Bind(arguments.AtIndex(1)); 907 position.Bind(arguments.AtIndex(1));
908 GotoUnless(TaggedIsSmi(position.value()), &call_runtime); 908 GotoUnless(TaggedIsSmi(position.value()), &call_runtime);
909 position.Bind(SmiMax(position.value(), SmiConstant(0)));
909 Goto(&fast_path); 910 Goto(&fast_path);
910 } 911 }
911 912
912 Bind(&fast_path); 913 Bind(&fast_path);
913 { 914 {
914 Comment("Fast Path"); 915 Comment("Fast Path");
915 Label zero_length_needle(this); 916 Label zero_length_needle(this);
916 GotoIf(TaggedIsSmi(receiver), &call_runtime); 917 GotoIf(TaggedIsSmi(receiver), &call_runtime);
917 Node* needle = search_string.value(); 918 Node* needle = search_string.value();
918 GotoIf(TaggedIsSmi(needle), &call_runtime); 919 GotoIf(TaggedIsSmi(needle), &call_runtime);
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 Runtime::kThrowIncompatibleMethodReceiver, context, 1614 Runtime::kThrowIncompatibleMethodReceiver, context,
1614 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( 1615 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked(
1615 "String Iterator.prototype.next", TENURED)), 1616 "String Iterator.prototype.next", TENURED)),
1616 iterator); 1617 iterator);
1617 assembler.Return(result); // Never reached. 1618 assembler.Return(result); // Never reached.
1618 } 1619 }
1619 } 1620 }
1620 1621
1621 } // namespace internal 1622 } // namespace internal
1622 } // namespace v8 1623 } // namespace v8
OLDNEW
« 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