From 0ccc3078639344c857e28e52110cf2057c10281d Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Tue, 26 Nov 2024 03:31:32 +0000 Subject: [PATCH 1/3] Adding GC: MMTk tag to banner when running with MMTk --- src/gc-interface.h | 7 +++++++ src/gc-mmtk.c | 4 ++++ src/gc-stock.c | 4 ++++ stdlib/REPL/src/REPL.jl | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/gc-interface.h b/src/gc-interface.h index 47baa4d7ead1a..e37010a3dfed4 100644 --- a/src/gc-interface.h +++ b/src/gc-interface.h @@ -100,6 +100,13 @@ 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); +// List of supported GCs +typedef enum { + STOCK = 0, + MMTK = 1, +} jl_gc_impl; +// Returns which GC implementation is being used according to the list of supported GCs +JL_DLLEXPORT jl_gc_impl jl_active_gc_impl(void); // ========================================================================= // // Metrics diff --git a/src/gc-mmtk.c b/src/gc-mmtk.c index 204bd2d349f97..cc049128792e7 100644 --- a/src/gc-mmtk.c +++ b/src/gc-mmtk.c @@ -310,6 +310,10 @@ JL_DLLEXPORT unsigned char jl_gc_pin_object(void* obj) { // GC Statistics // ========================================================================= // +JL_DLLEXPORT jl_gc_impl jl_active_gc_impl(void) { + return MMTK; +} + 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..cc54a88195dc5 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 jl_gc_impl jl_active_gc_impl(void) { + return STOCK; +} + #ifdef __cplusplus } #endif diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index ac791327e2d75..0f2426396b968 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -1771,6 +1771,14 @@ function banner(io::IO = stdout; short = false) end end + gc_string = "" + + with_mmtk = ccall(:jl_active_gc_impl, Cint, ()) + + if with_mmtk == 1 + gc_string = "(GC: MMTk)" + end + 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 +1792,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_string) $(d2)o$(tx) $(d4)o$(tx) | $(commit_string) """) else @@ -1793,7 +1801,7 @@ function banner(io::IO = stdout; short = false) $(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) | $(jl)_ _ _| |_ __ _$(tx) | Type \"?\" for help, \"]?\" for Pkg help. $(jl)| | | | | | |/ _` |$(tx) | - $(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date) + $(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date) $(gc_string) $(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string) $(jl)|__/$(tx) | @@ -1802,7 +1810,7 @@ function banner(io::IO = stdout; short = false) else if short print(io,""" - o | Version $(VERSION)$(commit_date) + o | Version $(VERSION)$(commit_date) $(gc_string) o o | $(commit_string) """) else @@ -1812,7 +1820,7 @@ function banner(io::IO = stdout; short = false) (_) | (_) (_) | _ _ _| |_ __ _ | Type \"?\" for help, \"]?\" for Pkg help. | | | | | | |/ _` | | - | | |_| | | | (_| | | Version $(VERSION)$(commit_date) + | | |_| | | | (_| | | Version $(VERSION)$(commit_date) $(gc_string) _/ |\\__'_|_|_|\\__'_| | $(commit_string) |__/ | From c61892ce8954d0fd16919bfa84e94c407c96bebf Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Tue, 26 Nov 2024 05:14:19 +0000 Subject: [PATCH 2/3] Getting info about MMTk build and printing it out --- src/gc-interface.h | 9 ++------- src/gc-mmtk.c | 5 +++-- src/gc-stock.c | 4 ++-- stdlib/REPL/src/REPL.jl | 24 +++++++++--------------- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/gc-interface.h b/src/gc-interface.h index e37010a3dfed4..ae41237a158ad 100644 --- a/src/gc-interface.h +++ b/src/gc-interface.h @@ -100,13 +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); -// List of supported GCs -typedef enum { - STOCK = 0, - MMTK = 1, -} jl_gc_impl; -// Returns which GC implementation is being used according to the list of supported GCs -JL_DLLEXPORT jl_gc_impl jl_active_gc_impl(void); +// 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 cc049128792e7..b0dcd47becc36 100644 --- a/src/gc-mmtk.c +++ b/src/gc-mmtk.c @@ -310,8 +310,9 @@ JL_DLLEXPORT unsigned char jl_gc_pin_object(void* obj) { // GC Statistics // ========================================================================= // -JL_DLLEXPORT jl_gc_impl jl_active_gc_impl(void) { - return MMTK; +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; diff --git a/src/gc-stock.c b/src/gc-stock.c index cc54a88195dc5..ac4c25c3647cd 100644 --- a/src/gc-stock.c +++ b/src/gc-stock.c @@ -4000,8 +4000,8 @@ JL_DLLEXPORT void jl_gc_wb2_slow(const void *parent, const void* ptr) JL_NOTSAFE { } -JL_DLLEXPORT jl_gc_impl jl_active_gc_impl(void) { - return STOCK; +JL_DLLEXPORT const char* jl_active_gc_impl(void) { + return ""; } #ifdef __cplusplus diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 0f2426396b968..f815570efe5c7 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -1771,13 +1771,7 @@ function banner(io::IO = stdout; short = false) end end - gc_string = "" - - with_mmtk = ccall(:jl_active_gc_impl, Cint, ()) - - if with_mmtk == 1 - gc_string = "(GC: MMTk)" - 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]))" @@ -1792,8 +1786,8 @@ function banner(io::IO = stdout; short = false) if short print(io,""" - $(d3)o$(tx) | Version $(VERSION)$(commit_date) $(gc_string) - $(d2)o$(tx) $(d4)o$(tx) | $(commit_string) + $(d3)o$(tx) | Version $(VERSION)$(commit_date) $(gc_version) + $(d2)o$(tx) $(d4)o$(tx) | $(commit_string) """) else print(io,""" $(d3)_$(tx) @@ -1801,17 +1795,17 @@ function banner(io::IO = stdout; short = false) $(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) | $(jl)_ _ _| |_ __ _$(tx) | Type \"?\" for help, \"]?\" for Pkg help. $(jl)| | | | | | |/ _` |$(tx) | - $(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date) $(gc_string) + $(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) $(gc_string) - o o | $(commit_string) + o | Version $(VERSION)$(commit_date) + o o | $(commit_string) """) else print(io,""" @@ -1820,9 +1814,9 @@ function banner(io::IO = stdout; short = false) (_) | (_) (_) | _ _ _| |_ __ _ | Type \"?\" for help, \"]?\" for Pkg help. | | | | | | |/ _` | | - | | |_| | | | (_| | | Version $(VERSION)$(commit_date) $(gc_string) + | | |_| | | | (_| | | Version $(VERSION)$(commit_date) _/ |\\__'_|_|_|\\__'_| | $(commit_string) - |__/ | + |__/ | $(gc_version) """) end From abe8d0c741a62c09cef57b85333da607a7e595fe Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Tue, 26 Nov 2024 05:17:01 +0000 Subject: [PATCH 3/3] Fixing whitespace --- stdlib/REPL/src/REPL.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index f815570efe5c7..ec38674a96482 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -1787,7 +1787,7 @@ function banner(io::IO = stdout; short = false) if short print(io,""" $(d3)o$(tx) | Version $(VERSION)$(commit_date) $(gc_version) - $(d2)o$(tx) $(d4)o$(tx) | $(commit_string) + $(d2)o$(tx) $(d4)o$(tx) | $(commit_string) """) else print(io,""" $(d3)_$(tx) @@ -1804,8 +1804,8 @@ function banner(io::IO = stdout; short = false) else if short print(io,""" - o | Version $(VERSION)$(commit_date) - o o | $(commit_string) + o | Version $(VERSION)$(commit_date) $(gc_version) + o o | $(commit_string) """) else print(io,"""