Bug 1551796 part 4 - Remove unnecessary hasJitScript() checks in BaselineInspector. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 23 May 2019 10:46:27 +0000
changeset 475185 71c4f7fd04f06c928a44738269bbd7615d110bd3
parent 475184 e81b72b586942a7a5c34fd5defd80772a031b45f
child 475186 53132931ba91cbd4a394734e32abbf387d6c6162
push id36057
push useraciure@mozilla.com
push dateThu, 23 May 2019 21:52:03 +0000
treeherdermozilla-central@d551d37b9ad0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1551796
milestone69.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 1551796 part 4 - Remove unnecessary hasJitScript() checks in BaselineInspector. r=tcampbell These have been unnecessary since the ICScript introduction: when performing the arguments analysis we have a JitScript but not a BaselineScript. Depends on D32103 Differential Revision: https://phabricator.services.mozilla.com/D32126
js/src/jit/BaselineInspector.cpp
js/src/jit/BaselineInspector.h
--- a/js/src/jit/BaselineInspector.cpp
+++ b/js/src/jit/BaselineInspector.cpp
@@ -134,17 +134,16 @@ JitScript* BaselineInspector::jitScript(
 
 ICEntry& BaselineInspector::icEntryFromPC(jsbytecode* pc) {
   ICEntry* entry = maybeICEntryFromPC(pc);
   MOZ_ASSERT(entry);
   return *entry;
 }
 
 ICEntry* BaselineInspector::maybeICEntryFromPC(jsbytecode* pc) {
-  MOZ_ASSERT(hasJitScript());
   MOZ_ASSERT(isValidPC(pc));
   ICEntry* ent = jitScript()->maybeICEntryFromPCOffset(script->pcToOffset(pc),
                                                        prevLookedUpEntry);
   if (!ent) {
     return nullptr;
   }
 
   MOZ_ASSERT(!ent->isForPrologue());
@@ -154,20 +153,16 @@ ICEntry* BaselineInspector::maybeICEntry
 
 bool BaselineInspector::maybeInfoForPropertyOp(jsbytecode* pc,
                                                ReceiverVector& receivers) {
   // Return a list of the receivers seen by the baseline IC for the current
   // op. Empty lists indicate no receivers are known, or there was an
   // uncacheable access.
   MOZ_ASSERT(receivers.empty());
 
-  if (!hasJitScript()) {
-    return true;
-  }
-
   MOZ_ASSERT(isValidPC(pc));
   const ICEntry& entry = icEntryFromPC(pc);
 
   ICStub* stub = entry.firstStub();
   while (stub->next()) {
     ReceiverGuard receiver;
     if (stub->isCacheIR_Monitored()) {
       if (!GetCacheIRReceiverForNativeReadSlot(stub->toCacheIR_Monitored(),
@@ -201,20 +196,16 @@ bool BaselineInspector::maybeInfoForProp
   if (receivers.length() > 5) {
     receivers.clear();
   }
 
   return true;
 }
 
 ICStub* BaselineInspector::monomorphicStub(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return nullptr;
-  }
-
   // IonBuilder::analyzeNewLoopTypes may call this (via expectedResultType
   // below) on code that's unreachable, according to BytecodeAnalysis. Use
   // maybeICEntryFromPC to handle this.
   const ICEntry* entry = maybeICEntryFromPC(pc);
   if (!entry) {
     return nullptr;
   }
 
@@ -225,20 +216,16 @@ ICStub* BaselineInspector::monomorphicSt
     return nullptr;
   }
 
   return stub;
 }
 
 bool BaselineInspector::dimorphicStub(jsbytecode* pc, ICStub** pfirst,
                                       ICStub** psecond) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
 
   ICStub* stub = entry.firstStub();
   ICStub* next = stub->next();
   ICStub* after = next ? next->next() : nullptr;
 
   if (!after || !after->isFallback()) {
     return false;
@@ -573,20 +560,16 @@ static bool TryToSpecializeBinaryArithOp
   }
 
   MOZ_ASSERT(sawInt32);
   *result = MIRType::Int32;
   return true;
 }
 
 MIRType BaselineInspector::expectedBinaryArithSpecialization(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return MIRType::None;
-  }
-
   MIRType result;
   ICStub* stubs[2];
 
   if (JSOp(*pc) == JSOP_POS) {
     // +x expanding to x*1, but no corresponding IC.
     return MIRType::None;
   }
 
@@ -608,61 +591,45 @@ MIRType BaselineInspector::expectedBinar
       return result;
     }
   }
 
   return MIRType::None;
 }
 
 bool BaselineInspector::hasSeenNonIntegerIndex(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   ICStub* stub = entry.fallbackStub();
 
   MOZ_ASSERT(stub->isGetElem_Fallback());
 
   return stub->toGetElem_Fallback()->sawNonIntegerIndex();
 }
 
 bool BaselineInspector::hasSeenNegativeIndexGetElement(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   ICStub* stub = entry.fallbackStub();
 
   if (stub->isGetElem_Fallback()) {
     return stub->toGetElem_Fallback()->hasNegativeIndex();
   }
   return false;
 }
 
 bool BaselineInspector::hasSeenAccessedGetter(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   ICStub* stub = entry.fallbackStub();
 
   if (stub->isGetProp_Fallback()) {
     return stub->toGetProp_Fallback()->hasAccessedGetter();
   }
   return false;
 }
 
 bool BaselineInspector::hasSeenDoubleResult(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   ICStub* stub = entry.fallbackStub();
 
   MOZ_ASSERT(stub->isUnaryArith_Fallback() || stub->isBinaryArith_Fallback());
 
   if (stub->isUnaryArith_Fallback()) {
     return stub->toUnaryArith_Fallback()->sawDoubleResult();
   }
@@ -718,20 +685,16 @@ JSObject* MaybeTemplateObject(ICStub* st
       argReader->metaKind<MetaTwoByteKind>() != kind ||
       !filter(*argReader, stubInfo)) {
     return nullptr;
   }
   return stubInfo->getStubField<JSObject*>(stub, argReader->stubOffset());
 }
 
 JSObject* BaselineInspector::getTemplateObject(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return nullptr;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   for (ICStub* stub = entry.firstStub(); stub; stub = stub->next()) {
     switch (stub->kind()) {
       case ICStub::NewArray_Fallback:
         return stub->toNewArray_Fallback()->templateObject();
       case ICStub::NewObject_Fallback:
         return stub->toNewObject_Fallback()->templateObject();
       case ICStub::Rest_Fallback:
@@ -758,40 +721,32 @@ JSObject* BaselineInspector::getTemplate
         break;
     }
   }
 
   return nullptr;
 }
 
 ObjectGroup* BaselineInspector::getTemplateObjectGroup(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return nullptr;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   for (ICStub* stub = entry.firstStub(); stub; stub = stub->next()) {
     switch (stub->kind()) {
       case ICStub::NewArray_Fallback:
         return stub->toNewArray_Fallback()->templateGroup();
       default:
         break;
     }
   }
 
   return nullptr;
 }
 
 JSFunction* BaselineInspector::getSingleCallee(jsbytecode* pc) {
   MOZ_ASSERT(*pc == JSOP_NEW);
 
-  if (!hasJitScript()) {
-    return nullptr;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   ICStub* stub = entry.firstStub();
 
   if (entry.fallbackStub()->state().hasFailures()) {
     return nullptr;
   }
 
   if (stub->next() != entry.fallbackStub()) {
@@ -813,20 +768,16 @@ JSFunction* BaselineInspector::getSingle
     // The callee is the first stub field in a ScriptedTemplateObject meta op.
     return stubInfo->getStubField<JSFunction*>(stub, argReader->stubOffset());
   }
   return nullptr;
 }
 
 JSObject* BaselineInspector::getTemplateObjectForNative(jsbytecode* pc,
                                                         Native native) {
-  if (!hasJitScript()) {
-    return nullptr;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   for (ICStub* stub = entry.firstStub(); stub; stub = stub->next()) {
     if (stub->isCall_Native() &&
         stub->toCall_Native()->callee()->native() == native) {
       return stub->toCall_Native()->templateObject();
     }
     if (ICStub::IsCacheIRKind(stub->kind())) {
       auto filter = [stub, native](CacheIRReader& reader,
@@ -843,20 +794,16 @@ JSObject* BaselineInspector::getTemplate
     }
   }
 
   return nullptr;
 }
 
 JSObject* BaselineInspector::getTemplateObjectForClassHook(jsbytecode* pc,
                                                            const Class* clasp) {
-  if (!hasJitScript()) {
-    return nullptr;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   for (ICStub* stub = entry.firstStub(); stub; stub = stub->next()) {
     if (stub->isCall_ClassHook() &&
         stub->toCall_ClassHook()->clasp() == clasp) {
       return stub->toCall_ClassHook()->templateObject();
     }
     if (ICStub::IsCacheIRKind(stub->kind())) {
       auto filter = [stub, clasp](CacheIRReader& args,
@@ -1202,20 +1149,16 @@ static bool AddCacheIRGetPropFunction(
   *isOwnProperty = false;
   return true;
 }
 
 bool BaselineInspector::commonGetPropFunction(
     jsbytecode* pc, jsid id, bool innerized, JSObject** holder,
     Shape** holderShape, JSFunction** commonGetter, Shape** globalShape,
     bool* isOwnProperty, ReceiverVector& receivers) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   MOZ_ASSERT(IsGetPropPC(pc) || IsGetElemPC(pc) || JSOp(*pc) == JSOP_GETGNAME);
   MOZ_ASSERT(receivers.empty());
 
   // Only GetElem operations need to guard against a specific property id.
   if (!IsGetElemPC(pc)) {
     id = JSID_EMPTY;
   }
 
@@ -1284,20 +1227,16 @@ static JSFunction* GetMegamorphicGetterS
 
   JSObject* obj =
       isGetter ? propShape->getterObject() : propShape->setterObject();
   return &obj->as<JSFunction>();
 }
 
 bool BaselineInspector::megamorphicGetterSetterFunction(
     jsbytecode* pc, jsid id, bool isGetter, JSFunction** getterOrSetter) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   MOZ_ASSERT(IsGetPropPC(pc) || IsGetElemPC(pc) || IsSetPropPC(pc) ||
              JSOp(*pc) == JSOP_GETGNAME || JSOp(*pc) == JSOP_INITGLEXICAL ||
              JSOp(*pc) == JSOP_INITPROP || JSOp(*pc) == JSOP_INITLOCKEDPROP ||
              JSOp(*pc) == JSOP_INITHIDDENPROP);
 
   // Only GetElem operations need to guard against a specific property id.
   if (!IsGetElemPC(pc)) {
     id = JSID_EMPTY;
@@ -1449,20 +1388,16 @@ static bool AddCacheIRSetPropFunction(
   return true;
 }
 
 bool BaselineInspector::commonSetPropFunction(jsbytecode* pc, JSObject** holder,
                                               Shape** holderShape,
                                               JSFunction** commonSetter,
                                               bool* isOwnProperty,
                                               ReceiverVector& receivers) {
-  if (!hasJitScript()) {
-    return false;
-  }
-
   MOZ_ASSERT(IsSetPropPC(pc) || JSOp(*pc) == JSOP_INITGLEXICAL ||
              JSOp(*pc) == JSOP_INITPROP || JSOp(*pc) == JSOP_INITLOCKEDPROP ||
              JSOp(*pc) == JSOP_INITHIDDENPROP);
   MOZ_ASSERT(receivers.empty());
 
   *commonSetter = nullptr;
   const ICEntry& entry = icEntryFromPC(pc);
 
@@ -1549,20 +1484,16 @@ bool BaselineInspector::maybeInfoForProt
                                                   ReceiverVector& receivers,
                                                   JSObject** holder) {
   // This is like maybeInfoForPropertyOp, but for when the property exists on
   // the prototype.
 
   MOZ_ASSERT(receivers.empty());
   MOZ_ASSERT(!*holder);
 
-  if (!hasJitScript()) {
-    return true;
-  }
-
   MOZ_ASSERT(isValidPC(pc));
   const ICEntry& entry = icEntryFromPC(pc);
 
   ICStub* stub = entry.firstStub();
   while (stub->next()) {
     ReceiverGuard receiver;
     if (stub->isCacheIR_Monitored()) {
       if (!GetCacheIRReceiverForProtoReadSlot(stub->toCacheIR_Monitored(),
@@ -1612,20 +1543,16 @@ static MIRType GetCacheIRExpectedInputTy
     return MIRTypeFromValueType(JSValueType(type));
   }
 
   MOZ_ASSERT_UNREACHABLE("Unexpected instruction");
   return MIRType::Value;
 }
 
 MIRType BaselineInspector::expectedPropertyAccessInputType(jsbytecode* pc) {
-  if (!hasJitScript()) {
-    return MIRType::Value;
-  }
-
   const ICEntry& entry = icEntryFromPC(pc);
   MIRType type = MIRType::None;
 
   for (ICStub* stub = entry.firstStub(); stub; stub = stub->next()) {
     MIRType stubType = MIRType::None;
     if (stub->isCacheIR_Monitored()) {
       stubType = GetCacheIRExpectedInputType(stub->toCacheIR_Monitored());
       if (stubType == MIRType::Value) {
@@ -1651,19 +1578,16 @@ MIRType BaselineInspector::expectedPrope
 
   return (type == MIRType::None) ? MIRType::Value : type;
 }
 
 bool BaselineInspector::instanceOfData(jsbytecode* pc, Shape** shape,
                                        uint32_t* slot,
                                        JSObject** prototypeObject) {
   MOZ_ASSERT(*pc == JSOP_INSTANCEOF);
-  if (!hasJitScript()) {
-    return false;
-  }
 
   const ICEntry& entry = icEntryFromPC(pc);
   ICStub* firstStub = entry.firstStub();
 
   // Ensure singleton instanceof stub
   if (!firstStub->next() || !firstStub->isCacheIR_Regular() ||
       !firstStub->next()->isInstanceOf_Fallback() ||
       firstStub->next()->toInstanceOf_Fallback()->state().hasFailures()) {
--- a/js/src/jit/BaselineInspector.h
+++ b/js/src/jit/BaselineInspector.h
@@ -42,36 +42,31 @@ class BaselineInspector {
   ICEntry* prevLookedUpEntry;
 
  public:
   explicit BaselineInspector(JSScript* script)
       : script(script), prevLookedUpEntry(nullptr) {
     MOZ_ASSERT(script);
   }
 
-  bool hasJitScript() const { return script->hasJitScript(); }
-
   JitScript* jitScript() const;
 
  private:
 #ifdef DEBUG
   bool isValidPC(jsbytecode* pc) { return script->containsPC(pc); }
 #endif
 
   ICEntry& icEntryFromPC(jsbytecode* pc);
   ICEntry* maybeICEntryFromPC(jsbytecode* pc);
 
   template <typename ICInspectorType>
   ICInspectorType makeICInspector(jsbytecode* pc,
                                   ICStub::Kind expectedFallbackKind) {
-    ICEntry* ent = nullptr;
-    if (hasJitScript()) {
-      ent = &icEntryFromPC(pc);
-      MOZ_ASSERT(ent->fallbackStub()->kind() == expectedFallbackKind);
-    }
+    ICEntry* ent = &icEntryFromPC(pc);
+    MOZ_ASSERT(ent->fallbackStub()->kind() == expectedFallbackKind);
     return ICInspectorType(this, pc, ent);
   }
 
   ICStub* monomorphicStub(jsbytecode* pc);
   MOZ_MUST_USE bool dimorphicStub(jsbytecode* pc, ICStub** pfirst,
                                   ICStub** psecond);
 
  public: