1 // Copyright 2013 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_OPCODES_H_ 6 #define V8_COMPILER_OPCODES_H_ 7 8 #include <iosfwd> 9 10 #include "src/common/globals.h" 11 12 // Opcodes for control operators. 13 #define CONTROL_OP_LIST(V) \ 14 V(Start) \ 15 V(Loop) \ 16 V(Branch) \ 17 V(Switch) \ 18 V(IfTrue) \ 19 V(IfFalse) \ 20 V(IfSuccess) \ 21 V(IfException) \ 22 V(IfValue) \ 23 V(IfDefault) \ 24 V(Merge) \ 25 V(Deoptimize) \ 26 V(DeoptimizeIf) \ 27 V(DeoptimizeUnless) \ 28 V(TrapIf) \ 29 V(TrapUnless) \ 30 V(Return) \ 31 V(TailCall) \ 32 V(Terminate) \ 33 V(Throw) \ 34 V(End) 35 36 // Opcodes for constant operators. 37 #define CONSTANT_OP_LIST(V) \ 38 V(Int32Constant) \ 39 V(Int64Constant) \ 40 V(TaggedIndexConstant) \ 41 V(Float32Constant) \ 42 V(Float64Constant) \ 43 V(ExternalConstant) \ 44 V(NumberConstant) \ 45 V(PointerConstant) \ 46 V(HeapConstant) \ 47 V(CompressedHeapConstant) \ 48 V(RelocatableInt32Constant) \ 49 V(RelocatableInt64Constant) 50 51 #define INNER_OP_LIST(V) \ 52 V(Select) \ 53 V(Phi) \ 54 V(EffectPhi) \ 55 V(InductionVariablePhi) \ 56 V(Checkpoint) \ 57 V(BeginRegion) \ 58 V(FinishRegion) \ 59 V(FrameState) \ 60 V(StateValues) \ 61 V(TypedStateValues) \ 62 V(ArgumentsElementsState) \ 63 V(ArgumentsLengthState) \ 64 V(ObjectState) \ 65 V(ObjectId) \ 66 V(TypedObjectState) \ 67 V(Call) \ 68 V(Parameter) \ 69 V(OsrValue) \ 70 V(LoopExit) \ 71 V(LoopExitValue) \ 72 V(LoopExitEffect) \ 73 V(Projection) \ 74 V(Retain) \ 75 V(MapGuard) \ 76 V(FoldConstant) \ 77 V(TypeGuard) 78 79 #define COMMON_OP_LIST(V) \ 80 CONSTANT_OP_LIST(V) \ 81 INNER_OP_LIST(V) \ 82 V(Unreachable) \ 83 V(DeadValue) \ 84 V(Dead) \ 85 V(StaticAssert) 86 87 // Opcodes for JavaScript operators. 88 // Arguments are JSName (the name with a 'JS' prefix), and Name. 89 #define JS_COMPARE_BINOP_LIST(V) \ 90 V(JSEqual, Equal) \ 91 V(JSStrictEqual, StrictEqual) \ 92 V(JSLessThan, LessThan) \ 93 V(JSGreaterThan, GreaterThan) \ 94 V(JSLessThanOrEqual, LessThanOrEqual) \ 95 V(JSGreaterThanOrEqual, GreaterThanOrEqual) 96 97 #define JS_BITWISE_BINOP_LIST(V) \ 98 V(JSBitwiseOr, BitwiseOr) \ 99 V(JSBitwiseXor, BitwiseXor) \ 100 V(JSBitwiseAnd, BitwiseAnd) \ 101 V(JSShiftLeft, ShiftLeft) \ 102 V(JSShiftRight, ShiftRight) \ 103 V(JSShiftRightLogical, ShiftRightLogical) 104 105 #define JS_ARITH_BINOP_LIST(V) \ 106 V(JSAdd, Add) \ 107 V(JSSubtract, Subtract) \ 108 V(JSMultiply, Multiply) \ 109 V(JSDivide, Divide) \ 110 V(JSModulus, Modulus) \ 111 V(JSExponentiate, Exponentiate) 112 113 #define JS_SIMPLE_BINOP_LIST(V) \ 114 JS_COMPARE_BINOP_LIST(V) \ 115 JS_BITWISE_BINOP_LIST(V) \ 116 JS_ARITH_BINOP_LIST(V) \ 117 V(JSHasInPrototypeChain) \ 118 V(JSInstanceOf) \ 119 V(JSOrdinaryHasInstance) 120 121 #define JS_CONVERSION_UNOP_LIST(V) \ 122 V(JSToLength) \ 123 V(JSToName) \ 124 V(JSToNumber) \ 125 V(JSToNumberConvertBigInt) \ 126 V(JSToNumeric) \ 127 V(JSToObject) \ 128 V(JSToString) \ 129 V(JSParseInt) 130 131 #define JS_BITWISE_UNOP_LIST(V) \ 132 V(JSBitwiseNot, BitwiseNot) \ 133 V(JSNegate, Negate) 134 135 #define JS_ARITH_UNOP_LIST(V) \ 136 V(JSDecrement, Decrement) \ 137 V(JSIncrement, Increment) 138 139 #define JS_SIMPLE_UNOP_LIST(V) \ 140 JS_ARITH_UNOP_LIST(V) \ 141 JS_BITWISE_UNOP_LIST(V) \ 142 JS_CONVERSION_UNOP_LIST(V) 143 144 #define JS_CREATE_OP_LIST(V) \ 145 V(JSCloneObject) \ 146 V(JSCreate) \ 147 V(JSCreateArguments) \ 148 V(JSCreateArray) \ 149 V(JSCreateArrayFromIterable) \ 150 V(JSCreateArrayIterator) \ 151 V(JSCreateAsyncFunctionObject) \ 152 V(JSCreateBoundFunction) \ 153 V(JSCreateClosure) \ 154 V(JSCreateCollectionIterator) \ 155 V(JSCreateEmptyLiteralArray) \ 156 V(JSCreateEmptyLiteralObject) \ 157 V(JSCreateGeneratorObject) \ 158 V(JSCreateIterResultObject) \ 159 V(JSCreateKeyValueArray) \ 160 V(JSCreateLiteralArray) \ 161 V(JSCreateLiteralObject) \ 162 V(JSCreateLiteralRegExp) \ 163 V(JSCreateObject) \ 164 V(JSCreatePromise) \ 165 V(JSCreateStringIterator) \ 166 V(JSCreateTypedArray) \ 167 V(JSGetTemplateObject) 168 169 #define JS_OBJECT_OP_LIST(V) \ 170 JS_CREATE_OP_LIST(V) \ 171 V(JSLoadProperty) \ 172 V(JSLoadNamed) \ 173 V(JSLoadNamedFromSuper) \ 174 V(JSLoadGlobal) \ 175 V(JSStoreProperty) \ 176 V(JSStoreNamed) \ 177 V(JSStoreNamedOwn) \ 178 V(JSStoreGlobal) \ 179 V(JSStoreDataPropertyInLiteral) \ 180 V(JSStoreInArrayLiteral) \ 181 V(JSDeleteProperty) \ 182 V(JSHasProperty) \ 183 V(JSGetSuperConstructor) 184 185 #define JS_CONTEXT_OP_LIST(V) \ 186 V(JSHasContextExtension) \ 187 V(JSLoadContext) \ 188 V(JSStoreContext) \ 189 V(JSCreateFunctionContext) \ 190 V(JSCreateCatchContext) \ 191 V(JSCreateWithContext) \ 192 V(JSCreateBlockContext) 193 194 #define JS_CALL_OP_LIST(V) \ 195 V(JSCall) \ 196 V(JSCallForwardVarargs) \ 197 V(JSCallWithArrayLike) \ 198 V(JSCallWithSpread) 199 200 #define JS_CONSTRUCT_OP_LIST(V) \ 201 V(JSConstructForwardVarargs) \ 202 V(JSConstruct) \ 203 V(JSConstructWithArrayLike) \ 204 V(JSConstructWithSpread) 205 206 #define JS_OTHER_OP_LIST(V) \ 207 JS_CALL_OP_LIST(V) \ 208 JS_CONSTRUCT_OP_LIST(V) \ 209 V(JSAsyncFunctionEnter) \ 210 V(JSAsyncFunctionReject) \ 211 V(JSAsyncFunctionResolve) \ 212 V(JSCallRuntime) \ 213 V(JSForInEnumerate) \ 214 V(JSForInNext) \ 215 V(JSForInPrepare) \ 216 V(JSGetIterator) \ 217 V(JSLoadMessage) \ 218 V(JSStoreMessage) \ 219 V(JSLoadModule) \ 220 V(JSStoreModule) \ 221 V(JSGetImportMeta) \ 222 V(JSGeneratorStore) \ 223 V(JSGeneratorRestoreContinuation) \ 224 V(JSGeneratorRestoreContext) \ 225 V(JSGeneratorRestoreRegister) \ 226 V(JSGeneratorRestoreInputOrDebugPos) \ 227 V(JSFulfillPromise) \ 228 V(JSPerformPromiseThen) \ 229 V(JSPromiseResolve) \ 230 V(JSRejectPromise) \ 231 V(JSResolvePromise) \ 232 V(JSStackCheck) \ 233 V(JSObjectIsArray) \ 234 V(JSRegExpTest) \ 235 V(JSDebugger) 236 237 #define JS_OP_LIST(V) \ 238 JS_SIMPLE_BINOP_LIST(V) \ 239 JS_SIMPLE_UNOP_LIST(V) \ 240 JS_OBJECT_OP_LIST(V) \ 241 JS_CONTEXT_OP_LIST(V) \ 242 JS_OTHER_OP_LIST(V) 243 244 // Opcodes for VirtuaMachine-level operators. 245 #define SIMPLIFIED_CHANGE_OP_LIST(V) \ 246 V(ChangeTaggedSignedToInt32) \ 247 V(ChangeTaggedSignedToInt64) \ 248 V(ChangeTaggedToInt32) \ 249 V(ChangeTaggedToInt64) \ 250 V(ChangeTaggedToUint32) \ 251 V(ChangeTaggedToFloat64) \ 252 V(ChangeTaggedToTaggedSigned) \ 253 V(ChangeInt31ToTaggedSigned) \ 254 V(ChangeInt32ToTagged) \ 255 V(ChangeInt64ToTagged) \ 256 V(ChangeUint32ToTagged) \ 257 V(ChangeUint64ToTagged) \ 258 V(ChangeFloat64ToTagged) \ 259 V(ChangeFloat64ToTaggedPointer) \ 260 V(ChangeTaggedToBit) \ 261 V(ChangeBitToTagged) \ 262 V(ChangeUint64ToBigInt) \ 263 V(TruncateBigIntToUint64) \ 264 V(TruncateTaggedToWord32) \ 265 V(TruncateTaggedToFloat64) \ 266 V(TruncateTaggedToBit) \ 267 V(TruncateTaggedPointerToBit) 268 269 #define SIMPLIFIED_CHECKED_OP_LIST(V) \ 270 V(CheckedInt32Add) \ 271 V(CheckedInt32Sub) \ 272 V(CheckedInt32Div) \ 273 V(CheckedInt32Mod) \ 274 V(CheckedUint32Div) \ 275 V(CheckedUint32Mod) \ 276 V(CheckedInt32Mul) \ 277 V(CheckedInt32ToTaggedSigned) \ 278 V(CheckedInt64ToInt32) \ 279 V(CheckedInt64ToTaggedSigned) \ 280 V(CheckedUint32Bounds) \ 281 V(CheckedUint32ToInt32) \ 282 V(CheckedUint32ToTaggedSigned) \ 283 V(CheckedUint64Bounds) \ 284 V(CheckedUint64ToInt32) \ 285 V(CheckedUint64ToTaggedSigned) \ 286 V(CheckedFloat64ToInt32) \ 287 V(CheckedFloat64ToInt64) \ 288 V(CheckedTaggedSignedToInt32) \ 289 V(CheckedTaggedToInt32) \ 290 V(CheckedTaggedToArrayIndex) \ 291 V(CheckedTruncateTaggedToWord32) \ 292 V(CheckedTaggedToFloat64) \ 293 V(CheckedTaggedToInt64) \ 294 V(CheckedTaggedToTaggedSigned) \ 295 V(CheckedTaggedToTaggedPointer) 296 297 #define SIMPLIFIED_COMPARE_BINOP_LIST(V) \ 298 V(NumberEqual) \ 299 V(NumberLessThan) \ 300 V(NumberLessThanOrEqual) \ 301 V(SpeculativeNumberEqual) \ 302 V(SpeculativeNumberLessThan) \ 303 V(SpeculativeNumberLessThanOrEqual) \ 304 V(ReferenceEqual) \ 305 V(SameValue) \ 306 V(SameValueNumbersOnly) \ 307 V(NumberSameValue) \ 308 V(StringEqual) \ 309 V(StringLessThan) \ 310 V(StringLessThanOrEqual) 311 312 #define SIMPLIFIED_NUMBER_BINOP_LIST(V) \ 313 V(NumberAdd) \ 314 V(NumberSubtract) \ 315 V(NumberMultiply) \ 316 V(NumberDivide) \ 317 V(NumberModulus) \ 318 V(NumberBitwiseOr) \ 319 V(NumberBitwiseXor) \ 320 V(NumberBitwiseAnd) \ 321 V(NumberShiftLeft) \ 322 V(NumberShiftRight) \ 323 V(NumberShiftRightLogical) \ 324 V(NumberAtan2) \ 325 V(NumberImul) \ 326 V(NumberMax) \ 327 V(NumberMin) \ 328 V(NumberPow) 329 330 #define SIMPLIFIED_BIGINT_BINOP_LIST(V) \ 331 V(BigIntAdd) \ 332 V(BigIntSubtract) 333 334 #define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \ 335 V(SpeculativeNumberAdd) \ 336 V(SpeculativeNumberSubtract) \ 337 V(SpeculativeNumberMultiply) \ 338 V(SpeculativeNumberDivide) \ 339 V(SpeculativeNumberModulus) \ 340 V(SpeculativeNumberBitwiseAnd) \ 341 V(SpeculativeNumberBitwiseOr) \ 342 V(SpeculativeNumberBitwiseXor) \ 343 V(SpeculativeNumberShiftLeft) \ 344 V(SpeculativeNumberShiftRight) \ 345 V(SpeculativeNumberShiftRightLogical) \ 346 V(SpeculativeSafeIntegerAdd) \ 347 V(SpeculativeSafeIntegerSubtract) 348 349 #define SIMPLIFIED_NUMBER_UNOP_LIST(V) \ 350 V(NumberAbs) \ 351 V(NumberAcos) \ 352 V(NumberAcosh) \ 353 V(NumberAsin) \ 354 V(NumberAsinh) \ 355 V(NumberAtan) \ 356 V(NumberAtanh) \ 357 V(NumberCbrt) \ 358 V(NumberCeil) \ 359 V(NumberClz32) \ 360 V(NumberCos) \ 361 V(NumberCosh) \ 362 V(NumberExp) \ 363 V(NumberExpm1) \ 364 V(NumberFloor) \ 365 V(NumberFround) \ 366 V(NumberLog) \ 367 V(NumberLog1p) \ 368 V(NumberLog2) \ 369 V(NumberLog10) \ 370 V(NumberRound) \ 371 V(NumberSign) \ 372 V(NumberSin) \ 373 V(NumberSinh) \ 374 V(NumberSqrt) \ 375 V(NumberTan) \ 376 V(NumberTanh) \ 377 V(NumberTrunc) \ 378 V(NumberToBoolean) \ 379 V(NumberToInt32) \ 380 V(NumberToString) \ 381 V(NumberToUint32) \ 382 V(NumberToUint8Clamped) \ 383 V(NumberSilenceNaN) 384 385 #define SIMPLIFIED_BIGINT_UNOP_LIST(V) \ 386 V(BigIntAsUintN) \ 387 V(BigIntNegate) \ 388 V(CheckBigInt) 389 390 #define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber) 391 392 #define SIMPLIFIED_OTHER_OP_LIST(V) \ 393 V(Allocate) \ 394 V(AllocateRaw) \ 395 V(ArgumentsFrame) \ 396 V(ArgumentsLength) \ 397 V(AssertType) \ 398 V(BooleanNot) \ 399 V(CheckBounds) \ 400 V(CheckClosure) \ 401 V(CheckEqualsInternalizedString) \ 402 V(CheckEqualsSymbol) \ 403 V(CheckFloat64Hole) \ 404 V(CheckHeapObject) \ 405 V(CheckIf) \ 406 V(CheckInternalizedString) \ 407 V(CheckMaps) \ 408 V(CheckNotTaggedHole) \ 409 V(CheckNumber) \ 410 V(CheckReceiver) \ 411 V(CheckReceiverOrNullOrUndefined) \ 412 V(CheckSmi) \ 413 V(CheckString) \ 414 V(CheckSymbol) \ 415 V(CompareMaps) \ 416 V(ConvertReceiver) \ 417 V(ConvertTaggedHoleToUndefined) \ 418 V(DateNow) \ 419 V(DelayedStringConstant) \ 420 V(DynamicCheckMaps) \ 421 V(EnsureWritableFastElements) \ 422 V(FastApiCall) \ 423 V(FindOrderedHashMapEntry) \ 424 V(FindOrderedHashMapEntryForInt32Key) \ 425 V(LoadDataViewElement) \ 426 V(LoadElement) \ 427 V(LoadField) \ 428 V(LoadFieldByIndex) \ 429 V(LoadFromObject) \ 430 V(LoadMessage) \ 431 V(LoadStackArgument) \ 432 V(LoadTypedElement) \ 433 V(MaybeGrowFastElements) \ 434 V(NewArgumentsElements) \ 435 V(NewConsString) \ 436 V(NewDoubleElements) \ 437 V(NewSmiOrObjectElements) \ 438 V(NumberIsFinite) \ 439 V(NumberIsFloat64Hole) \ 440 V(NumberIsInteger) \ 441 V(NumberIsMinusZero) \ 442 V(NumberIsNaN) \ 443 V(NumberIsSafeInteger) \ 444 V(ObjectIsArrayBufferView) \ 445 V(ObjectIsBigInt) \ 446 V(ObjectIsCallable) \ 447 V(ObjectIsConstructor) \ 448 V(ObjectIsDetectableCallable) \ 449 V(ObjectIsFiniteNumber) \ 450 V(ObjectIsInteger) \ 451 V(ObjectIsMinusZero) \ 452 V(ObjectIsNaN) \ 453 V(ObjectIsNonCallable) \ 454 V(ObjectIsNumber) \ 455 V(ObjectIsReceiver) \ 456 V(ObjectIsSafeInteger) \ 457 V(ObjectIsSmi) \ 458 V(ObjectIsString) \ 459 V(ObjectIsSymbol) \ 460 V(ObjectIsUndetectable) \ 461 V(PlainPrimitiveToFloat64) \ 462 V(PlainPrimitiveToNumber) \ 463 V(PlainPrimitiveToWord32) \ 464 V(PoisonIndex) \ 465 V(RestLength) \ 466 V(RuntimeAbort) \ 467 V(StoreDataViewElement) \ 468 V(StoreElement) \ 469 V(StoreField) \ 470 V(StoreMessage) \ 471 V(StoreSignedSmallElement) \ 472 V(StoreToObject) \ 473 V(StoreTypedElement) \ 474 V(StringCharCodeAt) \ 475 V(StringCodePointAt) \ 476 V(StringConcat) \ 477 V(StringFromCodePointAt) \ 478 V(StringFromSingleCharCode) \ 479 V(StringFromSingleCodePoint) \ 480 V(StringIndexOf) \ 481 V(StringLength) \ 482 V(StringSubstring) \ 483 V(StringToLowerCaseIntl) \ 484 V(StringToNumber) \ 485 V(StringToUpperCaseIntl) \ 486 V(TierUpCheck) \ 487 V(ToBoolean) \ 488 V(TransitionAndStoreElement) \ 489 V(TransitionAndStoreNonNumberElement) \ 490 V(TransitionAndStoreNumberElement) \ 491 V(TransitionElementsKind) \ 492 V(TypeOf) \ 493 V(UpdateInterruptBudget) 494 495 #define SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \ 496 V(SpeculativeBigIntAdd) \ 497 V(SpeculativeBigIntSubtract) 498 499 #define SIMPLIFIED_SPECULATIVE_BIGINT_UNOP_LIST(V) V(SpeculativeBigIntNegate) 500 501 #define SIMPLIFIED_OP_LIST(V) \ 502 SIMPLIFIED_CHANGE_OP_LIST(V) \ 503 SIMPLIFIED_CHECKED_OP_LIST(V) \ 504 SIMPLIFIED_COMPARE_BINOP_LIST(V) \ 505 SIMPLIFIED_NUMBER_BINOP_LIST(V) \ 506 SIMPLIFIED_BIGINT_BINOP_LIST(V) \ 507 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \ 508 SIMPLIFIED_NUMBER_UNOP_LIST(V) \ 509 SIMPLIFIED_BIGINT_UNOP_LIST(V) \ 510 SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) \ 511 SIMPLIFIED_SPECULATIVE_BIGINT_UNOP_LIST(V) \ 512 SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \ 513 SIMPLIFIED_OTHER_OP_LIST(V) 514 515 // Opcodes for Machine-level operators. 516 #define MACHINE_COMPARE_BINOP_LIST(V) \ 517 V(Word32Equal) \ 518 V(Word64Equal) \ 519 V(Int32LessThan) \ 520 V(Int32LessThanOrEqual) \ 521 V(Uint32LessThan) \ 522 V(Uint32LessThanOrEqual) \ 523 V(Int64LessThan) \ 524 V(Int64LessThanOrEqual) \ 525 V(Uint64LessThan) \ 526 V(Uint64LessThanOrEqual) \ 527 V(Float32Equal) \ 528 V(Float32LessThan) \ 529 V(Float32LessThanOrEqual) \ 530 V(Float64Equal) \ 531 V(Float64LessThan) \ 532 V(Float64LessThanOrEqual) 533 534 #define MACHINE_UNOP_32_LIST(V) \ 535 V(Word32Clz) \ 536 V(Word32Ctz) \ 537 V(Int32AbsWithOverflow) \ 538 V(Word32ReverseBits) \ 539 V(Word32ReverseBytes) 540 541 #define MACHINE_BINOP_32_LIST(V) \ 542 V(Word32And) \ 543 V(Word32Or) \ 544 V(Word32Xor) \ 545 V(Word32Shl) \ 546 V(Word32Shr) \ 547 V(Word32Sar) \ 548 V(Word32Rol) \ 549 V(Word32Ror) \ 550 V(Int32Add) \ 551 V(Int32AddWithOverflow) \ 552 V(Int32Sub) \ 553 V(Int32SubWithOverflow) \ 554 V(Int32Mul) \ 555 V(Int32MulWithOverflow) \ 556 V(Int32MulHigh) \ 557 V(Int32Div) \ 558 V(Int32Mod) \ 559 V(Uint32Div) \ 560 V(Uint32Mod) \ 561 V(Uint32MulHigh) 562 563 #define MACHINE_BINOP_64_LIST(V) \ 564 V(Word64And) \ 565 V(Word64Or) \ 566 V(Word64Xor) \ 567 V(Word64Shl) \ 568 V(Word64Shr) \ 569 V(Word64Sar) \ 570 V(Word64Rol) \ 571 V(Word64Ror) \ 572 V(Int64Add) \ 573 V(Int64AddWithOverflow) \ 574 V(Int64Sub) \ 575 V(Int64SubWithOverflow) \ 576 V(Int64Mul) \ 577 V(Int64Div) \ 578 V(Int64Mod) \ 579 V(Uint64Div) \ 580 V(Uint64Mod) 581 582 #define MACHINE_FLOAT32_UNOP_LIST(V) \ 583 V(Float32Abs) \ 584 V(Float32Neg) \ 585 V(Float32RoundDown) \ 586 V(Float32RoundTiesEven) \ 587 V(Float32RoundTruncate) \ 588 V(Float32RoundUp) \ 589 V(Float32Sqrt) 590 591 #define MACHINE_FLOAT32_BINOP_LIST(V) \ 592 V(Float32Add) \ 593 V(Float32Sub) \ 594 V(Float32Mul) \ 595 V(Float32Div) \ 596 V(Float32Max) \ 597 V(Float32Min) 598 599 #define MACHINE_FLOAT64_UNOP_LIST(V) \ 600 V(Float64Abs) \ 601 V(Float64Acos) \ 602 V(Float64Acosh) \ 603 V(Float64Asin) \ 604 V(Float64Asinh) \ 605 V(Float64Atan) \ 606 V(Float64Atanh) \ 607 V(Float64Cbrt) \ 608 V(Float64Cos) \ 609 V(Float64Cosh) \ 610 V(Float64Exp) \ 611 V(Float64Expm1) \ 612 V(Float64Log) \ 613 V(Float64Log1p) \ 614 V(Float64Log10) \ 615 V(Float64Log2) \ 616 V(Float64Neg) \ 617 V(Float64RoundDown) \ 618 V(Float64RoundTiesAway) \ 619 V(Float64RoundTiesEven) \ 620 V(Float64RoundTruncate) \ 621 V(Float64RoundUp) \ 622 V(Float64Sin) \ 623 V(Float64Sinh) \ 624 V(Float64Sqrt) \ 625 V(Float64Tan) \ 626 V(Float64Tanh) 627 628 #define MACHINE_FLOAT64_BINOP_LIST(V) \ 629 V(Float64Atan2) \ 630 V(Float64Max) \ 631 V(Float64Min) \ 632 V(Float64Add) \ 633 V(Float64Sub) \ 634 V(Float64Mul) \ 635 V(Float64Div) \ 636 V(Float64Mod) \ 637 V(Float64Pow) 638 639 #define MACHINE_ATOMIC_OP_LIST(V) \ 640 V(Word32AtomicLoad) \ 641 V(Word32AtomicStore) \ 642 V(Word32AtomicExchange) \ 643 V(Word32AtomicCompareExchange) \ 644 V(Word32AtomicAdd) \ 645 V(Word32AtomicSub) \ 646 V(Word32AtomicAnd) \ 647 V(Word32AtomicOr) \ 648 V(Word32AtomicXor) \ 649 V(Word32AtomicPairLoad) \ 650 V(Word32AtomicPairStore) \ 651 V(Word32AtomicPairAdd) \ 652 V(Word32AtomicPairSub) \ 653 V(Word32AtomicPairAnd) \ 654 V(Word32AtomicPairOr) \ 655 V(Word32AtomicPairXor) \ 656 V(Word32AtomicPairExchange) \ 657 V(Word32AtomicPairCompareExchange) \ 658 V(Word64AtomicLoad) \ 659 V(Word64AtomicStore) \ 660 V(Word64AtomicAdd) \ 661 V(Word64AtomicSub) \ 662 V(Word64AtomicAnd) \ 663 V(Word64AtomicOr) \ 664 V(Word64AtomicXor) \ 665 V(Word64AtomicExchange) \ 666 V(Word64AtomicCompareExchange) 667 668 #define MACHINE_OP_LIST(V) \ 669 MACHINE_UNOP_32_LIST(V) \ 670 MACHINE_BINOP_32_LIST(V) \ 671 MACHINE_BINOP_64_LIST(V) \ 672 MACHINE_COMPARE_BINOP_LIST(V) \ 673 MACHINE_FLOAT32_BINOP_LIST(V) \ 674 MACHINE_FLOAT32_UNOP_LIST(V) \ 675 MACHINE_FLOAT64_BINOP_LIST(V) \ 676 MACHINE_FLOAT64_UNOP_LIST(V) \ 677 MACHINE_ATOMIC_OP_LIST(V) \ 678 V(AbortCSAAssert) \ 679 V(DebugBreak) \ 680 V(Comment) \ 681 V(Load) \ 682 V(PoisonedLoad) \ 683 V(Store) \ 684 V(StackSlot) \ 685 V(Word32Popcnt) \ 686 V(Word64Popcnt) \ 687 V(Word64Clz) \ 688 V(Word64Ctz) \ 689 V(Word64ReverseBits) \ 690 V(Word64ReverseBytes) \ 691 V(Simd128ReverseBytes) \ 692 V(Int64AbsWithOverflow) \ 693 V(BitcastTaggedToWord) \ 694 V(BitcastTaggedToWordForTagAndSmiBits) \ 695 V(BitcastWordToTagged) \ 696 V(BitcastWordToTaggedSigned) \ 697 V(TruncateFloat64ToWord32) \ 698 V(ChangeFloat32ToFloat64) \ 699 V(ChangeFloat64ToInt32) \ 700 V(ChangeFloat64ToInt64) \ 701 V(ChangeFloat64ToUint32) \ 702 V(ChangeFloat64ToUint64) \ 703 V(Float64SilenceNaN) \ 704 V(TruncateFloat64ToInt64) \ 705 V(TruncateFloat64ToUint32) \ 706 V(TruncateFloat32ToInt32) \ 707 V(TruncateFloat32ToUint32) \ 708 V(TryTruncateFloat32ToInt64) \ 709 V(TryTruncateFloat64ToInt64) \ 710 V(TryTruncateFloat32ToUint64) \ 711 V(TryTruncateFloat64ToUint64) \ 712 V(ChangeInt32ToFloat64) \ 713 V(BitcastWord32ToWord64) \ 714 V(ChangeInt32ToInt64) \ 715 V(ChangeInt64ToFloat64) \ 716 V(ChangeUint32ToFloat64) \ 717 V(ChangeUint32ToUint64) \ 718 V(TruncateFloat64ToFloat32) \ 719 V(TruncateInt64ToInt32) \ 720 V(RoundFloat64ToInt32) \ 721 V(RoundInt32ToFloat32) \ 722 V(RoundInt64ToFloat32) \ 723 V(RoundInt64ToFloat64) \ 724 V(RoundUint32ToFloat32) \ 725 V(RoundUint64ToFloat32) \ 726 V(RoundUint64ToFloat64) \ 727 V(BitcastFloat32ToInt32) \ 728 V(BitcastFloat64ToInt64) \ 729 V(BitcastInt32ToFloat32) \ 730 V(BitcastInt64ToFloat64) \ 731 V(Float64ExtractLowWord32) \ 732 V(Float64ExtractHighWord32) \ 733 V(Float64InsertLowWord32) \ 734 V(Float64InsertHighWord32) \ 735 V(TaggedPoisonOnSpeculation) \ 736 V(Word32PoisonOnSpeculation) \ 737 V(Word64PoisonOnSpeculation) \ 738 V(LoadStackCheckOffset) \ 739 V(LoadFramePointer) \ 740 V(LoadParentFramePointer) \ 741 V(UnalignedLoad) \ 742 V(UnalignedStore) \ 743 V(Int32PairAdd) \ 744 V(Int32PairSub) \ 745 V(Int32PairMul) \ 746 V(Word32PairShl) \ 747 V(Word32PairShr) \ 748 V(Word32PairSar) \ 749 V(ProtectedLoad) \ 750 V(ProtectedStore) \ 751 V(MemoryBarrier) \ 752 V(SignExtendWord8ToInt32) \ 753 V(SignExtendWord16ToInt32) \ 754 V(SignExtendWord8ToInt64) \ 755 V(SignExtendWord16ToInt64) \ 756 V(SignExtendWord32ToInt64) \ 757 V(UnsafePointerAdd) \ 758 V(StackPointerGreaterThan) 759 760 #define MACHINE_SIMD_OP_LIST(V) \ 761 V(F64x2Splat) \ 762 V(F64x2ExtractLane) \ 763 V(F64x2ReplaceLane) \ 764 V(F64x2Abs) \ 765 V(F64x2Neg) \ 766 V(F64x2Sqrt) \ 767 V(F64x2Add) \ 768 V(F64x2Sub) \ 769 V(F64x2Mul) \ 770 V(F64x2Div) \ 771 V(F64x2Min) \ 772 V(F64x2Max) \ 773 V(F64x2Eq) \ 774 V(F64x2Ne) \ 775 V(F64x2Lt) \ 776 V(F64x2Le) \ 777 V(F64x2Qfma) \ 778 V(F64x2Qfms) \ 779 V(F64x2Pmin) \ 780 V(F64x2Pmax) \ 781 V(F64x2Ceil) \ 782 V(F64x2Floor) \ 783 V(F64x2Trunc) \ 784 V(F64x2NearestInt) \ 785 V(F32x4Splat) \ 786 V(F32x4ExtractLane) \ 787 V(F32x4ReplaceLane) \ 788 V(F32x4SConvertI32x4) \ 789 V(F32x4UConvertI32x4) \ 790 V(F32x4Abs) \ 791 V(F32x4Neg) \ 792 V(F32x4Sqrt) \ 793 V(F32x4RecipApprox) \ 794 V(F32x4RecipSqrtApprox) \ 795 V(F32x4Add) \ 796 V(F32x4AddHoriz) \ 797 V(F32x4Sub) \ 798 V(F32x4Mul) \ 799 V(F32x4Div) \ 800 V(F32x4Min) \ 801 V(F32x4Max) \ 802 V(F32x4Eq) \ 803 V(F32x4Ne) \ 804 V(F32x4Lt) \ 805 V(F32x4Le) \ 806 V(F32x4Gt) \ 807 V(F32x4Ge) \ 808 V(F32x4Qfma) \ 809 V(F32x4Qfms) \ 810 V(F32x4Pmin) \ 811 V(F32x4Pmax) \ 812 V(F32x4Ceil) \ 813 V(F32x4Floor) \ 814 V(F32x4Trunc) \ 815 V(F32x4NearestInt) \ 816 V(I64x2Splat) \ 817 V(I64x2SplatI32Pair) \ 818 V(I64x2ExtractLane) \ 819 V(I64x2ReplaceLane) \ 820 V(I64x2ReplaceLaneI32Pair) \ 821 V(I64x2Neg) \ 822 V(I64x2SConvertI32x4Low) \ 823 V(I64x2SConvertI32x4High) \ 824 V(I64x2UConvertI32x4Low) \ 825 V(I64x2UConvertI32x4High) \ 826 V(I64x2BitMask) \ 827 V(I64x2Shl) \ 828 V(I64x2ShrS) \ 829 V(I64x2Add) \ 830 V(I64x2Sub) \ 831 V(I64x2Mul) \ 832 V(I64x2Eq) \ 833 V(I64x2ShrU) \ 834 V(I64x2ExtMulLowI32x4S) \ 835 V(I64x2ExtMulHighI32x4S) \ 836 V(I64x2ExtMulLowI32x4U) \ 837 V(I64x2ExtMulHighI32x4U) \ 838 V(I64x2SignSelect) \ 839 V(I32x4Splat) \ 840 V(I32x4ExtractLane) \ 841 V(I32x4ReplaceLane) \ 842 V(I32x4SConvertF32x4) \ 843 V(I32x4SConvertI16x8Low) \ 844 V(I32x4SConvertI16x8High) \ 845 V(I32x4Neg) \ 846 V(I32x4Shl) \ 847 V(I32x4ShrS) \ 848 V(I32x4Add) \ 849 V(I32x4AddHoriz) \ 850 V(I32x4Sub) \ 851 V(I32x4Mul) \ 852 V(I32x4MinS) \ 853 V(I32x4MaxS) \ 854 V(I32x4Eq) \ 855 V(I32x4Ne) \ 856 V(I32x4LtS) \ 857 V(I32x4LeS) \ 858 V(I32x4GtS) \ 859 V(I32x4GeS) \ 860 V(I32x4UConvertF32x4) \ 861 V(I32x4UConvertI16x8Low) \ 862 V(I32x4UConvertI16x8High) \ 863 V(I32x4ShrU) \ 864 V(I32x4MinU) \ 865 V(I32x4MaxU) \ 866 V(I32x4LtU) \ 867 V(I32x4LeU) \ 868 V(I32x4GtU) \ 869 V(I32x4GeU) \ 870 V(I32x4Abs) \ 871 V(I32x4BitMask) \ 872 V(I32x4DotI16x8S) \ 873 V(I32x4ExtMulLowI16x8S) \ 874 V(I32x4ExtMulHighI16x8S) \ 875 V(I32x4ExtMulLowI16x8U) \ 876 V(I32x4ExtMulHighI16x8U) \ 877 V(I32x4SignSelect) \ 878 V(I32x4ExtAddPairwiseI16x8S) \ 879 V(I32x4ExtAddPairwiseI16x8U) \ 880 V(I16x8Splat) \ 881 V(I16x8ExtractLaneU) \ 882 V(I16x8ExtractLaneS) \ 883 V(I16x8ReplaceLane) \ 884 V(I16x8SConvertI8x16Low) \ 885 V(I16x8SConvertI8x16High) \ 886 V(I16x8Neg) \ 887 V(I16x8Shl) \ 888 V(I16x8ShrS) \ 889 V(I16x8SConvertI32x4) \ 890 V(I16x8Add) \ 891 V(I16x8AddSatS) \ 892 V(I16x8AddHoriz) \ 893 V(I16x8Sub) \ 894 V(I16x8SubSatS) \ 895 V(I16x8Mul) \ 896 V(I16x8MinS) \ 897 V(I16x8MaxS) \ 898 V(I16x8Eq) \ 899 V(I16x8Ne) \ 900 V(I16x8LtS) \ 901 V(I16x8LeS) \ 902 V(I16x8GtS) \ 903 V(I16x8GeS) \ 904 V(I16x8UConvertI8x16Low) \ 905 V(I16x8UConvertI8x16High) \ 906 V(I16x8ShrU) \ 907 V(I16x8UConvertI32x4) \ 908 V(I16x8AddSatU) \ 909 V(I16x8SubSatU) \ 910 V(I16x8MinU) \ 911 V(I16x8MaxU) \ 912 V(I16x8LtU) \ 913 V(I16x8LeU) \ 914 V(I16x8GtU) \ 915 V(I16x8GeU) \ 916 V(I16x8RoundingAverageU) \ 917 V(I16x8Q15MulRSatS) \ 918 V(I16x8Abs) \ 919 V(I16x8BitMask) \ 920 V(I16x8ExtMulLowI8x16S) \ 921 V(I16x8ExtMulHighI8x16S) \ 922 V(I16x8ExtMulLowI8x16U) \ 923 V(I16x8ExtMulHighI8x16U) \ 924 V(I16x8SignSelect) \ 925 V(I16x8ExtAddPairwiseI8x16S) \ 926 V(I16x8ExtAddPairwiseI8x16U) \ 927 V(I8x16Splat) \ 928 V(I8x16ExtractLaneU) \ 929 V(I8x16ExtractLaneS) \ 930 V(I8x16ReplaceLane) \ 931 V(I8x16SConvertI16x8) \ 932 V(I8x16Neg) \ 933 V(I8x16Shl) \ 934 V(I8x16ShrS) \ 935 V(I8x16Add) \ 936 V(I8x16AddSatS) \ 937 V(I8x16Sub) \ 938 V(I8x16SubSatS) \ 939 V(I8x16Mul) \ 940 V(I8x16MinS) \ 941 V(I8x16MaxS) \ 942 V(I8x16Eq) \ 943 V(I8x16Ne) \ 944 V(I8x16LtS) \ 945 V(I8x16LeS) \ 946 V(I8x16GtS) \ 947 V(I8x16GeS) \ 948 V(I8x16UConvertI16x8) \ 949 V(I8x16AddSatU) \ 950 V(I8x16SubSatU) \ 951 V(I8x16ShrU) \ 952 V(I8x16MinU) \ 953 V(I8x16MaxU) \ 954 V(I8x16LtU) \ 955 V(I8x16LeU) \ 956 V(I8x16GtU) \ 957 V(I8x16GeU) \ 958 V(I8x16RoundingAverageU) \ 959 V(I8x16Popcnt) \ 960 V(I8x16Abs) \ 961 V(I8x16BitMask) \ 962 V(I8x16SignSelect) \ 963 V(S128Load) \ 964 V(S128Store) \ 965 V(S128Zero) \ 966 V(S128Const) \ 967 V(S128Not) \ 968 V(S128And) \ 969 V(S128Or) \ 970 V(S128Xor) \ 971 V(S128Select) \ 972 V(S128AndNot) \ 973 V(I8x16Swizzle) \ 974 V(I8x16Shuffle) \ 975 V(V32x4AnyTrue) \ 976 V(V32x4AllTrue) \ 977 V(V16x8AnyTrue) \ 978 V(V16x8AllTrue) \ 979 V(V8x16AnyTrue) \ 980 V(V8x16AllTrue) \ 981 V(LoadTransform) \ 982 V(LoadLane) \ 983 V(StoreLane) 984 985 #define VALUE_OP_LIST(V) \ 986 COMMON_OP_LIST(V) \ 987 SIMPLIFIED_OP_LIST(V) \ 988 MACHINE_OP_LIST(V) \ 989 MACHINE_SIMD_OP_LIST(V) \ 990 JS_OP_LIST(V) 991 992 // The combination of all operators at all levels and the common operators. 993 #define ALL_OP_LIST(V) \ 994 CONTROL_OP_LIST(V) \ 995 VALUE_OP_LIST(V) 996 997 namespace v8 { 998 namespace internal { 999 namespace compiler { 1000 1001 // Declare an enumeration with all the opcodes at all levels so that they 1002 // can be globally, uniquely numbered. 1003 class V8_EXPORT_PRIVATE IrOpcode { 1004 public: 1005 enum Value { 1006 #define DECLARE_OPCODE(x, ...) k##x, 1007 ALL_OP_LIST(DECLARE_OPCODE) 1008 #undef DECLARE_OPCODE 1009 kLast = -1 1010 #define COUNT_OPCODE(...) +1 1011 ALL_OP_LIST(COUNT_OPCODE) 1012 #undef COUNT_OPCODE 1013 }; 1014 1015 // Returns the mnemonic name of an opcode. 1016 static char const* Mnemonic(Value value); 1017 1018 // Returns true if opcode for common operator. IsCommonOpcode(Value value)1019 static bool IsCommonOpcode(Value value) { 1020 return kStart <= value && value <= kStaticAssert; 1021 } 1022 1023 // Returns true if opcode for control operator. IsControlOpcode(Value value)1024 static bool IsControlOpcode(Value value) { 1025 return kStart <= value && value <= kEnd; 1026 } 1027 1028 // Returns true if opcode for JavaScript operator. IsJsOpcode(Value value)1029 static bool IsJsOpcode(Value value) { 1030 return kJSEqual <= value && value <= kJSDebugger; 1031 } 1032 1033 // Returns true if opcode for constant operator. IsConstantOpcode(Value value)1034 static bool IsConstantOpcode(Value value) { 1035 #define CASE(Name) \ 1036 case k##Name: \ 1037 return true; 1038 switch (value) { 1039 CONSTANT_OP_LIST(CASE); 1040 default: 1041 return false; 1042 } 1043 #undef CASE 1044 UNREACHABLE(); 1045 } 1046 IsPhiOpcode(Value value)1047 static bool IsPhiOpcode(Value value) { 1048 return value == kPhi || value == kEffectPhi; 1049 } 1050 IsMergeOpcode(Value value)1051 static bool IsMergeOpcode(Value value) { 1052 return value == kMerge || value == kLoop; 1053 } 1054 IsIfProjectionOpcode(Value value)1055 static bool IsIfProjectionOpcode(Value value) { 1056 return kIfTrue <= value && value <= kIfDefault; 1057 } 1058 1059 // Returns true if opcode terminates control flow in a graph (i.e. 1060 // respective nodes are expected to have control uses by the graphs {End} 1061 // node only). IsGraphTerminator(Value value)1062 static bool IsGraphTerminator(Value value) { 1063 return value == kDeoptimize || value == kReturn || value == kTailCall || 1064 value == kTerminate || value == kThrow; 1065 } 1066 1067 // Returns true if opcode can be inlined. IsInlineeOpcode(Value value)1068 static bool IsInlineeOpcode(Value value) { 1069 return value == kJSConstruct || value == kJSCall; 1070 } 1071 1072 // Returns true if opcode for comparison operator. IsComparisonOpcode(Value value)1073 static bool IsComparisonOpcode(Value value) { 1074 #define CASE(Name, ...) \ 1075 case k##Name: \ 1076 return true; 1077 switch (value) { 1078 JS_COMPARE_BINOP_LIST(CASE); 1079 SIMPLIFIED_COMPARE_BINOP_LIST(CASE); 1080 MACHINE_COMPARE_BINOP_LIST(CASE); 1081 default: 1082 return false; 1083 } 1084 #undef CASE 1085 UNREACHABLE(); 1086 } 1087 IsContextChainExtendingOpcode(Value value)1088 static bool IsContextChainExtendingOpcode(Value value) { 1089 return kJSCreateFunctionContext <= value && value <= kJSCreateBlockContext; 1090 } 1091 1092 // These opcode take the feedback vector as an input, and implement 1093 // feedback-collecting logic in generic lowering. IsFeedbackCollectingOpcode(Value value)1094 static bool IsFeedbackCollectingOpcode(Value value) { 1095 #define CASE(Name, ...) \ 1096 case k##Name: \ 1097 return true; 1098 switch (value) { 1099 JS_ARITH_BINOP_LIST(CASE) 1100 JS_ARITH_UNOP_LIST(CASE) 1101 JS_BITWISE_BINOP_LIST(CASE) 1102 JS_BITWISE_UNOP_LIST(CASE) 1103 JS_COMPARE_BINOP_LIST(CASE) 1104 case kJSCall: 1105 case kJSCallWithArrayLike: 1106 case kJSCallWithSpread: 1107 case kJSCloneObject: 1108 case kJSConstruct: 1109 case kJSConstructWithArrayLike: 1110 case kJSConstructWithSpread: 1111 case kJSCreateEmptyLiteralArray: 1112 case kJSCreateLiteralArray: 1113 case kJSCreateLiteralObject: 1114 case kJSCreateLiteralRegExp: 1115 case kJSForInNext: 1116 case kJSForInPrepare: 1117 case kJSGetIterator: 1118 case kJSGetTemplateObject: 1119 case kJSHasProperty: 1120 case kJSInstanceOf: 1121 case kJSLoadGlobal: 1122 case kJSLoadNamed: 1123 case kJSLoadNamedFromSuper: 1124 case kJSLoadProperty: 1125 case kJSStoreDataPropertyInLiteral: 1126 case kJSStoreGlobal: 1127 case kJSStoreInArrayLiteral: 1128 case kJSStoreNamed: 1129 case kJSStoreNamedOwn: 1130 case kJSStoreProperty: 1131 return true; 1132 default: 1133 return false; 1134 } 1135 #undef CASE 1136 UNREACHABLE(); 1137 } 1138 IsFeedbackCollectingOpcode(int16_t value)1139 static bool IsFeedbackCollectingOpcode(int16_t value) { 1140 DCHECK(0 <= value && value <= kLast); 1141 return IsFeedbackCollectingOpcode(static_cast<IrOpcode::Value>(value)); 1142 } 1143 }; 1144 1145 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value); 1146 1147 } // namespace compiler 1148 } // namespace internal 1149 } // namespace v8 1150 1151 #endif // V8_COMPILER_OPCODES_H_ 1152