Commit cbbdc6cb authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

Use code tracer for code printing

Fix up disassembly triggered by --print-*-code to print to the trace
file specified by --redirect-code-traces-to rather than unconditionally
to stdout.

Change-Id: I80a8772361e8fb0550efcbbab6a7b7d822385303
Reviewed-on: https://chromium-review.googlesource.com/973167
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52119}
parent f8184738
...@@ -4681,7 +4681,8 @@ Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module, ...@@ -4681,7 +4681,8 @@ Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph); Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code && !code.is_null()) { if (FLAG_print_opt_code && !code.is_null()) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
code->Disassemble(func_name.start(), os); code->Disassemble(func_name.start(), os);
} }
#endif #endif
...@@ -4814,7 +4815,8 @@ Handle<Code> CompileWasmToJSWrapper( ...@@ -4814,7 +4815,8 @@ Handle<Code> CompileWasmToJSWrapper(
code->set_deoptimization_data(*deopt_data); code->set_deoptimization_data(*deopt_data);
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code && !code.is_null()) { if (FLAG_print_opt_code && !code.is_null()) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
code->Disassemble(func_name.start(), os); code->Disassemble(func_name.start(), os);
} }
#endif #endif
...@@ -4883,7 +4885,8 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, wasm::WasmCode* target, ...@@ -4883,7 +4885,8 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, wasm::WasmCode* target,
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph); Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code && !code.is_null()) { if (FLAG_print_opt_code && !code.is_null()) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
code->Disassemble(buffer.start(), os); code->Disassemble(buffer.start(), os);
} }
#endif #endif
...@@ -4948,7 +4951,8 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index, ...@@ -4948,7 +4951,8 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index,
nullptr); nullptr);
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code && !code.is_null()) { if (FLAG_print_opt_code && !code.is_null()) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
code->Disassemble(func_name.start(), os); code->Disassemble(func_name.start(), os);
} }
#endif #endif
...@@ -5014,7 +5018,8 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig) { ...@@ -5014,7 +5018,8 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig) {
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph); Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code && !code.is_null()) { if (FLAG_print_opt_code && !code.is_null()) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
code->Disassemble(debug_name, os); code->Disassemble(debug_name, os);
} }
#endif #endif
......
...@@ -113,8 +113,10 @@ Code* BuiltinDeserializer::DeserializeBuiltin(int builtin_id) { ...@@ -113,8 +113,10 @@ Code* BuiltinDeserializer::DeserializeBuiltin(int builtin_id) {
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_builtin_code) { if (FLAG_print_builtin_code) {
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
DCHECK(isolate()->builtins()->is_initialized()); DCHECK(isolate()->builtins()->is_initialized());
OFStream os(stdout);
code->Disassemble(Builtins::name(builtin_id), os); code->Disassemble(Builtins::name(builtin_id), os);
os << std::flush; os << std::flush;
} }
...@@ -131,7 +133,9 @@ Code* BuiltinDeserializer::DeserializeHandler(Bytecode bytecode, ...@@ -131,7 +133,9 @@ Code* BuiltinDeserializer::DeserializeHandler(Bytecode bytecode,
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_builtin_code) { if (FLAG_print_builtin_code) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
code->Disassemble(Bytecodes::ToString(bytecode), os); code->Disassemble(Bytecodes::ToString(bytecode), os);
os << std::flush; os << std::flush;
} }
......
...@@ -389,7 +389,9 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode() { ...@@ -389,7 +389,9 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode() {
CHECK(!code_.is_null()); CHECK(!code_.is_null());
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code) { if (FLAG_print_opt_code) {
OFStream os(stdout); CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
code_->Disassemble("wasm wrapper", os); code_->Disassemble("wasm wrapper", os);
} }
#endif #endif
......
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