Bug 1444604 - Part 4: Construct FramePtrs from AbstractFramePtrs. r=jorendorff, a=RyanVM
authorJim Blandy <jimb@mozilla.com>
Thu, 15 Mar 2018 16:14:31 -0700
changeset 462980 4e8e98727140ceb78123bedbd5044b5ed0e20bd7
parent 462979 4518879e214025b16d6e57734c620f136119d246
child 462981 1e6efa9a8b0bc8397f27e21f804a3b074b78f45e
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)
reviewersjorendorff, RyanVM
bugs1444604
milestone60.0
Bug 1444604 - Part 4: Construct FramePtrs from AbstractFramePtrs. r=jorendorff, a=RyanVM
js/src/vm/Stack-inl.h
js/src/vm/Stack.h
--- a/js/src/vm/Stack-inl.h
+++ b/js/src/vm/Stack-inl.h
@@ -992,16 +992,35 @@ LiveSavedFrameCache::FramePtr::create(co
     if (afp.isWasmDebugFrame())
         return mozilla::Some(FramePtr(afp.asWasmDebugFrame()));
     if (afp.isRematerializedFrame())
         return mozilla::Some(FramePtr(afp.asRematerializedFrame()));
 
     MOZ_CRASH("unexpected frame type");
 }
 
+/* static */ inline LiveSavedFrameCache::FramePtr
+LiveSavedFrameCache::FramePtr::create(AbstractFramePtr afp)
+{
+    MOZ_ASSERT(afp);
+
+    if (afp.isBaselineFrame()) {
+        js::jit::CommonFrameLayout *common = afp.asBaselineFrame()->framePrefix();
+        return FramePtr(common);
+    }
+    if (afp.isInterpreterFrame())
+        return FramePtr(afp.asInterpreterFrame());
+    if (afp.isWasmDebugFrame())
+        return FramePtr(afp.asWasmDebugFrame());
+    if (afp.isRematerializedFrame())
+        return FramePtr(afp.asRematerializedFrame());
+
+    MOZ_CRASH("unexpected frame type");
+}
+
 struct LiveSavedFrameCache::FramePtr::HasCachedMatcher {
     template<typename Frame>
     bool match(Frame* f) const { return f->hasCachedSavedFrame(); }
 };
 
 inline bool
 LiveSavedFrameCache::FramePtr::hasCachedSavedFrame() const {
     return ptr.match(HasCachedMatcher());
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1258,16 +1258,19 @@ class LiveSavedFrameCache
         struct HasCachedMatcher;
         struct SetHasCachedMatcher;
 
       public:
         // If iter's frame is of a type that can be cached, construct a FramePtr
         // for its frame. Otherwise, return Nothing.
         static inline mozilla::Maybe<FramePtr> create(const FrameIter& iter);
 
+        // Construct a FramePtr from an AbstractFramePtr. This always succeeds.
+        static inline FramePtr create(AbstractFramePtr abstractFramePtr);
+
         inline bool hasCachedSavedFrame() const;
         inline void setHasCachedSavedFrame();
 
         bool operator==(const FramePtr& rhs) const { return rhs.ptr == this->ptr; }
         bool operator!=(const FramePtr& rhs) const { return !(rhs == *this); }
     };
 
   private: