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/compiler.h" | 10 #include "src/compiler.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace compiler { | 14 namespace compiler { |
15 | 15 |
16 class CallDescriptor; | 16 class CallDescriptor; |
17 class Graph; | 17 class Graph; |
18 class InstructionSequence; | 18 class InstructionSequence; |
19 class Linkage; | 19 class Linkage; |
20 class PipelineData; | 20 class PipelineData; |
21 class RegisterConfiguration; | 21 class RegisterConfiguration; |
22 class Schedule; | 22 class Schedule; |
23 | 23 |
24 class Pipeline { | 24 class Pipeline final { |
25 public: | 25 public: |
26 explicit Pipeline(CompilationInfo* info) : info_(info) {} | 26 explicit Pipeline(CompilationInfo* info); |
| 27 ~Pipeline(); |
| 28 |
| 29 // Separate pipeline steps. |
| 30 bool CreateGraph(); |
| 31 bool OptimizeGraph(); |
| 32 Handle<Code> CreateCode() { return DoGenerateCode(); } |
27 | 33 |
28 // Run the entire pipeline and generate a handle to a code object. | 34 // Run the entire pipeline and generate a handle to a code object. |
29 Handle<Code> GenerateCode(); | 35 Handle<Code> GenerateCode(); |
30 | 36 |
31 // Run the pipeline on a machine graph and generate code. If {schedule} is | 37 // Run the pipeline on a machine graph and generate code. If {schedule} is |
32 // {nullptr}, then compute a new schedule for code generation. | 38 // {nullptr}, then compute a new schedule for code generation. |
33 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, | 39 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, |
34 Graph* graph, | 40 Graph* graph, |
35 Schedule* schedule = nullptr); | 41 Schedule* schedule = nullptr); |
36 | 42 |
37 // Run the pipeline on a machine graph and generate code. If {schedule} is | 43 // Run the pipeline on a machine graph and generate code. If {schedule} is |
38 // {nullptr}, then compute a new schedule for code generation. | 44 // {nullptr}, then compute a new schedule for code generation. |
39 static Handle<Code> GenerateCodeForTesting(Isolate* isolate, | 45 static Handle<Code> GenerateCodeForTesting(Isolate* isolate, |
40 CallDescriptor* call_descriptor, | 46 CallDescriptor* call_descriptor, |
41 Graph* graph, | 47 Graph* graph, |
42 Schedule* schedule = nullptr); | 48 Schedule* schedule = nullptr); |
43 | 49 |
44 // Run just the register allocator phases. | 50 // Run just the register allocator phases. |
45 static bool AllocateRegistersForTesting(const RegisterConfiguration* config, | 51 static bool AllocateRegistersForTesting(const RegisterConfiguration* config, |
46 InstructionSequence* sequence, | 52 InstructionSequence* sequence, |
47 bool run_verifier); | 53 bool run_verifier); |
48 | 54 |
49 static inline bool SupportedBackend() { return V8_TURBOFAN_BACKEND != 0; } | 55 static inline bool SupportedBackend() { return V8_TURBOFAN_BACKEND != 0; } |
50 static inline bool SupportedTarget() { return V8_TURBOFAN_TARGET != 0; } | 56 static inline bool SupportedTarget() { return V8_TURBOFAN_TARGET != 0; } |
51 | 57 |
52 private: | 58 private: |
| 59 explicit Pipeline(PipelineData* data) : data_(data) { |
| 60 DCHECK_NOT_NULL(data_); |
| 61 } |
| 62 |
53 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, | 63 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, |
54 CallDescriptor* call_descriptor, | 64 CallDescriptor* call_descriptor, |
55 Graph* graph, Schedule* schedule); | 65 Graph* graph, Schedule* schedule); |
56 | 66 |
57 CompilationInfo* info_; | 67 PipelineData* const data_; |
58 PipelineData* data_; | |
59 | 68 |
60 // Helpers for executing pipeline phases. | 69 // Helpers for executing pipeline phases. |
61 template <typename Phase> | 70 template <typename Phase> |
62 void Run(); | 71 void Run(); |
63 template <typename Phase, typename Arg0> | 72 template <typename Phase, typename Arg0> |
64 void Run(Arg0 arg_0); | 73 void Run(Arg0 arg_0); |
65 | 74 |
66 CompilationInfo* info() const { return info_; } | 75 PipelineData* data() const { return data_; } |
67 Isolate* isolate() { return info_->isolate(); } | 76 CompilationInfo* info() const; |
| 77 Isolate* isolate() const { return info()->isolate(); } |
68 | 78 |
69 void BeginPhaseKind(const char* phase_kind); | 79 void BeginPhaseKind(const char* phase_kind); |
70 void RunPrintAndVerify(const char* phase, bool untyped = false); | 80 void RunPrintAndVerify(const char* phase, bool untyped = false); |
| 81 bool ScheduleAndAllocateRegisters(CallDescriptor* call_descriptor); |
| 82 Handle<Code> DoGenerateCode(); |
71 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); | 83 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); |
72 void AllocateRegisters(const RegisterConfiguration* config, | 84 void AllocateRegisters(const RegisterConfiguration* config, |
73 bool run_verifier); | 85 bool run_verifier); |
74 }; | 86 }; |
75 | 87 |
76 } // namespace compiler | 88 } // namespace compiler |
77 } // namespace internal | 89 } // namespace internal |
78 } // namespace v8 | 90 } // namespace v8 |
79 | 91 |
80 #endif // V8_COMPILER_PIPELINE_H_ | 92 #endif // V8_COMPILER_PIPELINE_H_ |
OLD | NEW |