From b1c2283bbf5128b4352026e819619a3fa3571698 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 ++++ src/llvm-late-gc-lowering.cpp | 3 +-- stdlib/REPL/src/REPL.jl | 10 ++++++---- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gc-interface.h b/src/gc-interface.h index 26c59496a721b8..74956f795d8206 100644 --- a/src/gc-interface.h +++ b/src/gc-interface.h @@ -98,6 +98,8 @@ JL_DLLEXPORT void jl_gc_set_max_memory(uint64_t max_mem); JL_DLLEXPORT void jl_gc_collect(jl_gc_collection_t collection); // Returns whether the thread with `tid` is a collector thread JL_DLLEXPORT int gc_is_collector_thread(int tid) JL_NOTSAFEPOINT; +// 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 7ad5ffc2498d73..65651f9c720db5 100644 --- a/src/gc-mmtk.c +++ b/src/gc-mmtk.c @@ -306,6 +306,11 @@ JL_DLLEXPORT void jl_gc_prepare_to_collect(void) // 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 2ca234e750485e..c0bfc26cabc6bd 100644 --- a/src/gc-stock.c +++ b/src/gc-stock.c @@ -3993,6 +3993,10 @@ void jl_gc_notify_image_load(const char* img_data, size_t len) // Do nothing } +JL_DLLEXPORT const char* jl_active_gc_impl(void) { + return ""; +} + #ifdef __cplusplus } #endif diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp index bf4ae7b2f74034..17cd5f3fbf8084 100644 --- a/src/llvm-late-gc-lowering.cpp +++ b/src/llvm-late-gc-lowering.cpp @@ -2605,8 +2605,7 @@ bool LateLowerGCFrame::runOnFunction(Function &F, bool *CFGModified) { if (auto *CI = dyn_cast(*it)) { *CFGModified = true; - Value *callee = CI->getCalledOperand(); - assert(callee == GCAllocBytes); + assert(CI->getCalledOperand() == GCAllocBytes); auto newI = lowerGCAllocBytesLate(CI, F); if (newI != CI) { diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 50f610ff3b3e8b..a4becf2755a669 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