< prev index next >

test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java

Print this page
@@ -299,10 +299,11 @@
  import jdk.test.lib.Platform;
  import jdk.test.whitebox.WhiteBox;
  
  public class GetObjectSizeIntrinsicsTest extends ASimpleInstrumentationTestCase {
  
+     private static final boolean COMPACT_HEADERS = Platform.is64bit() && WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
      static final Boolean COMPRESSED_OOPS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedOops");
      static final long REF_SIZE = (COMPRESSED_OOPS == null || COMPRESSED_OOPS == true) ? 4 : 8;
  
      static final Long align = WhiteBox.getWhiteBox().getIntVMFlag("ObjectAlignmentInBytes");
      static final int OBJ_ALIGN = (align == null ? 8 : align.intValue());

@@ -372,29 +373,39 @@
  
      private static long roundUp(long v, long a) {
          return (v + a - 1) / a * a;
      }
  
+     private static long expectedSmallObjSize() {
+         long size;
+         if (!Platform.is64bit() || COMPACT_HEADERS) {
+             size = 8;
+         } else {
+             size = 16;
+         }
+         return roundUp(size, OBJ_ALIGN);
+     }
+ 
      private void testSize_newObject() {
-         long expected = roundUp(Platform.is64bit() ? 16 : 8, OBJ_ALIGN);
+         long expected = expectedSmallObjSize();
          for (int c = 0; c < ITERS; c++) {
              assertEquals(expected, fInst.getObjectSize(new Object()));
          }
      }
  
      private void testSize_localObject() {
-         long expected = roundUp(Platform.is64bit() ? 16 : 8, OBJ_ALIGN);
+         long expected = expectedSmallObjSize();
          Object o = new Object();
          for (int c = 0; c < ITERS; c++) {
              assertEquals(expected, fInst.getObjectSize(o));
          }
      }
  
      static Object staticO = new Object();
  
      private void testSize_fieldObject() {
-         long expected = roundUp(Platform.is64bit() ? 16 : 8, OBJ_ALIGN);
+         long expected = expectedSmallObjSize();
          for (int c = 0; c < ITERS; c++) {
              assertEquals(expected, fInst.getObjectSize(staticO));
          }
      }
  
< prev index next >