Skip to content

Commit f68c919

Browse files
vtjnashKristofferC
authored and
KristofferC
committed
gc-ext: only sweep unmarked objects (#45035)
This prior conditional was a fixed constant branch, so this seems more like the intent. (cherry picked from commit ac51add)
1 parent afffbfd commit f68c919

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/gc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,20 +548,21 @@ JL_DLLEXPORT void jl_finalize_th(jl_ptls_t ptls, jl_value_t *o)
548548
arraylist_free(&copied_list);
549549
}
550550

551+
// explicitly scheduled objects for the sweepfunc callback
551552
static void gc_sweep_foreign_objs_in_list(arraylist_t *objs)
552553
{
553554
size_t p = 0;
554555
for (size_t i = 0; i < objs->len; i++) {
555-
jl_value_t *v = (jl_value_t *)(objs->items[i]);
556-
jl_datatype_t *t = (jl_datatype_t *)(jl_typeof(v));
556+
jl_value_t *v = (jl_value_t*)(objs->items[i]);
557+
jl_datatype_t *t = (jl_datatype_t*)(jl_typeof(v));
557558
const jl_datatype_layout_t *layout = t->layout;
558559
jl_fielddescdyn_t *desc = (jl_fielddescdyn_t*)jl_dt_layout_fields(layout);
559-
if (!gc_ptr_tag(v, 1)) {
560+
561+
int bits = jl_astaggedvalue(v)->bits.gc;
562+
if (!gc_marked(bits))
560563
desc->sweepfunc(v);
561-
}
562-
else {
564+
else
563565
objs->items[p++] = v;
564-
}
565566
}
566567
objs->len = p;
567568
}

test/gcext/gcext.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,10 @@ void sweep_stack_data(jl_value_t *p)
561561
{
562562
obj_sweeps++;
563563
dynstack_t *stk = (dynstack_t *)p;
564-
if (stk->size > stk->capacity)
565-
jl_error("internal error during sweeping");
564+
if (stk->size > stk->capacity) {
565+
assert(0 && "internal error during sweeping");
566+
abort();
567+
}
566568
}
567569

568570
// Safely execute Julia code

0 commit comments

Comments
 (0)