< prev index next > src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java
Print this page
// Size of the arrayOopDesc
private static long headerSize=0;
private static long lengthOffsetInBytes=0;
private static long typeSize;
+ // Check whether an element of a typeArrayOop with the given type must be
+ // aligned 0 mod 8. The typeArrayOop itself must be aligned at least this
+ // strongly.
+ public static boolean elementTypeShouldBeAligned(BasicType type) {
+ if (VM.getVM().isLP64()) {
+ if (type == BasicType.T_OBJECT || type == BasicType.T_ARRAY) {
+ return !VM.getVM().isCompressedOopsEnabled();
+ }
+ }
+ return type == BasicType.T_DOUBLE || type == BasicType.T_LONG;
+ }
+
private static long headerSizeInBytes() {
if (headerSize != 0) {
return headerSize;
}
- if (VM.getVM().isCompressedKlassPointersEnabled()) {
- headerSize = typeSize;
+ if (VM.getVM().isCompactObjectHeadersEnabled()) {
+ headerSize = lengthOffsetInBytes() + VM.getVM().getIntSize();
} else {
- headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(),
- VM.getVM().getHeapWordSize());
+ if (VM.getVM().isCompressedKlassPointersEnabled()) {
+ headerSize = typeSize;
+ } else {
+ headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(),
+ VM.getVM().getHeapWordSize());
+ }
}
return headerSize;
}
private static long headerSize(BasicType type) {
- if (Universe.elementTypeShouldBeAligned(type)) {
- return alignObjectSize(headerSizeInBytes())/VM.getVM().getHeapWordSize();
- } else {
- return headerSizeInBytes()/VM.getVM().getHeapWordSize();
- }
- }
+ if (elementTypeShouldBeAligned(type)) {
+ return alignObjectSize(headerSizeInBytes())/VM.getVM().getHeapWordSize();
+ } else {
+ return headerSizeInBytes()/VM.getVM().getHeapWordSize();
+ }
+ }
- private long lengthOffsetInBytes() {
+ private static long lengthOffsetInBytes() {
if (lengthOffsetInBytes != 0) {
return lengthOffsetInBytes;
}
- if (VM.getVM().isCompressedKlassPointersEnabled()) {
- lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
+ if (VM.getVM().isCompactObjectHeadersEnabled()) {
+ lengthOffsetInBytes = Oop.getHeaderSize();
} else {
- lengthOffsetInBytes = typeSize;
+ if (VM.getVM().isCompressedKlassPointersEnabled()) {
+ lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
+ } else {
+ lengthOffsetInBytes = typeSize;
+ }
}
return lengthOffsetInBytes;
}
// Accessors for declared fields
s = Oop.alignObjectSize(s);
return s;
}
public static long baseOffsetInBytes(BasicType type) {
- return headerSize(type) * VM.getVM().getHeapWordSize();
+ if (VM.getVM().isCompactObjectHeadersEnabled()) {
+ long typeSizeInBytes = headerSizeInBytes();
+ if (elementTypeShouldBeAligned(type)) {
+ VM vm = VM.getVM();
+ return vm.alignUp(typeSizeInBytes, vm.getVM().getHeapWordSize());
+ } else {
+ return typeSizeInBytes;
+ }
+ } else {
+ return headerSize(type) * VM.getVM().getHeapWordSize();
+ }
}
public boolean isArray() { return true; }
public void iterateFields(OopVisitor visitor, boolean doVMFields) {
< prev index next >