Skip to content

Commit

Permalink
refactor GC scanning code to reflect jl_binding_t are now first class (
Browse files Browse the repository at this point in the history
…#51035)

Removes some redundant code.

Credits to Eduardo for pointing this out in the GC meeting.

(cherry picked from commit 5bc558c)
  • Loading branch information
d-netto authored and KristofferC committed Nov 27, 2023
1 parent 9fd9746 commit 4cee83c
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2278,19 +2278,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);
Expand Down Expand Up @@ -2422,13 +2413,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)
Expand Down

0 comments on commit 4cee83c

Please sign in to comment.