Skip to content

Commit 5bc558c

Browse files
authored
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.
1 parent 6097140 commit 5bc558c

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/gc.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,19 +2318,10 @@ STATIC_INLINE void gc_mark_excstack(jl_ptls_t ptls, jl_excstack_t *excstack, siz
23182318
}
23192319

23202320
// Mark module binding
2321-
STATIC_INLINE void gc_mark_module_binding(jl_ptls_t ptls, jl_module_t *mb_parent, jl_binding_t **mb_begin,
2322-
jl_binding_t **mb_end, uintptr_t nptr,
2321+
STATIC_INLINE void gc_mark_module_binding(jl_ptls_t ptls, jl_module_t *mb_parent, uintptr_t nptr,
23232322
uint8_t bits) JL_NOTSAFEPOINT
23242323
{
23252324
jl_gc_markqueue_t *mq = &ptls->mark_queue;
2326-
for (; mb_begin < mb_end; mb_begin++) {
2327-
jl_binding_t *b = *mb_begin;
2328-
if (b == (jl_binding_t *)jl_nothing)
2329-
continue;
2330-
verify_parent1("module", mb_parent, mb_begin, "binding_buff");
2331-
gc_assert_parent_validity((jl_value_t *)mb_parent, (jl_value_t *)b);
2332-
gc_try_claim_and_push(mq, b, &nptr);
2333-
}
23342325
jl_value_t *bindings = (jl_value_t *)jl_atomic_load_relaxed(&mb_parent->bindings);
23352326
gc_assert_parent_validity((jl_value_t *)mb_parent, bindings);
23362327
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 *_
24612452
else if (foreign_alloc)
24622453
objprofile_count(jl_module_type, bits == GC_OLD_MARKED, sizeof(jl_module_t));
24632454
jl_module_t *mb_parent = (jl_module_t *)new_obj;
2464-
jl_svec_t *bindings = jl_atomic_load_relaxed(&mb_parent->bindings);
2465-
jl_binding_t **table = (jl_binding_t**)jl_svec_data(bindings);
2466-
size_t bsize = jl_svec_len(bindings);
2467-
uintptr_t nptr = ((bsize + mb_parent->usings.len + 1) << 2) | (bits & GC_OLD);
2468-
jl_binding_t **mb_begin = table + 1;
2469-
jl_binding_t **mb_end = table + bsize;
2470-
gc_mark_module_binding(ptls, mb_parent, mb_begin, mb_end, nptr, bits);
2455+
uintptr_t nptr = ((mb_parent->usings.len + 1) << 2) | (bits & GC_OLD);
2456+
gc_mark_module_binding(ptls, mb_parent, nptr, bits);
24712457
}
24722458
else if (vtag == jl_task_tag << 4) {
24732459
if (update_meta)

src/gc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ typedef struct _mallocarray_t {
146146

147147
// pool page metadata
148148
typedef struct _jl_gc_pagemeta_t {
149-
// next metadata structre in per-thread list
149+
// next metadata structure in per-thread list
150150
// or in one of the `jl_gc_global_page_pool_t`
151151
struct _jl_gc_pagemeta_t *next;
152152
// index of pool that owns this page

0 commit comments

Comments
 (0)