8148518: Unsafe.getCharUnaligned() loads aren't folded in case of -XX:-UseUnalignedAccesses
Reviewed-by: kvn, shade
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Mon Feb 15 20:27:12 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Wed Feb 17 18:49:38 2016 +0300
@@ -1159,7 +1159,12 @@
/** @see #getLongUnaligned(Object, long) */
@HotSpotIntrinsicCandidate
public final char getCharUnaligned(Object o, long offset) {
- return (char)getShortUnaligned(o, offset);
+ if ((offset & 1) == 0) {
+ return getChar(o, offset);
+ } else {
+ return (char)makeShort(getByte(o, offset),
+ getByte(o, offset + 1));
+ }
}
/** @see #getLongUnaligned(Object, long, boolean) */