• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/objects/code.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 struct AssemblerOptions;
18 class OptimizedCompilationInfo;
19 class OptimizedCompilationJob;
20 class RegisterConfiguration;
21 class JumpOptimizationInfo;
22 
23 namespace wasm {
24 enum ModuleOrigin : uint8_t;
25 struct FunctionBody;
26 class NativeModule;
27 class WasmEngine;
28 struct WasmModule;
29 }  // namespace wasm
30 
31 namespace compiler {
32 
33 class CallDescriptor;
34 class Graph;
35 class InstructionSequence;
36 class MachineGraph;
37 class NodeOriginTable;
38 class Schedule;
39 class SourcePositionTable;
40 
41 class Pipeline : public AllStatic {
42  public:
43   // Returns a new compilation job for the given JavaScript function.
44   static OptimizedCompilationJob* NewCompilationJob(Isolate* isolate,
45                                                     Handle<JSFunction> function,
46                                                     bool has_script);
47 
48   // Returns a new compilation job for the WebAssembly compilation info.
49   static OptimizedCompilationJob* NewWasmCompilationJob(
50       OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
51       MachineGraph* mcgraph, CallDescriptor* call_descriptor,
52       SourcePositionTable* source_positions, NodeOriginTable* node_origins,
53       wasm::FunctionBody function_body, wasm::WasmModule* wasm_module,
54       wasm::NativeModule* native_module, int function_index,
55       wasm::ModuleOrigin wasm_origin);
56 
57   // Run the pipeline on a machine graph and generate code. The {schedule} must
58   // be valid, hence the given {graph} does not need to be schedulable.
59   static MaybeHandle<Code> GenerateCodeForCodeStub(
60       Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
61       Schedule* schedule, Code::Kind kind, const char* debug_name,
62       uint32_t stub_key, int32_t builtin_index, JumpOptimizationInfo* jump_opt,
63       PoisoningMitigationLevel poisoning_level,
64       const AssemblerOptions& options);
65 
66   // ---------------------------------------------------------------------------
67   // The following methods are for testing purposes only. Avoid production use.
68   // ---------------------------------------------------------------------------
69 
70   // Run the pipeline on JavaScript bytecode and generate code.
71   static MaybeHandle<Code> GenerateCodeForTesting(
72       OptimizedCompilationInfo* info, Isolate* isolate);
73 
74   // Run the pipeline on a machine graph and generate code. If {schedule} is
75   // {nullptr}, then compute a new schedule for code generation.
76   V8_EXPORT_PRIVATE static MaybeHandle<Code> GenerateCodeForTesting(
77       OptimizedCompilationInfo* info, Isolate* isolate,
78       CallDescriptor* call_descriptor, Graph* graph,
79       const AssemblerOptions& options, Schedule* schedule = nullptr,
80       SourcePositionTable* source_positions = nullptr);
81 
82   // Run just the register allocator phases.
83   V8_EXPORT_PRIVATE static bool AllocateRegistersForTesting(
84       const RegisterConfiguration* config, InstructionSequence* sequence,
85       bool run_verifier);
86 
87  private:
88   DISALLOW_IMPLICIT_CONSTRUCTORS(Pipeline);
89 };
90 
91 }  // namespace compiler
92 }  // namespace internal
93 }  // namespace v8
94 
95 #endif  // V8_COMPILER_PIPELINE_H_
96