Bug 1395927 - Part 3: Inline IsRegExpObject with HasClass. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 08 Sep 2017 16:41:03 +0200
changeset 429418 d84c57174485f540cd0d86e7dc449c47e92800c6
parent 429417 6665f8db3a80067abdcc9625ff40c606f570d9c6
child 429419 a3a57ed979fa3800c23824a198a804be305d7b7e
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1395927
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1395927 - Part 3: Inline IsRegExpObject with HasClass. r=jandem
js/src/jit/MCallOptimize.cpp
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -2195,32 +2195,42 @@ IonBuilder::inlineIsRegExpObject(CallInf
     MOZ_ASSERT(!callInfo.constructing());
     MOZ_ASSERT(callInfo.argc() == 1);
 
     if (getInlineReturnType() != MIRType::Boolean)
         return InliningStatus_NotInlined;
 
     MDefinition* arg = callInfo.getArg(0);
 
-    bool isRegExpObject;
+    bool isRegExpObjectKnown = false;
+    bool isRegExpObjectConstant;
     if (!arg->mightBeType(MIRType::Object)) {
-        isRegExpObject = false;
+        // NB: This case only happens when Phi-nodes flow into IsRegExpObject.
+        // IsRegExpObject itself will never be called with a non-Object value.
+        isRegExpObjectConstant = false;
+        isRegExpObjectKnown = true;
     } else {
         if (arg->type() != MIRType::Object)
             return InliningStatus_NotInlined;
 
         TemporaryTypeSet* types = arg->resultTypeSet();
         const Class* clasp = types ? types->getKnownClass(constraints()) : nullptr;
-        if (!clasp || clasp->isProxy())
-            return InliningStatus_NotInlined;
-
-        isRegExpObject = (clasp == &RegExpObject::class_);
+        if (clasp) {
+            isRegExpObjectConstant = (clasp == &RegExpObject::class_);
+            isRegExpObjectKnown = true;
+        }
     }
 
-    pushConstant(BooleanValue(isRegExpObject));
+    if (isRegExpObjectKnown) {
+        pushConstant(BooleanValue(isRegExpObjectConstant));
+    } else {
+        MHasClass* hasClass = MHasClass::New(alloc(), arg, &RegExpObject::class_);
+        current->add(hasClass);
+        current->push(hasClass);
+    }
 
     callInfo.setImplicitlyUsedUnchecked();
     return InliningStatus_Inlined;
 }
 
 IonBuilder::InliningResult
 IonBuilder::inlineRegExpPrototypeOptimizable(CallInfo& callInfo)
 {