Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 942f77d

Browse files
committed
wip: move freeze_used to gc state
1 parent 72128e2 commit 942f77d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Include/internal/pycore_gc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ struct _gc_runtime_state {
351351
int visited_space;
352352
int phase;
353353

354+
int freeze_used;
355+
354356
#if WITH_GC_TIMING_STATS
355357
/* state for GC timing statistics */
356358
struct gc_timing_state timing_state;

Python/gc_free_threading.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,6 @@ record_deallocation(PyThreadState *tstate)
16021602
}
16031603
}
16041604

1605-
static bool freeze_used;
1606-
16071605
static void
16081606
gc_collect_internal(PyInterpreterState *interp, struct collection_state *state, int generation)
16091607
{
@@ -1633,7 +1631,7 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state,
16331631
process_delayed_frees(interp, state);
16341632

16351633
#if 1
1636-
if (!freeze_used) {
1634+
if (!state->gcstate->freeze_used) {
16371635
// Mark objects reachable from known roots as "alive". These will
16381636
// be ignored for rest of the GC pass.
16391637
int err = mark_root_reachable(interp, state);
@@ -2000,7 +1998,8 @@ _PyGC_Freeze(PyInterpreterState *interp)
20001998
{
20011999
struct visitor_args args;
20022000
_PyEval_StopTheWorld(interp);
2003-
freeze_used = true;
2001+
GCState *gcstate = get_gc_state();
2002+
gcstate->freeze_used = 1;
20042003
gc_visit_heaps(interp, &visit_freeze, &args);
20052004
_PyEval_StartTheWorld(interp);
20062005
}
@@ -2021,8 +2020,9 @@ _PyGC_Unfreeze(PyInterpreterState *interp)
20212020
{
20222021
struct visitor_args args;
20232022
_PyEval_StopTheWorld(interp);
2023+
GCState *gcstate = get_gc_state();
2024+
gcstate->freeze_used = 0;
20242025
gc_visit_heaps(interp, &visit_unfreeze, &args);
2025-
freeze_used = false;
20262026
_PyEval_StartTheWorld(interp);
20272027
}
20282028

0 commit comments

Comments
 (0)