| 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,
|
|
|