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 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3167 | 3167 |
3168 // Run the compiler pipeline to generate machine code. | 3168 // Run the compiler pipeline to generate machine code. |
3169 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( | 3169 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( |
3170 &compilation_zone_, function_->sig); | 3170 &compilation_zone_, function_->sig); |
3171 if (jsgraph_->machine()->Is32()) { | 3171 if (jsgraph_->machine()->Is32()) { |
3172 descriptor = | 3172 descriptor = |
3173 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); | 3173 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); |
3174 } | 3174 } |
3175 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), | 3175 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), |
3176 descriptor, source_positions)); | 3176 descriptor, source_positions)); |
3177 | 3177 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; |
3178 // The function name {OptimizeGraph()} is misleading but necessary because we | |
3179 // want to use the CompilationJob interface. A better name would be | |
3180 // ScheduleGraphAndSelectInstructions. | |
3181 ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED; | |
3182 // TODO(bradnelson): Improve histogram handling of size_t. | 3178 // TODO(bradnelson): Improve histogram handling of size_t. |
3183 // TODO(ahaas): The counters are not thread-safe at the moment. | 3179 // TODO(ahaas): The counters are not thread-safe at the moment. |
3184 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() | 3180 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() |
3185 // ->AddSample( | 3181 // ->AddSample( |
3186 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 3182 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); |
3187 | 3183 |
3188 if (FLAG_trace_wasm_decode_time) { | 3184 if (FLAG_trace_wasm_decode_time) { |
3189 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); | 3185 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); |
3190 PrintF( | 3186 PrintF( |
3191 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, " | 3187 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, " |
(...skipping 11 matching lines...) Expand all Loading... |
3203 ScopedVector<char> buffer(128); | 3199 ScopedVector<char> buffer(128); |
3204 wasm::WasmName name = module_env_->module->GetName( | 3200 wasm::WasmName name = module_env_->module->GetName( |
3205 function_->name_offset, function_->name_length); | 3201 function_->name_offset, function_->name_length); |
3206 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", | 3202 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", |
3207 function_->func_index, name.length(), name.start()); | 3203 function_->func_index, name.length(), name.start()); |
3208 thrower_->Failed(buffer.start(), graph_construction_result_); | 3204 thrower_->Failed(buffer.start(), graph_construction_result_); |
3209 } | 3205 } |
3210 | 3206 |
3211 return Handle<Code>::null(); | 3207 return Handle<Code>::null(); |
3212 } | 3208 } |
3213 if (job_->GenerateCode() != CompilationJob::SUCCEEDED) { | 3209 if (job_->FinalizeJob() != CompilationJob::SUCCEEDED) { |
3214 return Handle<Code>::null(); | 3210 return Handle<Code>::null(); |
3215 } | 3211 } |
3216 base::ElapsedTimer compile_timer; | 3212 base::ElapsedTimer compile_timer; |
3217 if (FLAG_trace_wasm_decode_time) { | 3213 if (FLAG_trace_wasm_decode_time) { |
3218 compile_timer.Start(); | 3214 compile_timer.Start(); |
3219 } | 3215 } |
3220 Handle<Code> code = info_.code(); | 3216 Handle<Code> code = info_.code(); |
3221 DCHECK(!code.is_null()); | 3217 DCHECK(!code.is_null()); |
3222 | 3218 |
3223 if (isolate_->logger()->is_logging_code_events() || | 3219 if (isolate_->logger()->is_logging_code_events() || |
(...skipping 12 matching lines...) Expand all Loading... |
3236 function_->code_start_offset), | 3232 function_->code_start_offset), |
3237 compile_ms); | 3233 compile_ms); |
3238 } | 3234 } |
3239 | 3235 |
3240 return code; | 3236 return code; |
3241 } | 3237 } |
3242 | 3238 |
3243 } // namespace compiler | 3239 } // namespace compiler |
3244 } // namespace internal | 3240 } // namespace internal |
3245 } // namespace v8 | 3241 } // namespace v8 |
OLD | NEW |