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/objects.h"
11
12namespace v8 {
13namespace internal {
14
15class CompilationInfo;
16class CompilationJob;
17class RegisterConfiguration;
18
19namespace compiler {
20
21class CallDescriptor;
22class Graph;
23class InstructionSequence;
24class Schedule;
25class SourcePositionTable;
26
27class Pipeline : public AllStatic {
28 public:
29  // Returns a new compilation job for the given function.
30  static CompilationJob* NewCompilationJob(Handle<JSFunction> function);
31
32  // Returns a new compilation job for the WebAssembly compilation info.
33  static CompilationJob* NewWasmCompilationJob(
34      CompilationInfo* info, Graph* graph, CallDescriptor* descriptor,
35      SourcePositionTable* source_positions);
36
37  // Run the pipeline on a machine graph and generate code. The {schedule} must
38  // be valid, hence the given {graph} does not need to be schedulable.
39  static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate,
40                                              CallDescriptor* call_descriptor,
41                                              Graph* graph, Schedule* schedule,
42                                              Code::Flags flags,
43                                              const char* debug_name);
44
45  // Run the entire pipeline and generate a handle to a code object suitable for
46  // testing.
47  static Handle<Code> GenerateCodeForTesting(CompilationInfo* info);
48
49  // Run the pipeline on a machine graph and generate code. If {schedule} is
50  // {nullptr}, then compute a new schedule for code generation.
51  static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
52                                             Graph* graph,
53                                             Schedule* schedule = nullptr);
54
55  // Run just the register allocator phases.
56  static bool AllocateRegistersForTesting(const RegisterConfiguration* config,
57                                          InstructionSequence* sequence,
58                                          bool run_verifier);
59
60  // Run the pipeline on a machine graph and generate code. If {schedule} is
61  // {nullptr}, then compute a new schedule for code generation.
62  static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
63                                             CallDescriptor* call_descriptor,
64                                             Graph* graph,
65                                             Schedule* schedule = nullptr);
66
67 private:
68  DISALLOW_IMPLICIT_CONSTRUCTORS(Pipeline);
69};
70
71}  // namespace compiler
72}  // namespace internal
73}  // namespace v8
74
75#endif  // V8_COMPILER_PIPELINE_H_
76