Skip to content

Commit

Permalink
use atomic-fetch-and in write barrier slow-path (#54744)
Browse files Browse the repository at this point in the history
Not sure why we're not using it, but we probably should.
  • Loading branch information
d-netto authored Jun 10, 2024
1 parent 5dfd57d commit fc2cafc
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 @@ -1918,9 +1918,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_relaxed((_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 fc2cafc

Please sign in to comment.