Skip to content

Commit

Permalink
gc-ext: only sweep unmarked objects (#45035)
Browse files Browse the repository at this point in the history
This prior conditional was a fixed constant branch, so this seems more like the intent.

(cherry picked from commit ac51add)
  • Loading branch information
vtjnash authored and staticfloat committed Dec 22, 2022
1 parent dcac96e commit c86451f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,21 @@ JL_DLLEXPORT void jl_finalize_th(jl_ptls_t ptls, jl_value_t *o)
arraylist_free(&copied_list);
}

// explicitly scheduled objects for the sweepfunc callback
static void gc_sweep_foreign_objs_in_list(arraylist_t *objs)
{
size_t p = 0;
for (size_t i = 0; i < objs->len; i++) {
jl_value_t *v = (jl_value_t *)(objs->items[i]);
jl_datatype_t *t = (jl_datatype_t *)(jl_typeof(v));
jl_value_t *v = (jl_value_t*)(objs->items[i]);
jl_datatype_t *t = (jl_datatype_t*)(jl_typeof(v));
const jl_datatype_layout_t *layout = t->layout;
jl_fielddescdyn_t *desc = (jl_fielddescdyn_t*)jl_dt_layout_fields(layout);
if (!gc_ptr_tag(v, 1)) {

int bits = jl_astaggedvalue(v)->bits.gc;
if (!gc_marked(bits))
desc->sweepfunc(v);
}
else {
else
objs->items[p++] = v;
}
}
objs->len = p;
}
Expand Down
6 changes: 4 additions & 2 deletions test/gcext/gcext.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,10 @@ void sweep_stack_data(jl_value_t *p)
{
obj_sweeps++;
dynstack_t *stk = (dynstack_t *)p;
if (stk->size > stk->capacity)
jl_error("internal error during sweeping");
if (stk->size > stk->capacity) {
assert(0 && "internal error during sweeping");
abort();
}
}

// Safely execute Julia code
Expand Down

0 comments on commit c86451f

Please sign in to comment.