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 committed Dec 2, 2024
1 parent e0110b7 commit b1c2283
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/gc-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/gc-mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/gc-stock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2605,8 +2605,7 @@ bool LateLowerGCFrame::runOnFunction(Function &F, bool *CFGModified) {
if (auto *CI = dyn_cast<CallInst>(*it)) {
*CFGModified = true;

Value *callee = CI->getCalledOperand();
assert(callee == GCAllocBytes);
assert(CI->getCalledOperand() == GCAllocBytes);

auto newI = lowerGCAllocBytesLate(CI, F);
if (newI != CI) {
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 b1c2283

Please sign in to comment.