Line data Source code
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_RAW_MACHINE_ASSEMBLER_H_
6 : #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
7 :
8 : #include "src/assembler.h"
9 : #include "src/compiler/access-builder.h"
10 : #include "src/compiler/common-operator.h"
11 : #include "src/compiler/graph.h"
12 : #include "src/compiler/linkage.h"
13 : #include "src/compiler/machine-operator.h"
14 : #include "src/compiler/node.h"
15 : #include "src/compiler/operator.h"
16 : #include "src/compiler/simplified-operator.h"
17 : #include "src/globals.h"
18 : #include "src/heap/factory.h"
19 : #include "src/isolate.h"
20 :
21 : namespace v8 {
22 : namespace internal {
23 : namespace compiler {
24 :
25 : class BasicBlock;
26 : class RawMachineLabel;
27 : class Schedule;
28 : class SourcePositionTable;
29 :
30 : // The RawMachineAssembler produces a low-level IR graph. All nodes are wired
31 : // into a graph and also placed into a schedule immediately, hence subsequent
32 : // code generation can happen without the need for scheduling.
33 : //
34 : // In order to create a schedule on-the-fly, the assembler keeps track of basic
35 : // blocks by having one current basic block being populated and by referencing
36 : // other basic blocks through the use of labels.
37 : //
38 : // Also note that the generated graph is only valid together with the generated
39 : // schedule, using one without the other is invalid as the graph is inherently
40 : // non-schedulable due to missing control and effect dependencies.
41 : class V8_EXPORT_PRIVATE RawMachineAssembler {
42 : public:
43 : RawMachineAssembler(
44 : Isolate* isolate, Graph* graph, CallDescriptor* call_descriptor,
45 : MachineRepresentation word = MachineType::PointerRepresentation(),
46 : MachineOperatorBuilder::Flags flags =
47 : MachineOperatorBuilder::Flag::kNoFlags,
48 : MachineOperatorBuilder::AlignmentRequirements alignment_requirements =
49 : MachineOperatorBuilder::AlignmentRequirements::
50 : FullUnalignedAccessSupport(),
51 : PoisoningMitigationLevel poisoning_level =
52 : PoisoningMitigationLevel::kPoisonCriticalOnly);
53 : ~RawMachineAssembler() = default;
54 :
55 : Isolate* isolate() const { return isolate_; }
56 : Graph* graph() const { return graph_; }
57 11019227 : Zone* zone() const { return graph()->zone(); }
58 : MachineOperatorBuilder* machine() { return &machine_; }
59 : CommonOperatorBuilder* common() { return &common_; }
60 : SimplifiedOperatorBuilder* simplified() { return &simplified_; }
61 : CallDescriptor* call_descriptor() const { return call_descriptor_; }
62 : PoisoningMitigationLevel poisoning_level() const { return poisoning_level_; }
63 :
64 : // Finalizes the schedule and exports it to be used for code generation. Note
65 : // that this RawMachineAssembler becomes invalid after export.
66 : Schedule* Export();
67 : // Finalizes the schedule and transforms it into a graph that's suitable for
68 : // it to be used for Turbofan optimization and re-scheduling. Note that this
69 : // RawMachineAssembler becomes invalid after export.
70 : Graph* ExportForOptimization();
71 :
72 : // ===========================================================================
73 : // The following utility methods create new nodes with specific operators and
74 : // place them into the current basic block. They don't perform control flow,
75 : // hence will not switch the current basic block.
76 :
77 : Node* NullConstant();
78 : Node* UndefinedConstant();
79 :
80 : // Constants.
81 : Node* PointerConstant(void* value) {
82 151293 : return IntPtrConstant(reinterpret_cast<intptr_t>(value));
83 : }
84 : Node* IntPtrConstant(intptr_t value) {
85 : // TODO(dcarney): mark generated code as unserializable if value != 0.
86 : return kSystemPointerSize == 8 ? Int64Constant(value)
87 4377276 : : Int32Constant(static_cast<int>(value));
88 : }
89 : Node* RelocatableIntPtrConstant(intptr_t value, RelocInfo::Mode rmode);
90 1769413 : Node* Int32Constant(int32_t value) {
91 3538826 : return AddNode(common()->Int32Constant(value));
92 : }
93 16 : Node* StackSlot(MachineRepresentation rep, int alignment = 0) {
94 32 : return AddNode(machine()->StackSlot(rep, alignment));
95 : }
96 4509318 : Node* Int64Constant(int64_t value) {
97 9018636 : return AddNode(common()->Int64Constant(value));
98 : }
99 172 : Node* NumberConstant(double value) {
100 344 : return AddNode(common()->NumberConstant(value));
101 : }
102 8007 : Node* Float32Constant(float value) {
103 16014 : return AddNode(common()->Float32Constant(value));
104 : }
105 25130 : Node* Float64Constant(double value) {
106 50260 : return AddNode(common()->Float64Constant(value));
107 : }
108 758461 : Node* HeapConstant(Handle<HeapObject> object) {
109 1516922 : return AddNode(common()->HeapConstant(object));
110 : }
111 220912 : Node* ExternalConstant(ExternalReference address) {
112 441824 : return AddNode(common()->ExternalConstant(address));
113 : }
114 : Node* RelocatableInt32Constant(int32_t value, RelocInfo::Mode rmode) {
115 : return AddNode(common()->RelocatableInt32Constant(value, rmode));
116 : }
117 0 : Node* RelocatableInt64Constant(int64_t value, RelocInfo::Mode rmode) {
118 0 : return AddNode(common()->RelocatableInt64Constant(value, rmode));
119 : }
120 :
121 210592 : Node* Projection(int index, Node* a) {
122 421184 : return AddNode(common()->Projection(index), a);
123 : }
124 :
125 : // Memory Operations.
126 73482 : Node* Load(MachineType rep, Node* base,
127 : LoadSensitivity needs_poisoning = LoadSensitivity::kSafe) {
128 73482 : return Load(rep, base, IntPtrConstant(0), needs_poisoning);
129 : }
130 1741621 : Node* Load(MachineType rep, Node* base, Node* index,
131 : LoadSensitivity needs_poisoning = LoadSensitivity::kSafe) {
132 1741621 : const Operator* op = machine()->Load(rep);
133 1741621 : CHECK_NE(PoisoningMitigationLevel::kPoisonAll, poisoning_level_);
134 1741621 : if (needs_poisoning == LoadSensitivity::kCritical &&
135 : poisoning_level_ == PoisoningMitigationLevel::kPoisonCriticalOnly) {
136 1266 : op = machine()->PoisonedLoad(rep);
137 : }
138 1741621 : return AddNode(op, base, index);
139 : }
140 130700 : Node* Store(MachineRepresentation rep, Node* base, Node* value,
141 : WriteBarrierKind write_barrier) {
142 261400 : return Store(rep, base, IntPtrConstant(0), value, write_barrier);
143 : }
144 400596 : Node* Store(MachineRepresentation rep, Node* base, Node* index, Node* value,
145 : WriteBarrierKind write_barrier) {
146 : return AddNode(machine()->Store(StoreRepresentation(rep, write_barrier)),
147 801192 : base, index, value);
148 : }
149 247912 : void OptimizedStoreField(MachineRepresentation rep, Node* object, int offset,
150 : Node* value, WriteBarrierKind write_barrier) {
151 : AddNode(simplified()->StoreField(FieldAccess(
152 : BaseTaggedness::kTaggedBase, offset, MaybeHandle<Name>(),
153 : MaybeHandle<Map>(), Type::Any(),
154 : MachineType::TypeForRepresentation(rep), write_barrier)),
155 743736 : object, value);
156 247912 : }
157 10812 : void OptimizedStoreMap(Node* object, Node* value) {
158 21624 : AddNode(simplified()->StoreField(AccessBuilder::ForMap()), object, value);
159 10812 : }
160 0 : Node* Retain(Node* value) { return AddNode(common()->Retain(), value); }
161 :
162 : Node* OptimizedAllocate(Node* size, PretenureFlag pretenure);
163 :
164 : // Unaligned memory operations
165 : Node* UnalignedLoad(MachineType type, Node* base) {
166 : return UnalignedLoad(type, base, IntPtrConstant(0));
167 : }
168 9340 : Node* UnalignedLoad(MachineType type, Node* base, Node* index) {
169 18680 : if (machine()->UnalignedLoadSupported(type.representation())) {
170 18680 : return AddNode(machine()->Load(type), base, index);
171 : } else {
172 0 : return AddNode(machine()->UnalignedLoad(type), base, index);
173 : }
174 : }
175 32 : Node* UnalignedStore(MachineRepresentation rep, Node* base, Node* value) {
176 32 : return UnalignedStore(rep, base, IntPtrConstant(0), value);
177 : }
178 2960 : Node* UnalignedStore(MachineRepresentation rep, Node* base, Node* index,
179 : Node* value) {
180 2960 : if (machine()->UnalignedStoreSupported(rep)) {
181 : return AddNode(machine()->Store(StoreRepresentation(
182 : rep, WriteBarrierKind::kNoWriteBarrier)),
183 5920 : base, index, value);
184 : } else {
185 : return AddNode(
186 : machine()->UnalignedStore(UnalignedStoreRepresentation(rep)), base,
187 0 : index, value);
188 : }
189 : }
190 :
191 : // Atomic memory operations.
192 448 : Node* AtomicLoad(MachineType type, Node* base, Node* index) {
193 448 : if (type.representation() == MachineRepresentation::kWord64) {
194 112 : if (machine()->Is64()) {
195 224 : return AddNode(machine()->Word64AtomicLoad(type), base, index);
196 : } else {
197 0 : return AddNode(machine()->Word32AtomicPairLoad(), base, index);
198 : }
199 : }
200 672 : return AddNode(machine()->Word32AtomicLoad(type), base, index);
201 : }
202 :
203 : #if defined(V8_TARGET_BIG_ENDIAN)
204 : #define VALUE_HALVES value_high, value
205 : #else
206 : #define VALUE_HALVES value, value_high
207 : #endif
208 :
209 224 : Node* AtomicStore(MachineRepresentation rep, Node* base, Node* index,
210 : Node* value, Node* value_high) {
211 224 : if (rep == MachineRepresentation::kWord64) {
212 56 : if (machine()->Is64()) {
213 : DCHECK_NULL(value_high);
214 112 : return AddNode(machine()->Word64AtomicStore(rep), base, index, value);
215 : } else {
216 : return AddNode(machine()->Word32AtomicPairStore(), base, index,
217 0 : VALUE_HALVES);
218 : }
219 : }
220 : DCHECK_NULL(value_high);
221 336 : return AddNode(machine()->Word32AtomicStore(rep), base, index, value);
222 : }
223 : #define ATOMIC_FUNCTION(name) \
224 : Node* Atomic##name(MachineType rep, Node* base, Node* index, Node* value, \
225 : Node* value_high) { \
226 : if (rep.representation() == MachineRepresentation::kWord64) { \
227 : if (machine()->Is64()) { \
228 : DCHECK_NULL(value_high); \
229 : return AddNode(machine()->Word64Atomic##name(rep), base, index, \
230 : value); \
231 : } else { \
232 : return AddNode(machine()->Word32AtomicPair##name(), base, index, \
233 : VALUE_HALVES); \
234 : } \
235 : } \
236 : DCHECK_NULL(value_high); \
237 : return AddNode(machine()->Word32Atomic##name(rep), base, index, value); \
238 : }
239 1008 : ATOMIC_FUNCTION(Exchange)
240 1008 : ATOMIC_FUNCTION(Add)
241 1008 : ATOMIC_FUNCTION(Sub)
242 1008 : ATOMIC_FUNCTION(And)
243 1008 : ATOMIC_FUNCTION(Or)
244 1008 : ATOMIC_FUNCTION(Xor)
245 : #undef ATOMIC_FUNCTION
246 : #undef VALUE_HALVES
247 :
248 448 : Node* AtomicCompareExchange(MachineType rep, Node* base, Node* index,
249 : Node* old_value, Node* old_value_high,
250 : Node* new_value, Node* new_value_high) {
251 448 : if (rep.representation() == MachineRepresentation::kWord64) {
252 112 : if (machine()->Is64()) {
253 : DCHECK_NULL(old_value_high);
254 : DCHECK_NULL(new_value_high);
255 : return AddNode(machine()->Word64AtomicCompareExchange(rep), base, index,
256 224 : old_value, new_value);
257 : } else {
258 : return AddNode(machine()->Word32AtomicPairCompareExchange(), base,
259 : index, old_value, old_value_high, new_value,
260 0 : new_value_high);
261 : }
262 : }
263 : DCHECK_NULL(old_value_high);
264 : DCHECK_NULL(new_value_high);
265 : return AddNode(machine()->Word32AtomicCompareExchange(rep), base, index,
266 672 : old_value, new_value);
267 : }
268 :
269 1 : Node* SpeculationFence() {
270 2 : return AddNode(machine()->SpeculationFence().op());
271 : }
272 :
273 : // Arithmetic Operations.
274 306137 : Node* WordAnd(Node* a, Node* b) {
275 612274 : return AddNode(machine()->WordAnd(), a, b);
276 : }
277 79786 : Node* WordOr(Node* a, Node* b) { return AddNode(machine()->WordOr(), a, b); }
278 5 : Node* WordXor(Node* a, Node* b) {
279 10 : return AddNode(machine()->WordXor(), a, b);
280 : }
281 401823 : Node* WordShl(Node* a, Node* b) {
282 803646 : return AddNode(machine()->WordShl(), a, b);
283 : }
284 23605 : Node* WordShr(Node* a, Node* b) {
285 47210 : return AddNode(machine()->WordShr(), a, b);
286 : }
287 162798 : Node* WordSar(Node* a, Node* b) {
288 325596 : return AddNode(machine()->WordSar(), a, b);
289 : }
290 0 : Node* WordRor(Node* a, Node* b) {
291 0 : return AddNode(machine()->WordRor(), a, b);
292 : }
293 704004 : Node* WordEqual(Node* a, Node* b) {
294 1408008 : return AddNode(machine()->WordEqual(), a, b);
295 : }
296 102960 : Node* WordNotEqual(Node* a, Node* b) {
297 102960 : return Word32BinaryNot(WordEqual(a, b));
298 : }
299 0 : Node* WordNot(Node* a) {
300 0 : if (machine()->Is32()) {
301 0 : return Word32BitwiseNot(a);
302 : } else {
303 0 : return Word64Not(a);
304 : }
305 : }
306 :
307 137267 : Node* Word32And(Node* a, Node* b) {
308 274534 : return AddNode(machine()->Word32And(), a, b);
309 : }
310 29003 : Node* Word32Or(Node* a, Node* b) {
311 58006 : return AddNode(machine()->Word32Or(), a, b);
312 : }
313 4043 : Node* Word32Xor(Node* a, Node* b) {
314 8086 : return AddNode(machine()->Word32Xor(), a, b);
315 : }
316 10456 : Node* Word32Shl(Node* a, Node* b) {
317 20912 : return AddNode(machine()->Word32Shl(), a, b);
318 : }
319 41586 : Node* Word32Shr(Node* a, Node* b) {
320 83172 : return AddNode(machine()->Word32Shr(), a, b);
321 : }
322 954 : Node* Word32Sar(Node* a, Node* b) {
323 1908 : return AddNode(machine()->Word32Sar(), a, b);
324 : }
325 398 : Node* Word32Ror(Node* a, Node* b) {
326 796 : return AddNode(machine()->Word32Ror(), a, b);
327 : }
328 122 : Node* Word32Clz(Node* a) { return AddNode(machine()->Word32Clz(), a); }
329 497924 : Node* Word32Equal(Node* a, Node* b) {
330 995848 : return AddNode(machine()->Word32Equal(), a, b);
331 : }
332 83348 : Node* Word32NotEqual(Node* a, Node* b) {
333 83348 : return Word32BinaryNot(Word32Equal(a, b));
334 : }
335 892 : Node* Word32BitwiseNot(Node* a) { return Word32Xor(a, Int32Constant(-1)); }
336 196456 : Node* Word32BinaryNot(Node* a) { return Word32Equal(a, Int32Constant(0)); }
337 :
338 13 : Node* Word64And(Node* a, Node* b) {
339 26 : return AddNode(machine()->Word64And(), a, b);
340 : }
341 1 : Node* Word64Or(Node* a, Node* b) {
342 2 : return AddNode(machine()->Word64Or(), a, b);
343 : }
344 1 : Node* Word64Xor(Node* a, Node* b) {
345 2 : return AddNode(machine()->Word64Xor(), a, b);
346 : }
347 96 : Node* Word64Shl(Node* a, Node* b) {
348 192 : return AddNode(machine()->Word64Shl(), a, b);
349 : }
350 22 : Node* Word64Shr(Node* a, Node* b) {
351 44 : return AddNode(machine()->Word64Shr(), a, b);
352 : }
353 3 : Node* Word64Sar(Node* a, Node* b) {
354 6 : return AddNode(machine()->Word64Sar(), a, b);
355 : }
356 0 : Node* Word64Ror(Node* a, Node* b) {
357 0 : return AddNode(machine()->Word64Ror(), a, b);
358 : }
359 8 : Node* Word64Clz(Node* a) { return AddNode(machine()->Word64Clz(), a); }
360 12580 : Node* Word64Equal(Node* a, Node* b) {
361 25160 : return AddNode(machine()->Word64Equal(), a, b);
362 : }
363 24 : Node* Word64NotEqual(Node* a, Node* b) {
364 24 : return Word32BinaryNot(Word64Equal(a, b));
365 : }
366 0 : Node* Word64Not(Node* a) { return Word64Xor(a, Int64Constant(-1)); }
367 :
368 44967 : Node* Int32Add(Node* a, Node* b) {
369 89934 : return AddNode(machine()->Int32Add(), a, b);
370 : }
371 13928 : Node* Int32AddWithOverflow(Node* a, Node* b) {
372 27856 : return AddNode(machine()->Int32AddWithOverflow(), a, b);
373 : }
374 16913 : Node* Int32Sub(Node* a, Node* b) {
375 33826 : return AddNode(machine()->Int32Sub(), a, b);
376 : }
377 13928 : Node* Int32SubWithOverflow(Node* a, Node* b) {
378 27856 : return AddNode(machine()->Int32SubWithOverflow(), a, b);
379 : }
380 32921 : Node* Int32Mul(Node* a, Node* b) {
381 65842 : return AddNode(machine()->Int32Mul(), a, b);
382 : }
383 7 : Node* Int32MulHigh(Node* a, Node* b) {
384 14 : return AddNode(machine()->Int32MulHigh(), a, b);
385 : }
386 14712 : Node* Int32MulWithOverflow(Node* a, Node* b) {
387 29424 : return AddNode(machine()->Int32MulWithOverflow(), a, b);
388 : }
389 535 : Node* Int32Div(Node* a, Node* b) {
390 1070 : return AddNode(machine()->Int32Div(), a, b);
391 : }
392 906 : Node* Int32Mod(Node* a, Node* b) {
393 1812 : return AddNode(machine()->Int32Mod(), a, b);
394 : }
395 33242 : Node* Int32LessThan(Node* a, Node* b) {
396 66484 : return AddNode(machine()->Int32LessThan(), a, b);
397 : }
398 24302 : Node* Int32LessThanOrEqual(Node* a, Node* b) {
399 48604 : return AddNode(machine()->Int32LessThanOrEqual(), a, b);
400 : }
401 10 : Node* Uint32Div(Node* a, Node* b) {
402 20 : return AddNode(machine()->Uint32Div(), a, b);
403 : }
404 8718 : Node* Uint32LessThan(Node* a, Node* b) {
405 17436 : return AddNode(machine()->Uint32LessThan(), a, b);
406 : }
407 13450 : Node* Uint32LessThanOrEqual(Node* a, Node* b) {
408 26900 : return AddNode(machine()->Uint32LessThanOrEqual(), a, b);
409 : }
410 10 : Node* Uint32Mod(Node* a, Node* b) {
411 20 : return AddNode(machine()->Uint32Mod(), a, b);
412 : }
413 5 : Node* Uint32MulHigh(Node* a, Node* b) {
414 10 : return AddNode(machine()->Uint32MulHigh(), a, b);
415 : }
416 4504 : Node* Int32GreaterThan(Node* a, Node* b) { return Int32LessThan(b, a); }
417 : Node* Int32GreaterThanOrEqual(Node* a, Node* b) {
418 16368 : return Int32LessThanOrEqual(b, a);
419 : }
420 120 : Node* Uint32GreaterThan(Node* a, Node* b) { return Uint32LessThan(b, a); }
421 : Node* Uint32GreaterThanOrEqual(Node* a, Node* b) {
422 4736 : return Uint32LessThanOrEqual(b, a);
423 : }
424 4 : Node* Int32Neg(Node* a) { return Int32Sub(Int32Constant(0), a); }
425 :
426 635454 : Node* Int64Add(Node* a, Node* b) {
427 1270908 : return AddNode(machine()->Int64Add(), a, b);
428 : }
429 31720 : Node* Int64AddWithOverflow(Node* a, Node* b) {
430 63440 : return AddNode(machine()->Int64AddWithOverflow(), a, b);
431 : }
432 103920 : Node* Int64Sub(Node* a, Node* b) {
433 207840 : return AddNode(machine()->Int64Sub(), a, b);
434 : }
435 29648 : Node* Int64SubWithOverflow(Node* a, Node* b) {
436 59296 : return AddNode(machine()->Int64SubWithOverflow(), a, b);
437 : }
438 35521 : Node* Int64Mul(Node* a, Node* b) {
439 71042 : return AddNode(machine()->Int64Mul(), a, b);
440 : }
441 449 : Node* Int64Div(Node* a, Node* b) {
442 898 : return AddNode(machine()->Int64Div(), a, b);
443 : }
444 : Node* Int64Mod(Node* a, Node* b) {
445 : return AddNode(machine()->Int64Mod(), a, b);
446 : }
447 : Node* Int64Neg(Node* a) { return Int64Sub(Int64Constant(0), a); }
448 48048 : Node* Int64LessThan(Node* a, Node* b) {
449 96096 : return AddNode(machine()->Int64LessThan(), a, b);
450 : }
451 14632 : Node* Int64LessThanOrEqual(Node* a, Node* b) {
452 29264 : return AddNode(machine()->Int64LessThanOrEqual(), a, b);
453 : }
454 161182 : Node* Uint64LessThan(Node* a, Node* b) {
455 322364 : return AddNode(machine()->Uint64LessThan(), a, b);
456 : }
457 42360 : Node* Uint64LessThanOrEqual(Node* a, Node* b) {
458 84720 : return AddNode(machine()->Uint64LessThanOrEqual(), a, b);
459 : }
460 27636 : Node* Int64GreaterThan(Node* a, Node* b) { return Int64LessThan(b, a); }
461 : Node* Int64GreaterThanOrEqual(Node* a, Node* b) {
462 4788 : return Int64LessThanOrEqual(b, a);
463 : }
464 4704 : Node* Uint64GreaterThan(Node* a, Node* b) { return Uint64LessThan(b, a); }
465 : Node* Uint64GreaterThanOrEqual(Node* a, Node* b) {
466 28788 : return Uint64LessThanOrEqual(b, a);
467 : }
468 : Node* Uint64Div(Node* a, Node* b) {
469 : return AddNode(machine()->Uint64Div(), a, b);
470 : }
471 : Node* Uint64Mod(Node* a, Node* b) {
472 : return AddNode(machine()->Uint64Mod(), a, b);
473 : }
474 : Node* Int32PairAdd(Node* a_low, Node* a_high, Node* b_low, Node* b_high) {
475 : return AddNode(machine()->Int32PairAdd(), a_low, a_high, b_low, b_high);
476 : }
477 : Node* Int32PairSub(Node* a_low, Node* a_high, Node* b_low, Node* b_high) {
478 : return AddNode(machine()->Int32PairSub(), a_low, a_high, b_low, b_high);
479 : }
480 : Node* Int32PairMul(Node* a_low, Node* a_high, Node* b_low, Node* b_high) {
481 : return AddNode(machine()->Int32PairMul(), a_low, a_high, b_low, b_high);
482 : }
483 : Node* Word32PairShl(Node* low_word, Node* high_word, Node* shift) {
484 : return AddNode(machine()->Word32PairShl(), low_word, high_word, shift);
485 : }
486 : Node* Word32PairShr(Node* low_word, Node* high_word, Node* shift) {
487 : return AddNode(machine()->Word32PairShr(), low_word, high_word, shift);
488 : }
489 : Node* Word32PairSar(Node* low_word, Node* high_word, Node* shift) {
490 : return AddNode(machine()->Word32PairSar(), low_word, high_word, shift);
491 : }
492 :
493 : #define INTPTR_BINOP(prefix, name) \
494 : Node* IntPtr##name(Node* a, Node* b) { \
495 : return kSystemPointerSize == 8 ? prefix##64##name(a, b) \
496 : : prefix##32##name(a, b); \
497 : }
498 :
499 634077 : INTPTR_BINOP(Int, Add)
500 4820 : INTPTR_BINOP(Int, AddWithOverflow)
501 102591 : INTPTR_BINOP(Int, Sub)
502 2748 : INTPTR_BINOP(Int, SubWithOverflow)
503 35065 : INTPTR_BINOP(Int, Mul)
504 449 : INTPTR_BINOP(Int, Div)
505 20412 : INTPTR_BINOP(Int, LessThan)
506 9844 : INTPTR_BINOP(Int, LessThanOrEqual)
507 7384 : INTPTR_BINOP(Word, Equal)
508 24 : INTPTR_BINOP(Word, NotEqual)
509 : INTPTR_BINOP(Int, GreaterThanOrEqual)
510 : INTPTR_BINOP(Int, GreaterThan)
511 :
512 : #undef INTPTR_BINOP
513 :
514 : #define UINTPTR_BINOP(prefix, name) \
515 : Node* UintPtr##name(Node* a, Node* b) { \
516 : return kSystemPointerSize == 8 ? prefix##64##name(a, b) \
517 : : prefix##32##name(a, b); \
518 : }
519 :
520 156478 : UINTPTR_BINOP(Uint, LessThan)
521 13572 : UINTPTR_BINOP(Uint, LessThanOrEqual)
522 : UINTPTR_BINOP(Uint, GreaterThanOrEqual)
523 : UINTPTR_BINOP(Uint, GreaterThan)
524 :
525 : #undef UINTPTR_BINOP
526 :
527 0 : Node* Int32AbsWithOverflow(Node* a) {
528 0 : return AddNode(machine()->Int32AbsWithOverflow().op(), a);
529 : }
530 :
531 0 : Node* Int64AbsWithOverflow(Node* a) {
532 0 : return AddNode(machine()->Int64AbsWithOverflow().op(), a);
533 : }
534 :
535 : Node* IntPtrAbsWithOverflow(Node* a) {
536 : return kSystemPointerSize == 8 ? Int64AbsWithOverflow(a)
537 0 : : Int32AbsWithOverflow(a);
538 : }
539 :
540 1268 : Node* Float32Add(Node* a, Node* b) {
541 2536 : return AddNode(machine()->Float32Add(), a, b);
542 : }
543 2256 : Node* Float32Sub(Node* a, Node* b) {
544 4512 : return AddNode(machine()->Float32Sub(), a, b);
545 : }
546 464 : Node* Float32Mul(Node* a, Node* b) {
547 928 : return AddNode(machine()->Float32Mul(), a, b);
548 : }
549 8 : Node* Float32Div(Node* a, Node* b) {
550 16 : return AddNode(machine()->Float32Div(), a, b);
551 : }
552 12 : Node* Float32Abs(Node* a) { return AddNode(machine()->Float32Abs(), a); }
553 : Node* Float32Neg(Node* a) { return AddNode(machine()->Float32Neg(), a); }
554 : Node* Float32Sqrt(Node* a) { return AddNode(machine()->Float32Sqrt(), a); }
555 0 : Node* Float32Equal(Node* a, Node* b) {
556 0 : return AddNode(machine()->Float32Equal(), a, b);
557 : }
558 : Node* Float32NotEqual(Node* a, Node* b) {
559 : return Word32BinaryNot(Float32Equal(a, b));
560 : }
561 4 : Node* Float32LessThan(Node* a, Node* b) {
562 8 : return AddNode(machine()->Float32LessThan(), a, b);
563 : }
564 0 : Node* Float32LessThanOrEqual(Node* a, Node* b) {
565 0 : return AddNode(machine()->Float32LessThanOrEqual(), a, b);
566 : }
567 0 : Node* Float32GreaterThan(Node* a, Node* b) { return Float32LessThan(b, a); }
568 : Node* Float32GreaterThanOrEqual(Node* a, Node* b) {
569 0 : return Float32LessThanOrEqual(b, a);
570 : }
571 4 : Node* Float32Max(Node* a, Node* b) {
572 8 : return AddNode(machine()->Float32Max(), a, b);
573 : }
574 4 : Node* Float32Min(Node* a, Node* b) {
575 8 : return AddNode(machine()->Float32Min(), a, b);
576 : }
577 7057 : Node* Float64Add(Node* a, Node* b) {
578 14114 : return AddNode(machine()->Float64Add(), a, b);
579 : }
580 4775 : Node* Float64Sub(Node* a, Node* b) {
581 9550 : return AddNode(machine()->Float64Sub(), a, b);
582 : }
583 2106 : Node* Float64Mul(Node* a, Node* b) {
584 4212 : return AddNode(machine()->Float64Mul(), a, b);
585 : }
586 738 : Node* Float64Div(Node* a, Node* b) {
587 1476 : return AddNode(machine()->Float64Div(), a, b);
588 : }
589 527 : Node* Float64Mod(Node* a, Node* b) {
590 1054 : return AddNode(machine()->Float64Mod(), a, b);
591 : }
592 64 : Node* Float64Max(Node* a, Node* b) {
593 128 : return AddNode(machine()->Float64Max(), a, b);
594 : }
595 64 : Node* Float64Min(Node* a, Node* b) {
596 128 : return AddNode(machine()->Float64Min(), a, b);
597 : }
598 15580 : Node* Float64Abs(Node* a) { return AddNode(machine()->Float64Abs(), a); }
599 404 : Node* Float64Neg(Node* a) { return AddNode(machine()->Float64Neg(), a); }
600 120 : Node* Float64Acos(Node* a) { return AddNode(machine()->Float64Acos(), a); }
601 120 : Node* Float64Acosh(Node* a) { return AddNode(machine()->Float64Acosh(), a); }
602 120 : Node* Float64Asin(Node* a) { return AddNode(machine()->Float64Asin(), a); }
603 120 : Node* Float64Asinh(Node* a) { return AddNode(machine()->Float64Asinh(), a); }
604 120 : Node* Float64Atan(Node* a) { return AddNode(machine()->Float64Atan(), a); }
605 120 : Node* Float64Atanh(Node* a) { return AddNode(machine()->Float64Atanh(), a); }
606 60 : Node* Float64Atan2(Node* a, Node* b) {
607 120 : return AddNode(machine()->Float64Atan2(), a, b);
608 : }
609 120 : Node* Float64Cbrt(Node* a) { return AddNode(machine()->Float64Cbrt(), a); }
610 120 : Node* Float64Cos(Node* a) { return AddNode(machine()->Float64Cos(), a); }
611 120 : Node* Float64Cosh(Node* a) { return AddNode(machine()->Float64Cosh(), a); }
612 120 : Node* Float64Exp(Node* a) { return AddNode(machine()->Float64Exp(), a); }
613 120 : Node* Float64Expm1(Node* a) { return AddNode(machine()->Float64Expm1(), a); }
614 120 : Node* Float64Log(Node* a) { return AddNode(machine()->Float64Log(), a); }
615 120 : Node* Float64Log1p(Node* a) { return AddNode(machine()->Float64Log1p(), a); }
616 120 : Node* Float64Log10(Node* a) { return AddNode(machine()->Float64Log10(), a); }
617 120 : Node* Float64Log2(Node* a) { return AddNode(machine()->Float64Log2(), a); }
618 112 : Node* Float64Pow(Node* a, Node* b) {
619 224 : return AddNode(machine()->Float64Pow(), a, b);
620 : }
621 120 : Node* Float64Sin(Node* a) { return AddNode(machine()->Float64Sin(), a); }
622 120 : Node* Float64Sinh(Node* a) { return AddNode(machine()->Float64Sinh(), a); }
623 112 : Node* Float64Sqrt(Node* a) { return AddNode(machine()->Float64Sqrt(), a); }
624 120 : Node* Float64Tan(Node* a) { return AddNode(machine()->Float64Tan(), a); }
625 120 : Node* Float64Tanh(Node* a) { return AddNode(machine()->Float64Tanh(), a); }
626 23791 : Node* Float64Equal(Node* a, Node* b) {
627 47582 : return AddNode(machine()->Float64Equal(), a, b);
628 : }
629 400 : Node* Float64NotEqual(Node* a, Node* b) {
630 400 : return Word32BinaryNot(Float64Equal(a, b));
631 : }
632 15578 : Node* Float64LessThan(Node* a, Node* b) {
633 31156 : return AddNode(machine()->Float64LessThan(), a, b);
634 : }
635 5410 : Node* Float64LessThanOrEqual(Node* a, Node* b) {
636 10820 : return AddNode(machine()->Float64LessThanOrEqual(), a, b);
637 : }
638 3536 : Node* Float64GreaterThan(Node* a, Node* b) { return Float64LessThan(b, a); }
639 : Node* Float64GreaterThanOrEqual(Node* a, Node* b) {
640 3873 : return Float64LessThanOrEqual(b, a);
641 : }
642 :
643 : // Conversions.
644 703836 : Node* BitcastTaggedToWord(Node* a) {
645 1407672 : return AddNode(machine()->BitcastTaggedToWord(), a);
646 : }
647 23860 : Node* BitcastMaybeObjectToWord(Node* a) {
648 47720 : return AddNode(machine()->BitcastMaybeObjectToWord(), a);
649 : }
650 125344 : Node* BitcastWordToTagged(Node* a) {
651 250688 : return AddNode(machine()->BitcastWordToTagged(), a);
652 : }
653 489229 : Node* BitcastWordToTaggedSigned(Node* a) {
654 978458 : return AddNode(machine()->BitcastWordToTaggedSigned(), a);
655 : }
656 8473 : Node* TruncateFloat64ToWord32(Node* a) {
657 16946 : return AddNode(machine()->TruncateFloat64ToWord32(), a);
658 : }
659 2489 : Node* ChangeFloat32ToFloat64(Node* a) {
660 4978 : return AddNode(machine()->ChangeFloat32ToFloat64(), a);
661 : }
662 62396 : Node* ChangeInt32ToFloat64(Node* a) {
663 124792 : return AddNode(machine()->ChangeInt32ToFloat64(), a);
664 : }
665 4 : Node* ChangeInt64ToFloat64(Node* a) {
666 8 : return AddNode(machine()->ChangeInt64ToFloat64(), a);
667 : }
668 4997 : Node* ChangeUint32ToFloat64(Node* a) {
669 9994 : return AddNode(machine()->ChangeUint32ToFloat64(), a);
670 : }
671 20 : Node* ChangeFloat64ToInt32(Node* a) {
672 40 : return AddNode(machine()->ChangeFloat64ToInt32(), a);
673 : }
674 4 : Node* ChangeFloat64ToInt64(Node* a) {
675 8 : return AddNode(machine()->ChangeFloat64ToInt64(), a);
676 : }
677 120 : Node* ChangeFloat64ToUint32(Node* a) {
678 240 : return AddNode(machine()->ChangeFloat64ToUint32(), a);
679 : }
680 1848 : Node* ChangeFloat64ToUint64(Node* a) {
681 3696 : return AddNode(machine()->ChangeFloat64ToUint64(), a);
682 : }
683 : Node* TruncateFloat64ToUint32(Node* a) {
684 : return AddNode(machine()->TruncateFloat64ToUint32(), a);
685 : }
686 228 : Node* TruncateFloat32ToInt32(Node* a) {
687 456 : return AddNode(machine()->TruncateFloat32ToInt32(), a);
688 : }
689 4 : Node* TruncateFloat32ToUint32(Node* a) {
690 8 : return AddNode(machine()->TruncateFloat32ToUint32(), a);
691 : }
692 8 : Node* TryTruncateFloat32ToInt64(Node* a) {
693 16 : return AddNode(machine()->TryTruncateFloat32ToInt64(), a);
694 : }
695 8 : Node* TryTruncateFloat64ToInt64(Node* a) {
696 16 : return AddNode(machine()->TryTruncateFloat64ToInt64(), a);
697 : }
698 8 : Node* TryTruncateFloat32ToUint64(Node* a) {
699 16 : return AddNode(machine()->TryTruncateFloat32ToUint64(), a);
700 : }
701 8 : Node* TryTruncateFloat64ToUint64(Node* a) {
702 16 : return AddNode(machine()->TryTruncateFloat64ToUint64(), a);
703 : }
704 209346 : Node* ChangeInt32ToInt64(Node* a) {
705 418692 : return AddNode(machine()->ChangeInt32ToInt64(), a);
706 : }
707 114935 : Node* ChangeUint32ToUint64(Node* a) {
708 229870 : return AddNode(machine()->ChangeUint32ToUint64(), a);
709 : }
710 2149 : Node* TruncateFloat64ToFloat32(Node* a) {
711 4298 : return AddNode(machine()->TruncateFloat64ToFloat32(), a);
712 : }
713 151537 : Node* TruncateInt64ToInt32(Node* a) {
714 303074 : return AddNode(machine()->TruncateInt64ToInt32(), a);
715 : }
716 14132 : Node* RoundFloat64ToInt32(Node* a) {
717 28264 : return AddNode(machine()->RoundFloat64ToInt32(), a);
718 : }
719 396 : Node* RoundInt32ToFloat32(Node* a) {
720 792 : return AddNode(machine()->RoundInt32ToFloat32(), a);
721 : }
722 4 : Node* RoundInt64ToFloat32(Node* a) {
723 8 : return AddNode(machine()->RoundInt64ToFloat32(), a);
724 : }
725 1188 : Node* RoundInt64ToFloat64(Node* a) {
726 2376 : return AddNode(machine()->RoundInt64ToFloat64(), a);
727 : }
728 4 : Node* RoundUint32ToFloat32(Node* a) {
729 8 : return AddNode(machine()->RoundUint32ToFloat32(), a);
730 : }
731 4 : Node* RoundUint64ToFloat32(Node* a) {
732 8 : return AddNode(machine()->RoundUint64ToFloat32(), a);
733 : }
734 1684 : Node* RoundUint64ToFloat64(Node* a) {
735 3368 : return AddNode(machine()->RoundUint64ToFloat64(), a);
736 : }
737 60 : Node* BitcastFloat32ToInt32(Node* a) {
738 120 : return AddNode(machine()->BitcastFloat32ToInt32(), a);
739 : }
740 4 : Node* BitcastFloat64ToInt64(Node* a) {
741 8 : return AddNode(machine()->BitcastFloat64ToInt64(), a);
742 : }
743 60 : Node* BitcastInt32ToFloat32(Node* a) {
744 120 : return AddNode(machine()->BitcastInt32ToFloat32(), a);
745 : }
746 4 : Node* BitcastInt64ToFloat64(Node* a) {
747 8 : return AddNode(machine()->BitcastInt64ToFloat64(), a);
748 : }
749 4 : Node* Float32RoundDown(Node* a) {
750 8 : return AddNode(machine()->Float32RoundDown().op(), a);
751 : }
752 118 : Node* Float64RoundDown(Node* a) {
753 236 : return AddNode(machine()->Float64RoundDown().op(), a);
754 : }
755 4 : Node* Float32RoundUp(Node* a) {
756 8 : return AddNode(machine()->Float32RoundUp().op(), a);
757 : }
758 114 : Node* Float64RoundUp(Node* a) {
759 228 : return AddNode(machine()->Float64RoundUp().op(), a);
760 : }
761 4 : Node* Float32RoundTruncate(Node* a) {
762 8 : return AddNode(machine()->Float32RoundTruncate().op(), a);
763 : }
764 338 : Node* Float64RoundTruncate(Node* a) {
765 676 : return AddNode(machine()->Float64RoundTruncate().op(), a);
766 : }
767 0 : Node* Float64RoundTiesAway(Node* a) {
768 0 : return AddNode(machine()->Float64RoundTiesAway().op(), a);
769 : }
770 4 : Node* Float32RoundTiesEven(Node* a) {
771 8 : return AddNode(machine()->Float32RoundTiesEven().op(), a);
772 : }
773 389 : Node* Float64RoundTiesEven(Node* a) {
774 778 : return AddNode(machine()->Float64RoundTiesEven().op(), a);
775 : }
776 : Node* Word32ReverseBytes(Node* a) {
777 : return AddNode(machine()->Word32ReverseBytes(), a);
778 : }
779 : Node* Word64ReverseBytes(Node* a) {
780 : return AddNode(machine()->Word64ReverseBytes(), a);
781 : }
782 :
783 : // Float64 bit operations.
784 60 : Node* Float64ExtractLowWord32(Node* a) {
785 120 : return AddNode(machine()->Float64ExtractLowWord32(), a);
786 : }
787 5900 : Node* Float64ExtractHighWord32(Node* a) {
788 11800 : return AddNode(machine()->Float64ExtractHighWord32(), a);
789 : }
790 60 : Node* Float64InsertLowWord32(Node* a, Node* b) {
791 120 : return AddNode(machine()->Float64InsertLowWord32(), a, b);
792 : }
793 60 : Node* Float64InsertHighWord32(Node* a, Node* b) {
794 120 : return AddNode(machine()->Float64InsertHighWord32(), a, b);
795 : }
796 2644 : Node* Float64SilenceNaN(Node* a) {
797 5288 : return AddNode(machine()->Float64SilenceNaN(), a);
798 : }
799 :
800 : // Stack operations.
801 38532 : Node* LoadStackPointer() { return AddNode(machine()->LoadStackPointer()); }
802 14568 : Node* LoadFramePointer() { return AddNode(machine()->LoadFramePointer()); }
803 28500 : Node* LoadParentFramePointer() {
804 57000 : return AddNode(machine()->LoadParentFramePointer());
805 : }
806 :
807 : // Parameters.
808 : Node* TargetParameter();
809 : Node* Parameter(size_t index);
810 :
811 : // Pointer utilities.
812 6204 : Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) {
813 12408 : return Load(rep, PointerConstant(address), Int32Constant(offset));
814 : }
815 103940 : Node* StoreToPointer(void* address, MachineRepresentation rep, Node* node) {
816 103940 : return Store(rep, PointerConstant(address), node, kNoWriteBarrier);
817 : }
818 76 : Node* UnalignedLoadFromPointer(void* address, MachineType rep,
819 : int32_t offset = 0) {
820 152 : return UnalignedLoad(rep, PointerConstant(address), Int32Constant(offset));
821 : }
822 32 : Node* UnalignedStoreToPointer(void* address, MachineRepresentation rep,
823 : Node* node) {
824 32 : return UnalignedStore(rep, PointerConstant(address), node);
825 : }
826 44 : Node* StringConstant(const char* string) {
827 88 : return HeapConstant(isolate()->factory()->InternalizeUtf8String(string));
828 : }
829 :
830 19112 : Node* TaggedPoisonOnSpeculation(Node* value) {
831 19112 : if (poisoning_level_ != PoisoningMitigationLevel::kDontPoison) {
832 1712 : return AddNode(machine()->TaggedPoisonOnSpeculation(), value);
833 : }
834 : return value;
835 : }
836 :
837 46536 : Node* WordPoisonOnSpeculation(Node* value) {
838 46536 : if (poisoning_level_ != PoisoningMitigationLevel::kDontPoison) {
839 0 : return AddNode(machine()->WordPoisonOnSpeculation(), value);
840 : }
841 : return value;
842 : }
843 :
844 : // Call a given call descriptor and the given arguments.
845 : // The call target is passed as part of the {inputs} array.
846 : Node* CallN(CallDescriptor* call_descriptor, int input_count,
847 : Node* const* inputs);
848 :
849 : // Call a given call descriptor and the given arguments and frame-state.
850 : // The call target and frame state are passed as part of the {inputs} array.
851 : Node* CallNWithFrameState(CallDescriptor* call_descriptor, int input_count,
852 : Node* const* inputs);
853 :
854 : // Tail call a given call descriptor and the given arguments.
855 : // The call target is passed as part of the {inputs} array.
856 : Node* TailCallN(CallDescriptor* call_descriptor, int input_count,
857 : Node* const* inputs);
858 :
859 : // Call to a C function with zero arguments.
860 : Node* CallCFunction0(MachineType return_type, Node* function);
861 : // Call to a C function with one parameter.
862 : Node* CallCFunction1(MachineType return_type, MachineType arg0_type,
863 : Node* function, Node* arg0);
864 : // Call to a C function with one argument, while saving/restoring caller
865 : // registers.
866 : Node* CallCFunction1WithCallerSavedRegisters(
867 : MachineType return_type, MachineType arg0_type, Node* function,
868 : Node* arg0, SaveFPRegsMode mode = kSaveFPRegs);
869 : // Call to a C function with two arguments.
870 : Node* CallCFunction2(MachineType return_type, MachineType arg0_type,
871 : MachineType arg1_type, Node* function, Node* arg0,
872 : Node* arg1);
873 : // Call to a C function with three arguments.
874 : Node* CallCFunction3(MachineType return_type, MachineType arg0_type,
875 : MachineType arg1_type, MachineType arg2_type,
876 : Node* function, Node* arg0, Node* arg1, Node* arg2);
877 : // Call to a C function with three arguments, while saving/restoring caller
878 : // registers.
879 : Node* CallCFunction3WithCallerSavedRegisters(
880 : MachineType return_type, MachineType arg0_type, MachineType arg1_type,
881 : MachineType arg2_type, Node* function, Node* arg0, Node* arg1, Node* arg2,
882 : SaveFPRegsMode mode = kSaveFPRegs);
883 : // Call to a C function with four arguments.
884 : Node* CallCFunction4(MachineType return_type, MachineType arg0_type,
885 : MachineType arg1_type, MachineType arg2_type,
886 : MachineType arg3_type, Node* function, Node* arg0,
887 : Node* arg1, Node* arg2, Node* arg3);
888 : // Call to a C function with five arguments.
889 : Node* CallCFunction5(MachineType return_type, MachineType arg0_type,
890 : MachineType arg1_type, MachineType arg2_type,
891 : MachineType arg3_type, MachineType arg4_type,
892 : Node* function, Node* arg0, Node* arg1, Node* arg2,
893 : Node* arg3, Node* arg4);
894 : // Call to a C function with six arguments.
895 : Node* CallCFunction6(MachineType return_type, MachineType arg0_type,
896 : MachineType arg1_type, MachineType arg2_type,
897 : MachineType arg3_type, MachineType arg4_type,
898 : MachineType arg5_type, Node* function, Node* arg0,
899 : Node* arg1, Node* arg2, Node* arg3, Node* arg4,
900 : Node* arg5);
901 : // Call to a C function with eight arguments.
902 : Node* CallCFunction8(MachineType return_type, MachineType arg0_type,
903 : MachineType arg1_type, MachineType arg2_type,
904 : MachineType arg3_type, MachineType arg4_type,
905 : MachineType arg5_type, MachineType arg6_type,
906 : MachineType arg7_type, Node* function, Node* arg0,
907 : Node* arg1, Node* arg2, Node* arg3, Node* arg4,
908 : Node* arg5, Node* arg6, Node* arg7);
909 : // Call to a C function with nine arguments.
910 : Node* CallCFunction9(MachineType return_type, MachineType arg0_type,
911 : MachineType arg1_type, MachineType arg2_type,
912 : MachineType arg3_type, MachineType arg4_type,
913 : MachineType arg5_type, MachineType arg6_type,
914 : MachineType arg7_type, MachineType arg8_type,
915 : Node* function, Node* arg0, Node* arg1, Node* arg2,
916 : Node* arg3, Node* arg4, Node* arg5, Node* arg6,
917 : Node* arg7, Node* arg8);
918 :
919 : // ===========================================================================
920 : // The following utility methods deal with control flow, hence might switch
921 : // the current basic block or create new basic blocks for labels.
922 :
923 : // Control flow.
924 : void Goto(RawMachineLabel* label);
925 : void Branch(Node* condition, RawMachineLabel* true_val,
926 : RawMachineLabel* false_val);
927 : void Switch(Node* index, RawMachineLabel* default_label,
928 : const int32_t* case_values, RawMachineLabel** case_labels,
929 : size_t case_count);
930 : void Return(Node* value);
931 : void Return(Node* v1, Node* v2);
932 : void Return(Node* v1, Node* v2, Node* v3);
933 : void Return(Node* v1, Node* v2, Node* v3, Node* v4);
934 : void Return(int count, Node* v[]);
935 : void PopAndReturn(Node* pop, Node* value);
936 : void PopAndReturn(Node* pop, Node* v1, Node* v2);
937 : void PopAndReturn(Node* pop, Node* v1, Node* v2, Node* v3);
938 : void PopAndReturn(Node* pop, Node* v1, Node* v2, Node* v3, Node* v4);
939 : void Bind(RawMachineLabel* label);
940 : void Deoptimize(Node* state);
941 : void DebugAbort(Node* message);
942 : void DebugBreak();
943 : void Unreachable();
944 : void Comment(std::string msg);
945 :
946 : #if DEBUG
947 : void Bind(RawMachineLabel* label, AssemblerDebugInfo info);
948 : void SetInitialDebugInformation(AssemblerDebugInfo info);
949 : void PrintCurrentBlock(std::ostream& os);
950 : #endif // DEBUG
951 : bool InsideBlock();
952 :
953 : // Add success / exception successor blocks and ends the current block ending
954 : // in a potentially throwing call node.
955 : void Continuations(Node* call, RawMachineLabel* if_success,
956 : RawMachineLabel* if_exception);
957 :
958 : // Variables.
959 158 : Node* Phi(MachineRepresentation rep, Node* n1, Node* n2) {
960 316 : return AddNode(common()->Phi(rep, 2), n1, n2, graph()->start());
961 : }
962 : Node* Phi(MachineRepresentation rep, Node* n1, Node* n2, Node* n3) {
963 : return AddNode(common()->Phi(rep, 3), n1, n2, n3, graph()->start());
964 : }
965 : Node* Phi(MachineRepresentation rep, Node* n1, Node* n2, Node* n3, Node* n4) {
966 : return AddNode(common()->Phi(rep, 4), n1, n2, n3, n4, graph()->start());
967 : }
968 : Node* Phi(MachineRepresentation rep, int input_count, Node* const* inputs);
969 : void AppendPhiInput(Node* phi, Node* new_input);
970 :
971 : // ===========================================================================
972 : // The following generic node creation methods can be used for operators that
973 : // are not covered by the above utility methods. There should rarely be a need
974 : // to do that outside of testing though.
975 :
976 : Node* AddNode(const Operator* op, int input_count, Node* const* inputs);
977 :
978 : Node* AddNode(const Operator* op) {
979 7535106 : return AddNode(op, 0, static_cast<Node* const*>(nullptr));
980 : }
981 :
982 : template <class... TArgs>
983 : Node* AddNode(const Operator* op, Node* n1, TArgs... args) {
984 8978718 : Node* buffer[] = {n1, args...};
985 8978718 : return AddNode(op, sizeof...(args) + 1, buffer);
986 : }
987 :
988 : void SetSourcePosition(const char* file, int line);
989 : SourcePositionTable* source_positions() { return source_positions_; }
990 :
991 : private:
992 : Node* MakeNode(const Operator* op, int input_count, Node* const* inputs);
993 : BasicBlock* Use(RawMachineLabel* label);
994 : BasicBlock* EnsureBlock(RawMachineLabel* label);
995 : BasicBlock* CurrentBlock();
996 :
997 : // A post-processing pass to add effect and control edges so that the graph
998 : // can be optimized and re-scheduled.
999 : // TODO(tebbi): Move this to a separate class.
1000 : void MakeReschedulable();
1001 : Node* CreateNodeFromPredecessors(const std::vector<BasicBlock*>& predecessors,
1002 : const std::vector<Node*>& sidetable,
1003 : const Operator* op,
1004 : const std::vector<Node*>& additional_inputs);
1005 : void MakePhiBinary(Node* phi, int split_point, Node* left_control,
1006 : Node* right_control);
1007 : void MarkControlDeferred(Node* control_input);
1008 :
1009 : Schedule* schedule() { return schedule_; }
1010 1255942 : size_t parameter_count() const { return call_descriptor_->ParameterCount(); }
1011 :
1012 : Isolate* isolate_;
1013 : Graph* graph_;
1014 : Schedule* schedule_;
1015 : SourcePositionTable* source_positions_;
1016 : MachineOperatorBuilder machine_;
1017 : CommonOperatorBuilder common_;
1018 : SimplifiedOperatorBuilder simplified_;
1019 : CallDescriptor* call_descriptor_;
1020 : Node* target_parameter_;
1021 : NodeVector parameters_;
1022 : BasicBlock* current_block_;
1023 : PoisoningMitigationLevel poisoning_level_;
1024 :
1025 : DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler);
1026 : };
1027 :
1028 : class V8_EXPORT_PRIVATE RawMachineLabel final {
1029 : public:
1030 : enum Type { kDeferred, kNonDeferred };
1031 :
1032 : explicit RawMachineLabel(Type type = kNonDeferred)
1033 3684408 : : deferred_(type == kDeferred) {}
1034 : ~RawMachineLabel();
1035 :
1036 : BasicBlock* block() const { return block_; }
1037 :
1038 : private:
1039 : BasicBlock* block_ = nullptr;
1040 : bool used_ = false;
1041 : bool bound_ = false;
1042 : bool deferred_;
1043 : friend class RawMachineAssembler;
1044 : DISALLOW_COPY_AND_ASSIGN(RawMachineLabel);
1045 : };
1046 :
1047 : } // namespace compiler
1048 : } // namespace internal
1049 : } // namespace v8
1050 :
1051 : #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
|