Bug 1641469 part 4 - Add ICStub::getEnteredCount. r=iain
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 29 May 2020 02:32:57 +0000
changeset 532947 2a57e124f45d956cab265383d56c8466f3403e77
parent 532946 d9c90baa217a733a88d2cba1125175635ee144f4
child 532948 9c257fb7548dd9f4bbd2df8f05192f239c733e02
push id37460
push userbtara@mozilla.com
push dateFri, 29 May 2020 15:59:09 +0000
treeherdermozilla-central@60a406d3b53a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersiain
bugs1641469
milestone78.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 1641469 part 4 - Add ICStub::getEnteredCount. r=iain Calling this "enteredCount" didn't work: the compiler complains about enteredCount being defined in multiple base classes for the CacheIR stub classes. Depends on D77241 Differential Revision: https://phabricator.services.mozilla.com/D77242
js/src/jit/BaselineIC.cpp
js/src/jit/BaselineIC.h
js/src/jit/JitScript.cpp
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -594,16 +594,29 @@ bool ICStub::makesGCCalls() const {
       return toCacheIR_Monitored()->stubInfo()->makesGCCalls();
     case CacheIR_Updated:
       return toCacheIR_Updated()->stubInfo()->makesGCCalls();
     default:
       return NonCacheIRStubMakesGCCalls(kind());
   }
 }
 
+uint32_t ICStub::getEnteredCount() const {
+  switch (kind()) {
+    case CacheIR_Regular:
+      return toCacheIR_Regular()->enteredCount();
+    case CacheIR_Updated:
+      return toCacheIR_Updated()->enteredCount();
+    case CacheIR_Monitored:
+      return toCacheIR_Monitored()->enteredCount();
+    default:
+      return toFallbackStub()->enteredCount();
+  }
+}
+
 void ICStub::updateCode(JitCode* code) {
   // Write barrier on the old code.
   JitCode::writeBarrierPre(jitCode());
   stubCode_ = code->raw();
 }
 
 /* static */
 void ICStub::trace(JSTracer* trc) {
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -627,16 +627,20 @@ class ICStub {
     return offsetof(ICStub, stubCode_);
   }
 
   static inline size_t offsetOfExtra() { return offsetof(ICStub, extra_); }
 
   static bool NonCacheIRStubMakesGCCalls(Kind kind);
   bool makesGCCalls() const;
 
+  // Returns the number of times this stub has been entered. Must only be called
+  // on stubs that have an enteredCount_ field (CacheIR or fallback stubs).
+  uint32_t getEnteredCount() const;
+
   // Optimized stubs get purged on GC.  But some stubs can be active on the
   // stack during GC - specifically the ones that can make calls.  To ensure
   // that these do not get purged, all stubs that can make calls are allocated
   // in the fallback stub space.
   bool allocatedInFallbackSpace() const {
     MOZ_ASSERT(next());
     return makesGCCalls();
   }
--- a/js/src/jit/JitScript.cpp
+++ b/js/src/jit/JitScript.cpp
@@ -658,29 +658,21 @@ void JitScript::setIonScriptImpl(JSFreeO
     AddCellMemory(script, ionScript_->allocBytes(), MemoryUse::IonScript);
   }
 
   script->updateJitCodeRaw(fop->runtime());
 }
 
 #ifdef JS_STRUCTURED_SPEW
 static bool GetStubEnteredCount(ICStub* stub, uint32_t* count) {
-  switch (stub->kind()) {
-    case ICStub::CacheIR_Regular:
-      *count = stub->toCacheIR_Regular()->enteredCount();
-      return true;
-    case ICStub::CacheIR_Updated:
-      *count = stub->toCacheIR_Updated()->enteredCount();
-      return true;
-    case ICStub::CacheIR_Monitored:
-      *count = stub->toCacheIR_Monitored()->enteredCount();
-      return true;
-    default:
-      return false;
+  if (ICStub::IsCacheIRKind(stub->kind())) {
+    *count = stub->getEnteredCount();
+    return true;
   }
+  return false;
 }
 
 static bool HasEnteredCounters(ICEntry& entry) {
   ICStub* stub = entry.firstStub();
   while (stub && !stub->isFallback()) {
     uint32_t count;
     if (GetStubEnteredCount(stub, &count)) {
       return true;