pipeline.h 4.26 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 23
class RegisterConfiguration;

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

32 33
namespace compiler {

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

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

52
  // Run the pipeline for the WebAssembly compilation info.
53
  static void GenerateCodeForWasmFunction(
54
      OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
55
      MachineGraph* mcgraph, CallDescriptor* call_descriptor,
56
      SourcePositionTable* source_positions, NodeOriginTable* node_origins,
57
      wasm::FunctionBody function_body, const wasm::WasmModule* module,
58
      int function_index);
59

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

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

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

83 84 85
  // ---------------------------------------------------------------------------
  // The following methods are for testing purposes only. Avoid production use.
  // ---------------------------------------------------------------------------
86

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

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

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

106
 private:
107
  DISALLOW_IMPLICIT_CONSTRUCTORS(Pipeline);
108
};
109 110 111 112

}  // namespace compiler
}  // namespace internal
}  // namespace v8
113 114

#endif  // V8_COMPILER_PIPELINE_H_