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

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

Issue 2440893003: [regexp] Extract implementation of RE.prototype.exec (Closed)
Patch Set: Rebase Created 4 years, 2 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 | no next file » | 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 a6dd9b93e28625ddd9472ec59d828d48dd138190..2b103d2c60f2ce6e507d3de987878735b3aeaf1d 100644
--- a/src/builtins/builtins-regexp.cc
+++ b/src/builtins/builtins-regexp.cc
@@ -323,29 +323,29 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate,
return result;
}
-} // namespace
-
// ES#sec-regexp.prototype.exec
// RegExp.prototype.exec ( string )
-void Builtins::Generate_RegExpPrototypeExec(CodeStubAssembler* a) {
+compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
+ compiler::Node* context,
+ compiler::Node* maybe_receiver,
+ compiler::Node* maybe_string) {
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Isolate* const isolate = a->isolate();
- Node* const receiver = a->Parameter(0);
- Node* const maybe_string = a->Parameter(1);
- Node* const context = a->Parameter(4);
-
Node* const null = a->NullConstant();
Node* const int_zero = a->IntPtrConstant(0);
Node* const smi_zero = a->SmiConstant(Smi::kZero);
- // Ensure {receiver} is a JSRegExp.
+ Variable var_result(a, MachineRepresentation::kTagged);
+ Label out(a);
+
+ // Ensure {maybe_receiver} is a JSRegExp.
Node* const regexp_map = a->ThrowIfNotInstanceType(
- context, receiver, JS_REGEXP_TYPE, "RegExp.prototype.exec");
- Node* const regexp = receiver;
+ context, maybe_receiver, JS_REGEXP_TYPE, "RegExp.prototype.exec");
+ Node* const regexp = maybe_receiver;
// Check whether the regexp instance is unmodified.
Node* const native_context = a->LoadNativeContext(context);
@@ -394,7 +394,8 @@ void Builtins::Generate_RegExpPrototypeExec(CodeStubAssembler* a) {
a->Bind(&if_isoob);
{
StoreLastIndex(a, context, has_initialmap, regexp, smi_zero);
- a->Return(null);
+ var_result.Bind(null);
+ a->Goto(&out);
}
}
@@ -429,7 +430,8 @@ void Builtins::Generate_RegExpPrototypeExec(CodeStubAssembler* a) {
a->Goto(&return_null);
a->Bind(&return_null);
- a->Return(null);
+ var_result.Bind(null);
+ a->Goto(&out);
}
Label construct_result(a);
@@ -449,9 +451,29 @@ void Builtins::Generate_RegExpPrototypeExec(CodeStubAssembler* a) {
{
Node* result = ConstructNewResultFromMatchInfo(isolate, a, context,
match_indices, string);
- a->Return(result);
+ var_result.Bind(result);
+ a->Goto(&out);
}
}
+
+ a->Bind(&out);
+ return var_result.value();
+}
+
+} // namespace
+
+// ES#sec-regexp.prototype.exec
+// RegExp.prototype.exec ( string )
+void Builtins::Generate_RegExpPrototypeExec(CodeStubAssembler* a) {
+ typedef compiler::Node Node;
+
+ Node* const maybe_receiver = a->Parameter(0);
+ Node* const maybe_string = a->Parameter(1);
+ Node* const context = a->Parameter(4);
+
+ Node* const result =
+ RegExpPrototypeExecInternal(a, context, maybe_receiver, maybe_string);
+ a->Return(result);
}
namespace {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698