RFR (S) 8150180: String.value contents should be trusted

Aleksey Shipilev aleksey.shipilev at oracle.com
Fri Feb 19 11:55:34 UTC 2016


Please review a simple performance improvement in Strings:

In short, we want VM to trust constant String contents, so that
"Foo".charAt(0) is folded. As far as current Hotspot goes, this is only
achievable with @Stable -- we need to trust the array contents:

This, however, steps into the compiler bug caused by StringUTF16.getChar
intrinsic producing a mismatched load, that is then folded incorrectly.
So we instead rely on Java level folding in cases like these:

...and it works:

While VM change looks like a workaround, Vladimir I. and me concluded
that @Stable folding code should just reject folding mismatched loads to
begin with. So, getChar intrinsic change is the actual fix. Vladimir I.
ought to add more assertions in @Stable folding code separately:

Since this issue might trigger compiler bugs, I would like to push
through hs-comp to pass compiler nightlies.


More information about the core-libs-dev mailing list