Commit 261a22e2 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Pass breakpoints to Liftoff compiler

This extends the API to pass breakpoint information to Liftoff. The
Liftoff compiler identifies the places where breakpoints should be set,
but does not emit breakpoints yet.
This allows us to see the performance overhead of just checking where to
emit breakpoints (which should be negligible).

R=thibaudm@chromium.org

Bug: v8:10147
Change-Id: I3fd40ab9009e9c317a26f70b4f06db512f96a763
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2019169Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65988}
parent 615ecdf8
......@@ -286,14 +286,17 @@ class LiftoffCompiler {
LiftoffCompiler(compiler::CallDescriptor* call_descriptor,
CompilationEnv* env, Zone* compilation_zone,
std::unique_ptr<AssemblerBuffer> buffer,
DebugSideTableBuilder* debug_sidetable_builder)
DebugSideTableBuilder* debug_sidetable_builder,
Vector<int> breakpoints = {})
: asm_(std::move(buffer)),
descriptor_(
GetLoweredCallDescriptor(compilation_zone, call_descriptor)),
env_(env),
debug_sidetable_builder_(debug_sidetable_builder),
compilation_zone_(compilation_zone),
safepoint_table_builder_(compilation_zone_) {}
safepoint_table_builder_(compilation_zone_),
next_breakpoint_ptr_(breakpoints.begin()),
next_breakpoint_end_(breakpoints.end()) {}
bool did_bailout() const { return bailout_reason_ != kSuccess; }
LiftoffBailoutReason bailout_reason() const { return bailout_reason_; }
......@@ -615,6 +618,8 @@ class LiftoffCompiler {
}
void FinishFunction(FullDecoder* decoder) {
// All breakpoints (if any) must be emitted by now.
DCHECK_NULL(next_breakpoint_ptr_);
if (DidAssemblerBailout(decoder)) return;
for (OutOfLineCode& ool : out_of_line_code_) {
GenerateOutOfLineCode(&ool);
......@@ -635,11 +640,24 @@ class LiftoffCompiler {
}
void NextInstruction(FullDecoder* decoder, WasmOpcode opcode) {
if (V8_UNLIKELY(next_breakpoint_ptr_) &&
*next_breakpoint_ptr_ == decoder->position()) {
++next_breakpoint_ptr_;
if (next_breakpoint_ptr_ == next_breakpoint_end_) {
next_breakpoint_ptr_ = next_breakpoint_end_ = nullptr;
}
EmitBreakpoint();
}
TraceCacheState(decoder);
SLOW_DCHECK(__ ValidateCacheState());
DEBUG_CODE_COMMENT(WasmOpcodes::OpcodeName(opcode));
}
void EmitBreakpoint() {
DEBUG_CODE_COMMENT("breakpoint");
// TODO(clemensb): Actually emit a breakpoint.
}
void Block(FullDecoder* decoder, Control* block) {}
void Loop(FullDecoder* decoder, Control* loop) {
......@@ -2429,6 +2447,10 @@ class LiftoffCompiler {
// The pc offset of the instructions to reserve the stack frame. Needed to
// patch the actually needed stack size in the end.
uint32_t pc_offset_stack_frame_construction_ = 0;
// For emitting breakpoint, we store a pointer to the position of the next
// breakpoint, and a pointer after the list of breakpoints as end marker.
int* next_breakpoint_ptr_ = nullptr;
int* next_breakpoint_end_ = nullptr;
bool has_outstanding_op() const {
return outstanding_op_ != kNoOutstandingOp;
......@@ -2454,12 +2476,10 @@ class LiftoffCompiler {
} // namespace
WasmCompilationResult ExecuteLiftoffCompilation(AccountingAllocator* allocator,
CompilationEnv* env,
const FunctionBody& func_body,
int func_index,
Counters* counters,
WasmFeatures* detected) {
WasmCompilationResult ExecuteLiftoffCompilation(
AccountingAllocator* allocator, CompilationEnv* env,
const FunctionBody& func_body, int func_index, Counters* counters,
WasmFeatures* detected, Vector<int> breakpoints) {
int func_body_size = static_cast<int>(func_body.end - func_body.start);
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm"),
"ExecuteLiftoffCompilation", "func_index", func_index,
......@@ -2481,7 +2501,7 @@ WasmCompilationResult ExecuteLiftoffCompilation(AccountingAllocator* allocator,
WasmFullDecoder<Decoder::kValidate, LiftoffCompiler> decoder(
&zone, env->module, env->enabled_features, detected, func_body,
call_descriptor, env, &zone, instruction_buffer->CreateView(),
kNoDebugSideTable);
kNoDebugSideTable, breakpoints);
decoder.Decode();
liftoff_compile_time_scope.reset();
LiftoffCompiler* compiler = &decoder.interface();
......
......@@ -54,7 +54,7 @@ enum LiftoffBailoutReason : int8_t {
V8_EXPORT_PRIVATE WasmCompilationResult ExecuteLiftoffCompilation(
AccountingAllocator*, CompilationEnv*, const FunctionBody&, int func_index,
Counters*, WasmFeatures* detected_features);
Counters*, WasmFeatures* detected_features, Vector<int> breakpoints = {});
V8_EXPORT_PRIVATE DebugSideTable GenerateLiftoffDebugSideTable(
AccountingAllocator*, CompilationEnv*, const FunctionBody&);
......
......@@ -597,10 +597,9 @@ class DebugInfoImpl {
FunctionBody body{function->sig, function->code.offset(),
wire_bytes.begin() + function->code.offset(),
wire_bytes.begin() + function->code.end_offset()};
// TODO(clemensb): Pass breakpoints to Liftoff.
WasmCompilationResult result =
ExecuteLiftoffCompilation(native_module_->engine()->allocator(), &env,
body, func_index, nullptr, nullptr);
WasmCompilationResult result = ExecuteLiftoffCompilation(
native_module_->engine()->allocator(), &env, body, func_index, nullptr,
nullptr, VectorOf(breakpoints));
DCHECK(result.succeeded());
WasmCodeRefScope wasm_code_ref_scope;
......
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