pipeline.h 4.47 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_PIPELINE_H_
#define V8_COMPILER_PIPELINE_H_

8 9
#include <memory>

10 11
// Clients of this interface shouldn't depend on lots of compiler internals.
// Do not include anything from src/compiler here!
12
#include "src/common/globals.h"
13
#include "src/objects/code.h"
14
#include "src/objects/objects.h"
15 16 17

namespace v8 {
namespace internal {
18

19
struct AssemblerOptions;
20 21
class OptimizedCompilationInfo;
class OptimizedCompilationJob;
22
class ProfileDataFromFile;
23 24
class RegisterConfiguration;

25
namespace wasm {
26
struct FunctionBody;
27
class NativeModule;
28
struct WasmCompilationResult;
29
class WasmEngine;
30
struct WasmModule;
31 32
}  // namespace wasm

33 34
namespace compiler {

35
class CallDescriptor;
36
class Graph;
37
class InstructionSequence;
38
class JSGraph;
39
class JSHeapBroker;
40
class MachineGraph;
41
class NodeOriginTable;
42
class Schedule;
43
class SourcePositionTable;
44
struct WasmLoopInfo;
45

46
class Pipeline : public AllStatic {
47
 public:
48
  // Returns a new compilation job for the given JavaScript function.
49 50 51
  static V8_EXPORT_PRIVATE std::unique_ptr<OptimizedCompilationJob>
  NewCompilationJob(Isolate* isolate, Handle<JSFunction> function,
                    CodeKind code_kind, bool has_script,
52
                    BytecodeOffset osr_offset = BytecodeOffset::None(),
53
                    JavaScriptFrame* osr_frame = nullptr);
54

55
  // Run the pipeline for the WebAssembly compilation info.
56
  static void GenerateCodeForWasmFunction(
57
      OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
58
      MachineGraph* mcgraph, CallDescriptor* call_descriptor,
59
      SourcePositionTable* source_positions, NodeOriginTable* node_origins,
60
      wasm::FunctionBody function_body, const wasm::WasmModule* module,
61
      int function_index, std::vector<compiler::WasmLoopInfo>* loop_infos);
62

63
  // Run the pipeline on a machine graph and generate code.
64
  static wasm::WasmCompilationResult GenerateCodeForWasmNativeStub(
65
      wasm::WasmEngine* wasm_engine, CallDescriptor* call_descriptor,
66
      MachineGraph* mcgraph, CodeKind kind, int wasm_kind,
67
      const char* debug_name, const AssemblerOptions& assembler_options,
68 69
      SourcePositionTable* source_positions = nullptr);

70 71
  // Returns a new compilation job for a wasm heap stub.
  static std::unique_ptr<OptimizedCompilationJob> NewWasmHeapStubCompilationJob(
72 73
      Isolate* isolate, wasm::WasmEngine* wasm_engine,
      CallDescriptor* call_descriptor, std::unique_ptr<Zone> zone, Graph* graph,
74
      CodeKind kind, std::unique_ptr<char[]> debug_name,
75
      const AssemblerOptions& options,
76 77
      SourcePositionTable* source_positions = nullptr);

78
  // Run the pipeline on a machine graph and generate code.
79
  static MaybeHandle<Code> GenerateCodeForCodeStub(
80
      Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
81
      JSGraph* jsgraph, SourcePositionTable* source_positions, CodeKind kind,
82
      const char* debug_name, int32_t builtin_index,
83 84
      PoisoningMitigationLevel poisoning_level, const AssemblerOptions& options,
      const ProfileDataFromFile* profile_data);
85

86 87 88
  // ---------------------------------------------------------------------------
  // The following methods are for testing purposes only. Avoid production use.
  // ---------------------------------------------------------------------------
89

90 91 92
  // Run the pipeline on JavaScript bytecode and generate code.  If requested,
  // hands out the heap broker on success, transferring its ownership to the
  // caller.
93
  V8_EXPORT_PRIVATE static MaybeHandle<Code> GenerateCodeForTesting(
94
      OptimizedCompilationInfo* info, Isolate* isolate,
95
      std::unique_ptr<JSHeapBroker>* out_broker = nullptr);
96

97 98
  // Run the pipeline on a machine graph and generate code. If {schedule} is
  // {nullptr}, then compute a new schedule for code generation.
99
  V8_EXPORT_PRIVATE static MaybeHandle<Code> GenerateCodeForTesting(
100 101
      OptimizedCompilationInfo* info, Isolate* isolate,
      CallDescriptor* call_descriptor, Graph* graph,
102
      const AssemblerOptions& options, Schedule* schedule = nullptr);
103

104 105 106
  // Run just the register allocator phases.
  V8_EXPORT_PRIVATE static bool AllocateRegistersForTesting(
      const RegisterConfiguration* config, InstructionSequence* sequence,
107
      bool use_fast_register_allocator, bool run_verifier);
108

109
 private:
110
  DISALLOW_IMPLICIT_CONSTRUCTORS(Pipeline);
111
};
112 113 114 115

}  // namespace compiler
}  // namespace internal
}  // namespace v8
116 117

#endif  // V8_COMPILER_PIPELINE_H_