< prev index next >

test/compiler/unsafe/UnsafeGetConstantField.java

Print this page

        

@@ -26,16 +26,16 @@
 /*
  * @test
  * @summary tests on constant folding of unsafe get operations
  * @library /testlibrary /../../test/lib
  * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions
- *                   -Xbatch -XX:-TieredCompilation
+ *                   -Xbatch -XX:-TieredCompilation -Xverify:all
  *                   -XX:+FoldStableValues
  *                   -XX:+UseUnalignedAccesses
  *                   java.lang.invoke.UnsafeGetConstantField
  * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions
- *                   -Xbatch -XX:-TieredCompilation
+ *                   -Xbatch -XX:-TieredCompilation -Xverify:all
  *                   -XX:+FoldStableValues
  *                   -XX:-UseUnalignedAccesses
  *                   java.lang.invoke.UnsafeGetConstantField
  */
 package java.lang.invoke;

@@ -178,10 +178,11 @@
         final JavaType type;
         final int flags;
         final boolean stable;
         final boolean hasDefaultValue;
         final String nameSuffix;
+        final boolean useRawOffset;
 
         final String className;
         final String classDesc;
         final String fieldDesc;
 

@@ -190,10 +191,11 @@
             this.flags = flags;
             this.stable = stable;
             this.hasDefaultValue = hasDefaultValue;
             this.nameSuffix = suffix;
 
+            useRawOffset = suffix.equals("Unaligned");
             fieldDesc = type.desc();
             className = String.format("%s$Test%s%s__f=%d__s=%b__d=%b", internalName(THIS_CLASS), type.typeName,
                                       suffix, flags, stable, hasDefaultValue);
             classDesc = String.format("L%s;", className);
         }

@@ -274,10 +276,14 @@
                 // Compute field offset
                 getUnsafe(mv);
                 getField(mv);
                 mv.visitMethodInsn(INVOKEVIRTUAL, UNSAFE_NAME, (isStatic() ? "staticFieldOffset" : "objectFieldOffset"),
                         "(Ljava/lang/reflect/Field;)J", false);
+                if (useRawOffset) {
+                    mv.visitLdcInsn(1);
+                    mv.visitInsn(LSHR);
+                }
                 mv.visitFieldInsn(PUTSTATIC, className, "FIELD_OFFSET", "J");
 
                 // Compute base offset for static field
                 if (isStatic()) {
                     getUnsafe(mv);
< prev index next >