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