Commit e29a2cd5 authored by clemensh's avatar clemensh Committed by Commit bot

[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}
parent b7947f8c
......@@ -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!
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