Skip to content

Commit

Permalink
gc: faster invalid object lookup in conservative GC (#50599)
Browse files Browse the repository at this point in the history
Optimizes invalid object lookup in conservative GC by just looking at the
page metadata and GC bits.
  • Loading branch information
d-netto authored Jul 22, 2023
1 parent bf00ff4 commit c82656d
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4070,18 +4070,11 @@ JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p)
// before the freelist pointer was either live during the last
// sweep or has been allocated since.
if (gc_page_data(cell) == gc_page_data(pool->freelist)
&& (char *)cell < (char *)pool->freelist) {
&& (char *)cell < (char *)pool->freelist)
goto valid_object;
}
else {
jl_taggedvalue_t *v = pool->freelist;
while (v != NULL) {
if (v == cell) {
return NULL;
}
v = v->next;
}
}
// already skipped marked or old objects above, so here
// the age bits are 0, thus the object is on the freelist
return NULL;
// Not a freelist entry, therefore a valid object.
valid_object:
// We have to treat objects with type `jl_buff_tag` differently,
Expand Down

0 comments on commit c82656d

Please sign in to comment.