File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1864,8 +1864,9 @@ impl ExecutingFrame<'_> {
18641864 self . push_value ( x2) ;
18651865 Ok ( None )
18661866 }
1867- // TODO: Implement true borrow optimization (skip Arc::clone).
1868- // Currently this just clones like LoadFast.
1867+ // Borrow optimization not yet active; falls back to clone.
1868+ // push_borrowed() is available but disabled until stack
1869+ // lifetime issues at yield/exception points are resolved.
18691870 Instruction :: LoadFastBorrow ( idx) => {
18701871 let idx = idx. get ( arg) as usize ;
18711872 let x = unsafe { self . fastlocals . borrow ( ) } [ idx]
@@ -2685,6 +2686,14 @@ impl ExecutingFrame<'_> {
26852686 self . unwind_blocks ( vm, UnwindReason :: Returning { value } )
26862687 }
26872688 Instruction :: InstrumentedYieldValue => {
2689+ debug_assert ! (
2690+ self . state
2691+ . stack
2692+ . iter( )
2693+ . flatten( )
2694+ . all( |sr| !sr. is_borrowed( ) ) ,
2695+ "borrowed refs on stack at yield point"
2696+ ) ;
26882697 let value = self . pop_value ( ) ;
26892698 if self . monitoring_mask & monitoring:: EVENT_PY_YIELD != 0 {
26902699 let offset = ( self . lasti ( ) - 1 ) * 2 ;
Original file line number Diff line number Diff line change @@ -1401,10 +1401,6 @@ impl fmt::Debug for PyObjectRef {
14011401 }
14021402}
14031403
1404- // ---------------------------------------------------------------------------
1405- // PyStackRef – tagged stack reference (owned or borrowed)
1406- // ---------------------------------------------------------------------------
1407-
14081404const STACKREF_BORROW_TAG : usize = 1 ;
14091405
14101406/// A tagged stack reference to a Python object.
You can’t perform that action at this time.
0 commit comments