summaryrefslogtreecommitdiffstats
path: root/js/src/wasm/WasmFrameIter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/wasm/WasmFrameIter.cpp')
-rw-r--r--js/src/wasm/WasmFrameIter.cpp64
1 files changed, 63 insertions, 1 deletions
diff --git a/js/src/wasm/WasmFrameIter.cpp b/js/src/wasm/WasmFrameIter.cpp
index 90555720da..e9f27bbda0 100644
--- a/js/src/wasm/WasmFrameIter.cpp
+++ b/js/src/wasm/WasmFrameIter.cpp
@@ -26,6 +26,7 @@
#include "wasm/WasmDebugFrame.h"
#include "wasm/WasmInstance.h"
#include "wasm/WasmInstanceData.h"
+#include "wasm/WasmPI.h"
#include "wasm/WasmStubs.h"
#include "jit/MacroAssembler-inl.h"
@@ -65,7 +66,8 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp)
unwind_(Unwind::False),
unwoundAddressOfReturnAddress_(nullptr),
resumePCinCurrentFrame_(nullptr),
- failedUnwindSignatureMismatch_(false) {
+ failedUnwindSignatureMismatch_(false),
+ stackSwitched_(false) {
MOZ_ASSERT(fp_);
instance_ = GetNearestEffectiveInstance(fp_);
@@ -88,6 +90,19 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp)
lineOrBytecode_ = trapData.bytecodeOffset;
failedUnwindSignatureMismatch_ = trapData.failedUnwindSignatureMismatch;
+#ifdef ENABLE_WASM_TAIL_CALLS
+ // The debugEnabled() relies on valid value of resumePCinCurrentFrame_
+ // to identify DebugFrame. Normally this field is updated at popFrame().
+ // The only case when this can happend is during IndirectCallBadSig
+ // trapping and stack unwinding. The top frame will never be at ReturnStub
+ // callsite, except during IndirectCallBadSig unwinding.
+ const CallSite* site = code_->lookupCallSite(unwoundPC);
+ if (site && site->kind() == CallSite::ReturnStub) {
+ MOZ_ASSERT(trapData.trap == Trap::IndirectCallBadSig);
+ resumePCinCurrentFrame_ = (uint8_t*)unwoundPC;
+ }
+#endif
+
MOZ_ASSERT(!done());
return;
}
@@ -102,6 +117,39 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp)
MOZ_ASSERT(!done() || unwoundCallerFP_);
}
+WasmFrameIter::WasmFrameIter(FrameWithInstances* fp, void* returnAddress)
+ : activation_(nullptr),
+ code_(nullptr),
+ codeRange_(nullptr),
+ lineOrBytecode_(0),
+ fp_(fp),
+ instance_(fp->calleeInstance()),
+ unwoundCallerFP_(nullptr),
+ unwind_(Unwind::False),
+ unwoundAddressOfReturnAddress_(nullptr),
+ resumePCinCurrentFrame_((uint8_t*)returnAddress),
+ failedUnwindSignatureMismatch_(false),
+ stackSwitched_(false) {
+ // Specialized implementation to avoid popFrame() interation.
+ // It is expected that the iterator starts at a callsite that is in
+ // the function body and has instance reference.
+ code_ = LookupCode(returnAddress, &codeRange_);
+ MOZ_ASSERT(code_ && codeRange_ && codeRange_->kind() == CodeRange::Function);
+
+ const CallSite* callsite = code_->lookupCallSite(returnAddress);
+ MOZ_ASSERT(callsite && callsite->mightBeCrossInstance());
+
+#ifdef ENABLE_WASM_JSPI
+ stackSwitched_ = callsite->isStackSwitch();
+#endif
+
+ MOZ_ASSERT(code_ == &instance_->code());
+ lineOrBytecode_ = callsite->lineOrBytecode();
+ failedUnwindSignatureMismatch_ = false;
+
+ MOZ_ASSERT(!done());
+}
+
bool WasmFrameIter::done() const {
MOZ_ASSERT(!!fp_ == !!code_);
MOZ_ASSERT(!!fp_ == !!codeRange_);
@@ -145,6 +193,9 @@ static inline void AssertDirectJitCall(const void* fp) {
void WasmFrameIter::popFrame() {
uint8_t* returnAddress = fp_->returnAddress();
code_ = LookupCode(returnAddress, &codeRange_);
+#ifdef ENABLE_WASM_JSPI
+ stackSwitched_ = false;
+#endif
if (!code_) {
// This is a direct call from the jit into the wasm function's body. The
@@ -241,6 +292,13 @@ void WasmFrameIter::popFrame() {
instance_ = ExtractCallerInstanceFromFrameWithInstances(prevFP);
}
+#ifdef ENABLE_WASM_JSPI
+ stackSwitched_ = callsite->isStackSwitch();
+ if (stackSwitched_ && unwind_ == Unwind::True) {
+ wasm::UnwindStackSwitch(activation_->cx());
+ }
+#endif
+
MOZ_ASSERT(code_ == &instance()->code());
lineOrBytecode_ = callsite->lineOrBytecode();
failedUnwindSignatureMismatch_ = false;
@@ -1811,6 +1869,10 @@ static const char* ThunkedNativeToDescription(SymbolicAddress func) {
return "call to native " #op " builtin (in wasm)";
FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC)
#undef VISIT_BUILTIN_FUNC
+#ifdef ENABLE_WASM_JSPI
+ case SymbolicAddress::UpdateSuspenderState:
+ return "call to native update suspender state util";
+#endif
#ifdef WASM_CODEGEN_DEBUG
case SymbolicAddress::PrintI32:
case SymbolicAddress::PrintPtr: