| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_COMPILER_PIPELINE_H_ | 5 #ifndef V8_COMPILER_PIPELINE_H_ |
| 6 #define V8_COMPILER_PIPELINE_H_ | 6 #define V8_COMPILER_PIPELINE_H_ |
| 7 | 7 |
| 8 // Clients of this interface shouldn't depend on lots of compiler internals. | 8 // Clients of this interface shouldn't depend on lots of compiler internals. |
| 9 // Do not include anything from src/compiler here! | 9 // Do not include anything from src/compiler here! |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class CallDescriptor; | 21 class CallDescriptor; |
| 22 class Graph; | 22 class Graph; |
| 23 class InstructionSequence; | 23 class InstructionSequence; |
| 24 class Linkage; | 24 class Linkage; |
| 25 class PipelineData; | 25 class PipelineData; |
| 26 class Schedule; | 26 class Schedule; |
| 27 class SourcePositionTable; | 27 class SourcePositionTable; |
| 28 | 28 |
| 29 class Pipeline { | 29 class Pipeline { |
| 30 public: | 30 public: |
| 31 explicit Pipeline(PipelineData* data) : data_(data) {} | 31 // Returns a new compilation job for the given function. |
| 32 static CompilationJob* NewCompilationJob(Handle<JSFunction> function); |
| 32 | 33 |
| 33 // Run the graph creation and initial optimization passes. | 34 // Returns a new compilation job for the WebAssembly compilation info. |
| 34 bool CreateGraph(); | 35 static CompilationJob* NewWasmCompilationJob( |
| 35 | 36 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, |
| 36 // Run the concurrent optimization passes. | 37 SourcePositionTable* source_positions); |
| 37 bool OptimizeGraph(Linkage* linkage); | |
| 38 | |
| 39 // Perform the actual code generation and return handle to a code object. | |
| 40 Handle<Code> GenerateCode(Linkage* linkage); | |
| 41 | |
| 42 // Run the entire pipeline and generate a handle to a code object. | |
| 43 Handle<Code> GenerateCode(); | |
| 44 | 38 |
| 45 // Run the pipeline on a machine graph and generate code. The {schedule} must | 39 // Run the pipeline on a machine graph and generate code. The {schedule} must |
| 46 // be valid, hence the given {graph} does not need to be schedulable. | 40 // be valid, hence the given {graph} does not need to be schedulable. |
| 47 static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate, | 41 static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate, |
| 48 CallDescriptor* call_descriptor, | 42 CallDescriptor* call_descriptor, |
| 49 Graph* graph, Schedule* schedule, | 43 Graph* graph, Schedule* schedule, |
| 50 Code::Flags flags, | 44 Code::Flags flags, |
| 51 const char* debug_name); | 45 const char* debug_name); |
| 52 | 46 |
| 53 // Run the entire pipeline and generate a handle to a code object suitable for | 47 // Run the entire pipeline and generate a handle to a code object suitable for |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 InstructionSequence* sequence, | 59 InstructionSequence* sequence, |
| 66 bool run_verifier); | 60 bool run_verifier); |
| 67 | 61 |
| 68 // Run the pipeline on a machine graph and generate code. If {schedule} is | 62 // Run the pipeline on a machine graph and generate code. If {schedule} is |
| 69 // {nullptr}, then compute a new schedule for code generation. | 63 // {nullptr}, then compute a new schedule for code generation. |
| 70 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, | 64 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, |
| 71 CallDescriptor* call_descriptor, | 65 CallDescriptor* call_descriptor, |
| 72 Graph* graph, | 66 Graph* graph, |
| 73 Schedule* schedule = nullptr); | 67 Schedule* schedule = nullptr); |
| 74 | 68 |
| 75 // Returns a new compilation job for the given function. | 69 private: |
| 76 static CompilationJob* NewCompilationJob(Handle<JSFunction> function); | 70 friend class PipelineCompilationJob; |
| 71 friend class PipelineWasmCompilationJob; |
| 77 | 72 |
| 78 // Returns a new compilation job for the WebAssembly compilation info. | 73 explicit Pipeline(PipelineData* data) : data_(data) {} |
| 79 static CompilationJob* NewWasmCompilationJob( | |
| 80 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, | |
| 81 SourcePositionTable* source_positions); | |
| 82 | |
| 83 private: | |
| 84 // The wasm compilation job calls ScheduleAndSelectInstructions and | |
| 85 // RunPrintAndVerify, so we make it a member class. | |
| 86 friend class PipelineWasmCompilationJob; | |
| 87 | 74 |
| 88 // Helpers for executing pipeline phases. | 75 // Helpers for executing pipeline phases. |
| 89 template <typename Phase> | 76 template <typename Phase> |
| 90 void Run(); | 77 void Run(); |
| 91 template <typename Phase, typename Arg0> | 78 template <typename Phase, typename Arg0> |
| 92 void Run(Arg0 arg_0); | 79 void Run(Arg0 arg_0); |
| 93 template <typename Phase, typename Arg0, typename Arg1> | 80 template <typename Phase, typename Arg0, typename Arg1> |
| 94 void Run(Arg0 arg_0, Arg1 arg_1); | 81 void Run(Arg0 arg_0, Arg1 arg_1); |
| 95 | 82 |
| 83 // Run the graph creation and initial optimization passes. |
| 84 bool CreateGraph(); |
| 85 |
| 86 // Run the concurrent optimization passes. |
| 87 bool OptimizeGraph(Linkage* linkage); |
| 88 |
| 89 // Perform the actual code generation and return handle to a code object. |
| 90 Handle<Code> GenerateCode(Linkage* linkage); |
| 91 |
| 92 // Run the entire pipeline and generate a handle to a code object. |
| 93 Handle<Code> GenerateCode(); |
| 94 |
| 96 void BeginPhaseKind(const char* phase_kind); | 95 void BeginPhaseKind(const char* phase_kind); |
| 97 void EndPhaseKind(); | 96 void EndPhaseKind(); |
| 98 bool ScheduleAndSelectInstructions(Linkage* linkage); | 97 bool ScheduleAndSelectInstructions(Linkage* linkage); |
| 99 void RunPrintAndVerify(const char* phase, bool untyped = false); | 98 void RunPrintAndVerify(const char* phase, bool untyped = false); |
| 100 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); | 99 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); |
| 101 void AllocateRegisters(const RegisterConfiguration* config, | 100 void AllocateRegisters(const RegisterConfiguration* config, |
| 102 CallDescriptor* descriptor, bool run_verifier); | 101 CallDescriptor* descriptor, bool run_verifier); |
| 103 | 102 |
| 104 CompilationInfo* info() const; | 103 CompilationInfo* info() const; |
| 105 Isolate* isolate() const; | 104 Isolate* isolate() const; |
| 106 | 105 |
| 107 PipelineData* const data_; | 106 PipelineData* const data_; |
| 108 | 107 |
| 109 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 108 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 } // namespace compiler | 111 } // namespace compiler |
| 113 } // namespace internal | 112 } // namespace internal |
| 114 } // namespace v8 | 113 } // namespace v8 |
| 115 | 114 |
| 116 #endif // V8_COMPILER_PIPELINE_H_ | 115 #endif // V8_COMPILER_PIPELINE_H_ |
| OLD | NEW |