[Liftoff] Also disassemble code on the native heap
With --jit-to-native, we current don't disassemble any Liftoff code. This CL adds that, and also adds printing of relocation info of native wasm code. R=mstarzinger@chromium.org CC=titzer@chromium.org Bug: v8:6600 Change-Id: Icb1249868224180171107b82e2dd7dc69e23db16 Reviewed-on: https://chromium-review.googlesource.com/863762 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#50553}
This commit is contained in:
parent
08cdc02316
commit
8cf7223fb1
@ -5218,22 +5218,6 @@ WasmCodeWrapper WasmCompilationUnit::FinishLiftoffCompilation(
|
||||
false, // is_turbofanned
|
||||
liftoff_.asm_.GetTotalFrameSlotCount(), // stack_slots
|
||||
liftoff_.safepoint_table_offset_);
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
if (FLAG_print_code || FLAG_print_wasm_code) {
|
||||
// TODO(wasm): Use proper log files, here and elsewhere.
|
||||
OFStream os(stdout);
|
||||
os << "--- Wasm liftoff code ---\n";
|
||||
EmbeddedVector<char, 64> func_name;
|
||||
if (func_name_.start() != nullptr) {
|
||||
SNPrintF(func_name, "#%d:%.*s", func_index(), func_name_.length(),
|
||||
func_name_.start());
|
||||
} else {
|
||||
SNPrintF(func_name, "wasm#%d", func_index());
|
||||
}
|
||||
code->Disassemble(func_name.start(), os);
|
||||
os << "--- End code ---\n";
|
||||
}
|
||||
#endif
|
||||
if (isolate_->logger()->is_logging_code_events() ||
|
||||
isolate_->is_profiling()) {
|
||||
RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate_, code,
|
||||
@ -5241,17 +5225,34 @@ WasmCodeWrapper WasmCompilationUnit::FinishLiftoffCompilation(
|
||||
}
|
||||
|
||||
PackProtectedInstructions(code);
|
||||
return WasmCodeWrapper(code);
|
||||
ret = WasmCodeWrapper(code);
|
||||
} else {
|
||||
// TODO(mtrofin): figure a way to raise events; also, disassembly.
|
||||
// Consider lifting them both to FinishCompilation.
|
||||
// TODO(mtrofin): figure a way to raise events.
|
||||
// Consider lifting it to FinishCompilation.
|
||||
native_module_->compiled_module()->source_positions()->set(
|
||||
func_index_, *source_positions);
|
||||
return WasmCodeWrapper(
|
||||
ret = WasmCodeWrapper(
|
||||
native_module_->AddCode(desc, liftoff_.asm_.GetTotalFrameSlotCount(),
|
||||
func_index_, liftoff_.safepoint_table_offset_,
|
||||
std::move(protected_instructions_), true));
|
||||
}
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
if (FLAG_print_code || FLAG_print_wasm_code) {
|
||||
// TODO(wasm): Use proper log files, here and elsewhere.
|
||||
OFStream os(stdout);
|
||||
os << "--- Wasm liftoff code ---\n";
|
||||
EmbeddedVector<char, 64> func_name;
|
||||
if (func_name_.start() != nullptr) {
|
||||
SNPrintF(func_name, "#%d:%.*s", func_index(), func_name_.length(),
|
||||
func_name_.start());
|
||||
} else {
|
||||
SNPrintF(func_name, "wasm#%d", func_index());
|
||||
}
|
||||
ret.Disassemble(func_name.start(), isolate_, os);
|
||||
os << "--- End code ---\n";
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -180,14 +180,20 @@ void WasmCode::ResetTrapHandlerIndex() { trap_handler_index_ = -1; }
|
||||
|
||||
void WasmCode::Print(Isolate* isolate) const {
|
||||
OFStream os(stdout);
|
||||
if (index_.IsJust()) {
|
||||
os << "index: " << index_.FromJust() << "\n";
|
||||
}
|
||||
Disassemble(nullptr, isolate, os);
|
||||
}
|
||||
|
||||
void WasmCode::Disassemble(const char* name, Isolate* isolate,
|
||||
std::ostream& os) const {
|
||||
if (name) os << "name: " << name << "\n";
|
||||
if (index_.IsJust()) os << "index: " << index_.FromJust() << "\n";
|
||||
os << "kind: " << GetWasmCodeKindAsString(kind_) << "\n";
|
||||
os << "compiler: " << (is_liftoff() ? "Liftoff" : "TurboFan") << "\n";
|
||||
size_t body_size = instructions().size();
|
||||
os << "Body (size = " << body_size << ")\n";
|
||||
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
|
||||
size_t instruction_size =
|
||||
std::min(constant_pool_offset_, safepoint_table_offset_);
|
||||
os << "Instructions (size = " << instruction_size << ")\n";
|
||||
@ -210,6 +216,14 @@ void WasmCode::Print(Isolate* isolate) const {
|
||||
}
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
os << "RelocInfo (size = " << reloc_size_ << ")\n";
|
||||
for (RelocIterator it(instructions(), reloc_info(), constant_pool());
|
||||
!it.done(); it.next()) {
|
||||
it.rinfo()->Print(isolate, os);
|
||||
}
|
||||
os << "\n";
|
||||
#endif // ENABLE_DISASSEMBLER
|
||||
}
|
||||
|
||||
const char* GetWasmCodeKindAsString(WasmCode::Kind kind) {
|
||||
|
@ -124,6 +124,7 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
}
|
||||
|
||||
void Print(Isolate* isolate) const;
|
||||
void Disassemble(const char* name, Isolate* isolate, std::ostream& os) const;
|
||||
|
||||
~WasmCode();
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/objects.h"
|
||||
#include "src/objects/code.h"
|
||||
#include "src/wasm/wasm-code-manager.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -34,5 +35,16 @@ const wasm::WasmCode* WasmCodeWrapper::GetWasmCode() const {
|
||||
|
||||
bool WasmCodeWrapper::IsCodeObject() const { return !FLAG_wasm_jit_to_native; }
|
||||
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
void WasmCodeWrapper::Disassemble(const char* name, Isolate* isolate,
|
||||
std::ostream& os) const {
|
||||
if (IsCodeObject()) {
|
||||
GetCode()->Disassemble(name, os);
|
||||
} else {
|
||||
GetWasmCode()->Disassemble(name, isolate, os);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -26,6 +26,10 @@ class WasmCodeWrapper {
|
||||
bool is_null() const { return code_ptr_.wasm_code_ == nullptr; }
|
||||
bool IsCodeObject() const;
|
||||
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
void Disassemble(const char* name, Isolate* isolate, std::ostream& os) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
union {
|
||||
const wasm::WasmCode* wasm_code_;
|
||||
|
Loading…
Reference in New Issue
Block a user