[wasm] Print wasm code kind in disassembly
The disassembler currently shows calls from JS code objects to wasm code as: REX.W movq r10,0x58466fd5120 ;; js to wasm call This does not show which code kind is being called (wasm function, lazy compile stub, or wasm-to-wasm wrapper). This CL extends the output to: REX.W movq r10,0x58466fd5120 (wasm-to-wasm) ;; js to wasm call R=mtrofin@chromium.org, titzer@chromium.org Bug: v8:6876, v8:7140 Change-Id: Ib350088017f767528ec0acd7d4c1c347758adcf2 Reviewed-on: https://chromium-review.googlesource.com/796270 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Cr-Commit-Position: refs/heads/master@{#49727}
This commit is contained in:
parent
1ca9756f91
commit
0762f35fa7
@ -17,6 +17,7 @@
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/snapshot/serializer-common.h"
|
||||
#include "src/string-stream.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -37,21 +38,28 @@ class V8NameConverter: public disasm::NameConverter {
|
||||
|
||||
|
||||
const char* V8NameConverter::NameOfAddress(byte* pc) const {
|
||||
const char* name =
|
||||
code_ == nullptr ? nullptr : code_->GetIsolate()->builtins()->Lookup(pc);
|
||||
|
||||
if (name != nullptr) {
|
||||
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc), name);
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
|
||||
if (code_ != nullptr) {
|
||||
Isolate* isolate = code_->GetIsolate();
|
||||
const char* name = isolate->builtins()->Lookup(pc);
|
||||
|
||||
if (name != nullptr) {
|
||||
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc), name);
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
|
||||
int offs = static_cast<int>(pc - code_->instruction_start());
|
||||
// print as code offset, if it seems reasonable
|
||||
if (0 <= offs && offs < code_->instruction_size()) {
|
||||
SNPrintF(v8_buffer_, "%p <+0x%x>", static_cast<void*>(pc), offs);
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
|
||||
wasm::WasmCode* wasm_code = isolate->wasm_code_manager()->LookupCode(pc);
|
||||
if (wasm_code != nullptr) {
|
||||
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc),
|
||||
GetWasmCodeKindAsString(wasm_code->kind()));
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
}
|
||||
|
||||
return disasm::NameConverter::NameOfAddress(pc);
|
||||
|
@ -190,6 +190,26 @@ void WasmCode::Print(Isolate* isolate) const {
|
||||
Disassemble(isolate, "", os);
|
||||
}
|
||||
|
||||
const char* GetWasmCodeKindAsString(WasmCode::Kind kind) {
|
||||
switch (kind) {
|
||||
case WasmCode::Function:
|
||||
return "wasm function";
|
||||
case WasmCode::WasmToWasmWrapper:
|
||||
return "wasm-to-wasm";
|
||||
case WasmCode::WasmToJsWrapper:
|
||||
return "wasm-to-js";
|
||||
case WasmCode::LazyStub:
|
||||
return "lazy-compile";
|
||||
case WasmCode::InterpreterStub:
|
||||
return "interpreter-entry";
|
||||
case WasmCode::CopiedStub:
|
||||
return "copied stub";
|
||||
case WasmCode::Trampoline:
|
||||
return "trampoline";
|
||||
}
|
||||
return "unknown kind";
|
||||
}
|
||||
|
||||
WasmCode::~WasmCode() {
|
||||
// Depending on finalizer order, the WasmCompiledModule finalizer may be
|
||||
// called first, case in which we release here. If the InstanceFinalizer is
|
||||
@ -847,7 +867,11 @@ void WasmCodeManager::FreeNativeModuleMemories(NativeModule* native_module) {
|
||||
// easily identify those places where we know we have the first
|
||||
// instruction PC.
|
||||
WasmCode* WasmCodeManager::GetCodeFromStartAddress(Address pc) const {
|
||||
return LookupCode(pc);
|
||||
WasmCode* code = LookupCode(pc);
|
||||
// This method can only be called for valid instruction start addresses.
|
||||
DCHECK_NOT_NULL(code);
|
||||
DCHECK_EQ(pc, code->instructions().start());
|
||||
return code;
|
||||
}
|
||||
|
||||
WasmCode* WasmCodeManager::LookupCode(Address pc) const {
|
||||
|
@ -174,6 +174,9 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
bool is_liftoff_;
|
||||
};
|
||||
|
||||
// Return a textual description of the kind.
|
||||
const char* GetWasmCodeKindAsString(WasmCode::Kind);
|
||||
|
||||
class WasmCodeManager;
|
||||
|
||||
// Note that we currently need to add code on the main thread, because we may
|
||||
|
Loading…
Reference in New Issue
Block a user