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