diff --git a/src/hotspot/share/oops/arrayOop.hpp b/src/hotspot/share/oops/arrayOop.hpp index 3e78998e2cb..6dd55a55a5b 100644 --- a/src/hotspot/share/oops/arrayOop.hpp +++ b/src/hotspot/share/oops/arrayOop.hpp @@ -96,7 +96,8 @@ class arrayOopDesc : public oopDesc { // Returns the offset of the first element. static int base_offset_in_bytes(BasicType type) { size_t hs = header_size_in_bytes(); - return (int)(element_type_should_be_aligned(type) ? align_up(hs, BytesPerLong) : hs); + // When we are not using UseCompactObjectHeaders, revert back to a more conservative alignment. + return (int)((!UseCompactObjectHeaders || element_type_should_be_aligned(type)) ? align_up(hs, BytesPerLong) : hs); } // Returns the address of the first element. The elements in the array will not diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java index 413764c4736..2ca98808336 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java @@ -110,7 +110,7 @@ public long getObjectSize() { public static long baseOffsetInBytes(BasicType type) { long typeSizeInBytes = headerSizeInBytes(); - if (elementTypeShouldBeAligned(type)) { + if (!VM.getVM().isCompactObjectHeadersEnabled() || elementTypeShouldBeAligned(type)) { VM vm = VM.getVM(); return vm.alignUp(typeSizeInBytes, vm.getVM().getHeapWordSize()); } else { diff --git a/test/hotspot/gtest/oops/test_arrayOop.cpp b/test/hotspot/gtest/oops/test_arrayOop.cpp index daec71172fd..eab66d02e40 100644 --- a/test/hotspot/gtest/oops/test_arrayOop.cpp +++ b/test/hotspot/gtest/oops/test_arrayOop.cpp @@ -105,17 +105,17 @@ TEST_VM(arrayOopDesc, base_offset) { EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 16); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 16); } else { - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BOOLEAN), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BYTE), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_SHORT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_CHAR), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_INT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_FLOAT), 20); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BOOLEAN), 24); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BYTE), 24); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_SHORT), 24); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_CHAR), 24); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_INT), 24); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_FLOAT), 24); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_LONG), 24); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_DOUBLE), 24); if (UseCompressedOops) { - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 20); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 24); + EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 24); } else { EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 24); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 24); diff --git a/test/hotspot/gtest/oops/test_objArrayOop.cpp b/test/hotspot/gtest/oops/test_objArrayOop.cpp index 89608f76fc9..a8166685843 100644 --- a/test/hotspot/gtest/oops/test_objArrayOop.cpp +++ b/test/hotspot/gtest/oops/test_objArrayOop.cpp @@ -32,16 +32,16 @@ TEST_VM(objArrayOop, osize) { } x[] = { // ObjAligInB, UseCCP, UseCoops, UseCOH, object size in heap words #ifdef _LP64 - { 8, false, false, false, 4 }, // 20 byte header, 8 byte oops - { 8, false, true, false, 3 }, // 20 byte header, 4 byte oops + { 8, false, false, false, 4 }, // 24 byte header, 8 byte oops + { 8, false, true, false, 4 }, // 24 byte header, 4 byte oops { 8, true, false, false, 3 }, // 16 byte header, 8 byte oops { 8, true, true, false, 3 }, // 16 byte header, 4 byte oops - { 16, false, false, false, 4 }, // 20 byte header, 8 byte oops, 16-byte align - { 16, false, true, false, 4 }, // 20 byte header, 4 byte oops, 16-byte align + { 16, false, false, false, 4 }, // 24 byte header, 8 byte oops, 16-byte align + { 16, false, true, false, 4 }, // 24 byte header, 4 byte oops, 16-byte align { 16, true, false, false, 4 }, // 16 byte header, 8 byte oops, 16-byte align { 16, true, true, false, 4 }, // 16 byte header, 4 byte oops, 16-byte align - { 256, false, false, false, 32 }, // 20 byte header, 8 byte oops, 256-byte align - { 256, false, true, false, 32 }, // 20 byte header, 4 byte oops, 256-byte align + { 256, false, false, false, 32 }, // 24 byte header, 8 byte oops, 256-byte align + { 256, false, true, false, 32 }, // 24 byte header, 4 byte oops, 256-byte align { 256, true, false, false, 32 }, // 16 byte header, 8 byte oops, 256-byte align { 256, true, true, false, 32 }, // 16 byte header, 4 byte oops, 256-byte align { 8, false, false, true, 3 }, // 16 byte header, 8 byte oops diff --git a/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java b/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java index 0d62429b2be..42294357397 100644 --- a/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java +++ b/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java @@ -96,7 +96,7 @@ static class LIClass { LONG_ARRAY_OFFSET = 16; } else { INT_OFFSET = 16; - INT_ARRAY_OFFSET = 20; + INT_ARRAY_OFFSET = 24; LONG_ARRAY_OFFSET = 24; } } diff --git a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java index 0435a9bb73f..c4a7c44eb41 100644 --- a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java +++ b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java @@ -315,7 +315,7 @@ public class GetObjectSizeIntrinsicsTest extends ASimpleInstrumentationTestCase static final int LARGE_OBJ_ARRAY_SIZE = (4096/(int)REF_SIZE)*1024*1024 + 1024; static final boolean CCP = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers"); - static final int ARRAY_HEADER_SIZE = CCP ? 16 : (Platform.is64bit() ? 20 : 16); + static final int ARRAY_HEADER_SIZE = CCP ? 16 : (Platform.is64bit() ? 24 : 16); final String mode;