Skip to content

Commit e217a22

Browse files
vtjnashKristofferC
authored andcommitted
array: fix some atomic orderings (#48888)
(cherry picked from commit 6124987)
1 parent 278f86a commit e217a22

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

base/array.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ function _unsetindex!(A::Array{T}, i::Int) where {T}
177177
t = @_gc_preserve_begin A
178178
p = Ptr{Ptr{Cvoid}}(pointer(A, i))
179179
if !allocatedinline(T)
180-
unsafe_store!(p, C_NULL)
180+
Intrinsics.atomic_pointerset(p, C_NULL, :monotonic)
181181
elseif T isa DataType
182182
if !datatype_pointerfree(T)
183-
for j = 1:(Core.sizeof(T) ÷ Core.sizeof(Ptr{Cvoid}))
184-
unsafe_store!(p, C_NULL, j)
183+
for j = 1:Core.sizeof(Ptr{Cvoid}):Core.sizeof(T)
184+
Intrinsics.atomic_pointerset(p + j - 1, C_NULL, :monotonic)
185185
end
186186
end
187187
end

src/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ JL_DLLEXPORT void jl_arrayunset(jl_array_t *a, size_t i)
627627
if (i >= jl_array_len(a))
628628
jl_bounds_error_int((jl_value_t*)a, i + 1);
629629
if (a->flags.ptrarray)
630-
jl_atomic_store_release(((_Atomic(jl_value_t*)*)a->data) + i, NULL);
630+
jl_atomic_store_relaxed(((_Atomic(jl_value_t*)*)a->data) + i, NULL);
631631
else if (a->flags.hasptr) {
632632
size_t elsize = a->elsize;
633633
jl_assume(elsize >= sizeof(void*) && elsize % sizeof(void*) == 0);

src/datatype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ JL_DLLEXPORT jl_typename_t *jl_new_typename_in(jl_sym_t *name, jl_module_t *modu
6868
tn->name = name;
6969
tn->module = module;
7070
tn->wrapper = NULL;
71-
jl_atomic_store_release(&tn->Typeofwrapper, NULL);
71+
jl_atomic_store_relaxed(&tn->Typeofwrapper, NULL);
7272
jl_atomic_store_relaxed(&tn->cache, jl_emptysvec);
7373
jl_atomic_store_relaxed(&tn->linearcache, jl_emptysvec);
7474
tn->names = NULL;

0 commit comments

Comments
 (0)