diff --git a/base/Base.jl b/base/Base.jl index 63898854b9fac..379347f027f69 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -128,7 +128,7 @@ include("sysinfo.jl") include("libc.jl") using .Libc: getpid, gethostname, time, memcpy, memset, memmove, memcmp -const USING_STOCK_GC = occursin("stock", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ()))) +const USING_STOCK_GC = occursin("stock", GC.gc_active_impl()) # These used to be in build_h.jl and are retained for backwards compatibility. # NOTE: keep in sync with `libblastrampoline_jll.libblastrampoline`. diff --git a/base/gcutils.jl b/base/gcutils.jl index 60b8ecdd17d65..d5e6f4597739f 100644 --- a/base/gcutils.jl +++ b/base/gcutils.jl @@ -281,4 +281,15 @@ function logging_enabled() ccall(:jl_is_gc_logging_enabled, Cint, ()) != 0 end +""" + GC.gc_active_impl() + +Return a string stating which GC implementation is being used and possibly +its version according to the list of supported GCs +""" +function gc_active_impl() + unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ())) +end + + end # module GC diff --git a/test/checked.jl b/test/checked.jl index 4031918a38730..b93c8796162c5 100644 --- a/test/checked.jl +++ b/test/checked.jl @@ -331,8 +331,12 @@ end @test checked_pow(BigInt(2), 2) == BigInt(4) @test checked_pow(BigInt(2), 100) == BigInt(1267650600228229401496703205376) - # Perf test: Make sure BigInts allocs don't scale with the power: - @test @allocations(checked_pow(BigInt(2), 2)) ≈ @allocations(checked_pow(BigInt(2), 10000)) rtol=0.9 + # FIXME: Issue #57103: the following test may fail because + # allocation may not be logged via MMTk's fastpath allocation + @static if Base.USING_STOCK_GC + # Perf test: Make sure BigInts allocs don't scale with the power: + @test @allocations(checked_pow(BigInt(2), 2)) ≈ @allocations(checked_pow(BigInt(2), 10000)) rtol=0.9 + end end @testset "Additional tests" begin diff --git a/test/gc.jl b/test/gc.jl index 18a3a3aa54ffc..3e9f03ef40d92 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -17,9 +17,6 @@ function run_gctest(file) end end -#FIXME: Issue #57103 disabling tests for MMTk, since -# they rely on information that is specific to the stock GC. -@static if Base.USING_STOCK_GC function run_nonzero_page_utilization_test() GC.gc() page_utilization = Base.gc_page_utilization_data() @@ -27,6 +24,16 @@ function run_nonzero_page_utilization_test() @test any(page_utilization .> 0) end +function run_pg_size_test() + page_size = @ccall jl_get_pg_size()::UInt64 + # supported page sizes: 4KB and 16KB + @test page_size == (1 << 12) || page_size == (1 << 14) +end + +function issue_54275_alloc_string() + String(UInt8['a' for i in 1:10000000]) +end + function issue_54275_test() GC.gc(true) baseline = Base.gc_live_bytes() @@ -48,17 +55,6 @@ function full_sweep_reasons_test() @test reasons[:FULL_SWEEP_REASON_FORCED_FULL_SWEEP] >= 1 @test keys(reasons) == Set(Base.FULL_SWEEP_REASONS) end -end - -function run_pg_size_test() - page_size = @ccall jl_get_pg_size()::UInt64 - # supported page sizes: 4KB and 16KB - @test page_size == (1 << 12) || page_size == (1 << 14) -end - -function issue_54275_alloc_string() - String(UInt8['a' for i in 1:10000000]) -end # !!! note: # Since we run our tests on 32bit OS as well we confine ourselves @@ -71,6 +67,9 @@ end run_gctest("gc/chunks.jl") end +#FIXME: Issue #57103 disabling tests for MMTk, since +# they rely on information that is specific to the stock GC. +@static if Base.USING_STOCK_GC @testset "GC page metrics" begin run_nonzero_page_utilization_test() run_pg_size_test() @@ -80,13 +79,14 @@ end issue_54275_test() end -@testset "Base.GC docstrings" begin - @test isempty(Docs.undocumented_names(GC)) -end - @testset "Full GC reasons" begin full_sweep_reasons_test() end +end + +@testset "Base.GC docstrings" begin + @test isempty(Docs.undocumented_names(GC)) +end #testset doesn't work here because this needs to run in top level #Check that we ensure objects in toplevel exprs are rooted