RFR: 8221836: Avoid recalculating String.hash when zero
claes.redestad at oracle.com
Mon Apr 8 08:41:23 UTC 2019
by adding a bit to String that is true iff String.hash has been
calculated as being 0, we can get rid of the corner case where such hash
codes are recalculated on every call.
Peter Levart came up with a elegant scheme for ensuring that we can keep
using non-volatile stores without explicit fencing and still reap the
benefits of this, and I've synced up the hotspot code that deals with
the String.hash value to mirror that logic.
Since there exists small padding gaps in the current object layout of
strings (on all VM bitness and compressed oops varieties), adding this
boolean does not add any extra footprint per String instance.
Testing: tier1-3, verified a speed-up in targeted microbenchmarks.
More information about the core-libs-dev