Commit e287b61f authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[liftoff][debug] Add source positions after calls

To fully support debugging in Liftoff, we need to OSR active frames by
updating their return address. Introducing source positions after
each call will help us find the correct return address in the new code.

R=clemensb@chromium.org

Bug: v8:10147
Change-Id: I0a97fa86929c471abb4cd1ed75ac6724fc385944
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2064216Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66350}
parent 4dc1fb4e
......@@ -660,9 +660,14 @@ class LiftoffCompiler {
void EmitBreakpoint(FullDecoder* decoder) {
DEBUG_CODE_COMMENT("breakpoint");
DCHECK(env_->debug);
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(decoder->position()), false);
__ CallRuntimeStub(WasmCode::kWasmDebugBreak);
// This source position helps updating return addresses on the stack after
// installing a new Liftoff code object.
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(decoder->position()), false);
RegisterDebugSideTableEntry();
safepoint_table_builder_.DefineSafepoint(&asm_, Safepoint::kNoLazyDeopt);
}
......@@ -2055,6 +2060,13 @@ class LiftoffCompiler {
__ CallNativeWasmCode(addr);
}
if (env_->debug) {
// This source position helps updating return addresses on the stack after
// installing a new Liftoff code object.
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(decoder->position()), false);
}
RegisterDebugSideTableEntry();
safepoint_table_builder_.DefineSafepoint(&asm_, Safepoint::kNoLazyDeopt);
......@@ -2188,6 +2200,13 @@ class LiftoffCompiler {
__ PrepareCall(imm.sig, call_descriptor, &target, explicit_instance);
__ CallIndirect(imm.sig, call_descriptor, target);
if (env_->debug) {
// This source position helps updating return addresses on the stack after
// installing a new Liftoff code object.
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(decoder->position()), false);
}
RegisterDebugSideTableEntry();
safepoint_table_builder_.DefineSafepoint(&asm_, Safepoint::kNoLazyDeopt);
......
......@@ -60,11 +60,15 @@ struct CompilationEnv {
const LowerSimd lower_simd;
// Whether the debugger is active.
const bool debug;
constexpr CompilationEnv(const WasmModule* module,
UseTrapHandler use_trap_handler,
RuntimeExceptionSupport runtime_exception_support,
const WasmFeatures& enabled_features,
LowerSimd lower_simd = kNoLowerSimd)
LowerSimd lower_simd = kNoLowerSimd,
bool debug = false)
: module(module),
use_trap_handler(use_trap_handler),
runtime_exception_support(runtime_exception_support),
......@@ -75,7 +79,8 @@ struct CompilationEnv {
: max_mem_pages()) *
uint64_t{kWasmPageSize}),
enabled_features(enabled_features),
lower_simd(lower_simd) {}
lower_simd(lower_simd),
debug(debug) {}
};
// The wire bytes are either owned by the StreamingDecoder, or (after streaming)
......
......@@ -784,8 +784,8 @@ void NativeModule::LogWasmCodes(Isolate* isolate) {
}
CompilationEnv NativeModule::CreateCompilationEnv() const {
return {module(), use_trap_handler_, kRuntimeExceptionSupport,
enabled_features_};
return {module(), use_trap_handler_, kRuntimeExceptionSupport,
enabled_features_, kNoLowerSimd, tier_down_};
}
WasmCode* NativeModule::AddCodeForTesting(Handle<Code> code) {
......
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