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.
  • Loading branch information
d-netto authored Aug 26, 2023
1 parent 6097140 commit 5bc558c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
20 changes: 3 additions & 17 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5bc558c

Please sign in to comment.