Bug 1641469 part 1 - Add Baseline IC stubs at the front of the chain. r=iain
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 29 May 2020 02:32:56 +0000
changeset 532944 f9470da46b897ee82cedfac9566e2483e58b9a70
parent 532943 a8f7a2c1d5073d8d1e0904b941f44f6e51cf4e39
child 532945 0117bc73a8641b7cdb254f0b1bd14a4d388777d6
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 1 - Add Baseline IC stubs at the front of the chain. r=iain This helps Warp a lot because it will make it possible to use the enteredCount of old stubs to determine they're no longer being used, for example when an int32 stub gets replaced by a more generic int32-or-double stub. Performance is unaffected or improves slightly. This also removes a pointer from all fallback stubs and is easier to implement. Differential Revision: https://phabricator.services.mozilla.com/D77239
js/src/jit/BaselineIC.cpp
js/src/jit/BaselineIC.h
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -798,33 +798,22 @@ static void TryAttachStub(const char* na
       stub->state().trackNotAttached();
     }
   }
 }
 
 void ICFallbackStub::unlinkStub(Zone* zone, ICStub* prev, ICStub* stub) {
   MOZ_ASSERT(stub->next());
 
-  // If stub is the last optimized stub, update lastStubPtrAddr.
-  if (stub->next() == this) {
-    MOZ_ASSERT(lastStubPtrAddr_ == stub->addressOfNext());
-    if (prev) {
-      lastStubPtrAddr_ = prev->addressOfNext();
-    } else {
-      lastStubPtrAddr_ = icEntry()->addressOfFirstStub();
-    }
-    *lastStubPtrAddr_ = this;
+  if (prev) {
+    MOZ_ASSERT(prev->next() == stub);
+    prev->setNext(stub->next());
   } else {
-    if (prev) {
-      MOZ_ASSERT(prev->next() == stub);
-      prev->setNext(stub->next());
-    } else {
-      MOZ_ASSERT(icEntry()->firstStub() == stub);
-      icEntry()->setFirstStub(stub->next());
-    }
+    MOZ_ASSERT(icEntry()->firstStub() == stub);
+    icEntry()->setFirstStub(stub->next());
   }
 
   state_.trackUnlinkedStub();
 
   if (zone->needsIncrementalBarrier()) {
     // We are removing edges from ICStub to gcthings. Perform one final trace
     // of the stub for incremental GC, as it must know about those edges.
     stub->trace(zone->barrierTracer());
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -656,64 +656,50 @@ class ICFallbackStub : public ICStub {
   ICState state_;
 
   // Counts the number of times the stub was entered
   //
   // See Bug 1494473 comment 6 for a mechanism to handle overflow if overflow
   // becomes a concern.
   uint32_t enteredCount_;
 
-  // A pointer to the location stub pointer that needs to be
-  // changed to add a new "last" stub immediately before the fallback
-  // stub.  This'll start out pointing to the icEntry's "firstStub_"
-  // field, and as new stubs are added, it'll point to the current
-  // last stub's "next_" field.
-  ICStub** lastStubPtrAddr_;
-
   ICFallbackStub(Kind kind, TrampolinePtr stubCode)
       : ICStub(kind, ICStub::Fallback, stubCode.value),
         icEntry_(nullptr),
         state_(),
-        enteredCount_(0),
-        lastStubPtrAddr_(nullptr) {}
+        enteredCount_(0) {}
 
   ICFallbackStub(Kind kind, Trait trait, TrampolinePtr stubCode)
       : ICStub(kind, trait, stubCode.value),
         icEntry_(nullptr),
         state_(),
-        enteredCount_(0),
-        lastStubPtrAddr_(nullptr) {
+        enteredCount_(0) {
     MOZ_ASSERT(trait == ICStub::Fallback || trait == ICStub::MonitoredFallback);
   }
 
  public:
   inline ICEntry* icEntry() const { return icEntry_; }
 
   inline size_t numOptimizedStubs() const { return state_.numOptimizedStubs(); }
 
   ICState& state() { return state_; }
 
-  // The icEntry and lastStubPtrAddr_ fields can't be initialized when the stub
-  // is created since the stub is created at compile time, and we won't know the
-  // IC entry address until after compile when the JitScript is created.  This
-  // method allows these fields to be fixed up at that point.
+  // The icEntry_ field can't be initialized when the stub is created since we
+  // won't know the ICEntry address until we add the stub to JitScript. This
+  // method allows this field to be fixed up at that point.
   void fixupICEntry(ICEntry* icEntry) {
     MOZ_ASSERT(icEntry_ == nullptr);
-    MOZ_ASSERT(lastStubPtrAddr_ == nullptr);
     icEntry_ = icEntry;
-    lastStubPtrAddr_ = icEntry_->addressOfFirstStub();
   }
 
   // Add a new stub to the IC chain terminated by this fallback stub.
   void addNewStub(ICStub* stub) {
-    MOZ_ASSERT(*lastStubPtrAddr_ == this);
     MOZ_ASSERT(stub->next() == nullptr);
-    stub->setNext(this);
-    *lastStubPtrAddr_ = stub;
-    lastStubPtrAddr_ = stub->addressOfNext();
+    stub->setNext(icEntry_->firstStub());
+    icEntry_->setFirstStub(stub);
     state_.trackAttached();
   }
 
   ICStubConstIterator beginChainConst() const {
     return ICStubConstIterator(icEntry_->firstStub());
   }
 
   ICStubIterator beginChain() { return ICStubIterator(this); }