From 5bc558c9cde5db6fa89b7b4d1d56bf3f8dbe8454 Mon Sep 17 00:00:00 2001 From: Diogo Netto <61364108+d-netto@users.noreply.github.com> Date: Sat, 26 Aug 2023 14:03:21 -0300 Subject: [PATCH] refactor GC scanning code to reflect jl_binding_t are now first class (#51035) Removes some redundant code. Credits to Eduardo for pointing this out in the GC meeting. --- src/gc.c | 20 +++----------------- src/gc.h | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/gc.c b/src/gc.c index 4848ac888dadf..bbf996c98040a 100644 --- a/src/gc.c +++ b/src/gc.c @@ -2318,19 +2318,10 @@ STATIC_INLINE void gc_mark_excstack(jl_ptls_t ptls, jl_excstack_t *excstack, siz } // Mark module binding -STATIC_INLINE void gc_mark_module_binding(jl_ptls_t ptls, jl_module_t *mb_parent, jl_binding_t **mb_begin, - jl_binding_t **mb_end, uintptr_t nptr, +STATIC_INLINE void gc_mark_module_binding(jl_ptls_t ptls, jl_module_t *mb_parent, uintptr_t nptr, uint8_t bits) JL_NOTSAFEPOINT { jl_gc_markqueue_t *mq = &ptls->mark_queue; - for (; mb_begin < mb_end; mb_begin++) { - jl_binding_t *b = *mb_begin; - if (b == (jl_binding_t *)jl_nothing) - continue; - verify_parent1("module", mb_parent, mb_begin, "binding_buff"); - gc_assert_parent_validity((jl_value_t *)mb_parent, (jl_value_t *)b); - gc_try_claim_and_push(mq, b, &nptr); - } jl_value_t *bindings = (jl_value_t *)jl_atomic_load_relaxed(&mb_parent->bindings); gc_assert_parent_validity((jl_value_t *)mb_parent, bindings); gc_try_claim_and_push(mq, bindings, &nptr); @@ -2461,13 +2452,8 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_ else if (foreign_alloc) objprofile_count(jl_module_type, bits == GC_OLD_MARKED, sizeof(jl_module_t)); jl_module_t *mb_parent = (jl_module_t *)new_obj; - jl_svec_t *bindings = jl_atomic_load_relaxed(&mb_parent->bindings); - jl_binding_t **table = (jl_binding_t**)jl_svec_data(bindings); - size_t bsize = jl_svec_len(bindings); - uintptr_t nptr = ((bsize + mb_parent->usings.len + 1) << 2) | (bits & GC_OLD); - jl_binding_t **mb_begin = table + 1; - jl_binding_t **mb_end = table + bsize; - gc_mark_module_binding(ptls, mb_parent, mb_begin, mb_end, nptr, bits); + uintptr_t nptr = ((mb_parent->usings.len + 1) << 2) | (bits & GC_OLD); + gc_mark_module_binding(ptls, mb_parent, nptr, bits); } else if (vtag == jl_task_tag << 4) { if (update_meta) diff --git a/src/gc.h b/src/gc.h index 07e177b9ea907..90943cba84d4b 100644 --- a/src/gc.h +++ b/src/gc.h @@ -146,7 +146,7 @@ typedef struct _mallocarray_t { // pool page metadata typedef struct _jl_gc_pagemeta_t { - // next metadata structre in per-thread list + // next metadata structure in per-thread list // or in one of the `jl_gc_global_page_pool_t` struct _jl_gc_pagemeta_t *next; // index of pool that owns this page