Commit 4d43ab04 authored by Philip Pfaffe's avatar Philip Pfaffe Committed by V8 LUCI CQ

Add constructor to WasmValueObjects

WasmValueObjects used to not have a constructor defined. That prevents
custom devtoolsFormatters from being applied to such objects.

Change-Id: Id775cdb710d0c4106f70858cc1fc92b1f8bd4590
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2991243Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Philip Pfaffe <pfaffe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75438}
parent 4a092170
......@@ -844,6 +844,7 @@ Handle<WasmValueObject> WasmValueObject::New(Isolate* isolate,
WASM_VALUE_OBJECT_TYPE, WasmValueObject::kSize,
TERMINAL_FAST_ELEMENTS_KIND, 2);
Map::EnsureDescriptorSlack(isolate, map, 2);
map->SetConstructor(*isolate->object_function());
{ // type
Descriptor d = Descriptor::DataField(
isolate,
......
......@@ -135,3 +135,16 @@ Debugger paused in $main.
> Object.keys(stack) = Array(2)
> stack[0] = i32 {5}
> stack[1] = i32 {42}
Running test: testCustomFormatters
Compile module.
Set breakpoint in main.
Install custom formatter.
Instantiate module.
Call main.
Debugger paused in $main.
> locals = {"header":"[\"div\",{},\"{\\\"$x\\\":{\\\"type\\\":\\\"i32\\\",\\\"value\\\":5}}\"]"}
> Object.keys(locals) = {"header":"[\"div\",{},\"[\\\"$x\\\"]\"]"}
> locals[0] = {"header":"[\"div\",{},\"{\\\"type\\\":\\\"i32\\\",\\\"value\\\":5}\"]"}
> locals["$x"] = {"header":"[\"div\",{},\"{\\\"type\\\":\\\"i32\\\",\\\"value\\\":5}\"]"}
> $x = {"header":"[\"div\",{},\"{\\\"type\\\":\\\"i32\\\",\\\"value\\\":5}\"]"}
......@@ -34,7 +34,10 @@ async function dumpOnCallFrame(callFrameId, expression) {
const {result: {result: object}} = await Protocol.Debugger.evaluateOnCallFrame({
callFrameId, expression
});
if (object.type === 'object' && object.subtype === 'wasmvalue') {
if ('customPreview' in object) {
InspectorTest.log(
`> ${expression} = ${JSON.stringify(object.customPreview)}`);
} else if (object.type === 'object' && object.subtype === 'wasmvalue') {
const {result: {result: properties}} = await Protocol.Runtime.getProperties({objectId: object.objectId, ownProperties: true})
const valueProperty = properties.find(p => p.name === 'value');
InspectorTest.log(`> ${expression} = ${object.description} {${valueProperty.value.description}}`);
......@@ -344,6 +347,50 @@ InspectorTest.runAsyncTestSuite([
await dumpOnCallFrame(callFrameId, `stack`);
await dumpOnCallFrame(callFrameId, `Object.keys(stack)`);
await dumpKeysOnCallFrame(callFrameId, "stack", [0, 1]);
await Protocol.Debugger.resume();
await callMainPromise;
},
async function testCustomFormatters() {
const builder = new WasmModuleBuilder();
const main = builder.addFunction('main', kSig_i_i, ['x'])
.addBody([
kExprLocalGet,
0,
])
.exportFunc();
InspectorTest.log('Compile module.');
const [module, scriptId] = await compileModule(builder);
await Protocol.Runtime.enable();
InspectorTest.log('Set breakpoint in main.');
await Protocol.Debugger.setBreakpoint(
{location: {scriptId, lineNumber: 0, columnNumber: main.body_offset}});
InspectorTest.log('Install custom formatter.');
await Protocol.Runtime.onConsoleAPICalled(m => InspectorTest.logMessage(m));
await Protocol.Runtime.setCustomObjectFormatterEnabled({enabled: true});
await Protocol.Runtime.evaluate({
expression: `this.devtoolsFormatters = [{
header: function(obj) { return ["div", {}, JSON.stringify(obj)]; },
hasBody: function() { return false; }
}]`
});
InspectorTest.log('Instantiate module.');
const instance = await instantiateModule(module);
InspectorTest.log('Call main.');
const callMainPromise = Protocol.Runtime.callFunctionOn({
functionDeclaration: `function() { return this.exports.main(5); }`,
objectId: instance.objectId
});
let callFrameId = await waitForDebuggerPaused();
await dumpOnCallFrame(callFrameId, `locals`);
await dumpOnCallFrame(callFrameId, `Object.keys(locals)`);
await dumpKeysOnCallFrame(callFrameId, 'locals', [0, '$x']);
await Protocol.Debugger.resume();
await callMainPromise;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment