diff --git a/js/src/jit-test/tests/wasm/gc/anyref.js b/js/src/jit-test/tests/wasm/gc/anyref.js index 4b702bb44832..d06b2154755a 100644 --- a/js/src/jit-test/tests/wasm/gc/anyref.js +++ b/js/src/jit-test/tests/wasm/gc/anyref.js @@ -150,12 +150,6 @@ ref = exports.nested(baguette, 0); assertEq(ref, baguette); assertEq(ref.calories, baguette.calories); -if (wasmDebuggingIsSupported()) { - let g = newGlobal(); - let dbg = new Debugger(g); - g.eval(`o = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func (result anyref) (param anyref) get_local 0) (export "" 0))')));`); -} - // More interesting use cases about control flow joins. function assertJoin(body) { diff --git a/js/src/jit-test/tests/wasm/gc/debugger.js b/js/src/jit-test/tests/wasm/gc/debugger.js new file mode 100644 index 000000000000..db87f5c7c7e8 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/debugger.js @@ -0,0 +1,35 @@ +if (!wasmGcEnabled() || !wasmDebuggingIsSupported()) { + quit(0); +} + +(function() { + let g = newGlobal(); + let dbg = new Debugger(g); + g.eval(`o = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func (result anyref) (param anyref) get_local 0) (export "" 0))')));`); +})(); + +(function() { + var g = newGlobal(); + g.parent = this; + + let src = ` + (module + (func (export "func") (result anyref) (param $ref anyref) + get_local $ref + ) + ) + `; + + g.eval(` + var obj = { somekey: 'somevalue' }; + + Debugger(parent).onEnterFrame = function(frame) { + let v = frame.environment.getVariable('var0'); + assertEq(typeof v === 'object', true); + assertEq(typeof v.somekey === 'string', true); + assertEq(v.somekey === 'somevalue', true); + }; + + new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(\`${src}\`))).exports.func(obj); + `); +})(); diff --git a/js/src/wasm/WasmTypes.cpp b/js/src/wasm/WasmTypes.cpp index c97e1cfebd94..67a0a8a9d03d 100644 --- a/js/src/wasm/WasmTypes.cpp +++ b/js/src/wasm/WasmTypes.cpp @@ -647,6 +647,9 @@ DebugFrame::getLocal(uint32_t localIndex, MutableHandleValue vp) case jit::MIRType::Double: vp.set(NumberValue(JS::CanonicalizeNaN(*static_cast(dataPtr)))); break; + case jit::MIRType::Pointer: + vp.set(ObjectOrNullValue(*(JSObject**)dataPtr)); + break; default: MOZ_CRASH("local type"); } @@ -675,6 +678,9 @@ DebugFrame::updateReturnJSValue() case ExprType::F64: cachedReturnJSValue_.setDouble(JS::CanonicalizeNaN(resultF64_)); break; + case ExprType::AnyRef: + cachedReturnJSValue_ = ObjectOrNullValue(*(JSObject**)&resultRef_); + break; default: MOZ_CRASH("result type"); } diff --git a/js/src/wasm/WasmTypes.h b/js/src/wasm/WasmTypes.h index 6220282deaf9..0867cd989a3d 100644 --- a/js/src/wasm/WasmTypes.h +++ b/js/src/wasm/WasmTypes.h @@ -1961,10 +1961,11 @@ class DebugFrame // the return value of a frame being debugged. union { - int32_t resultI32_; - int64_t resultI64_; - float resultF32_; - double resultF64_; + int32_t resultI32_; + int64_t resultI64_; + intptr_t resultRef_; + float resultF32_; + double resultF64_; }; // The returnValue() method returns a HandleValue pointing to this field.