v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
register-allocation-phase.h
Go to the documentation of this file.
1// Copyright 2024 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_TURBOSHAFT_REGISTER_ALLOCATION_PHASE_H_
6#define V8_COMPILER_TURBOSHAFT_REGISTER_ALLOCATION_PHASE_H_
7
16
18
21 static constexpr bool kOutputIsTraceableGraph = false;
22
23 void Run(PipelineData* data, Zone* temp_zone) {
24 ConstraintBuilder builder(data->register_allocation_data());
26 }
27};
28
31 static constexpr bool kOutputIsTraceableGraph = false;
32
33 void Run(PipelineData* data, Zone* temp_zone) {
34 ConstraintBuilder builder(data->register_allocation_data());
35 builder.ResolvePhis();
36 }
37};
38
41 static constexpr bool kOutputIsTraceableGraph = false;
42
43 void Run(PipelineData* data, Zone* temp_zone) {
44 LiveRangeBuilder builder(data->register_allocation_data(), temp_zone);
45 builder.BuildLiveRanges();
46 }
47};
48
51 static constexpr bool kOutputIsTraceableGraph = false;
52
53 void Run(PipelineData* data, Zone* temp_zone) {
54 BundleBuilder builder(data->register_allocation_data());
55 builder.BuildBundles();
56 }
57};
58
59template <typename RegAllocator>
62 static constexpr bool kOutputIsTraceableGraph = false;
63
64 void Run(PipelineData* data, Zone* temp_zone) {
65 RegAllocator allocator(data->register_allocation_data(),
66 RegisterKind::kGeneral, temp_zone);
67 allocator.AllocateRegisters();
68 }
69};
70
71template <typename RegAllocator>
74 static constexpr bool kOutputIsTraceableGraph = false;
75
76 void Run(PipelineData* data, Zone* temp_zone) {
77 RegAllocator allocator(data->register_allocation_data(),
78 RegisterKind::kDouble, temp_zone);
79 allocator.AllocateRegisters();
80 }
81};
82
83template <typename RegAllocator>
86 static constexpr bool kOutputIsTraceableGraph = false;
87
88 void Run(PipelineData* data, Zone* temp_zone) {
89 RegAllocator allocator(data->register_allocation_data(),
90 RegisterKind::kSimd128, temp_zone);
91 allocator.AllocateRegisters();
92 }
93};
94
97 static constexpr bool kOutputIsTraceableGraph = false;
98
99 void Run(PipelineData* data, Zone* temp_zone) {
100 OperandAssigner assigner(data->register_allocation_data());
101 assigner.DecideSpillingMode();
102 }
103};
104
107 static constexpr bool kOutputIsTraceableGraph = false;
108
109 void Run(PipelineData* data, Zone* temp_zone) {
110 OperandAssigner assigner(data->register_allocation_data());
111 assigner.AssignSpillSlots();
112 }
113};
114
117 static constexpr bool kOutputIsTraceableGraph = false;
118
119 void Run(PipelineData* data, Zone* temp_zone) {
120 OperandAssigner assigner(data->register_allocation_data());
121 assigner.CommitAssignment();
122 }
123};
124
127 static constexpr bool kOutputIsTraceableGraph = false;
128
129 void Run(PipelineData* data, Zone* temp_zone) {
130 ReferenceMapPopulator populator(data->register_allocation_data());
131 populator.PopulateReferenceMaps();
132 }
133};
134
137 static constexpr bool kOutputIsTraceableGraph = false;
138
139 void Run(PipelineData* data, Zone* temp_zone) {
140 LiveRangeConnector connector(data->register_allocation_data());
141 connector.ConnectRanges(temp_zone);
142 }
143};
144
147 static constexpr bool kOutputIsTraceableGraph = false;
148
149 void Run(PipelineData* data, Zone* temp_zone) {
150 LiveRangeConnector connector(data->register_allocation_data());
151 connector.ResolveControlFlow(temp_zone);
152 }
153};
154
157 static constexpr bool kOutputIsTraceableGraph = false;
158
159 void Run(PipelineData* data, Zone* temp_zone) {
160 MoveOptimizer move_optimizer(temp_zone, data->sequence());
161 move_optimizer.Run();
162 }
163};
164
167 static constexpr bool kOutputIsTraceableGraph = false;
168
169 void Run(PipelineData* data, Zone* temp_zone) {
170#if V8_ENABLE_WEBASSEMBLY
171 const bool is_wasm_to_js =
172 data->info()->code_kind() == CodeKind::WASM_TO_JS_FUNCTION ||
173 data->info()->builtin() == Builtin::kWasmToJsWrapperCSA;
174#else
175 const bool is_wasm_to_js = false;
176#endif
177 FrameElider(data->sequence(), false, is_wasm_to_js).Run();
178 }
179};
180
183 static constexpr bool kOutputIsTraceableGraph = false;
184
185 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) {
186 ZoneVector<RpoNumber> result(temp_zone);
187 if (JumpThreading::ComputeForwarding(temp_zone, &result, data->sequence(),
188 frame_at_start)) {
189 JumpThreading::ApplyForwarding(temp_zone, result, data->sequence());
190 }
191 }
192};
193
196 static constexpr bool kOutputIsTraceableGraph = false;
197
198 void Run(PipelineData* data, Zone* temp_zone) {
199 CodeGenerator* code_generator = data->code_generator();
200 DCHECK_NOT_NULL(code_generator);
201 code_generator->AssembleCode();
202 }
203};
204
207 FinalizeCode)
208 static constexpr bool kOutputIsTraceableGraph = false;
209
210 void Run(PipelineData* data, Zone* temp_zone) {
211 CodeGenerator* code_generator = data->code_generator();
212 DCHECK_NOT_NULL(code_generator);
213 data->set_code(code_generator->FinalizeCode());
214 }
215};
216
217} // namespace v8::internal::compiler::turboshaft
218
219#endif // V8_COMPILER_TURBOSHAFT_REGISTER_ALLOCATION_PHASE_H_
static bool ComputeForwarding(Zone *local_zone, ZoneVector< RpoNumber > *result, InstructionSequence *code, bool frame_at_start)
static void ApplyForwarding(Zone *local_zone, ZoneVector< RpoNumber > const &forwarding, InstructionSequence *code)
ZoneVector< RpoNumber > & result
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
DECL_TURBOSHAFT_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS_WITH_LEGACY_NAME(FinalizeCode) static const expr bool kOutputIsTraceableGraph
void Run(PipelineData *data, Zone *temp_zone, bool frame_at_start)
#define DECL_TURBOSHAFT_PHASE_CONSTANTS_WITH_LEGACY_NAME(Name)
Definition phase.h:41