⚡ Sangsakala Proxy 🏠 Home
Skip to content

Commit e6b1810

Browse files
committed
Add borrowed ref debug_assert to InstrumentedYieldValue, clean up comments
1 parent 5c25fc7 commit e6b1810

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎crates/vm/src/frame.rs‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

‎crates/vm/src/object/core.rs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff 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-
14081404
const STACKREF_BORROW_TAG: usize = 1;
14091405

14101406
/// A tagged stack reference to a Python object.

0 commit comments

Comments
 (0)