Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 2bf4fe3adb18548e05268298739152b3de1f29bf..942bbc1211bcc3ffa87c79424cafdfeb19cfc916 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -1977,6 +1977,26 @@ Object* GetSimpleHash(Object* object) { |
} // namespace |
+Maybe<bool> Object::IsRegExp(Isolate* isolate, Handle<Object> object) { |
+ if (!object->IsJSReceiver()) return Just(false); |
+ |
+ Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); |
+ |
+ if (isolate->regexp_function()->initial_map() == receiver->map()) { |
+ // Fast-path for unmodified JSRegExp instances. |
+ return Just(true); |
+ } |
+ |
+ Handle<Object> match; |
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
+ isolate, match, |
+ JSObject::GetProperty(receiver, isolate->factory()->match_symbol()), |
+ Nothing<bool>()); |
+ |
+ if (!match->IsUndefined(isolate)) return Just(match->BooleanValue()); |
+ return Just(object->IsJSRegExp()); |
+} |
+ |
Object* Object::GetHash() { |
Object* hash = GetSimpleHash(this); |
if (hash->IsSmi()) return hash; |