Lines Matching refs:gc
11 http://www.arctrix.com/nas/python/gc/
29 #include "pycore_interp.h" // PyInterpreterState.gc
38 module gc
123 #define DEBUG_SAVEALL (1<<5) /* save all garbage in gc.garbage */
135 return &interp->gc;
162 GCState *gcstate = &interp->gc;
188 During a collection, _gc_prev is temporary used for gc_refs, and the gc list
261 /* Remove `node` from the gc list it's currently in. */
274 /* Move `node` from the gc list it's currently in (which is not explicitly
320 PyGC_Head *gc;
322 for (gc = GC_NEXT(list); gc != list; gc = GC_NEXT(gc)) {
332 PyGC_Head *gc;
333 for (gc = GC_NEXT(collectable); gc != collectable; gc = GC_NEXT(gc)) {
334 gc_clear_collecting(gc);
344 PyGC_Head *gc;
345 for (gc = GC_NEXT(gc_list); gc != gc_list; gc = GC_NEXT(gc)) {
346 PyObject *op = FROM_GC(gc);
365 // `head` must be a doubly-linked gc list, although it's fine (expected!) if
395 PyGC_Head *gc = GC_NEXT(head);
396 while (gc != head) {
397 PyGC_Head *trueprev = GC_PREV(gc);
398 PyGC_Head *truenext = (PyGC_Head *)(gc->_gc_next & ~NEXT_MASK_UNREACHABLE);
401 assert((gc->_gc_prev & PREV_MASK_COLLECTING) == prev_value);
402 assert((gc->_gc_next & NEXT_MASK_UNREACHABLE) == next_value);
403 prev = gc;
404 gc = truenext;
421 PyGC_Head *gc = GC_NEXT(containers);
422 for (; gc != containers; gc = GC_NEXT(gc)) {
423 gc_reset_refs(gc, Py_REFCNT(FROM_GC(gc)));
424 /* Python's cyclic gc should never see an incoming refcount
428 * routine left a gc-aware object tracked during its teardown
430 * that called back into Python. gc can trigger then, and may
432 * was added, such mistakes went on to allow gc to try to
442 _PyObject_ASSERT(FROM_GC(gc), gc_get_refs(gc) != 0);
453 PyGC_Head *gc = AS_GC(op);
458 if (gc_is_collecting(gc)) {
459 gc_decref(gc);
466 * for all objects in containers, and is GC_REACHABLE for all tracked gc
474 PyGC_Head *gc = GC_NEXT(containers);
475 for (; gc != containers; gc = GC_NEXT(gc)) {
476 PyObject *op = FROM_GC(gc);
492 PyGC_Head *gc = AS_GC(op);
493 const Py_ssize_t gc_refs = gc_get_refs(gc);
499 if (! gc_is_collecting(gc)) {
504 assert(gc->_gc_next != 0);
506 if (gc->_gc_next & NEXT_MASK_UNREACHABLE) {
513 // Manually unlink gc from unreachable list because the list functions
515 PyGC_Head *prev = GC_PREV(gc);
516 PyGC_Head *next = (PyGC_Head*)(gc->_gc_next & ~NEXT_MASK_UNREACHABLE);
521 prev->_gc_next = gc->_gc_next; // copy NEXT_MASK_UNREACHABLE
524 gc_list_append(gc, reachable);
525 gc_set_refs(gc, 1);
533 gc_set_refs(gc, 1);
562 PyGC_Head *gc = GC_NEXT(young);
573 while (gc != young) {
574 if (gc_get_refs(gc)) {
575 /* gc is definitely reachable from outside the
583 PyObject *op = FROM_GC(gc);
585 _PyObject_ASSERT_WITH_MSG(op, gc_get_refs(gc) > 0,
587 // NOTE: visit_reachable may change gc->_gc_next when
588 // young->_gc_prev == gc. Don't do gc = GC_NEXT(gc) before!
593 _PyGCHead_SET_PREV(gc, prev);
594 // gc is not COLLECTING state after here.
595 gc_clear_collecting(gc);
596 prev = gc;
600 * assume it is. gc isn't directly reachable from
603 * visit_reachable will eventually move gc back into
606 // Move gc to unreachable.
607 // No need to gc->next->prev = prev because it is single linked.
608 prev->_gc_next = gc->_gc_next;
618 last->_gc_next = (NEXT_MASK_UNREACHABLE | (uintptr_t)gc);
619 _PyGCHead_SET_PREV(gc, last);
620 gc->_gc_next = (NEXT_MASK_UNREACHABLE | (uintptr_t)unreachable);
621 unreachable->_gc_prev = (uintptr_t)gc;
623 gc = (PyGC_Head*)prev->_gc_next;
634 PyGC_Head *next, *gc = GC_NEXT(head);
635 while (gc != head) {
636 PyObject *op = FROM_GC(gc);
637 next = GC_NEXT(gc);
641 gc = next;
649 PyGC_Head *next, *gc = GC_NEXT(head);
650 while (gc != head) {
651 PyObject *op = FROM_GC(gc);
652 next = GC_NEXT(gc);
656 gc = next;
675 PyGC_Head *gc, *next;
681 for (gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
682 PyObject *op = FROM_GC(gc);
684 _PyObject_ASSERT(op, gc->_gc_next & NEXT_MASK_UNREACHABLE);
685 gc->_gc_next &= ~NEXT_MASK_UNREACHABLE;
686 next = (PyGC_Head*)gc->_gc_next;
689 gc_clear_collecting(gc);
690 gc_list_move(gc, finalizers);
701 PyGC_Head *gc, *next;
703 for (gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
704 _PyObject_ASSERT((PyObject*)FROM_GC(gc), gc->_gc_next & NEXT_MASK_UNREACHABLE);
705 gc->_gc_next &= ~NEXT_MASK_UNREACHABLE;
706 next = (PyGC_Head*)gc->_gc_next;
716 PyGC_Head *gc = AS_GC(op);
717 if (gc_is_collecting(gc)) {
718 gc_list_move(gc, tolist);
719 gc_clear_collecting(gc);
732 PyGC_Head *gc = GC_NEXT(finalizers);
733 for (; gc != finalizers; gc = GC_NEXT(gc)) {
735 traverse = Py_TYPE(FROM_GC(gc))->tp_traverse;
736 (void) traverse(FROM_GC(gc),
756 PyGC_Head *gc;
757 PyObject *op; /* generally FROM_GC(gc) */
773 for (gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
776 op = FROM_GC(gc);
777 next = GC_NEXT(gc);
875 gc = (PyGC_Head*)wrcb_to_call._gc_next;
876 op = FROM_GC(gc);
893 * weakref was reachable to begin with, gc didn't already
901 if (wrcb_to_call._gc_next == (uintptr_t)gc) {
903 gc_list_move(gc, old);
916 PySys_FormatStderr("gc: %s <%s %p>\n",
935 PyGC_Head *gc = GC_NEXT(finalizers);
936 for (; gc != finalizers; gc = GC_NEXT(gc)) {
937 PyObject *op = FROM_GC(gc);
971 PyGC_Head *gc = GC_NEXT(collectable);
972 PyObject *op = FROM_GC(gc);
973 gc_list_move(gc, &seen);
974 if (!_PyGCHead_FINALIZED(gc) &&
976 _PyGCHead_SET_FINALIZED(gc);
997 PyGC_Head *gc = GC_NEXT(collectable);
998 PyObject *op = FROM_GC(gc);
1021 if (GC_NEXT(collectable) == gc) {
1023 gc_clear_collecting(gc);
1024 gc_list_move(gc, old);
1059 "gc: objects in each generation:%s\n"
1060 "gc: objects in permanent generation: %zd\n",
1189 PyGC_Head *gc;
1191 GCState *gcstate = &tstate->interp->gc;
1199 PySys_WriteStderr("gc: collecting generation %d...\n", generation);
1262 for (gc = GC_NEXT(&unreachable); gc != &unreachable; gc = GC_NEXT(gc)) {
1263 debug_cycle("collectable", FROM_GC(gc));
1291 for (gc = GC_NEXT(&finalizers); gc != &finalizers; gc = GC_NEXT(gc)) {
1294 debug_cycle("uncollectable", FROM_GC(gc));
1299 "gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
1357 GCState *gcstate = &tstate->interp->gc;
1409 GCState *gcstate = &tstate->interp->gc;
1465 gc.enable
1479 gc.disable
1493 gc.isenabled -> bool
1506 gc.collect -> Py_ssize_t
1530 GCState *gcstate = &tstate->interp->gc;
1545 gc.set_debug
1553 DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.
1572 gc.get_debug -> int
1608 gc.get_threshold
1625 gc.get_count
1654 PyGC_Head *gc;
1657 for (gc = GC_NEXT(list); gc != list; gc = GC_NEXT(gc)) {
1658 obj = FROM_GC(gc);
1677 if (PySys_Audit("gc.get_referrers", "(O)", args) < 0) {
1711 if (PySys_Audit("gc.get_referents", "(O)", args) < 0) {
1737 gc.get_objects
1754 GCState *gcstate = &tstate->interp->gc;
1756 if (PySys_Audit("gc.get_objects", "n", generation) < 0) {
1802 gc.get_stats
1850 gc.is_tracked
1875 gc.is_finalized
1894 gc.freeze
1898 This can be used before a POSIX fork() call to make the gc copy-on-write friendly.
1916 gc.unfreeze
1934 gc.get_freeze_count -> Py_ssize_t
2027 .m_name = "gc",
2066 /* Public API to invoke gc.collect() from C */
2071 GCState *gcstate = &tstate->interp->gc;
2103 GCState *gcstate = &tstate->interp->gc;
2118 GCState *gcstate = &interp->gc;
2123 message = "gc: %zd uncollectable objects at " \
2126 message = "gc: %zd uncollectable objects at " \
2127 "shutdown; use gc.set_debug(gc.DEBUG_UNCOLLECTABLE) to list them";
2131 if (PyErr_WarnExplicitFormat(PyExc_ResourceWarning, "gc", 0,
2132 "gc", NULL, message,
2156 PyGC_Head *gc;
2157 for (gc = GC_NEXT(list); gc != list; gc = GC_NEXT(list)) {
2158 PyObject *op = FROM_GC(gc);
2173 GCState *gcstate = &interp->gc;
2259 GCState *gcstate = &tstate->interp->gc;
2351 if (PyErr_WarnExplicitFormat(PyExc_ResourceWarning, "gc", 0,
2352 "gc", NULL, "Object of type %s is not untracked before destruction",