Skip to content

Commit 519c8fb

Browse files
udesouLuis Eduardo de Souza Amorim
authored and
Luis Eduardo de Souza Amorim
committed
Adding GC.gc_active_impl
1 parent fb9029d commit 519c8fb

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

base/Base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ include("sysinfo.jl")
128128
include("libc.jl")
129129
using .Libc: getpid, gethostname, time, memcpy, memset, memmove, memcmp
130130

131-
const USING_STOCK_GC = occursin("stock", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ())))
131+
const USING_STOCK_GC = occursin("stock", GC.gc_active_impl())
132132

133133
# These used to be in build_h.jl and are retained for backwards compatibility.
134134
# NOTE: keep in sync with `libblastrampoline_jll.libblastrampoline`.

base/gcutils.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,15 @@ function logging_enabled()
281281
ccall(:jl_is_gc_logging_enabled, Cint, ()) != 0
282282
end
283283

284+
"""
285+
GC.gc_active_impl()
286+
287+
Return a string stating which GC implementation is being used and possibly
288+
its version according to the list of supported GCs
289+
"""
290+
function gc_active_impl()
291+
unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ()))
292+
end
293+
294+
284295
end # module GC

test/checked.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,12 @@ end
331331
@test checked_pow(BigInt(2), 2) == BigInt(4)
332332
@test checked_pow(BigInt(2), 100) == BigInt(1267650600228229401496703205376)
333333

334-
# Perf test: Make sure BigInts allocs don't scale with the power:
335-
@test @allocations(checked_pow(BigInt(2), 2)) @allocations(checked_pow(BigInt(2), 10000)) rtol=0.9
334+
# FIXME: Issue #57103: the following test may fail because
335+
# allocation may not be logged via MMTk's fastpath allocation
336+
@static if Base.USING_STOCK_GC
337+
# Perf test: Make sure BigInts allocs don't scale with the power:
338+
@test @allocations(checked_pow(BigInt(2), 2)) @allocations(checked_pow(BigInt(2), 10000)) rtol=0.9
339+
end
336340
end
337341

338342
@testset "Additional tests" begin

test/gc.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ function run_gctest(file)
1717
end
1818
end
1919

20-
#FIXME: Issue #57103 disabling tests for MMTk, since
21-
# they rely on information that is specific to the stock GC.
22-
@static if Base.USING_STOCK_GC
2320
function run_nonzero_page_utilization_test()
2421
GC.gc()
2522
page_utilization = Base.gc_page_utilization_data()
@@ -42,14 +39,6 @@ function issue_54275_test()
4239
@test !live_bytes_has_grown_too_much
4340
end
4441

45-
function full_sweep_reasons_test()
46-
GC.gc()
47-
reasons = Base.full_sweep_reasons()
48-
@test reasons[:FULL_SWEEP_REASON_FORCED_FULL_SWEEP] >= 1
49-
@test keys(reasons) == Set(Base.FULL_SWEEP_REASONS)
50-
end
51-
end
52-
5342
function run_pg_size_test()
5443
page_size = @ccall jl_get_pg_size()::UInt64
5544
# supported page sizes: 4KB and 16KB
@@ -60,6 +49,13 @@ function issue_54275_alloc_string()
6049
String(UInt8['a' for i in 1:10000000])
6150
end
6251

52+
function full_sweep_reasons_test()
53+
GC.gc()
54+
reasons = Base.full_sweep_reasons()
55+
@test reasons[:FULL_SWEEP_REASON_FORCED_FULL_SWEEP] >= 1
56+
@test keys(reasons) == Set(Base.FULL_SWEEP_REASONS)
57+
end
58+
6359
# !!! note:
6460
# Since we run our tests on 32bit OS as well we confine ourselves
6561
# to parameters that allocate about 512MB of objects. Max RSS is lower
@@ -71,6 +67,9 @@ end
7167
run_gctest("gc/chunks.jl")
7268
end
7369

70+
#FIXME: Issue #57103 disabling tests for MMTk, since
71+
# they rely on information that is specific to the stock GC.
72+
@static if Base.USING_STOCK_GC
7473
@testset "GC page metrics" begin
7574
run_nonzero_page_utilization_test()
7675
run_pg_size_test()
@@ -80,13 +79,14 @@ end
8079
issue_54275_test()
8180
end
8281

83-
@testset "Base.GC docstrings" begin
84-
@test isempty(Docs.undocumented_names(GC))
85-
end
86-
8782
@testset "Full GC reasons" begin
8883
full_sweep_reasons_test()
8984
end
85+
end
86+
87+
@testset "Base.GC docstrings" begin
88+
@test isempty(Docs.undocumented_names(GC))
89+
end
9090

9191
#testset doesn't work here because this needs to run in top level
9292
#Check that we ensure objects in toplevel exprs are rooted

0 commit comments

Comments
 (0)