Commit 2a303b1c authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[liftoff] Add code comments for OOL code

For easier debugging of Liftoff code generation issues, add code
comments or out-of-line code.

The name is generated from the {RuntimeStubId}. The respective name
accessor is currently defined on the {NativeModule}, this CL makes it a
top-level function so we can reuse it from Liftoff.

R=thibaudm@chromium.org

Bug: v8:10235
Change-Id: I7b99779217b9c052e34ad132eb34859b20548092
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2134307
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66978}
parent e84e9b92
......@@ -245,9 +245,9 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
}
} else if (RelocInfo::IsWasmStubCall(rmode) && host.is_wasm_code()) {
// Host is isolate-independent, try wasm native module instead.
const char* runtime_stub_name =
host.as_wasm_code()->native_module()->GetRuntimeStubName(
relocinfo->wasm_stub_call_address());
const char* runtime_stub_name = GetRuntimeStubName(
host.as_wasm_code()->native_module()->GetRuntimeStubId(
relocinfo->wasm_stub_call_address()));
out->AddFormatted(" ;; wasm stub: %s", runtime_stub_name);
} else if (RelocInfo::IsRuntimeEntry(rmode) && isolate &&
isolate->deoptimizer_data() != nullptr) {
......
......@@ -634,6 +634,8 @@ class LiftoffCompiler {
}
void GenerateOutOfLineCode(OutOfLineCode* ool) {
DEBUG_CODE_COMMENT(
(std::string("Out of line: ") + GetRuntimeStubName(ool->stub)).c_str());
__ bind(ool->label.get());
const bool is_stack_check = ool->stub == WasmCode::kWasmStackGuard;
const bool is_mem_out_of_bounds =
......
......@@ -1452,22 +1452,6 @@ WasmCode::RuntimeStubId NativeModule::GetRuntimeStubId(Address target) const {
return WasmCode::kRuntimeStubCount;
}
const char* NativeModule::GetRuntimeStubName(Address target) const {
WasmCode::RuntimeStubId stub_id = GetRuntimeStubId(target);
#define RUNTIME_STUB_NAME(Name) #Name,
#define RUNTIME_STUB_NAME_TRAP(Name) "ThrowWasm" #Name,
constexpr const char* runtime_stub_names[] = {WASM_RUNTIME_STUB_LIST(
RUNTIME_STUB_NAME, RUNTIME_STUB_NAME_TRAP) "<unknown>"};
#undef RUNTIME_STUB_NAME
#undef RUNTIME_STUB_NAME_TRAP
STATIC_ASSERT(arraysize(runtime_stub_names) ==
WasmCode::kRuntimeStubCount + 1);
DCHECK_GT(arraysize(runtime_stub_names), stub_id);
return runtime_stub_names[stub_id];
}
NativeModule::~NativeModule() {
TRACE_HEAP("Deleting native module: %p\n", this);
// Cancel all background compilation before resetting any field of the
......@@ -1998,6 +1982,20 @@ void WasmCodeRefScope::AddRef(WasmCode* code) {
if (entry.second) code->IncRef();
}
const char* GetRuntimeStubName(WasmCode::RuntimeStubId stub_id) {
#define RUNTIME_STUB_NAME(Name) #Name,
#define RUNTIME_STUB_NAME_TRAP(Name) "ThrowWasm" #Name,
constexpr const char* runtime_stub_names[] = {WASM_RUNTIME_STUB_LIST(
RUNTIME_STUB_NAME, RUNTIME_STUB_NAME_TRAP) "<unknown>"};
#undef RUNTIME_STUB_NAME
#undef RUNTIME_STUB_NAME_TRAP
STATIC_ASSERT(arraysize(runtime_stub_names) ==
WasmCode::kRuntimeStubCount + 1);
DCHECK_GT(arraysize(runtime_stub_names), stub_id);
return runtime_stub_names[stub_id];
}
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -561,8 +561,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
// must be a far jump table slot). Returns {kRuntimeStubCount} on failure.
WasmCode::RuntimeStubId GetRuntimeStubId(Address runtime_stub_target) const;
const char* GetRuntimeStubName(Address runtime_stub_target) const;
// Sample the current code size of this modules to the given counters.
enum CodeSamplingTime : int8_t { kAfterBaseline, kAfterTopTier, kSampling };
void SampleCodeSize(Counters*, CodeSamplingTime) const;
......@@ -881,6 +879,8 @@ class GlobalWasmCodeRef {
DISALLOW_COPY_AND_ASSIGN(GlobalWasmCodeRef);
};
const char* GetRuntimeStubName(WasmCode::RuntimeStubId);
} // namespace wasm
} // namespace internal
} // namespace v8
......
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