Commit 82be80aa authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Print stub call target with --print-wasm-code.

R=titzer@chromium.org

Change-Id: Id2766ee8d69ebd1a747374f1be71788c77a41d70
Reviewed-on: https://chromium-review.googlesource.com/1254128Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56318}
parent e3da3c67
......@@ -142,8 +142,8 @@ static const int kRelocInfoPosition = 57;
static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
const ExternalReferenceEncoder* ref_encoder,
std::ostream* os, RelocInfo* relocinfo,
bool first_reloc_info = true) {
std::ostream* os, CodeReference host,
RelocInfo* relocinfo, bool first_reloc_info = true) {
// Indent the printing of the reloc info.
if (first_reloc_info) {
// The first reloc info is printed after the disassembled instruction.
......@@ -199,6 +199,10 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
} else {
out->AddFormatted(" %s", Code::Kind2String(kind));
}
} else if (RelocInfo::IsWasmStubCall(rmode)) {
wasm::WasmCode* code = host.as_wasm_code()->native_module()->Lookup(
relocinfo->wasm_stub_call_address());
out->AddFormatted(" ;; wasm stub: %s", code->GetRuntimeStubName());
} else if (RelocInfo::IsRuntimeEntry(rmode) && isolate &&
isolate->deoptimizer_data() != nullptr) {
// A runtime entry relocinfo might be a deoptimization bailout.
......@@ -313,7 +317,7 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], nullptr, constant_pool);
bool first_reloc_info = (i == 0);
PrintRelocInfo(&out, isolate, ref_encoder, os, &relocinfo,
PrintRelocInfo(&out, isolate, ref_encoder, os, code, &relocinfo,
first_reloc_info);
}
......@@ -331,7 +335,8 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
if (reloc_it.rinfo()->IsInConstantPool() &&
(reloc_it.rinfo()->constant_pool_entry_address() ==
constant_pool_entry_address)) {
PrintRelocInfo(&out, isolate, ref_encoder, os, reloc_it.rinfo());
PrintRelocInfo(&out, isolate, ref_encoder, os, code,
reloc_it.rinfo());
break;
}
reloc_it.next();
......
......@@ -179,6 +179,19 @@ void WasmCode::LogCode(Isolate* isolate) const {
}
}
const char* WasmCode::GetRuntimeStubName() const {
DCHECK_EQ(WasmCode::kRuntimeStub, kind());
#define RETURN_NAME(Name) \
if (native_module_->runtime_stub_table_[WasmCode::k##Name] == this) { \
return #Name; \
}
#define RETURN_NAME_TRAP(Name) RETURN_NAME(ThrowWasm##Name)
WASM_RUNTIME_STUB_LIST(RETURN_NAME, RETURN_NAME_TRAP)
#undef RETURN_NAME_TRAP
#undef RETURN_NAME
return "<unknown>";
}
void WasmCode::Validate() const {
#ifdef DEBUG
// We expect certain relocation info modes to never appear in {WasmCode}
......@@ -456,7 +469,7 @@ void NativeModule::SetRuntimeStubs(Isolate* isolate) {
AddAnonymousCode(isolate->builtins()->builtin_handle(Builtins::k##Name), \
WasmCode::kRuntimeStub, #Name);
#define COPY_BUILTIN_TRAP(Name) COPY_BUILTIN(ThrowWasm##Name)
WASM_RUNTIME_STUB_LIST(COPY_BUILTIN, COPY_BUILTIN_TRAP);
WASM_RUNTIME_STUB_LIST(COPY_BUILTIN, COPY_BUILTIN_TRAP)
#undef COPY_BUILTIN_TRAP
#undef COPY_BUILTIN
}
......
......@@ -126,6 +126,8 @@ class V8_EXPORT_PRIVATE WasmCode final {
return protected_instructions_.as_vector();
}
const char* GetRuntimeStubName() const;
void Validate() const;
void Print(const char* name = nullptr) const;
void Disassemble(const char* name, std::ostream& os,
......
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