Skip to content

Commit

Permalink
Adding GC: MMTk tag to Julia's banner when building with MMTk (#72)
Browse files Browse the repository at this point in the history
* Adding GC: MMTk tag to banner when running with MMTk

* Getting info about MMTk build and printing it out

* Fixing whitespace
  • Loading branch information
udesou authored Nov 26, 2024
1 parent 7a953be commit 5cacfa4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/gc-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/gc-mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/gc-stock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -1814,7 +1816,7 @@ function banner(io::IO = stdout; short = false)
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version $(VERSION)$(commit_date)
_/ |\\__'_|_|_|\\__'_| | $(commit_string)
|__/ |
|__/ | $(gc_version)
""")
end
Expand Down

0 comments on commit 5cacfa4

Please sign in to comment.