MCPcopy Index your code
hub / github.com/RustPython/RustPython / track_object

Method track_object

crates/vm/src/gc_state.rs:268–276  ·  view source on GitHub ↗

Track a new object (add to gen0). O(1) — intrusive linked list push_front, no hashing. # Safety obj must be a valid pointer to a PyObject

(&self, obj: NonNull<PyObject>)

Source from the content-addressed store, hash-verified

266 /// # Safety
267 /// obj must be a valid pointer to a PyObject
268 pub unsafe fn track_object(&self, obj: NonNull<PyObject>) {
269 let obj_ref = unsafe { obj.as_ref() };
270 obj_ref.set_gc_tracked();
271 obj_ref.set_gc_generation(0);
272
273 self.generation_lists[0].write().push_front(obj);
274 self.generations[0].count.fetch_add(1, Ordering::SeqCst);
275 self.alloc_count.fetch_add(1, Ordering::SeqCst);
276 }
277
278 /// Untrack an object (remove from GC lists).
279 /// O(1) — intrusive linked list remove by node pointer.

Callers 1

new_refMethod · 0.80

Calls 5

set_gc_trackedMethod · 0.80
set_gc_generationMethod · 0.80
push_frontMethod · 0.80
as_refMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected