Bug 1350143: Don't allow debug mode when there's no more frames in wasm non-profiling iteration; r?yury
MozReview-Commit-ID: 67FECD9GRho
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/debug-noprofiling.js
@@ -0,0 +1,32 @@
+// |jit-test| exitstatus: 6;
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+if (!wasmIsSupported())
+ quit(6);
+
+newGlobal().Debugger().addDebuggee(this);
+
+var t = new WebAssembly.Table({
+ initial: 1,
+ element: "anyfunc"
+});
+
+new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
+(module
+ (func $iloop loop $top br $top end)
+ (import "imports" "t" (table1 anyfunc))
+ (elem (i32.const0) $iloop))
+`)), { imports: { t } });
+
+outer = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
+(module
+ (import "imports" "t" (table1 anyfunc))
+ (type $v2v (func))
+ (func (export "run")
+ i32.const0
+ call_indirect $v2v)
+ )`)), { imports: { t } });
+
+timeout(1);
+outer.exports.run();
--- a/js/src/wasm/WasmFrameIterator.cpp
+++ b/js/src/wasm/WasmFrameIterator.cpp
@@ -221,25 +221,29 @@ FrameIterator::instance() const
return FrameToDebugFrame(fp_)->instance();
}
bool
FrameIterator::debugEnabled() const
{
MOZ_ASSERT(!done() && code_);
MOZ_ASSERT_IF(!missingFrameMessage_, codeRange_->kind() == CodeRange::Function);
+ MOZ_ASSERT_IF(missingFrameMessage_, !codeRange_ && !fp_);
// Only non-imported functions can have debug frames.
return code_->metadata().debugEnabled &&
+ fp_ &&
+ !missingFrameMessage_ &&
codeRange_->funcIndex() >= code_->metadata().funcImports.length();
}
DebugFrame*
FrameIterator::debugFrame() const
{
MOZ_ASSERT(!done() && debugEnabled());
+ MOZ_ASSERT(fp_);
return FrameToDebugFrame(fp_);
}
const CallSite*
FrameIterator::debugTrapCallsite() const
{
MOZ_ASSERT(!done() && debugEnabled());
MOZ_ASSERT(callsite_->kind() == CallSite::EnterFrame || callsite_->kind() == CallSite::LeaveFrame ||