From 549389d3274f9148d5aab5f30133a03289af76db Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 18 Jan 2023 14:08:50 +0100 Subject: [PATCH] No issue - factor out some frame iterator helper functions. --- js/src/jit/JitFrameIterator-inl.h | 6 ++++++ js/src/jit/JitFrameIterator.h | 4 ++++ js/src/jsopcode.cpp | 12 ++++++------ js/src/vm/Stack.cpp | 15 +++++++++++++++ js/src/vm/Stack.h | 3 +++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/js/src/jit/JitFrameIterator-inl.h b/js/src/jit/JitFrameIterator-inl.h index 6854941c37..c13e1670b2 100644 --- a/js/src/jit/JitFrameIterator-inl.h +++ b/js/src/jit/JitFrameIterator-inl.h @@ -35,6 +35,12 @@ JitFrameIterator::baselineFrame() const return (BaselineFrame*)(fp() - BaselineFrame::FramePointerOffset - BaselineFrame::Size()); } +inline uint32_t +JitFrameIterator::baselineFrameNumValueSlots() const { + MOZ_ASSERT(isBaselineJS()); + return baselineFrame()->numValueSlots(); +} + template bool JitFrameIterator::isExitFrameLayout() const diff --git a/js/src/jit/JitFrameIterator.h b/js/src/jit/JitFrameIterator.h index 417d11afcc..b5b217b4e1 100644 --- a/js/src/jit/JitFrameIterator.h +++ b/js/src/jit/JitFrameIterator.h @@ -256,6 +256,10 @@ class JitFrameIterator inline BaselineFrame* baselineFrame() const; + // Returns the number of local and expression stack Values for the current + // Baseline frame. + inline uint32_t baselineFrameNumValueSlots() const; + // This function isn't used, but we keep it here (debug-only) because it is // helpful when chasing issues with the jitcode map. #ifdef DEBUG diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 30fcd0c87a..1ba19731eb 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -1568,18 +1568,18 @@ DecompileExpressionFromStack(JSContext* cx, int spindex, int skipStackHits, Hand FrameIter frameIter(cx); - if (frameIter.done() || !frameIter.hasScript() || frameIter.compartment() != cx->compartment()) - return true; + if (frameIter.done() || + !frameIter.hasScript() || + frameIter.compartment() != cx->compartment() || + frameIter.inPrologue()) { + return true; + } RootedScript script(cx, frameIter.script()); jsbytecode* valuepc = frameIter.pc(); MOZ_ASSERT(script->containsPC(valuepc)); - // Give up if in prologue. - if (valuepc < script->main()) - return true; - if (!FindStartPC(cx, frameIter, spindex, skipStackHits, v, &valuepc)) return false; if (!valuepc) diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index a9c585b295..cdc1046bcc 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -1331,6 +1331,21 @@ NonBuiltinScriptFrameIter::settle() } } +bool + FrameIter::inPrologue() const { + if (pc() < script()->main()) { + return true; + } + // If we do a VM call before pushing locals in baseline, the stack frame will + // not include space for those locals. + if (pc() == script()->code() && isBaseline() && + data_.jitFrames_.baselineFrameNumValueSlots() < script()->nfixed()) { + return true; + } + + return false; +} + ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx) : cx_(cx), entryMonitor_(cx->runtime()->entryMonitor) { diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index 6b1b5ba993..b0d29831a3 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -1884,6 +1884,9 @@ class FrameIter // This is used to provide a raw interface for debugging. void* rawFramePtr() const; + + // Determines if we're in the prologue of a baseline function. + bool inPrologue() const; private: Data data_;