Skip to content

Commit 85301f9

Browse files
d-nettoKristofferC
authored andcommitted
gc: faster invalid object lookup in conservative GC (#50599)
Optimizes invalid object lookup in conservative GC by just looking at the page metadata and GC bits. (cherry picked from commit c82656d)
1 parent a4ba969 commit 85301f9

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/gc.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,18 +4067,11 @@ JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p)
40674067
// before the freelist pointer was either live during the last
40684068
// sweep or has been allocated since.
40694069
if (gc_page_data(cell) == gc_page_data(pool->freelist)
4070-
&& (char *)cell < (char *)pool->freelist) {
4070+
&& (char *)cell < (char *)pool->freelist)
40714071
goto valid_object;
4072-
}
4073-
else {
4074-
jl_taggedvalue_t *v = pool->freelist;
4075-
while (v != NULL) {
4076-
if (v == cell) {
4077-
return NULL;
4078-
}
4079-
v = v->next;
4080-
}
4081-
}
4072+
// already skipped marked or old objects above, so here
4073+
// the age bits are 0, thus the object is on the freelist
4074+
return NULL;
40824075
// Not a freelist entry, therefore a valid object.
40834076
valid_object:
40844077
// We have to treat objects with type `jl_buff_tag` differently,

0 commit comments

Comments
 (0)