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