@@ -1262,8 +1262,8 @@ impl ExecutingFrame<'_> {
12621262 }
12631263 Instruction :: CompareOp { op } => self . execute_compare ( vm, op. get ( arg) ) ,
12641264 Instruction :: ContainsOp ( invert) => {
1265- let b = self . pop_stackref ( ) ;
1266- let a = self . pop_stackref ( ) ;
1265+ let b = self . pop_value ( ) ;
1266+ let a = self . pop_value ( ) ;
12671267
12681268 let value = match invert. get ( arg) {
12691269 bytecode:: Invert :: No => self . _in ( vm, & a, & b) ?,
@@ -1281,12 +1281,7 @@ impl ExecutingFrame<'_> {
12811281 // This is 1-indexed to match CPython
12821282 let idx = index. get ( arg) as usize ;
12831283 let stack_len = self . state . stack . len ( ) ;
1284- if stack_len < idx {
1285- eprintln ! ( "CopyItem ERROR: stack_len={}, idx={}" , stack_len, idx) ;
1286- eprintln ! ( " code: {}" , self . code. obj_name) ;
1287- eprintln ! ( " lasti: {}" , self . lasti( ) ) ;
1288- panic ! ( "CopyItem: stack underflow" ) ;
1289- }
1284+ debug_assert ! ( stack_len >= idx, "CopyItem: stack underflow" ) ;
12901285 let value = self . state . stack [ stack_len - idx] . clone ( ) ;
12911286 self . push_stackref_opt ( value) ;
12921287 Ok ( None )
@@ -1913,7 +1908,6 @@ impl ExecutingFrame<'_> {
19131908 . into ( ) ,
19141909 )
19151910 } ) ?;
1916- drop ( fastlocals) ;
19171911 self . push_value ( x1) ;
19181912 self . push_value ( x2) ;
19191913 Ok ( None )
@@ -2505,7 +2499,11 @@ impl ExecutingFrame<'_> {
25052499 }
25062500 Instruction :: YieldValue { arg : oparg } => {
25072501 debug_assert ! (
2508- self . state. stack. iter( ) . flatten( ) . all( |sr| !sr. is_borrowed( ) ) ,
2502+ self . state
2503+ . stack
2504+ . iter( )
2505+ . flatten( )
2506+ . all( |sr| !sr. is_borrowed( ) ) ,
25092507 "borrowed refs on stack at yield point"
25102508 ) ;
25112509 let value = self . pop_value ( ) ;
@@ -3779,37 +3777,37 @@ impl ExecutingFrame<'_> {
37793777
37803778 #[ cfg_attr( feature = "flame-it" , flame( "Frame" ) ) ]
37813779 fn execute_bin_op ( & mut self , vm : & VirtualMachine , op : bytecode:: BinaryOperator ) -> FrameResult {
3782- let b_ref = self . pop_stackref ( ) ;
3783- let a_ref = self . pop_stackref ( ) ;
3780+ let b_ref = & self . pop_value ( ) ;
3781+ let a_ref = & self . pop_value ( ) ;
37843782 let value = match op {
3785- bytecode:: BinaryOperator :: Subtract => vm. _sub ( & a_ref, & b_ref) ,
3786- bytecode:: BinaryOperator :: Add => vm. _add ( & a_ref, & b_ref) ,
3787- bytecode:: BinaryOperator :: Multiply => vm. _mul ( & a_ref, & b_ref) ,
3788- bytecode:: BinaryOperator :: MatrixMultiply => vm. _matmul ( & a_ref, & b_ref) ,
3789- bytecode:: BinaryOperator :: Power => vm. _pow ( & a_ref, & b_ref, vm. ctx . none . as_object ( ) ) ,
3790- bytecode:: BinaryOperator :: TrueDivide => vm. _truediv ( & a_ref, & b_ref) ,
3791- bytecode:: BinaryOperator :: FloorDivide => vm. _floordiv ( & a_ref, & b_ref) ,
3792- bytecode:: BinaryOperator :: Remainder => vm. _mod ( & a_ref, & b_ref) ,
3793- bytecode:: BinaryOperator :: Lshift => vm. _lshift ( & a_ref, & b_ref) ,
3794- bytecode:: BinaryOperator :: Rshift => vm. _rshift ( & a_ref, & b_ref) ,
3795- bytecode:: BinaryOperator :: Xor => vm. _xor ( & a_ref, & b_ref) ,
3796- bytecode:: BinaryOperator :: Or => vm. _or ( & a_ref, & b_ref) ,
3797- bytecode:: BinaryOperator :: And => vm. _and ( & a_ref, & b_ref) ,
3798- bytecode:: BinaryOperator :: InplaceSubtract => vm. _isub ( & a_ref, & b_ref) ,
3799- bytecode:: BinaryOperator :: InplaceAdd => vm. _iadd ( & a_ref, & b_ref) ,
3800- bytecode:: BinaryOperator :: InplaceMultiply => vm. _imul ( & a_ref, & b_ref) ,
3801- bytecode:: BinaryOperator :: InplaceMatrixMultiply => vm. _imatmul ( & a_ref, & b_ref) ,
3783+ bytecode:: BinaryOperator :: Subtract => vm. _sub ( a_ref, b_ref) ,
3784+ bytecode:: BinaryOperator :: Add => vm. _add ( a_ref, b_ref) ,
3785+ bytecode:: BinaryOperator :: Multiply => vm. _mul ( a_ref, b_ref) ,
3786+ bytecode:: BinaryOperator :: MatrixMultiply => vm. _matmul ( a_ref, b_ref) ,
3787+ bytecode:: BinaryOperator :: Power => vm. _pow ( a_ref, b_ref, vm. ctx . none . as_object ( ) ) ,
3788+ bytecode:: BinaryOperator :: TrueDivide => vm. _truediv ( a_ref, b_ref) ,
3789+ bytecode:: BinaryOperator :: FloorDivide => vm. _floordiv ( a_ref, b_ref) ,
3790+ bytecode:: BinaryOperator :: Remainder => vm. _mod ( a_ref, b_ref) ,
3791+ bytecode:: BinaryOperator :: Lshift => vm. _lshift ( a_ref, b_ref) ,
3792+ bytecode:: BinaryOperator :: Rshift => vm. _rshift ( a_ref, b_ref) ,
3793+ bytecode:: BinaryOperator :: Xor => vm. _xor ( a_ref, b_ref) ,
3794+ bytecode:: BinaryOperator :: Or => vm. _or ( a_ref, b_ref) ,
3795+ bytecode:: BinaryOperator :: And => vm. _and ( a_ref, b_ref) ,
3796+ bytecode:: BinaryOperator :: InplaceSubtract => vm. _isub ( a_ref, b_ref) ,
3797+ bytecode:: BinaryOperator :: InplaceAdd => vm. _iadd ( a_ref, b_ref) ,
3798+ bytecode:: BinaryOperator :: InplaceMultiply => vm. _imul ( a_ref, b_ref) ,
3799+ bytecode:: BinaryOperator :: InplaceMatrixMultiply => vm. _imatmul ( a_ref, b_ref) ,
38023800 bytecode:: BinaryOperator :: InplacePower => {
3803- vm. _ipow ( & a_ref, & b_ref, vm. ctx . none . as_object ( ) )
3804- }
3805- bytecode:: BinaryOperator :: InplaceTrueDivide => vm. _itruediv ( & a_ref, & b_ref) ,
3806- bytecode:: BinaryOperator :: InplaceFloorDivide => vm. _ifloordiv ( & a_ref, & b_ref) ,
3807- bytecode:: BinaryOperator :: InplaceRemainder => vm. _imod ( & a_ref, & b_ref) ,
3808- bytecode:: BinaryOperator :: InplaceLshift => vm. _ilshift ( & a_ref, & b_ref) ,
3809- bytecode:: BinaryOperator :: InplaceRshift => vm. _irshift ( & a_ref, & b_ref) ,
3810- bytecode:: BinaryOperator :: InplaceXor => vm. _ixor ( & a_ref, & b_ref) ,
3811- bytecode:: BinaryOperator :: InplaceOr => vm. _ior ( & a_ref, & b_ref) ,
3812- bytecode:: BinaryOperator :: InplaceAnd => vm. _iand ( & a_ref, & b_ref) ,
3801+ vm. _ipow ( a_ref, b_ref, vm. ctx . none . as_object ( ) )
3802+ }
3803+ bytecode:: BinaryOperator :: InplaceTrueDivide => vm. _itruediv ( a_ref, b_ref) ,
3804+ bytecode:: BinaryOperator :: InplaceFloorDivide => vm. _ifloordiv ( a_ref, b_ref) ,
3805+ bytecode:: BinaryOperator :: InplaceRemainder => vm. _imod ( a_ref, b_ref) ,
3806+ bytecode:: BinaryOperator :: InplaceLshift => vm. _ilshift ( a_ref, b_ref) ,
3807+ bytecode:: BinaryOperator :: InplaceRshift => vm. _irshift ( a_ref, b_ref) ,
3808+ bytecode:: BinaryOperator :: InplaceXor => vm. _ixor ( a_ref, b_ref) ,
3809+ bytecode:: BinaryOperator :: InplaceOr => vm. _ior ( a_ref, b_ref) ,
3810+ bytecode:: BinaryOperator :: InplaceAnd => vm. _iand ( a_ref, b_ref) ,
38133811 bytecode:: BinaryOperator :: Subscr => a_ref. get_item ( b_ref. as_object ( ) , vm) ,
38143812 } ?;
38153813
@@ -4102,6 +4100,7 @@ impl ExecutingFrame<'_> {
41024100 /// The compiler guarantees consumption within the same basic block.
41034101 #[ inline]
41044102 #[ track_caller]
4103+ #[ allow( dead_code) ]
41054104 unsafe fn push_borrowed ( & mut self , obj : & PyObject ) {
41064105 self . push_stackref_opt ( Some ( unsafe { PyStackRef :: new_borrowed ( obj) } ) ) ;
41074106 }
@@ -4311,8 +4310,7 @@ impl ExecutingFrame<'_> {
43114310 ) ;
43124311 }
43134312 self . state . stack . drain ( stack_len - count..) . map ( |obj| {
4314- expect_unchecked ( obj, "pop_multiple but null found. This is a compiler bug." )
4315- . to_pyobj ( )
4313+ expect_unchecked ( obj, "pop_multiple but null found. This is a compiler bug." ) . to_pyobj ( )
43164314 } )
43174315 }
43184316
0 commit comments