RFR 8169389 : Use a bitmap to control StackTraceElement::toString format and save footprint
brent.christian at oracle.com
Wed Dec 7 21:56:58 UTC 2016
Please review my fix for 8169389.
The addition of classloader names (JDK-6749237) updated the format of
StackTraceElement.toString(). A field was added to store the
"[[class-loader-name]/[module-name[@module-version]]]" portion of the
Instead of storing a String, we can cut down on footprint by using a
bitfield to indicate which fields to include in the toString() output.
Looking at the heap usage of a simple test case indicates ~25% reduction
in space used by Throwable's StackTraceElement. (Of course this could
vary quite a bit, depending on the specifics of the call stack.)
The additional byte field does not increase the instance size of a
StackTraceElement; it is within space already lost for alignment (per
linux_x64 w/ CompressedOops).
While working on this, it was noticed that with the new toString()
format, there are circumstances in which two StackTraceElements can be
equals(), but return different values from toString(). I thought it was
worth updating the JavaDoc to call out this unusual possibility.
Likewise, there can be information reflected in the StackTraceElement
getter methods that is not reflected in the toString() value. I updated
the test code to check for this.
More information about the core-libs-dev