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

Unified Diff: src/objects.cc

Issue 2399423003: [builtins] Move StringIncludes to a builtin. (Closed)
Patch Set: Add another test. Re-use IsRegExp logic 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/objects.h ('k') | test/mjsunit/es6/string-includes.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/es6/string-includes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698