RFR (XS): 8148518: Unsafe.getCharUnaligned() loads aren't folded in case of -XX:-UseUnalignedAccesses
vladimir.x.ivanov at oracle.com
Mon Feb 15 19:01:47 UTC 2016
Current Unsafe::getCharUnaligned Java implementation isn't fully
optimized by C2: it never constant folds such loads from char fields.
C2 matches the types of a load and a location and does constant folding
only if they match. For getCharUnaligned it sees a load of a short
value, but the field is of type char.
The fix is to call Unsafe::getChar when offset is aligned. It doesn't
matter what is used for unaligned case, so I decided to keep makeShort().
Testing: failing test, JPRT.
PS: I don't update the test because it was refactored in Jigsaw . To
avoid unnecessary conflicts during merges, I filed an RFE  to adjust
the test once the fix and Jake are integrated.
More information about the hotspot-compiler-dev