Skip to content

Commit 22df0c6

Browse files
committed
Clean up comments: remove redundant/stale remarks, fix CPython references
1 parent 16778fc commit 22df0c6

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

crates/common/src/lock.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ cfg_if::cfg_if! {
2020
}
2121
}
2222

23-
// LazyLock: thread-safe lazy initialization for `static` items.
24-
// In non-threading mode with std, use std::sync::LazyLock for safety
25-
// (Rust test runner uses parallel threads even without the threading feature).
26-
// Without std, use a LazyCell wrapper (truly single-threaded environments only).
23+
// LazyLock: uses std::sync::LazyLock when std is available (even without
24+
// threading, because Rust test runner uses parallel threads).
25+
// Without std, uses a LazyCell wrapper (truly single-threaded only).
2726
cfg_if::cfg_if! {
2827
if #[cfg(any(feature = "threading", feature = "std"))] {
2928
pub use std::sync::LazyLock;

crates/vm/src/datastack.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
/// Thread data stack for interpreter frames.
1+
/// Thread data stack for interpreter frames (`_PyStackChunk` /
2+
/// `tstate->datastack_*`).
23
///
34
/// A linked list of chunks providing bump allocation for frame-local data
4-
/// (localsplus arrays). Mirrors `_PyStackChunk` / `tstate->datastack_*`
5-
/// from CPython.
6-
///
7-
/// Normal function calls allocate from the data stack via `push()` (pointer
8-
/// bump). Generators and coroutines use heap-allocated storage instead.
5+
/// (localsplus arrays). Normal function calls allocate via `push()`
6+
/// (pointer bump). Generators and coroutines use heap-allocated storage.
97
use alloc::alloc::{alloc, dealloc};
108
use core::alloc::Layout;
119
use core::ptr;
1210

13-
/// Minimum chunk size in bytes (16 KB, matching CPython `_PY_DATA_STACK_CHUNK_SIZE`).
11+
/// Minimum chunk size in bytes (`_PY_DATA_STACK_CHUNK_SIZE`).
1412
const MIN_CHUNK_SIZE: usize = 16 * 1024;
1513

1614
/// Extra headroom (in bytes) to avoid allocating a new chunk for the next
@@ -66,7 +64,7 @@ impl DataStack {
6664
let top = unsafe { (*chunk).data_start() };
6765
let limit = unsafe { (*chunk).data_limit() };
6866
// Skip one ALIGN-sized slot in the root chunk so that `pop()` never
69-
// frees it (same trick as CPython's `push_chunk`).
67+
// frees it (`push_chunk` convention).
7068
let top = unsafe { top.add(ALIGN) };
7169
Self { chunk, top, limit }
7270
}

crates/vm/src/frame.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ enum UnwindReason {
6666
Raising { exception: PyBaseExceptionRef },
6767
}
6868

69-
// FrameState fields are stored directly on Frame as UnsafeCell.
70-
// See Frame.localsplus, Frame.cells_frees, Frame.prev_line.
71-
7269
/// Tracks who owns a frame.
7370
// = `_PyFrameOwner`
7471
#[repr(i8)]
@@ -203,7 +200,6 @@ impl LocalsPlus {
203200
fn materialize_to_heap(&mut self) -> Option<*mut u8> {
204201
if let LocalsPlusData::DataStack { ptr, capacity } = &self.data {
205202
let base = *ptr as *mut u8;
206-
// Copy all data to a heap allocation (preserves locals for tracebacks).
207203
let heap_data = unsafe { core::slice::from_raw_parts(*ptr, *capacity) }
208204
.to_vec()
209205
.into_boxed_slice();
@@ -461,7 +457,6 @@ impl ExactSizeIterator for LocalsPlusStackDrain<'_> {}
461457

462458
impl Drop for LocalsPlusStackDrain<'_> {
463459
fn drop(&mut self) {
464-
// Drop any remaining elements that weren't consumed.
465460
while self.current < self.end {
466461
let idx = self.localsplus.nlocalsplus as usize + self.current;
467462
let data = self.localsplus.data_as_mut_slice();
@@ -671,7 +666,6 @@ impl Frame {
671666
.chain(closure.iter().cloned())
672667
.collect();
673668

674-
// Create unified localsplus: varnames + cellvars + freevars + stack
675669
let nlocalsplus = nlocals
676670
.checked_add(num_cells)
677671
.and_then(|v| v.checked_add(nfrees))
@@ -1001,8 +995,8 @@ impl Py<Frame> {
1001995
}
1002996
}
1003997

1004-
/// An executing frame; essentially just a struct to combine the immutable data outside the mutex
1005-
/// with the mutable data inside
998+
/// An executing frame; borrows mutable frame-internal data for the duration
999+
/// of bytecode execution.
10061000
struct ExecutingFrame<'a> {
10071001
code: &'a PyRef<PyCode>,
10081002
localsplus: &'a mut LocalsPlus,

0 commit comments

Comments
 (0)