@@ -351,6 +351,10 @@ impl ExecutingFrame<'_> {
351
351
let mut arg_state = bytecode:: OpArgState :: default ( ) ;
352
352
loop {
353
353
let idx = self . lasti ( ) as usize ;
354
+ // eprintln!(
355
+ // "location: {:?} {}",
356
+ // self.code.locations[idx], self.code.source_path
357
+ // );
354
358
self . update_lasti ( |i| * i += 1 ) ;
355
359
let bytecode:: CodeUnit { op, arg } = instrs[ idx] ;
356
360
let arg = arg_state. extend ( arg) ;
@@ -993,6 +997,8 @@ impl ExecutingFrame<'_> {
993
997
Ok ( None )
994
998
}
995
999
bytecode:: Instruction :: GetANext => {
1000
+ #[ cfg( debug_assertions) ] // remove when async bugs are all fixed
1001
+ let orig_stack_len = self . state . stack . len ( ) ;
996
1002
let aiter = self . top_value ( ) ;
997
1003
let awaitable = if aiter. class ( ) . is ( vm. ctx . types . async_generator ) {
998
1004
vm. call_special_method ( aiter, identifier ! ( vm, __anext__) , ( ) ) ?
@@ -1030,6 +1036,7 @@ impl ExecutingFrame<'_> {
1030
1036
} ) ?
1031
1037
} ;
1032
1038
self . push_value ( awaitable) ;
1039
+ debug_assert_eq ! ( orig_stack_len + 1 , self . state. stack. len( ) ) ;
1033
1040
Ok ( None )
1034
1041
}
1035
1042
bytecode:: Instruction :: EndAsyncFor => {
@@ -1238,6 +1245,7 @@ impl ExecutingFrame<'_> {
1238
1245
fn unwind_blocks ( & mut self , vm : & VirtualMachine , reason : UnwindReason ) -> FrameResult {
1239
1246
// First unwind all existing blocks on the block stack:
1240
1247
while let Some ( block) = self . current_block ( ) {
1248
+ // eprintln!("unwinding block: {:.60?} {:.60?}", block.typ, reason);
1241
1249
match block. typ {
1242
1250
BlockType :: Loop => match reason {
1243
1251
UnwindReason :: Break { target } => {
@@ -1935,6 +1943,7 @@ impl ExecutingFrame<'_> {
1935
1943
}
1936
1944
1937
1945
fn push_block ( & mut self , typ : BlockType ) {
1946
+ // eprintln!("block pushed: {:.60?} {}", typ, self.state.stack.len());
1938
1947
self . state . blocks . push ( Block {
1939
1948
typ,
1940
1949
level : self . state . stack . len ( ) ,
@@ -1944,7 +1953,12 @@ impl ExecutingFrame<'_> {
1944
1953
#[ track_caller]
1945
1954
fn pop_block ( & mut self ) -> Block {
1946
1955
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);
1956
+ // eprintln!(
1957
+ // "block popped: {:.60?} {} -> {} ",
1958
+ // block.typ,
1959
+ // self.state.stack.len(),
1960
+ // block.level
1961
+ // );
1948
1962
#[ cfg( debug_assertions) ]
1949
1963
if self . state . stack . len ( ) < block. level {
1950
1964
dbg ! ( & self ) ;
@@ -1966,6 +1980,11 @@ impl ExecutingFrame<'_> {
1966
1980
#[ inline]
1967
1981
#[ track_caller] // not a real track_caller but push_value is not very useful
1968
1982
fn push_value ( & mut self , obj : PyObjectRef ) {
1983
+ // eprintln!(
1984
+ // "push_value {} / len: {} +1",
1985
+ // obj.class().name(),
1986
+ // self.state.stack.len()
1987
+ // );
1969
1988
match self . state . stack . try_push ( obj) {
1970
1989
Ok ( ( ) ) => { }
1971
1990
Err ( _e) => self . fatal ( "tried to push value onto stack but overflowed max_stackdepth" ) ,
@@ -1976,7 +1995,14 @@ impl ExecutingFrame<'_> {
1976
1995
#[ track_caller] // not a real track_caller but pop_value is not very useful
1977
1996
fn pop_value ( & mut self ) -> PyObjectRef {
1978
1997
match self . state . stack . pop ( ) {
1979
- Some ( x) => x,
1998
+ Some ( x) => {
1999
+ // eprintln!(
2000
+ // "pop_value {} / len: {}",
2001
+ // x.class().name(),
2002
+ // self.state.stack.len()
2003
+ // );
2004
+ x
2005
+ }
1980
2006
None => self . fatal ( "tried to pop value but there was nothing on the stack" ) ,
1981
2007
}
1982
2008
}
0 commit comments