Commit d69b2df9 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Add code printing for native wasm code

This makes --print-code and --print-wasm-code also print code emitted
on the native wasm heap.
It also extends code printing to include the code kind and the index.

R=mtrofin@chromium.org

Change-Id: I39c23f4b65168c059f23477ec5d264924ca83e82
Reviewed-on: https://chromium-review.googlesource.com/831987Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50166}
parent 362e9894
......@@ -5066,6 +5066,15 @@ WasmCodeWrapper WasmCompilationUnit::FinishTurbofanCompilation(
codegen_ms);
}
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code || FLAG_print_wasm_code) {
// TODO(wasm): Use proper log files, here and elsewhere.
PrintF("--- Native Wasm code ---\n");
code->Print(isolate_);
PrintF("--- End code ---\n");
}
#endif
Handle<ByteArray> source_positions =
tf_.job_->compilation_info()->wasm_code_desc()->source_positions_table;
MaybeHandle<HandlerTable> handler_table =
......
......@@ -180,14 +180,18 @@ void WasmCode::ResetTrapHandlerIndex() { trap_handler_index_ = -1; }
// Disassembler::Decode.
void WasmCode::Disassemble(Isolate* isolate, const char* name,
std::ostream& os) const {
os << name << std::endl;
if (name) os << name << std::endl;
Disassembler::Decode(isolate, &os, instructions().start(),
instructions().end(), nullptr);
}
void WasmCode::Print(Isolate* isolate) const {
OFStream os(stdout);
Disassemble(isolate, "", os);
if (index_.IsJust()) {
os << "index: " << index_.FromJust() << "\n";
}
os << "kind: " << GetWasmCodeKindAsString(kind_) << "\n";
Disassemble(isolate, nullptr, os);
}
const char* GetWasmCodeKindAsString(WasmCode::Kind kind) {
......
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