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

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

Issue 2434983002: [regexp] Use consistent map checks for fast paths (Closed)
Patch Set: Unmark coerce-* tests as failing 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.h ('k') | src/runtime/runtime-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-utils.cc
diff --git a/src/regexp/regexp-utils.cc b/src/regexp/regexp-utils.cc
index 7f54cf97f932bab5fcf4258cee7685f25c5834b8..7309afa12176109e45b86cbcf5061544684478d8 100644
--- a/src/regexp/regexp-utils.cc
+++ b/src/regexp/regexp-utils.cc
@@ -136,13 +136,24 @@ Maybe<bool> RegExpUtils::IsRegExp(Isolate* isolate, Handle<Object> object) {
return Just(object->IsJSRegExp());
}
-bool RegExpUtils::IsBuiltinExec(Handle<Object> exec) {
- if (!exec->IsJSFunction()) return false;
+bool RegExpUtils::IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj) {
+ // TODO(ishell): Update this check once map changes for constant field
+ // tracking are landing.
- Code* code = Handle<JSFunction>::cast(exec)->code();
- if (code == nullptr) return false;
+ if (!obj->IsJSReceiver()) return false;
- return (code->builtin_index() == Builtins::kRegExpPrototypeExec);
+ JSReceiver* recv = JSReceiver::cast(*obj);
+
+ // Check the receiver's map.
+ Handle<JSFunction> regexp_function = isolate->regexp_function();
+ if (recv->map() != regexp_function->initial_map()) return false;
+
+ // Check the receiver's prototype's map.
+ Object* proto = recv->map()->prototype();
+ if (!proto->IsJSReceiver()) return false;
+
+ Handle<Map> initial_proto_initial_map = isolate->regexp_prototype_map();
+ return (JSReceiver::cast(proto)->map() == *initial_proto_initial_map);
}
int RegExpUtils::AdvanceStringIndex(Isolate* isolate, Handle<String> string,
« no previous file with comments | « src/regexp/regexp-utils.h ('k') | src/runtime/runtime-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698