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 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_PIPELINE_H_ 6 #define V8_COMPILER_PIPELINE_H_ 7 8 // Clients of this interface shouldn't depend on lots of compiler internals. 9 // Do not include anything from src/compiler here! 10 #include "src/compiler.h" 11 12 namespace v8 { 13 namespace internal { 14 15 class RegisterConfiguration; 16 17 namespace compiler { 18 19 class CallDescriptor; 20 class Graph; 21 class InstructionSequence; 22 class Linkage; 23 class PipelineData; 24 class Schedule; 25 26 class Pipeline { 27 public: Pipeline(CompilationInfo * info)28 explicit Pipeline(CompilationInfo* info) : info_(info) {} 29 30 // Run the entire pipeline and generate a handle to a code object. 31 Handle<Code> GenerateCode(); 32 33 // Run the pipeline on a machine graph and generate code. The {schedule} must 34 // be valid, hence the given {graph} does not need to be schedulable. 35 static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate, 36 CallDescriptor* call_descriptor, 37 Graph* graph, Schedule* schedule, 38 Code::Kind kind, 39 const char* debug_name); 40 41 // Run the pipeline on a machine graph and generate code. If {schedule} is 42 // {nullptr}, then compute a new schedule for code generation. 43 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, 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); 51 52 // Run the pipeline on a machine graph and generate code. If {schedule} is 53 // {nullptr}, then compute a new schedule for code generation. 54 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, 55 CallDescriptor* call_descriptor, 56 Graph* graph, 57 Schedule* schedule = nullptr); 58 59 private: 60 CompilationInfo* info_; 61 PipelineData* data_; 62 63 // Helpers for executing pipeline phases. 64 template <typename Phase> 65 void Run(); 66 template <typename Phase, typename Arg0> 67 void Run(Arg0 arg_0); 68 info()69 CompilationInfo* info() const { return info_; } isolate()70 Isolate* isolate() { return info_->isolate(); } 71 72 void BeginPhaseKind(const char* phase_kind); 73 void RunPrintAndVerify(const char* phase, bool untyped = false); 74 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); 75 void AllocateRegisters(const RegisterConfiguration* config, 76 CallDescriptor* descriptor, bool run_verifier); 77 }; 78 79 } // namespace compiler 80 } // namespace internal 81 } // namespace v8 82 83 #endif // V8_COMPILER_PIPELINE_H_ 84