Home | History | Annotate | Download | only in compiler
      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/globals.h"
     11 #include "src/objects.h"
     12 #include "src/zone/zone-containers.h"
     13 
     14 namespace v8 {
     15 namespace internal {
     16 
     17 class CompilationInfo;
     18 class CompilationJob;
     19 class RegisterConfiguration;
     20 
     21 namespace trap_handler {
     22 struct ProtectedInstructionData;
     23 }  // namespace trap_handler
     24 
     25 namespace compiler {
     26 
     27 class CallDescriptor;
     28 class JSGraph;
     29 class Graph;
     30 class InstructionSequence;
     31 class Schedule;
     32 class SourcePositionTable;
     33 
     34 class Pipeline : public AllStatic {
     35  public:
     36   // Returns a new compilation job for the given function.
     37   static CompilationJob* NewCompilationJob(Handle<JSFunction> function,
     38                                            bool has_script);
     39 
     40   // Returns a new compilation job for the WebAssembly compilation info.
     41   static CompilationJob* NewWasmCompilationJob(
     42       CompilationInfo* info, JSGraph* jsgraph, CallDescriptor* descriptor,
     43       SourcePositionTable* source_positions,
     44       ZoneVector<trap_handler::ProtectedInstructionData>*
     45           protected_instructions,
     46       bool wasm_origin);
     47 
     48   // Run the pipeline on a machine graph and generate code. The {schedule} must
     49   // be valid, hence the given {graph} does not need to be schedulable.
     50   static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate,
     51                                               CallDescriptor* call_descriptor,
     52                                               Graph* graph, Schedule* schedule,
     53                                               Code::Flags flags,
     54                                               const char* debug_name);
     55 
     56   // Run the entire pipeline and generate a handle to a code object suitable for
     57   // testing.
     58   static Handle<Code> GenerateCodeForTesting(CompilationInfo* info);
     59 
     60   // Run the pipeline on a machine graph and generate code. If {schedule} is
     61   // {nullptr}, then compute a new schedule for code generation.
     62   static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
     63                                              Graph* graph,
     64                                              Schedule* schedule = nullptr);
     65 
     66   // Run just the register allocator phases.
     67   V8_EXPORT_PRIVATE static bool AllocateRegistersForTesting(
     68       const RegisterConfiguration* config, InstructionSequence* sequence,
     69       bool run_verifier);
     70 
     71   // Run the pipeline on a machine graph and generate code. If {schedule} is
     72   // {nullptr}, then compute a new schedule for code generation.
     73   static Handle<Code> GenerateCodeForTesting(
     74       CompilationInfo* info, CallDescriptor* call_descriptor, Graph* graph,
     75       Schedule* schedule = nullptr,
     76       SourcePositionTable* source_positions = nullptr);
     77 
     78  private:
     79   DISALLOW_IMPLICIT_CONSTRUCTORS(Pipeline);
     80 };
     81 
     82 }  // namespace compiler
     83 }  // namespace internal
     84 }  // namespace v8
     85 
     86 #endif  // V8_COMPILER_PIPELINE_H_
     87