[wasm][debug] Fix OSR at stack check

Add missing source position for stack check, used by OSR to find the
correct return address.

R=clemensb@chromium.org

Bug: v8:10235
Change-Id: Ie26dd3b2079168e846f84b3a4ffe18b838649be7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2339625
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69309}
This commit is contained in:
Thibaud Michaud 2020-08-06 18:22:22 +02:00 committed by Commit Bot
parent bea6922bfb
commit d16f404cba
3 changed files with 12 additions and 9 deletions

View File

@ -728,7 +728,7 @@ class LiftoffCompiler {
}
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(ool->position), true);
__ pc_offset(), SourcePosition(ool->position), false);
__ CallRuntimeStub(ool->stub);
DCHECK_EQ(!debug_sidetable_builder_, !ool->debug_sidetable_entry_builder);
if (V8_UNLIKELY(ool->debug_sidetable_entry_builder)) {
@ -738,10 +738,10 @@ class LiftoffCompiler {
DCHECK_EQ(ool->continuation.get()->is_bound(), is_stack_check);
if (!ool->regs_to_save.is_empty()) __ PopRegisters(ool->regs_to_save);
if (is_stack_check) {
// TODO(thibaudm): If the top frame is OSR'ed during stack check,
// execution will resume at the next instruction, skipping the following
// register reloads.
if (V8_UNLIKELY(ool->spilled_registers != nullptr)) {
DCHECK(for_debugging_);
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(ool->position), true);
for (auto& entry : ool->spilled_registers->entries) {
__ Fill(entry.reg, entry.offset, entry.type);
}

View File

@ -5,4 +5,8 @@ Got wasm script: wasm://wasm/c84b7cde
Run
Expecting to pause at 61
Paused at offset 61; local: [12]; wasm-expression-stack: []
Paused at offset 62; local: [12]; wasm-expression-stack: []
Paused at offset 64; local: [12]; wasm-expression-stack: [12]
Paused at offset 66; local: [12]; wasm-expression-stack: [12, 1]
Paused at offset 67; local: [12]; wasm-expression-stack: [13]
Finished!

View File

@ -46,12 +46,11 @@ function instantiate(bytes, imports) {
InspectorTest.log('Run');
Protocol.Runtime.evaluate({expression: 'instance.exports.main()'});
// TODO(thibaudm): Fix source position and OSR at stack checks.
InspectorTest.log('Expecting to pause at ' + (f.body_offset - 1));
// await waitForPauseAndStep('stepInto');
// await waitForPauseAndStep('stepInto');
// await waitForPauseAndStep('stepInto');
// await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('resume');
InspectorTest.log('Finished!');
InspectorTest.completeTest();