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

Unified Diff: src/js/regexp.js

Issue 2337923002: [regexp] Merge exec implementations (Closed)
Patch Set: Created 4 years, 3 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/js/regexp.js
diff --git a/src/js/regexp.js b/src/js/regexp.js
index b9b096492b754095d41056f72e82411e49376e13..bde4c1fa2d3ce187f7b74c912a0b7576ff20d5e4 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -207,46 +207,6 @@ function RegExpSubclassExecJS(string) {
%FunctionRemovePrototype(RegExpSubclassExecJS);
-// Legacy implementation of RegExp.prototype.exec
-function RegExpExecJS(string) {
- if (!IS_REGEXP(this)) {
- throw %make_type_error(kIncompatibleMethodReceiver,
- 'RegExp.prototype.exec', this);
- }
-
- string = TO_STRING(string);
- var lastIndex = this.lastIndex;
-
- // Conversion is required by the ES2015 specification (RegExpBuiltinExec
- // algorithm, step 4) even if the value is discarded for non-global RegExps.
- var i = TO_LENGTH(lastIndex);
-
- var updateLastIndex = REGEXP_GLOBAL(this) || REGEXP_STICKY(this);
- if (updateLastIndex) {
- if (i < 0 || i > string.length) {
- this.lastIndex = 0;
- return null;
- }
- } else {
- i = 0;
- }
-
- // matchIndices is either null or the RegExpLastMatchInfo array.
- var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
-
- if (IS_NULL(matchIndices)) {
- this.lastIndex = 0;
- return null;
- }
-
- // Successful match.
- if (updateLastIndex) {
- this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
- }
- RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string);
-}
-
-
// ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S )
// Also takes an optional exec method in case our caller
// has already fetched exec.
@@ -261,7 +221,7 @@ function RegExpSubclassExec(regexp, string, exec) {
}
return result;
}
- return %_Call(RegExpExecJS, regexp, string);
+ return %_Call(RegExpSubclassExecJS, regexp, string);
}
%SetForceInlineFlag(RegExpSubclassExec);
« 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