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

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

Issue 2681323002: [regexp] Update lastIndex semantics in RegExpBuiltinExec (Closed)
Patch Set: Update test262.status 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/regexp.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-regexp.cc
diff --git a/src/builtins/builtins-regexp.cc b/src/builtins/builtins-regexp.cc
index 4d8340d71ea3853d41bae497daf0b901d1cf36ed..2923cc2ba1a15b3a824b7b915c54d3c00af3f85d 100644
--- a/src/builtins/builtins-regexp.cc
+++ b/src/builtins/builtins-regexp.cc
@@ -241,6 +241,27 @@ Node* RegExpBuiltinsAssembler::RegExpPrototypeExecBodyWithoutResult(
Node* const native_context = LoadNativeContext(context);
Node* const string_length = LoadStringLength(string);
+ // Load lastIndex.
+ Variable var_lastindex(this, MachineRepresentation::kTagged);
+ {
+ Node* const regexp_lastindex = LoadLastIndex(context, regexp, is_fastpath);
+ var_lastindex.Bind(regexp_lastindex);
+
+ // Omit ToLength if lastindex is a non-negative smi.
+ Label call_tolength(this, Label::kDeferred), next(this);
+ Branch(TaggedIsPositiveSmi(regexp_lastindex), &next, &call_tolength);
+
+ Bind(&call_tolength);
+ {
+ Callable tolength_callable = CodeFactory::ToLength(isolate);
+ var_lastindex.Bind(
+ CallStub(tolength_callable, context, regexp_lastindex));
+ Goto(&next);
+ }
+
+ Bind(&next);
+ }
+
// Check whether the regexp is global or sticky, which determines whether we
// update last index later on.
Node* const flags = LoadObjectField(regexp, JSRegExp::kFlagsOffset);
@@ -251,33 +272,12 @@ Node* RegExpBuiltinsAssembler::RegExpPrototypeExecBodyWithoutResult(
// Grab and possibly update last index.
Label run_exec(this);
- Variable var_lastindex(this, MachineRepresentation::kTagged);
{
Label if_doupdate(this), if_dontupdate(this);
Branch(should_update_last_index, &if_doupdate, &if_dontupdate);
Bind(&if_doupdate);
{
- Node* const regexp_lastindex =
- LoadLastIndex(context, regexp, is_fastpath);
- var_lastindex.Bind(regexp_lastindex);
-
- // Omit ToLength if lastindex is a non-negative smi.
- {
- Label call_tolength(this, Label::kDeferred), next(this);
- Branch(TaggedIsPositiveSmi(regexp_lastindex), &next, &call_tolength);
-
- Bind(&call_tolength);
- {
- Callable tolength_callable = CodeFactory::ToLength(isolate);
- var_lastindex.Bind(
- CallStub(tolength_callable, context, regexp_lastindex));
- Goto(&next);
- }
-
- Bind(&next);
- }
-
Node* const lastindex = var_lastindex.value();
Label if_isoob(this, Label::kDeferred);
« no previous file with comments | « no previous file | test/mjsunit/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698