Bug 1461337: Handle anyref locales/return value in debugger; r=lth

--HG--
extra : rebase_source : 112bc0e889607af422e765f32ce9151d6e90a94a
extra : histedit_source : 5fb22d23a9ae8209da4cc61da0c3a99a037e10ee
This commit is contained in:
Benjamin Bouvier 2018-05-14 19:22:42 +02:00
Родитель 6faf449ca5
Коммит 7b4477d1d2
4 изменённых файлов: 46 добавлений и 10 удалений

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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);
`);
})();

Просмотреть файл

@ -647,6 +647,9 @@ DebugFrame::getLocal(uint32_t localIndex, MutableHandleValue vp)
case jit::MIRType::Double:
vp.set(NumberValue(JS::CanonicalizeNaN(*static_cast<double*>(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");
}

Просмотреть файл

@ -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.