| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
| 10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| (...skipping 4073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4084 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; | 4084 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; |
| 4085 // TODO(bradnelson): Improve histogram handling of size_t. | 4085 // TODO(bradnelson): Improve histogram handling of size_t. |
| 4086 // TODO(ahaas): The counters are not thread-safe at the moment. | 4086 // TODO(ahaas): The counters are not thread-safe at the moment. |
| 4087 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() | 4087 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() |
| 4088 // ->AddSample( | 4088 // ->AddSample( |
| 4089 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 4089 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); |
| 4090 | 4090 |
| 4091 if (FLAG_trace_wasm_decode_time) { | 4091 if (FLAG_trace_wasm_decode_time) { |
| 4092 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); | 4092 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); |
| 4093 PrintF( | 4093 PrintF( |
| 4094 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, " | 4094 "wasm-compilation phase 1 ok: %u bytes, %0.3f ms decode, %zu nodes, " |
| 4095 "%0.3f ms pipeline\n", | 4095 "%0.3f ms pipeline\n", |
| 4096 static_cast<int>(function_->code_end_offset - | 4096 function_->code_end_offset - function_->code_start_offset, decode_ms, |
| 4097 function_->code_start_offset), | 4097 node_count, pipeline_ms); |
| 4098 decode_ms, node_count, pipeline_ms); | |
| 4099 } | 4098 } |
| 4100 } | 4099 } |
| 4101 | 4100 |
| 4102 Handle<Code> WasmCompilationUnit::FinishCompilation() { | 4101 Handle<Code> WasmCompilationUnit::FinishCompilation() { |
| 4103 if (!ok_) { | 4102 if (!ok_) { |
| 4104 if (graph_construction_result_.failed()) { | 4103 if (graph_construction_result_.failed()) { |
| 4105 // Add the function as another context for the exception | 4104 // Add the function as another context for the exception |
| 4106 ScopedVector<char> buffer(128); | 4105 ScopedVector<char> buffer(128); |
| 4107 wasm::WasmName name = module_env_->wire_bytes.GetName(function_); | 4106 wasm::WasmName name = module_env_->wire_bytes.GetName(function_); |
| 4108 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", | 4107 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", |
| 4109 function_->func_index, name.length(), name.start()); | 4108 function_->func_index, name.length(), name.start()); |
| 4110 thrower_->CompileFailed(buffer.start(), graph_construction_result_); | 4109 thrower_->CompileFailed(buffer.start(), graph_construction_result_); |
| 4111 } | 4110 } |
| 4112 | 4111 |
| 4113 return Handle<Code>::null(); | 4112 return Handle<Code>::null(); |
| 4114 } | 4113 } |
| 4114 base::ElapsedTimer codegen_timer; |
| 4115 if (FLAG_trace_wasm_decode_time) { |
| 4116 codegen_timer.Start(); |
| 4117 } |
| 4115 if (job_->FinalizeJob() != CompilationJob::SUCCEEDED) { | 4118 if (job_->FinalizeJob() != CompilationJob::SUCCEEDED) { |
| 4116 return Handle<Code>::null(); | 4119 return Handle<Code>::null(); |
| 4117 } | 4120 } |
| 4118 base::ElapsedTimer compile_timer; | |
| 4119 if (FLAG_trace_wasm_decode_time) { | |
| 4120 compile_timer.Start(); | |
| 4121 } | |
| 4122 Handle<Code> code = info_.code(); | 4121 Handle<Code> code = info_.code(); |
| 4123 DCHECK(!code.is_null()); | 4122 DCHECK(!code.is_null()); |
| 4124 | 4123 |
| 4125 if (isolate_->logger()->is_logging_code_events() || | 4124 if (isolate_->logger()->is_logging_code_events() || |
| 4126 isolate_->is_profiling()) { | 4125 isolate_->is_profiling()) { |
| 4127 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate_, code, | 4126 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate_, code, |
| 4128 "WASM_function", function_->func_index, | 4127 "WASM_function", function_->func_index, |
| 4129 wasm::WasmName("module"), | 4128 wasm::WasmName("module"), |
| 4130 module_env_->wire_bytes.GetName(function_)); | 4129 module_env_->wire_bytes.GetName(function_)); |
| 4131 } | 4130 } |
| 4132 | 4131 |
| 4133 if (FLAG_trace_wasm_decode_time) { | 4132 if (FLAG_trace_wasm_decode_time) { |
| 4134 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); | 4133 double codegen_ms = codegen_timer.Elapsed().InMillisecondsF(); |
| 4135 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n", | 4134 PrintF("wasm-code-generation ok: %u bytes, %0.3f ms code generation\n", |
| 4136 static_cast<int>(function_->code_end_offset - | 4135 function_->code_end_offset - function_->code_start_offset, |
| 4137 function_->code_start_offset), | 4136 codegen_ms); |
| 4138 compile_ms); | |
| 4139 } | 4137 } |
| 4140 | 4138 |
| 4141 return code; | 4139 return code; |
| 4142 } | 4140 } |
| 4143 | 4141 |
| 4144 } // namespace compiler | 4142 } // namespace compiler |
| 4145 } // namespace internal | 4143 } // namespace internal |
| 4146 } // namespace v8 | 4144 } // namespace v8 |
| OLD | NEW |