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

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

Issue 2438283002: Revert of [regexp] Use consistent map checks for fast paths (Closed)
Patch Set: 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 | « src/regexp/regexp-utils.cc ('k') | test/mjsunit/es6/regexp-flags.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-regexp.cc
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
index 97f46736f3b9b60ade191968f2e1f33c6134c61e..94a4936b9f1925de03d33c53c58f9b688ac5e6c7 100644
--- a/src/runtime/runtime-regexp.cc
+++ b/src/runtime/runtime-regexp.cc
@@ -1500,13 +1500,6 @@
string = String::Flatten(string);
- // Fast-path for unmodified JSRegExps.
- if (RegExpUtils::IsUnmodifiedRegExp(isolate, recv)) {
- RETURN_RESULT_OR_FAILURE(
- isolate, RegExpReplace(isolate, Handle<JSRegExp>::cast(recv), string,
- replace_obj));
- }
-
const int length = string->length();
const bool functional_replace = replace_obj->IsCallable();
@@ -1534,14 +1527,35 @@
RegExpUtils::SetLastIndex(isolate, recv, 0));
}
+ // TODO(jgruber): Here and at all other fast path checks, rely on map checks
+ // instead.
+ // TODO(jgruber): We could speed up the fast path by checking flags
+ // afterwards, but that would violate the spec (which states that exec is
+ // accessed after global and unicode).
+ // TODO(adamk): this fast path is wrong as we doesn't ensure that 'exec'
+ // is actually a data property on RegExp.prototype.
+ Handle<Object> exec = factory->undefined_value();
+ if (recv->IsJSRegExp()) {
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, exec, JSObject::GetProperty(
+ recv, factory->NewStringFromAsciiChecked("exec")));
+ if (RegExpUtils::IsBuiltinExec(exec)) {
+ RETURN_RESULT_OR_FAILURE(
+ isolate, RegExpReplace(isolate, Handle<JSRegExp>::cast(recv), string,
+ replace_obj));
+ }
+ }
+
Zone zone(isolate->allocator(), ZONE_NAME);
ZoneVector<Handle<Object>> results(&zone);
while (true) {
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, RegExpUtils::RegExpExec(isolate, recv, string,
- factory->undefined_value()));
+ isolate, result, RegExpUtils::RegExpExec(isolate, recv, string, exec));
+
+ // Ensure exec will be read again on the next loop through.
+ exec = factory->undefined_value();
if (result->IsNull(isolate)) break;
« no previous file with comments | « src/regexp/regexp-utils.cc ('k') | test/mjsunit/es6/regexp-flags.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698