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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class CompilationInfo; | 15 class CompilationInfo; |
16 class OptimizedCompileJob; | 16 class OptimizedCompileJob; |
17 class RegisterConfiguration; | 17 class RegisterConfiguration; |
18 class Zone; | |
19 | 18 |
20 namespace compiler { | 19 namespace compiler { |
21 | 20 |
22 class CallDescriptor; | 21 class CallDescriptor; |
23 class Graph; | 22 class Graph; |
24 class InstructionSequence; | 23 class InstructionSequence; |
25 class Linkage; | 24 class Linkage; |
26 class PipelineData; | 25 class PipelineData; |
27 class Schedule; | 26 class Schedule; |
28 class SourcePositionTable; | 27 class SourcePositionTable; |
29 class ZonePool; | |
30 | 28 |
31 class Pipeline { | 29 class Pipeline { |
32 public: | 30 public: |
33 explicit Pipeline(CompilationInfo* info) : info_(info), data_(nullptr) {} | 31 explicit Pipeline(PipelineData* data) : data_(data) {} |
| 32 |
| 33 // Run the graph creation and initial optimization passes. |
| 34 bool CreateGraph(); |
| 35 |
| 36 // Run the concurrent optimization passes. |
| 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); |
34 | 41 |
35 // Run the entire pipeline and generate a handle to a code object. | 42 // Run the entire pipeline and generate a handle to a code object. |
36 Handle<Code> GenerateCode(); | 43 Handle<Code> GenerateCode(); |
37 | 44 |
38 // Run the pipeline on a machine graph and generate code. The {schedule} must | 45 // Run the pipeline on a machine graph and generate code. The {schedule} must |
39 // be valid, hence the given {graph} does not need to be schedulable. | 46 // be valid, hence the given {graph} does not need to be schedulable. |
40 static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate, | 47 static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate, |
41 CallDescriptor* call_descriptor, | 48 CallDescriptor* call_descriptor, |
42 Graph* graph, Schedule* schedule, | 49 Graph* graph, Schedule* schedule, |
43 Code::Flags flags, | 50 Code::Flags flags, |
44 const char* debug_name); | 51 const char* debug_name); |
45 | 52 |
| 53 // Run the entire pipeline and generate a handle to a code object suitable for |
| 54 // testing. |
| 55 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info); |
| 56 |
46 // Run the pipeline on a machine graph and generate code. If {schedule} is | 57 // Run the pipeline on a machine graph and generate code. If {schedule} is |
47 // {nullptr}, then compute a new schedule for code generation. | 58 // {nullptr}, then compute a new schedule for code generation. |
48 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, | 59 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, |
49 Graph* graph, | 60 Graph* graph, |
50 Schedule* schedule = nullptr); | 61 Schedule* schedule = nullptr); |
51 | 62 |
52 // Run just the register allocator phases. | 63 // Run just the register allocator phases. |
53 static bool AllocateRegistersForTesting(const RegisterConfiguration* config, | 64 static bool AllocateRegistersForTesting(const RegisterConfiguration* config, |
54 InstructionSequence* sequence, | 65 InstructionSequence* sequence, |
55 bool run_verifier); | 66 bool run_verifier); |
56 | 67 |
57 // Run the pipeline on a machine graph and generate code. If {schedule} is | 68 // Run the pipeline on a machine graph and generate code. If {schedule} is |
58 // {nullptr}, then compute a new schedule for code generation. | 69 // {nullptr}, then compute a new schedule for code generation. |
59 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, | 70 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, |
60 CallDescriptor* call_descriptor, | 71 CallDescriptor* call_descriptor, |
61 Graph* graph, | 72 Graph* graph, |
62 Schedule* schedule = nullptr); | 73 Schedule* schedule = nullptr); |
63 | 74 |
64 // Returns a new compilation job for the given compilation info. | 75 // Returns a new compilation job for the given compilation info. |
65 static OptimizedCompileJob* NewCompilationJob(CompilationInfo* info); | 76 static OptimizedCompileJob* NewCompilationJob(CompilationInfo* info); |
66 | 77 |
67 void InitializeWasmCompilation(Zone* pipeline_zone, ZonePool* zone_pool, | 78 // Returns a new compilation job for the WebAssembly compilation info. |
68 Graph* graph, | 79 static OptimizedCompileJob* NewWasmCompilationJob( |
69 SourcePositionTable* source_positions); | 80 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, |
70 bool ExecuteWasmCompilation(CallDescriptor* descriptor); | 81 SourcePositionTable* source_positions); |
71 Handle<Code> FinalizeWasmCompilation(CallDescriptor* descriptor); | 82 |
| 83 // TODO(mstarzinger, bmeurer): This shouldn't be public! |
| 84 bool ScheduleAndSelectInstructions(Linkage* linkage); |
72 | 85 |
73 private: | 86 private: |
74 // Helpers for executing pipeline phases. | 87 // Helpers for executing pipeline phases. |
75 template <typename Phase> | 88 template <typename Phase> |
76 void Run(); | 89 void Run(); |
77 template <typename Phase, typename Arg0> | 90 template <typename Phase, typename Arg0> |
78 void Run(Arg0 arg_0); | 91 void Run(Arg0 arg_0); |
79 template <typename Phase, typename Arg0, typename Arg1> | 92 template <typename Phase, typename Arg0, typename Arg1> |
80 void Run(Arg0 arg_0, Arg1 arg_1); | 93 void Run(Arg0 arg_0, Arg1 arg_1); |
81 | 94 |
82 void BeginPhaseKind(const char* phase_kind); | 95 void BeginPhaseKind(const char* phase_kind); |
| 96 void EndPhaseKind(); |
83 void RunPrintAndVerify(const char* phase, bool untyped = false); | 97 void RunPrintAndVerify(const char* phase, bool untyped = false); |
| 98 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); |
84 void AllocateRegisters(const RegisterConfiguration* config, | 99 void AllocateRegisters(const RegisterConfiguration* config, |
85 CallDescriptor* descriptor, bool run_verifier); | 100 CallDescriptor* descriptor, bool run_verifier); |
86 bool ScheduleGraph(CallDescriptor* call_descriptor); | 101 |
87 Handle<Code> GenerateCode(CallDescriptor* descriptor); | 102 CompilationInfo* info() const; |
88 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); | |
89 CompilationInfo* info() const { return info_; } | |
90 Isolate* isolate() const; | 103 Isolate* isolate() const; |
91 | 104 |
92 CompilationInfo* const info_; | 105 PipelineData* const data_; |
93 PipelineData* data_; | |
94 | 106 |
95 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 107 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
96 }; | 108 }; |
97 | 109 |
98 } // namespace compiler | 110 } // namespace compiler |
99 } // namespace internal | 111 } // namespace internal |
100 } // namespace v8 | 112 } // namespace v8 |
101 | 113 |
102 #endif // V8_COMPILER_PIPELINE_H_ | 114 #endif // V8_COMPILER_PIPELINE_H_ |
OLD | NEW |