Lines Matching refs:bytecode
13 #include "src/interpreter/bytecode-operands.h"
42 // The list of bytecodes which have unique handlers (no other bytecode is
44 // Format is V(<bytecode>, <implicit_register_use>, <operands>).
51 /* and one for each operand widening prefix bytecode */ \
441 // Format is V(<bytecode>, <implicit_register_use>, <operands>).
448 /* Illegal bytecode */ \
551 // evaluate to the same value as the last real bytecode.
560 // The maximum number of operands a bytecode may have.
570 // Returns string representation of |bytecode|.
571 static const char* ToString(Bytecode bytecode);
573 // Returns string representation of |bytecode| combined with |operand_scale|
575 static std::string ToString(Bytecode bytecode, OperandScale operand_scale,
578 // Returns byte value of bytecode.
579 static uint8_t ToByte(Bytecode bytecode) {
580 DCHECK_LE(bytecode, Bytecode::kLast);
581 return static_cast<uint8_t>(bytecode);
584 // Returns bytecode for |value|.
586 Bytecode bytecode = static_cast<Bytecode>(value);
587 DCHECK_LE(bytecode, Bytecode::kLast);
588 return bytecode;
591 // Returns the prefix bytecode representing an operand scale to be
592 // applied to a a bytecode.
604 // Returns true if the operand scale requires a prefix bytecode.
609 // Returns the scaling applied to scalable operands if bytecode is
611 static OperandScale PrefixBytecodeToOperandScale(Bytecode bytecode) {
612 switch (bytecode) {
624 // Returns how accumulator is used by |bytecode|.
625 static ImplicitRegisterUse GetImplicitRegisterUse(Bytecode bytecode) {
626 DCHECK_LE(bytecode, Bytecode::kLast);
627 return kImplicitRegisterUse[static_cast<size_t>(bytecode)];
630 // Returns true if |bytecode| reads the accumulator.
631 static bool ReadsAccumulator(Bytecode bytecode) {
632 return BytecodeOperands::ReadsAccumulator(GetImplicitRegisterUse(bytecode));
635 // Returns true if |bytecode| writes the accumulator.
636 static bool WritesAccumulator(Bytecode bytecode) {
638 GetImplicitRegisterUse(bytecode));
641 // Returns true if |bytecode| writes to a register not specified by an
643 static bool WritesImplicitRegister(Bytecode bytecode) {
645 GetImplicitRegisterUse(bytecode));
648 // Return true if |bytecode| is an accumulator load without effects,
650 static constexpr bool IsAccumulatorLoadWithoutEffects(Bytecode bytecode) {
652 return bytecode >= Bytecode::kLdar &&
653 bytecode <= Bytecode::kLdaImmutableCurrentContextSlot;
656 // Returns true if |bytecode| is a compare operation without external effects
658 static constexpr bool IsCompareWithoutEffects(Bytecode bytecode) {
660 return bytecode >= Bytecode::kTestReferenceEqual &&
661 bytecode <= Bytecode::kTestTypeOf;
664 static constexpr bool IsShortStar(Bytecode bytecode) {
665 return bytecode >= Bytecode::kFirstShortStar &&
666 bytecode <= Bytecode::kLastShortStar;
669 static constexpr bool IsAnyStar(Bytecode bytecode) {
670 return bytecode == Bytecode::kStar || IsShortStar(bytecode);
673 // Return true if |bytecode| is a register load without effects,
675 static constexpr bool IsRegisterLoadWithoutEffects(Bytecode bytecode) {
676 return IsShortStar(bytecode) ||
677 (bytecode >= Bytecode::kStar && bytecode <= Bytecode::kPopContext);
680 // Returns true if the bytecode is a conditional jump taking
682 static constexpr bool IsConditionalJumpImmediate(Bytecode bytecode) {
683 return bytecode >= Bytecode::kJumpIfToBooleanTrue &&
684 bytecode <= Bytecode::kJumpIfJSReceiver;
687 // Returns true if the bytecode is a conditional jump taking
689 static constexpr bool IsConditionalJumpConstant(Bytecode bytecode) {
690 return bytecode >= Bytecode::kJumpIfNullConstant &&
691 bytecode <= Bytecode::kJumpIfToBooleanFalseConstant;
694 // Returns true if the bytecode is a conditional jump taking
696 static constexpr bool IsConditionalJump(Bytecode bytecode) {
697 return bytecode >= Bytecode::kJumpIfNullConstant &&
698 bytecode <= Bytecode::kJumpIfJSReceiver;
701 // Returns true if the bytecode is an unconditional jump.
702 static constexpr bool IsUnconditionalJump(Bytecode bytecode) {
703 return bytecode >= Bytecode::kJumpLoop &&
704 bytecode <= Bytecode::kJumpConstant;
707 // Returns true if the bytecode is a jump or a conditional jump taking
709 static constexpr bool IsJumpImmediate(Bytecode bytecode) {
710 return bytecode == Bytecode::kJump || bytecode == Bytecode::kJumpLoop ||
711 IsConditionalJumpImmediate(bytecode);
714 // Returns true if the bytecode is a jump or conditional jump taking a
716 static constexpr bool IsJumpConstant(Bytecode bytecode) {
717 return bytecode >= Bytecode::kJumpConstant &&
718 bytecode <= Bytecode::kJumpIfToBooleanFalseConstant;
721 // Returns true if the bytecode is a jump that internally coerces the
723 static constexpr bool IsJumpIfToBoolean(Bytecode bytecode) {
724 return bytecode >= Bytecode::kJumpIfToBooleanTrueConstant &&
725 bytecode <= Bytecode::kJumpIfToBooleanFalse;
728 // Returns true if the bytecode is a jump or conditional jump taking
730 static constexpr bool IsJump(Bytecode bytecode) {
731 return bytecode >= Bytecode::kJumpLoop &&
732 bytecode <= Bytecode::kJumpIfJSReceiver;
735 // Returns true if the bytecode is a forward jump or conditional jump taking
737 static constexpr bool IsForwardJump(Bytecode bytecode) {
738 return bytecode >= Bytecode::kJump &&
739 bytecode <= Bytecode::kJumpIfJSReceiver;
742 // Return true if |bytecode| is a jump without effects,
745 static constexpr bool IsJumpWithoutEffects(Bytecode bytecode) {
746 return IsJump(bytecode) && !IsJumpIfToBoolean(bytecode) &&
747 bytecode != Bytecode::kJumpLoop;
750 // Returns true if the bytecode is a switch.
751 static constexpr bool IsSwitch(Bytecode bytecode) {
752 return bytecode == Bytecode::kSwitchOnSmiNoFeedback ||
753 bytecode == Bytecode::kSwitchOnGeneratorState;
756 // Returns true if |bytecode| has no effects. These bytecodes only manipulate
758 static constexpr bool IsWithoutExternalSideEffects(Bytecode bytecode) {
759 return (IsAccumulatorLoadWithoutEffects(bytecode) ||
760 IsRegisterLoadWithoutEffects(bytecode) ||
761 IsCompareWithoutEffects(bytecode) ||
762 IsJumpWithoutEffects(bytecode) || IsSwitch(bytecode));
765 // Returns true if the bytecode is Ldar or Star.
766 static constexpr bool IsLdarOrStar(Bytecode bytecode) {
767 return bytecode == Bytecode::kLdar || IsAnyStar(bytecode);
770 // Returns true if the bytecode is a call or a constructor call.
771 static constexpr bool IsCallOrConstruct(Bytecode bytecode) {
772 return bytecode == Bytecode::kCallAnyReceiver ||
773 bytecode == Bytecode::kCallProperty ||
774 bytecode == Bytecode::kCallProperty0 ||
775 bytecode == Bytecode::kCallProperty1 ||
776 bytecode == Bytecode::kCallProperty2 ||
777 bytecode == Bytecode::kCallUndefinedReceiver ||
778 bytecode == Bytecode::kCallUndefinedReceiver0 ||
779 bytecode == Bytecode::kCallUndefinedReceiver1 ||
780 bytecode == Bytecode::kCallUndefinedReceiver2 ||
781 bytecode == Bytecode::kConstruct ||
782 bytecode == Bytecode::kCallWithSpread ||
783 bytecode == Bytecode::kConstructWithSpread ||
784 bytecode == Bytecode::kCallJSRuntime;
787 // Returns true if the bytecode is a call to the runtime.
788 static constexpr bool IsCallRuntime(Bytecode bytecode) {
789 return bytecode == Bytecode::kCallRuntime ||
790 bytecode == Bytecode::kCallRuntimeForPair ||
791 bytecode == Bytecode::kInvokeIntrinsic;
794 // Returns true if the bytecode is a scaling prefix bytecode.
795 static constexpr bool IsPrefixScalingBytecode(Bytecode bytecode) {
796 return bytecode == Bytecode::kExtraWide || bytecode == Bytecode::kWide ||
797 bytecode == Bytecode::kDebugBreakExtraWide ||
798 bytecode == Bytecode::kDebugBreakWide;
801 // Returns true if the bytecode returns.
802 static constexpr bool Returns(Bytecode bytecode) {
803 #define OR_BYTECODE(NAME) || bytecode == Bytecode::k##NAME
808 // Returns true if the bytecode unconditionally throws.
809 static constexpr bool UnconditionallyThrows(Bytecode bytecode) {
810 #define OR_BYTECODE(NAME) || bytecode == Bytecode::k##NAME
815 // Returns the number of operands expected by |bytecode|.
816 static int NumberOfOperands(Bytecode bytecode) {
817 DCHECK_LE(bytecode, Bytecode::kLast);
818 return kOperandCount[static_cast<size_t>(bytecode)];
821 // Returns the i-th operand of |bytecode|.
822 static OperandType GetOperandType(Bytecode bytecode, int i) {
823 DCHECK_LE(bytecode, Bytecode::kLast);
824 DCHECK_LT(i, NumberOfOperands(bytecode));
826 return GetOperandTypes(bytecode)[i];
831 static const OperandType* GetOperandTypes(Bytecode bytecode) {
832 DCHECK_LE(bytecode, Bytecode::kLast);
833 return kOperandTypes[static_cast<size_t>(bytecode)];
836 static bool OperandIsScalableSignedByte(Bytecode bytecode,
838 DCHECK_LE(bytecode, Bytecode::kLast);
839 return kOperandTypeInfos[static_cast<size_t>(bytecode)][operand_index] ==
843 static bool OperandIsScalableUnsignedByte(Bytecode bytecode,
845 DCHECK_LE(bytecode, Bytecode::kLast);
846 return kOperandTypeInfos[static_cast<size_t>(bytecode)][operand_index] ==
850 static bool OperandIsScalable(Bytecode bytecode, int operand_index) {
851 return OperandIsScalableSignedByte(bytecode, operand_index) ||
852 OperandIsScalableUnsignedByte(bytecode, operand_index);
855 // Returns true if the bytecode has wider operand forms.
856 static bool IsBytecodeWithScalableOperands(Bytecode bytecode);
858 // Returns the size of the i-th operand of |bytecode|.
859 static OperandSize GetOperandSize(Bytecode bytecode, int i,
861 CHECK_LT(i, NumberOfOperands(bytecode));
862 return GetOperandSizes(bytecode, operand_scale)[i];
865 // Returns the operand sizes of |bytecode| with scale |operand_scale|.
866 static const OperandSize* GetOperandSizes(Bytecode bytecode,
868 DCHECK_LE(bytecode, Bytecode::kLast);
874 return kOperandSizes[scale_index][static_cast<size_t>(bytecode)];
877 // Returns the offset of the i-th operand of |bytecode| relative to the start
878 // of the bytecode.
879 static int GetOperandOffset(Bytecode bytecode, int i,
882 // Returns the size of the bytecode including its operands for the
884 static int Size(Bytecode bytecode, OperandScale operand_scale) {
885 DCHECK_LE(bytecode, Bytecode::kLast);
889 return kBytecodeSizes[scale_index][static_cast<size_t>(bytecode)];
892 // Returns a debug break bytecode to replace |bytecode|.
893 static Bytecode GetDebugBreak(Bytecode bytecode);
895 // Returns the equivalent jump bytecode without the accumulator coercion.
896 static Bytecode GetJumpWithoutToBoolean(Bytecode bytecode);
899 // through the bytecode's handler.
900 static bool MakesCallAlongCriticalPath(Bytecode bytecode);
902 // Returns the receiver mode of the given call bytecode.
903 static ConvertReceiverMode GetReceiverMode(Bytecode bytecode) {
904 DCHECK(IsCallOrConstruct(bytecode) ||
905 bytecode == Bytecode::kInvokeIntrinsic);
906 switch (bytecode) {
929 // Returns true if the bytecode is a debug break.
930 static bool IsDebugBreak(Bytecode bytecode);
944 // Returns true if the handler for |bytecode| should look ahead and inline a
945 // dispatch to a Star bytecode.
946 static bool IsStarLookahead(Bytecode bytecode, OperandScale operand_scale);
989 // Returns true if a handler is generated for a bytecode at a given
993 static bool BytecodeHasHandler(Bytecode bytecode, OperandScale operand_scale);
1047 const Bytecode& bytecode);