@@ -351,6 +351,10 @@ impl ExecutingFrame<'_> {
351351 let mut arg_state = bytecode:: OpArgState :: default ( ) ;
352352 loop {
353353 let idx = self . lasti ( ) as usize ;
354+ // eprintln!(
355+ // "location: {:?} {}",
356+ // self.code.locations[idx], self.code.source_path
357+ // );
354358 self . update_lasti ( |i| * i += 1 ) ;
355359 let bytecode:: CodeUnit { op, arg } = instrs[ idx] ;
356360 let arg = arg_state. extend ( arg) ;
@@ -993,6 +997,9 @@ impl ExecutingFrame<'_> {
993997 Ok ( None )
994998 }
995999 bytecode:: Instruction :: GetANext => {
1000+ #[ cfg( debug_assertions) ] // remove when GetANext is fully implemented
1001+ let orig_stack_len = self . state . stack . len ( ) ;
1002+
9961003 let aiter = self . top_value ( ) ;
9971004 let awaitable = if aiter. class ( ) . is ( vm. ctx . types . async_generator ) {
9981005 vm. call_special_method ( aiter, identifier ! ( vm, __anext__) , ( ) ) ?
@@ -1030,6 +1037,8 @@ impl ExecutingFrame<'_> {
10301037 } ) ?
10311038 } ;
10321039 self . push_value ( awaitable) ;
1040+ #[ cfg( debug_assertions) ]
1041+ debug_assert_eq ! ( orig_stack_len + 1 , self . state. stack. len( ) ) ;
10331042 Ok ( None )
10341043 }
10351044 bytecode:: Instruction :: EndAsyncFor => {
@@ -1238,6 +1247,7 @@ impl ExecutingFrame<'_> {
12381247 fn unwind_blocks ( & mut self , vm : & VirtualMachine , reason : UnwindReason ) -> FrameResult {
12391248 // First unwind all existing blocks on the block stack:
12401249 while let Some ( block) = self . current_block ( ) {
1250+ // eprintln!("unwinding block: {:.60?} {:.60?}", block.typ, reason);
12411251 match block. typ {
12421252 BlockType :: Loop => match reason {
12431253 UnwindReason :: Break { target } => {
@@ -1935,6 +1945,7 @@ impl ExecutingFrame<'_> {
19351945 }
19361946
19371947 fn push_block ( & mut self , typ : BlockType ) {
1948+ // eprintln!("block pushed: {:.60?} {}", typ, self.state.stack.len());
19381949 self . state . blocks . push ( Block {
19391950 typ,
19401951 level : self . state . stack . len ( ) ,
@@ -1944,7 +1955,12 @@ impl ExecutingFrame<'_> {
19441955 #[ track_caller]
19451956 fn pop_block ( & mut self ) -> Block {
19461957 let block = self . state . blocks . pop ( ) . expect ( "No more blocks to pop!" ) ;
1947- // eprintln!("popped block: {:?} stack: {} truncate to {}", block.typ, self.state.stack.len(), block.level);
1958+ // eprintln!(
1959+ // "block popped: {:.60?} {} -> {} ",
1960+ // block.typ,
1961+ // self.state.stack.len(),
1962+ // block.level
1963+ // );
19481964 #[ cfg( debug_assertions) ]
19491965 if self . state . stack . len ( ) < block. level {
19501966 dbg ! ( & self ) ;
@@ -1966,6 +1982,11 @@ impl ExecutingFrame<'_> {
19661982 #[ inline]
19671983 #[ track_caller] // not a real track_caller but push_value is not very useful
19681984 fn push_value ( & mut self , obj : PyObjectRef ) {
1985+ // eprintln!(
1986+ // "push_value {} / len: {} +1",
1987+ // obj.class().name(),
1988+ // self.state.stack.len()
1989+ // );
19691990 match self . state . stack . try_push ( obj) {
19701991 Ok ( ( ) ) => { }
19711992 Err ( _e) => self . fatal ( "tried to push value onto stack but overflowed max_stackdepth" ) ,
@@ -1976,7 +1997,14 @@ impl ExecutingFrame<'_> {
19761997 #[ track_caller] // not a real track_caller but pop_value is not very useful
19771998 fn pop_value ( & mut self ) -> PyObjectRef {
19781999 match self . state . stack . pop ( ) {
1979- Some ( x) => x,
2000+ Some ( x) => {
2001+ // eprintln!(
2002+ // "pop_value {} / len: {}",
2003+ // x.class().name(),
2004+ // self.state.stack.len()
2005+ // );
2006+ x
2007+ }
19802008 None => self . fatal ( "tried to pop value but there was nothing on the stack" ) ,
19812009 }
19822010 }
0 commit comments