< prev index next > test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java
Print this page
// These should overflow 4G size boundary
static final int LARGE_INT_ARRAY_SIZE = 1024*1024*1024 + 1024;
static final int LARGE_OBJ_ARRAY_SIZE = (4096/(int)REF_SIZE)*1024*1024 + 1024;
+ static final boolean COMPACT_HEADERS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
+ static final int HEADER_SIZE = COMPACT_HEADERS ? 8 : (Platform.is64bit() ? 16 : 8);
+
final String mode;
public GetObjectSizeIntrinsicsTest(String name, String mode) {
super(name);
this.mode = mode;
private static long roundUp(long v, long a) {
return (v + a - 1) / a * a;
}
private void testSize_newObject() {
! long expected = roundUp(Platform.is64bit() ? 16 : 8, OBJ_ALIGN);
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);
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);
for (int c = 0; c < ITERS; c++) {
assertEquals(expected, fInst.getObjectSize(staticO));
}
}
private static long roundUp(long v, long a) {
return (v + a - 1) / a * a;
}
private void testSize_newObject() {
! long expected = roundUp(HEADER_SIZE, OBJ_ALIGN);
for (int c = 0; c < ITERS; c++) {
assertEquals(expected, fInst.getObjectSize(new Object()));
}
}
private void testSize_localObject() {
! long expected = roundUp(HEADER_SIZE, OBJ_ALIGN);
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(HEADER_SIZE, OBJ_ALIGN);
for (int c = 0; c < ITERS; c++) {
assertEquals(expected, fInst.getObjectSize(staticO));
}
}
< prev index next >