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