changeset 36121:ba46027ccfb5

8148518: Unsafe.getCharUnaligned() loads aren't folded in case of -XX:-UseUnalignedAccesses Reviewed-by: kvn, shade
author vlivanov
date Wed, 17 Feb 2016 18:49:38 +0300
parents 192b3ccf06ba
children bcdde35f856f
files jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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) */