[9] RFR (XS): 8148518: Unsafe.getCharUnaligned() loads aren't folded in case of -XX:-UseUnalignedAccesses

Vladimir Kozlov vladimir.kozlov at oracle.com
Mon Feb 15 19:45:58 UTC 2016


Looks good to me.

Thanks,
Vladimir K

On 2/15/16 11:01 AM, Vladimir Ivanov wrote:
> http://cr.openjdk.java.net/~vlivanov/8148518/webrev.00/
> https://bugs.openjdk.java.net/browse/JDK-8148518
>
> 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.
>
> Best regards,
> Vladimir Ivanov
>
> PS: I don't update the test because it was refactored in Jigsaw [1]. To avoid unnecessary conflicts during merges, I
> filed an RFE [2] to adjust the test once the fix and Jake are integrated.
>
> [1] http://hg.openjdk.java.net/jigsaw/jake/hotspot/file/f6daf3633512/test/compiler/unsafe/UnsafeGetConstantField.java
>
> [2] https://bugs.openjdk.java.net/browse/JDK-8149844


More information about the hotspot-compiler-dev mailing list