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