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/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 | 10 |
(...skipping 3147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3158 | 3158 |
3159 // Run the compiler pipeline to generate machine code. | 3159 // Run the compiler pipeline to generate machine code. |
3160 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( | 3160 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( |
3161 &compilation_zone_, function_->sig); | 3161 &compilation_zone_, function_->sig); |
3162 if (jsgraph_->machine()->Is32()) { | 3162 if (jsgraph_->machine()->Is32()) { |
3163 descriptor = | 3163 descriptor = |
3164 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); | 3164 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); |
3165 } | 3165 } |
3166 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), | 3166 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), |
3167 descriptor, source_positions)); | 3167 descriptor, source_positions)); |
3168 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; | 3168 |
| 3169 // The function name {OptimizeGraph()} is misleading but necessary because we |
| 3170 // want to use the CompilationJob interface. A better name would be |
| 3171 // ScheduleGraphAndSelectInstructions. |
| 3172 ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED; |
3169 // TODO(bradnelson): Improve histogram handling of size_t. | 3173 // TODO(bradnelson): Improve histogram handling of size_t. |
3170 // TODO(ahaas): The counters are not thread-safe at the moment. | 3174 // TODO(ahaas): The counters are not thread-safe at the moment. |
3171 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() | 3175 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() |
3172 // ->AddSample( | 3176 // ->AddSample( |
3173 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 3177 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); |
3174 | 3178 |
3175 if (FLAG_trace_wasm_decode_time) { | 3179 if (FLAG_trace_wasm_decode_time) { |
3176 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); | 3180 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); |
3177 PrintF( | 3181 PrintF( |
3178 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, " | 3182 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, " |
(...skipping 11 matching lines...) Expand all Loading... |
3190 ScopedVector<char> buffer(128); | 3194 ScopedVector<char> buffer(128); |
3191 wasm::WasmName name = module_env_->module->GetName( | 3195 wasm::WasmName name = module_env_->module->GetName( |
3192 function_->name_offset, function_->name_length); | 3196 function_->name_offset, function_->name_length); |
3193 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", | 3197 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", |
3194 function_->func_index, name.length(), name.start()); | 3198 function_->func_index, name.length(), name.start()); |
3195 thrower_->Failed(buffer.start(), graph_construction_result_); | 3199 thrower_->Failed(buffer.start(), graph_construction_result_); |
3196 } | 3200 } |
3197 | 3201 |
3198 return Handle<Code>::null(); | 3202 return Handle<Code>::null(); |
3199 } | 3203 } |
3200 if (job_->FinalizeJob() != CompilationJob::SUCCEEDED) { | 3204 if (job_->GenerateCode() != CompilationJob::SUCCEEDED) { |
3201 return Handle<Code>::null(); | 3205 return Handle<Code>::null(); |
3202 } | 3206 } |
3203 base::ElapsedTimer compile_timer; | 3207 base::ElapsedTimer compile_timer; |
3204 if (FLAG_trace_wasm_decode_time) { | 3208 if (FLAG_trace_wasm_decode_time) { |
3205 compile_timer.Start(); | 3209 compile_timer.Start(); |
3206 } | 3210 } |
3207 Handle<Code> code = info_.code(); | 3211 Handle<Code> code = info_.code(); |
3208 DCHECK(!code.is_null()); | 3212 DCHECK(!code.is_null()); |
3209 | 3213 |
3210 if (isolate_->logger()->is_logging_code_events() || | 3214 if (isolate_->logger()->is_logging_code_events() || |
(...skipping 12 matching lines...) Expand all Loading... |
3223 function_->code_start_offset), | 3227 function_->code_start_offset), |
3224 compile_ms); | 3228 compile_ms); |
3225 } | 3229 } |
3226 | 3230 |
3227 return code; | 3231 return code; |
3228 } | 3232 } |
3229 | 3233 |
3230 } // namespace compiler | 3234 } // namespace compiler |
3231 } // namespace internal | 3235 } // namespace internal |
3232 } // namespace v8 | 3236 } // namespace v8 |
OLD | NEW |