[wasm] Interpreter: Don't pause on invalid position
Always execute the implicit return if we fell off the function bytes. This is not considered an additional "step" as it is not executing a wasm instruction. Otherwise, we might pause at an invalid position (one after the function bytes). R=titzer@chromium.org BUG=v8:5822 Review-Url: https://codereview.chromium.org/2650293003 Cr-Commit-Position: refs/heads/master@{#42730}
This commit is contained in:
parent
b7947f8cd7
commit
e29a2cd529
@ -1183,15 +1183,7 @@ class ThreadImpl {
|
||||
#define PAUSE_IF_BREAK_FLAG(flag) \
|
||||
if (V8_UNLIKELY(break_flags_ & WasmInterpreter::BreakFlag::flag)) max = 0;
|
||||
|
||||
if (pc >= limit) {
|
||||
// Fell off end of code; do an implicit return.
|
||||
TRACE("@%-3zu: ImplicitReturn\n", pc);
|
||||
if (!DoReturn(&code, &pc, &limit, code->function->sig->return_count()))
|
||||
return;
|
||||
decoder.Reset(code->start, code->end);
|
||||
PAUSE_IF_BREAK_FLAG(AfterReturn);
|
||||
continue;
|
||||
}
|
||||
DCHECK_GT(limit, pc);
|
||||
|
||||
const char* skip = " ";
|
||||
int len = 1;
|
||||
@ -1635,6 +1627,14 @@ class ThreadImpl {
|
||||
}
|
||||
|
||||
pc += len;
|
||||
if (pc == limit) {
|
||||
// Fell off end of code; do an implicit return.
|
||||
TRACE("@%-3zu: ImplicitReturn\n", pc);
|
||||
if (!DoReturn(&code, &pc, &limit, code->function->sig->return_count()))
|
||||
return;
|
||||
decoder.Reset(code->start, code->end);
|
||||
PAUSE_IF_BREAK_FLAG(AfterReturn);
|
||||
}
|
||||
}
|
||||
// Set break_pc_, even though we might have stopped because max was reached.
|
||||
// We don't want to stop after executing zero instructions next time.
|
||||
|
@ -219,7 +219,7 @@ TEST(Breakpoint_I32Add) {
|
||||
}
|
||||
|
||||
TEST(Step_I32Mul) {
|
||||
static const int kTraceLength = 5;
|
||||
static const int kTraceLength = 4;
|
||||
byte code[] = {WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
|
||||
|
||||
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreted);
|
||||
|
@ -77,7 +77,7 @@ Paused at wasm://wasm/wasm-ccfaf3fa/wasm-ccfaf3fa-0:2:2: >nop
|
||||
Step action: stepInto
|
||||
Paused at wasm://wasm/wasm-ccfaf3fa/wasm-ccfaf3fa-0:3:0: >end
|
||||
Step action: stepInto
|
||||
Paused at wasm://wasm/wasm-ccfaf3fa/wasm-ccfaf3fa-0:0:0: >func $wasm_A
|
||||
Paused at wasm://wasm/wasm-ccfaf3fa/wasm-ccfaf3fa-1:9:6: >br 1
|
||||
Step action: resume
|
||||
exports.main returned!
|
||||
Finished!
|
||||
|
Loading…
Reference in New Issue
Block a user