pipeline.h 4.03 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
// Clients of this interface shouldn't depend on lots of compiler internals.
// 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 15

namespace v8 {
namespace internal {
16

17
struct AssemblerOptions;
18 19
class OptimizedCompilationInfo;
class OptimizedCompilationJob;
20 21
class RegisterConfiguration;

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

30 31
namespace compiler {

32
class CallDescriptor;
33
class Graph;
34
class InstructionSequence;
35
class JSHeapBroker;
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 45
  static OptimizedCompilationJob* NewCompilationJob(Isolate* isolate,
                                                    Handle<JSFunction> function,
46
                                                    bool has_script);
47

48
  // Run the pipeline for the WebAssembly compilation info.
49
  static void GenerateCodeForWasmFunction(
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, const wasm::WasmModule* module,
54
      int function_index);
55

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

  // Run the pipeline on a machine graph and generate code.
  static MaybeHandle<Code> GenerateCodeForWasmHeapStub(
65 66 67 68 69
      Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
      Code::Kind kind, const char* debug_name,
      const AssemblerOptions& assembler_options,
      SourcePositionTable* source_positions = nullptr);

70
  // Run the pipeline on a machine graph and generate code.
71
  static MaybeHandle<Code> GenerateCodeForCodeStub(
72
      Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
73 74
      SourcePositionTable* source_positions, Code::Kind kind,
      const char* debug_name, int32_t builtin_index,
75 76
      PoisoningMitigationLevel poisoning_level,
      const AssemblerOptions& options);
77

78 79 80
  // ---------------------------------------------------------------------------
  // The following methods are for testing purposes only. Avoid production use.
  // ---------------------------------------------------------------------------
81

82
  // Run the pipeline on JavaScript bytecode and generate code.
83 84
  // If requested, hands out the heap broker, which is allocated
  // in {info}'s zone.
85
  V8_EXPORT_PRIVATE static MaybeHandle<Code> GenerateCodeForTesting(
86 87
      OptimizedCompilationInfo* info, Isolate* isolate,
      JSHeapBroker** out_broker = nullptr);
88

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

96 97 98 99 100
  // Run just the register allocator phases.
  V8_EXPORT_PRIVATE static bool AllocateRegistersForTesting(
      const RegisterConfiguration* config, InstructionSequence* sequence,
      bool run_verifier);

101
 private:
102
  DISALLOW_IMPLICIT_CONSTRUCTORS(Pipeline);
103
};
104 105 106 107

}  // namespace compiler
}  // namespace internal
}  // namespace v8
108 109

#endif  // V8_COMPILER_PIPELINE_H_