Commit 3c7e3a43 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [interpreter] Fix notifying debug listeners

We were notifying the debug event listeners after every 1000 steps.
This CL fixes this to only notify them if we actually paused because of
a hit breakpoint.

R=ahaas@chromium.org
BUG=v8:5822

Change-Id: I00e36b89307c7e761ceb24ccdb3157056cfb8178
Reviewed-on: https://chromium-review.googlesource.com/459480Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44175}
parent 6c4c6c84
......@@ -1114,7 +1114,8 @@ class ThreadImpl {
TRACE(" => Run()\n");
state_ = WasmInterpreter::RUNNING;
Execute(frames_.back().code, frames_.back().pc, kRunSteps);
} while (state_ == WasmInterpreter::STOPPED && !frames_.empty());
} while (state_ == WasmInterpreter::PAUSED && !frames_.empty() &&
!PausedAtBreakpoint());
return state_;
}
......@@ -1170,6 +1171,12 @@ class ThreadImpl {
pc_t GetBreakpointPc() { return break_pc_; }
bool PausedAtBreakpoint() {
DCHECK_IMPLIES(break_pc_ != kInvalidPc,
!frames_.empty() && break_pc_ == frames_.back().pc);
return break_pc_ != kInvalidPc;
}
bool PossibleNondeterminism() { return possible_nondeterminism_; }
uint64_t NumInterpretedCalls() { return num_interpreted_calls_; }
......@@ -1453,9 +1460,14 @@ class ThreadImpl {
void Execute(InterpreterCode* code, pc_t pc, int max) {
Decoder decoder(code->start, code->end);
pc_t limit = code->end - code->start;
while (--max >= 0) {
#define PAUSE_IF_BREAK_FLAG(flag) \
if (V8_UNLIKELY(break_flags_ & WasmInterpreter::BreakFlag::flag)) max = 0;
bool hit_break = false;
while (true) {
#define PAUSE_IF_BREAK_FLAG(flag) \
if (V8_UNLIKELY(break_flags_ & WasmInterpreter::BreakFlag::flag)) { \
hit_break = true; \
max = 0; \
}
DCHECK_GT(limit, pc);
DCHECK_NOT_NULL(code->start);
......@@ -1474,10 +1486,14 @@ class ThreadImpl {
WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(orig)));
TraceValueStack();
TRACE("\n");
hit_break = true;
break;
}
}
// If max == 0, do only break after setting hit_break correctly.
if (--max < 0) break;
USE(skip);
TRACE("@%-3zu: %s%-24s:", pc, skip,
WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(orig)));
......@@ -1906,10 +1922,9 @@ class ThreadImpl {
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.
break_pc_ = pc;
state_ = WasmInterpreter::PAUSED;
break_pc_ = hit_break ? pc : kInvalidPc;
CommitPc(pc);
}
......
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