Bug 1443592: Part 3: Change LiveSavedFrameCache::find to take a FramePtr, not a FrameIter. r=fitzgen
authorJim Blandy <jimb@mozilla.com>
Tue, 06 Mar 2018 11:42:36 -0800
changeset 462170 269e77f6b1e5878062f9b4a5e12533cc20da01d0
parent 462169 1790490874a09b2da5731945e629e6b708ce9f5f
child 462171 3262afac47e8f293e20d9fac470b695c3e3d8836
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1443592
milestone60.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 1443592: Part 3: Change LiveSavedFrameCache::find to take a FramePtr, not a FrameIter. r=fitzgen This obviates dynamic checks in find about the state of the iterator, since they're covered by the fact that we were able to obtain a FramePtr at all. This does mean that we have to pass the pc separately. But that's symmetrical with the insert method, so it's okay. MozReview-Commit-ID: FgsDjHB2il4
js/src/vm/SavedStacks.cpp
js/src/vm/Stack.h
--- a/js/src/vm/SavedStacks.cpp
+++ b/js/src/vm/SavedStacks.cpp
@@ -98,27 +98,23 @@ LiveSavedFrameCache::insert(JSContext* c
     }
 
     framePtr.setHasCachedSavedFrame();
 
     return true;
 }
 
 void
-LiveSavedFrameCache::find(JSContext* cx, FrameIter& frameIter, MutableHandleSavedFrame frame) const
+LiveSavedFrameCache::find(JSContext* cx, FramePtr& framePtr, const jsbytecode* pc,
+                          MutableHandleSavedFrame frame) const
 {
     MOZ_ASSERT(initialized());
-    MOZ_ASSERT(!frameIter.done());
 
-    Maybe<FramePtr> maybeFramePtr = getFramePtr(frameIter);
-    MOZ_ASSERT(maybeFramePtr.isSome());
-    MOZ_ASSERT(maybeFramePtr->hasCachedSavedFrame());
-
-    Key key(*maybeFramePtr);
-    const jsbytecode* pc = frameIter.pc();
+    MOZ_ASSERT(framePtr.hasCachedSavedFrame());
+    Key key(framePtr);
     size_t numberStillValid = 0;
 
     frame.set(nullptr);
     for (auto* p = frames->begin(); p < frames->end(); p++) {
         numberStillValid++;
         if (key == p->key && pc == p->pc) {
             frame.set(p->savedFrame);
             break;
@@ -1414,17 +1410,17 @@ SavedStacks::insertFrames(JSContext* cx,
 
         if (parentIsInCache &&
             framePtr &&
             framePtr->hasCachedSavedFrame())
         {
             auto* cache = activation.getLiveSavedFrameCache(cx);
             if (!cache)
                 return false;
-            cache->find(cx, iter, &cachedFrame);
+            cache->find(cx, *framePtr, iter.pc(), &cachedFrame);
             if (cachedFrame)
                 break;
         }
 
         if (capture.is<JS::MaxFrames>())
             capture.as<JS::MaxFrames>().maxFrames--;
     }
 
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1250,17 +1250,18 @@ class LiveSavedFrameCache
             return false;
         }
         return true;
     }
 
     static mozilla::Maybe<FramePtr> getFramePtr(const FrameIter& iter);
     void trace(JSTracer* trc);
 
-    void find(JSContext* cx, FrameIter& frameIter, MutableHandleSavedFrame frame) const;
+    void find(JSContext* cx, FramePtr& frameptr, const jsbytecode* pc,
+              MutableHandleSavedFrame frame) const;
     bool insert(JSContext* cx, FramePtr& framePtr, const jsbytecode* pc,
                 HandleSavedFrame savedFrame);
 };
 
 static_assert(sizeof(LiveSavedFrameCache) == sizeof(uintptr_t),
               "Every js::Activation has a LiveSavedFrameCache, so we need to be pretty careful "
               "about avoiding bloat. If you're adding members to LiveSavedFrameCache, maybe you "
               "should consider figuring out a way to make js::Activation have a "