@@ -614,23 +614,15 @@ impl Instruction {
614614 /// Map a specialized opcode back to its adaptive (base) variant.
615615 /// `_PyOpcode_Deopt`
616616 pub const fn deopt ( self ) -> Option < Self > {
617- Some ( match self {
618- // RESUME specializations
619- Self :: ResumeCheck => Self :: Resume {
620- context : Arg :: marker ( ) ,
621- } ,
622- // LOAD_CONST specializations
623- Self :: LoadConstMortal | Self :: LoadConstImmortal => Self :: LoadConst {
624- consti : Arg :: marker ( ) ,
625- } ,
626- // TO_BOOL specializations
617+ let opcode = match self {
618+ Self :: ResumeCheck => Opcode :: Resume ,
619+ Self :: LoadConstMortal | Self :: LoadConstImmortal => Opcode :: LoadConst ,
627620 Self :: ToBoolAlwaysTrue
628621 | Self :: ToBoolBool
629622 | Self :: ToBoolInt
630623 | Self :: ToBoolList
631624 | Self :: ToBoolNone
632- | Self :: ToBoolStr => Self :: ToBool ,
633- // BINARY_OP specializations
625+ | Self :: ToBoolStr => Opcode :: ToBool ,
634626 Self :: BinaryOpMultiplyInt
635627 | Self :: BinaryOpAddInt
636628 | Self :: BinaryOpSubtractInt
@@ -645,34 +637,18 @@ impl Instruction {
645637 | Self :: BinaryOpSubscrDict
646638 | Self :: BinaryOpSubscrGetitem
647639 | Self :: BinaryOpExtend
648- | Self :: BinaryOpInplaceAddUnicode => Self :: BinaryOp { op : Arg :: marker ( ) } ,
649- // STORE_SUBSCR specializations
650- Self :: StoreSubscrDict | Self :: StoreSubscrListInt => Self :: StoreSubscr ,
651- // SEND specializations
652- Self :: SendGen => Self :: Send {
653- delta : Arg :: marker ( ) ,
654- } ,
655- // UNPACK_SEQUENCE specializations
640+ | Self :: BinaryOpInplaceAddUnicode => Opcode :: BinaryOp ,
641+ Self :: StoreSubscrDict | Self :: StoreSubscrListInt => Opcode :: StoreSubscr ,
642+ Self :: SendGen => Opcode :: Send ,
656643 Self :: UnpackSequenceTwoTuple | Self :: UnpackSequenceTuple | Self :: UnpackSequenceList => {
657- Self :: UnpackSequence {
658- count : Arg :: marker ( ) ,
659- }
644+ Opcode :: UnpackSequence
660645 }
661- // STORE_ATTR specializations
646+
662647 Self :: StoreAttrInstanceValue | Self :: StoreAttrSlot | Self :: StoreAttrWithHint => {
663- Self :: StoreAttr {
664- namei : Arg :: marker ( ) ,
665- }
648+ Opcode :: StoreAttr
666649 }
667- // LOAD_GLOBAL specializations
668- Self :: LoadGlobalModule | Self :: LoadGlobalBuiltin => Self :: LoadGlobal {
669- namei : Arg :: marker ( ) ,
670- } ,
671- // LOAD_SUPER_ATTR specializations
672- Self :: LoadSuperAttrAttr | Self :: LoadSuperAttrMethod => Self :: LoadSuperAttr {
673- namei : Arg :: marker ( ) ,
674- } ,
675- // LOAD_ATTR specializations
650+ Self :: LoadGlobalModule | Self :: LoadGlobalBuiltin => Opcode :: LoadGlobal ,
651+ Self :: LoadSuperAttrAttr | Self :: LoadSuperAttrMethod => Opcode :: LoadSuperAttr ,
676652 Self :: LoadAttrInstanceValue
677653 | Self :: LoadAttrModule
678654 | Self :: LoadAttrWithHint
@@ -685,28 +661,13 @@ impl Instruction {
685661 | Self :: LoadAttrMethodNoDict
686662 | Self :: LoadAttrMethodLazyDict
687663 | Self :: LoadAttrNondescriptorWithValues
688- | Self :: LoadAttrNondescriptorNoDict => Self :: LoadAttr {
689- namei : Arg :: marker ( ) ,
690- } ,
691- // COMPARE_OP specializations
692- Self :: CompareOpFloat | Self :: CompareOpInt | Self :: CompareOpStr => Self :: CompareOp {
693- opname : Arg :: marker ( ) ,
694- } ,
695- // CONTAINS_OP specializations
696- Self :: ContainsOpSet | Self :: ContainsOpDict => Self :: ContainsOp {
697- invert : Arg :: marker ( ) ,
698- } ,
699- // JUMP_BACKWARD specializations
700- Self :: JumpBackwardNoJit | Self :: JumpBackwardJit => Self :: JumpBackward {
701- delta : Arg :: marker ( ) ,
702- } ,
703- // FOR_ITER specializations
664+ | Self :: LoadAttrNondescriptorNoDict => Opcode :: LoadAttr ,
665+ Self :: CompareOpFloat | Self :: CompareOpInt | Self :: CompareOpStr => Opcode :: CompareOp ,
666+ Self :: ContainsOpSet | Self :: ContainsOpDict => Opcode :: ContainsOp ,
667+ Self :: JumpBackwardNoJit | Self :: JumpBackwardJit => Opcode :: JumpBackward ,
704668 Self :: ForIterList | Self :: ForIterTuple | Self :: ForIterRange | Self :: ForIterGen => {
705- Self :: ForIter {
706- delta : Arg :: marker ( ) ,
707- }
669+ Opcode :: ForIter
708670 }
709- // CALL specializations
710671 Self :: CallBoundMethodExactArgs
711672 | Self :: CallPyExactArgs
712673 | Self :: CallType1
@@ -726,15 +687,12 @@ impl Instruction {
726687 | Self :: CallAllocAndEnterInit
727688 | Self :: CallPyGeneral
728689 | Self :: CallBoundMethodGeneral
729- | Self :: CallNonPyGeneral => Self :: Call {
730- argc : Arg :: marker ( ) ,
731- } ,
732- // CALL_KW specializations
733- Self :: CallKwBoundMethod | Self :: CallKwPy | Self :: CallKwNonPy => Self :: CallKw {
734- argc : Arg :: marker ( ) ,
735- } ,
690+ | Self :: CallNonPyGeneral => Opcode :: Call ,
691+ Self :: CallKwBoundMethod | Self :: CallKwPy | Self :: CallKwNonPy => Opcode :: CallKw ,
736692 _ => return None ,
737- } )
693+ } ;
694+
695+ Some ( opcode. as_instruction ( ) )
738696 }
739697
740698 /// Map a specialized or instrumented opcode back to its adaptive (base) variant.
0 commit comments