From 5cacfa481ccb467a14cdba322c65fd7805d6d8f6 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 27 Nov 2024 09:56:53 +1100 Subject: [PATCH] Adding `GC: MMTk` tag to Julia's banner when building with MMTk (#72) * Adding GC: MMTk tag to banner when running with MMTk * Getting info about MMTk build and printing it out * Fixing whitespace --- src/gc-interface.h | 2 ++ src/gc-mmtk.c | 5 +++++ src/gc-stock.c | 4 ++++ stdlib/REPL/src/REPL.jl | 10 ++++++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gc-interface.h b/src/gc-interface.h index 47baa4d7ead1a..ae41237a158ad 100644 --- a/src/gc-interface.h +++ b/src/gc-interface.h @@ -100,6 +100,8 @@ JL_DLLEXPORT void jl_gc_collect(jl_gc_collection_t collection); JL_DLLEXPORT int gc_is_collector_thread(int tid) JL_NOTSAFEPOINT; // Pinning objects; Returns whether the object has been pinned by this call. JL_DLLEXPORT unsigned char jl_gc_pin_object(void* obj); +// Returns the version of which GC implementation is being used according to the list of supported GCs +JL_DLLEXPORT const char* jl_active_gc_impl(void); // ========================================================================= // // Metrics diff --git a/src/gc-mmtk.c b/src/gc-mmtk.c index 204bd2d349f97..b0dcd47becc36 100644 --- a/src/gc-mmtk.c +++ b/src/gc-mmtk.c @@ -310,6 +310,11 @@ JL_DLLEXPORT unsigned char jl_gc_pin_object(void* obj) { // GC Statistics // ========================================================================= // +JL_DLLEXPORT const char* jl_active_gc_impl(void) { + const char* mmtk_version = get_mmtk_version(); + return mmtk_version; +} + int64_t last_gc_total_bytes = 0; int64_t last_live_bytes = 0; // live_bytes at last collection int64_t live_bytes = 0; diff --git a/src/gc-stock.c b/src/gc-stock.c index ab9784c985131..ac4c25c3647cd 100644 --- a/src/gc-stock.c +++ b/src/gc-stock.c @@ -4000,6 +4000,10 @@ JL_DLLEXPORT void jl_gc_wb2_slow(const void *parent, const void* ptr) JL_NOTSAFE { } +JL_DLLEXPORT const char* jl_active_gc_impl(void) { + return ""; +} + #ifdef __cplusplus } #endif diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index ac791327e2d75..ec38674a96482 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -1771,6 +1771,8 @@ function banner(io::IO = stdout; short = false) end end + gc_version = unsafe_string(ccall(:jl_active_gc_impl, Ptr{UInt8}, ())) + commit_date = isempty(Base.GIT_VERSION_INFO.date_string) ? "" : " ($(split(Base.GIT_VERSION_INFO.date_string)[1]))" if get(io, :color, false)::Bool @@ -1784,7 +1786,7 @@ function banner(io::IO = stdout; short = false) if short print(io,""" - $(d3)o$(tx) | Version $(VERSION)$(commit_date) + $(d3)o$(tx) | Version $(VERSION)$(commit_date) $(gc_version) $(d2)o$(tx) $(d4)o$(tx) | $(commit_string) """) else @@ -1795,14 +1797,14 @@ function banner(io::IO = stdout; short = false) $(jl)| | | | | | |/ _` |$(tx) | $(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date) $(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string) - $(jl)|__/$(tx) | + $(jl)|__/$(tx) | $(gc_version) """) end else if short print(io,""" - o | Version $(VERSION)$(commit_date) + o | Version $(VERSION)$(commit_date) $(gc_version) o o | $(commit_string) """) else @@ -1814,7 +1816,7 @@ function banner(io::IO = stdout; short = false) | | | | | | |/ _` | | | | |_| | | | (_| | | Version $(VERSION)$(commit_date) _/ |\\__'_|_|_|\\__'_| | $(commit_string) - |__/ | + |__/ | $(gc_version) """) end