Commit be8faa4e authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[liftoff] Add test for opcode-merging during stepping

We currently still merge opcodes (i.e. i32 comparisons plus a br_if).
This CL adds a test for this, which checks for the current behaviour.
A follow-up CL will fix this and update the expected output accordingly.

R=thibaudm@chromium.org

Bug: v8:10350
Change-Id: I846aa931a3ec1a27043f04e830503d5732ae473e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2307232Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68957}
parent c108d7a0
Tests that Liftoff does not merge opcodes while stepping
Warning: This test tests the current (incorrect) behaviour. It will be fixed in a follow-up CL.
Setting breakpoint at offset 33.
Paused at offset 33: [0]
Paused at offset 35: [0, 0]
Paused at offset 36: [0, 0]
Paused at offset 33: [-1]
Paused at offset 35: [-1, -1]
Paused at offset 36: [-1, -1]
Paused at offset 38: [-1]
Paused at offset 33: [13]
Paused at offset 35: [13, 13]
Paused at offset 36: [13, 13]
Paused at offset 38: [13]
Finished.
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
utils.load('test/inspector/wasm-inspector-test.js');
let {session, contextGroup, Protocol} = InspectorTest.start(
'Tests that Liftoff does not merge opcodes while stepping');
session.setupScriptMap();
let builder = new WasmModuleBuilder();
// i32.eqz and br_if are usually merged, so we wouldn't see any
// update on the operand stack after i32.eqz. For debugging,
// this is disabled, so we should see the result.
let body = [kExprLocalGet, 0, kExprI32Eqz, kExprBrIf, 0];
let fun = builder.addFunction('fun', kSig_v_i).addBody(body).exportFunc();
let module_bytes = builder.toArray();
let wasm_script_id = undefined;
Protocol.Debugger.onPaused(printPauseLocationAndStep);
(async function test() {
await Protocol.Debugger.enable();
WasmInspectorTest.instantiate(module_bytes);
[, {params: {scriptId: wasm_script_id}}] = await Protocol.Debugger.onceScriptParsed(2);
// TODO(clemensb): Fix this.
InspectorTest.log(
'Warning: This test tests the current (incorrect) behaviour. ' +
'It will be fixed in a follow-up CL.');
// Set a breakpoint at the beginning of 'fun'.
const offset = fun.body_offset;
InspectorTest.log(`Setting breakpoint at offset ${offset}.`);
let bpmsg = await Protocol.Debugger.setBreakpoint({
location: {scriptId: wasm_script_id, lineNumber: 0, columnNumber: offset}
});
for (let value of [0, -1, 13]) {
await Protocol.Runtime.evaluate(
{expression: `instance.exports.fun(${value})`});
}
InspectorTest.log('Finished.');
})().catch(reason => InspectorTest.log(`Failed: ${reason}`))
.finally(InspectorTest.completeTest);
async function printPauseLocationAndStep(msg) {
// If we are outside of wasm, continue.
let loc = msg.params.callFrames[0].location;
if (loc.scriptId != wasm_script_id) {
Protocol.Debugger.resume();
return;
}
// Inspect only the top wasm frame.
let frame = msg.params.callFrames[0];
let scopes = {};
for (let scope of frame.scopeChain) {
if (scope.type == 'module') continue;
let scope_properties =
await Protocol.Runtime.getProperties({objectId: scope.object.objectId});
scopes[scope.type] = scope_properties.result.result.map(
elem => WasmInspectorTest.getWasmValue(elem.value));
}
let values = scopes['local'].concat(scopes['wasm-expression-stack']).join(', ');
InspectorTest.log(`Paused at offset ${loc.columnNumber}: [${values}]`);
Protocol.Debugger.stepOver();
}
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