pipeline.h 4.41 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

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

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

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

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

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

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

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

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

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

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

}  // namespace compiler
}  // namespace internal
}  // namespace v8
115 116

#endif  // V8_COMPILER_PIPELINE_H_