RFR: 8353559: Restructure CollectedHeap error printing
Joel Sikström
jsikstro at openjdk.org
Wed Apr 2 18:20:00 UTC 2025
Calling Universe::heap()->print_on_error() gets dispatched to the most specific implementation, which for some GCs is their own implementation instead of the default in CollectedHeap. Each GC-specific implementation calls back to CollectedHeap::print_on_error(), which then dispatches back into the specific implementation of print_on(). This is kind of awkward and creates a call-chain that's not straightforward to wrap your head around, jumping back and forth via CollectedHeap and the specific implementation.
To make the call-chain cleaner, I have made print_on_error() a pure virtual method in CollectedHeap, and implemented print_on_error() in each GC's implementation of CollectedHeap. In addition, I have removed print_extended_on() from CollectedHeap and implemented that for the GCs that actually need/use it.
Removing the usage of the common print_on_error() also means that GCs that do not print anything interesting for their barrier set can omit this. So, I've removed it from ZGC and Shenandoah.
To make print_on_error() consistent with print_on(), I have moved the printing of "Heap:" to the caller(s) of print_on_error() (only inside vmError.cpp). This is a trivial change for all GCs except ZGC, which requires some restructuring in its error printing.
The old and new printing orders are shown below for ZGC:
# Old
<precious log>
<zgc globals>
<heap>
<zgc page table>
<barrier set>
<polling page>
# New
<precious log>
<heap>
<zgc globals>
<zgc page table>
<polling page>
Testing:
* GHA
* Tiers 1 & 2
* Manually verified that printing still works and outputs the intended information via running the following commands and comparing the output.
../fastdebug-old/jdk/bin/java -XX:ErrorHandlerTest=14 -XX:+ErrorFileToStdout -XX:+Use${gc}GC --version > ${gc}_old.txt
../fastdebug-new/jdk/bin/java -XX:ErrorHandlerTest=14 -XX:+ErrorFileToStdout -XX:+Use${gc}GC --version > ${gc}_new.txt
-------------
Commit messages:
- Copyright years
- 8353559: Restructure CollectedHeap error printing
Changes: https://git.openjdk.org/jdk/pull/24387/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24387&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8353559
Stats: 141 lines in 16 files changed: 75 ins; 52 del; 14 mod
Patch: https://git.openjdk.org/jdk/pull/24387.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24387/head:pull/24387
PR: https://git.openjdk.org/jdk/pull/24387
More information about the hotspot-gc-dev
mailing list