| 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> |
| 8 |
| 7 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 8 | 10 |
| 9 #include "src/base/platform/elapsed-timer.h" | 11 #include "src/base/platform/elapsed-timer.h" |
| 10 #include "src/base/platform/platform.h" | 12 #include "src/base/platform/platform.h" |
| 11 | 13 |
| 12 #include "src/compiler/access-builder.h" | 14 #include "src/compiler/access-builder.h" |
| 13 #include "src/compiler/common-operator.h" | 15 #include "src/compiler/common-operator.h" |
| 14 #include "src/compiler/diamond.h" | 16 #include "src/compiler/diamond.h" |
| 15 #include "src/compiler/graph-visualizer.h" | 17 #include "src/compiler/graph-visualizer.h" |
| 16 #include "src/compiler/graph.h" | 18 #include "src/compiler/graph.h" |
| (...skipping 3560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3577 if (FLAG_trace_wasm_compiler) { | 3579 if (FLAG_trace_wasm_compiler) { |
| 3578 OFStream os(stdout); | 3580 OFStream os(stdout); |
| 3579 os << "Compiling WASM function " | 3581 os << "Compiling WASM function " |
| 3580 << wasm::WasmFunctionName(function_, module_env_) << std::endl; | 3582 << wasm::WasmFunctionName(function_, module_env_) << std::endl; |
| 3581 os << std::endl; | 3583 os << std::endl; |
| 3582 } | 3584 } |
| 3583 | 3585 |
| 3584 double decode_ms = 0; | 3586 double decode_ms = 0; |
| 3585 size_t node_count = 0; | 3587 size_t node_count = 0; |
| 3586 | 3588 |
| 3587 base::SmartPointer<Zone> graph_zone(graph_zone_.Detach()); | 3589 std::unique_ptr<Zone> graph_zone(graph_zone_.release()); |
| 3588 SourcePositionTable* source_positions = BuildGraphForWasmFunction(&decode_ms); | 3590 SourcePositionTable* source_positions = BuildGraphForWasmFunction(&decode_ms); |
| 3589 | 3591 |
| 3590 if (graph_construction_result_.failed()) { | 3592 if (graph_construction_result_.failed()) { |
| 3591 ok_ = false; | 3593 ok_ = false; |
| 3592 return; | 3594 return; |
| 3593 } | 3595 } |
| 3594 | 3596 |
| 3595 base::ElapsedTimer pipeline_timer; | 3597 base::ElapsedTimer pipeline_timer; |
| 3596 if (FLAG_trace_wasm_decode_time) { | 3598 if (FLAG_trace_wasm_decode_time) { |
| 3597 node_count = jsgraph_->graph()->NodeCount(); | 3599 node_count = jsgraph_->graph()->NodeCount(); |
| 3598 pipeline_timer.Start(); | 3600 pipeline_timer.Start(); |
| 3599 } | 3601 } |
| 3600 | 3602 |
| 3601 // Run the compiler pipeline to generate machine code. | 3603 // Run the compiler pipeline to generate machine code. |
| 3602 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( | 3604 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( |
| 3603 &compilation_zone_, function_->sig); | 3605 &compilation_zone_, function_->sig); |
| 3604 if (jsgraph_->machine()->Is32()) { | 3606 if (jsgraph_->machine()->Is32()) { |
| 3605 descriptor = | 3607 descriptor = |
| 3606 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); | 3608 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); |
| 3607 } | 3609 } |
| 3608 job_.Reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), | 3610 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), |
| 3609 descriptor, source_positions)); | 3611 descriptor, source_positions)); |
| 3610 | 3612 |
| 3611 // The function name {OptimizeGraph()} is misleading but necessary because we | 3613 // The function name {OptimizeGraph()} is misleading but necessary because we |
| 3612 // want to use the CompilationJob interface. A better name would be | 3614 // want to use the CompilationJob interface. A better name would be |
| 3613 // ScheduleGraphAndSelectInstructions. | 3615 // ScheduleGraphAndSelectInstructions. |
| 3614 ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED; | 3616 ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED; |
| 3615 // TODO(bradnelson): Improve histogram handling of size_t. | 3617 // TODO(bradnelson): Improve histogram handling of size_t. |
| 3616 // TODO(ahaas): The counters are not thread-safe at the moment. | 3618 // TODO(ahaas): The counters are not thread-safe at the moment. |
| 3617 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() | 3619 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() |
| 3618 // ->AddSample( | 3620 // ->AddSample( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3669 function_->code_start_offset), | 3671 function_->code_start_offset), |
| 3670 compile_ms); | 3672 compile_ms); |
| 3671 } | 3673 } |
| 3672 | 3674 |
| 3673 return code; | 3675 return code; |
| 3674 } | 3676 } |
| 3675 | 3677 |
| 3676 } // namespace compiler | 3678 } // namespace compiler |
| 3677 } // namespace internal | 3679 } // namespace internal |
| 3678 } // namespace v8 | 3680 } // namespace v8 |
| OLD | NEW |