Skip to content

Commit

Permalink
use atomic-fetch-and in write barrier slow-path
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto committed Jun 9, 2024
1 parent 77c28ab commit e72e694
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1917,9 +1917,7 @@ JL_DLLEXPORT void jl_gc_queue_root(const jl_value_t *ptr)
// We need to ensure that objects are in the remset at
// most once, since the mark phase may update page metadata,
// which is not idempotent. See comments in https://github.com/JuliaLang/julia/issues/50419
uintptr_t header = jl_atomic_load_relaxed((_Atomic(uintptr_t) *)&o->header);
header &= ~GC_OLD; // clear the age bit
header = jl_atomic_exchange_relaxed((_Atomic(uintptr_t) *)&o->header, header);
uintptr_t header = jl_atomic_fetch_and((_Atomic(uintptr_t) *)&o->header, ~GC_OLD);
if (header & GC_OLD) { // write barrier has not been triggered in this object yet
arraylist_push(ptls->heap.remset, (jl_value_t*)ptr);
ptls->heap.remset_nptr++; // conservative
Expand Down

0 comments on commit e72e694

Please sign in to comment.