Skip to content

Commit c82656d

Browse files
authored
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.
1 parent bf00ff4 commit c82656d

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
@@ -4070,18 +4070,11 @@ JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p)
40704070
// before the freelist pointer was either live during the last
40714071
// sweep or has been allocated since.
40724072
if (gc_page_data(cell) == gc_page_data(pool->freelist)
4073-
&& (char *)cell < (char *)pool->freelist) {
4073+
&& (char *)cell < (char *)pool->freelist)
40744074
goto valid_object;
4075-
}
4076-
else {
4077-
jl_taggedvalue_t *v = pool->freelist;
4078-
while (v != NULL) {
4079-
if (v == cell) {
4080-
return NULL;
4081-
}
4082-
v = v->next;
4083-
}
4084-
}
4075+
// already skipped marked or old objects above, so here
4076+
// the age bits are 0, thus the object is on the freelist
4077+
return NULL;
40854078
// Not a freelist entry, therefore a valid object.
40864079
valid_object:
40874080
// We have to treat objects with type `jl_buff_tag` differently,

0 commit comments

Comments
 (0)