Skip to content

Commit 788eff9

Browse files
authored
Correctly port realloc from 1.9 to 1.10 (#52929)
I think when we backed off the new heuristics for 1.10 this got missed in the meanwhile. Should fix #52923
1 parent aaaf5de commit 788eff9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/gc.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,7 +3729,10 @@ JL_DLLEXPORT void *jl_gc_counted_realloc_with_old_size(void *p, size_t old, size
37293729
if (data != NULL && pgcstack != NULL && ct->world_age) {
37303730
jl_ptls_t ptls = ct->ptls;
37313731
maybe_collect(ptls);
3732-
if (!(sz < old))
3732+
if (sz < old)
3733+
jl_atomic_store_relaxed(&ptls->gc_num.freed,
3734+
jl_atomic_load_relaxed(&ptls->gc_num.freed) + (old - sz));
3735+
else
37333736
jl_atomic_store_relaxed(&ptls->gc_num.allocd,
37343737
jl_atomic_load_relaxed(&ptls->gc_num.allocd) + (sz - old));
37353738
jl_atomic_store_relaxed(&ptls->gc_num.realloc,
@@ -3856,7 +3859,10 @@ static void *gc_managed_realloc_(jl_ptls_t ptls, void *d, size_t sz, size_t olds
38563859
ptls->gc_cache.perm_scanned_bytes += allocsz - oldsz;
38573860
inc_live_bytes(allocsz - oldsz);
38583861
}
3859-
else if (!(allocsz < oldsz))
3862+
else if (allocsz < oldsz)
3863+
jl_atomic_store_relaxed(&ptls->gc_num.freed,
3864+
jl_atomic_load_relaxed(&ptls->gc_num.freed) + (oldsz - allocsz));
3865+
else
38603866
jl_atomic_store_relaxed(&ptls->gc_num.allocd,
38613867
jl_atomic_load_relaxed(&ptls->gc_num.allocd) + (allocsz - oldsz));
38623868
jl_atomic_store_relaxed(&ptls->gc_num.realloc,

0 commit comments

Comments
 (0)