42 }
43
44 Array(OopHandle handle, ObjectHeap heap) {
45 super(handle, heap);
46 }
47
48 private static void initialize(TypeDataBase db) throws WrongTypeException {
49 Type type = db.lookupType("arrayOopDesc");
50 typeSize = (int)type.getSize();
51 }
52
53 // Size of the arrayOopDesc
54 private static long headerSize=0;
55 private static long lengthOffsetInBytes=0;
56 private static long typeSize;
57
58 private static long headerSizeInBytes() {
59 if (headerSize != 0) {
60 return headerSize;
61 }
62 if (VM.getVM().isCompressedHeadersEnabled()) {
63 headerSize = typeSize;
64 } else {
65 headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(),
66 VM.getVM().getHeapWordSize());
67 }
68 return headerSize;
69 }
70
71 private static long headerSize(BasicType type) {
72 if (Universe.elementTypeShouldBeAligned(type)) {
73 return alignObjectSize(headerSizeInBytes())/VM.getVM().getHeapWordSize();
74 } else {
75 return headerSizeInBytes()/VM.getVM().getHeapWordSize();
76 }
77 }
78
79 private long lengthOffsetInBytes() {
80 if (lengthOffsetInBytes != 0) {
81 return lengthOffsetInBytes;
82 }
83 if (VM.getVM().isCompressedHeadersEnabled()) {
84 lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
85 } else {
86 lengthOffsetInBytes = typeSize;
87 }
88 return lengthOffsetInBytes;
89 }
90
91 // Accessors for declared fields
92 public long getLength() {
93 boolean isUnsigned = true;
94 return this.getHandle().getCIntegerAt(lengthOffsetInBytes(), VM.getVM().getIntSize(), isUnsigned);
95 }
96
97 public long getObjectSize() {
98 ArrayKlass klass = (ArrayKlass) getKlass();
99 // We have to fetch the length of the array, shift (multiply) it
100 // appropriately, up to wordSize, add the header, and align to
101 // object size.
102 long s = getLength() << klass.getLog2ElementSize();
103 s += klass.getArrayHeaderInBytes();
|
42 }
43
44 Array(OopHandle handle, ObjectHeap heap) {
45 super(handle, heap);
46 }
47
48 private static void initialize(TypeDataBase db) throws WrongTypeException {
49 Type type = db.lookupType("arrayOopDesc");
50 typeSize = (int)type.getSize();
51 }
52
53 // Size of the arrayOopDesc
54 private static long headerSize=0;
55 private static long lengthOffsetInBytes=0;
56 private static long typeSize;
57
58 private static long headerSizeInBytes() {
59 if (headerSize != 0) {
60 return headerSize;
61 }
62 if (VM.getVM().isCompressedKlassPointersEnabled()) {
63 headerSize = typeSize;
64 } else {
65 headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(),
66 VM.getVM().getHeapWordSize());
67 }
68 return headerSize;
69 }
70
71 private static long headerSize(BasicType type) {
72 if (Universe.elementTypeShouldBeAligned(type)) {
73 return alignObjectSize(headerSizeInBytes())/VM.getVM().getHeapWordSize();
74 } else {
75 return headerSizeInBytes()/VM.getVM().getHeapWordSize();
76 }
77 }
78
79 private long lengthOffsetInBytes() {
80 if (lengthOffsetInBytes != 0) {
81 return lengthOffsetInBytes;
82 }
83 if (VM.getVM().isCompressedKlassPointersEnabled()) {
84 lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
85 } else {
86 lengthOffsetInBytes = typeSize;
87 }
88 return lengthOffsetInBytes;
89 }
90
91 // Accessors for declared fields
92 public long getLength() {
93 boolean isUnsigned = true;
94 return this.getHandle().getCIntegerAt(lengthOffsetInBytes(), VM.getVM().getIntSize(), isUnsigned);
95 }
96
97 public long getObjectSize() {
98 ArrayKlass klass = (ArrayKlass) getKlass();
99 // We have to fetch the length of the array, shift (multiply) it
100 // appropriately, up to wordSize, add the header, and align to
101 // object size.
102 long s = getLength() << klass.getLog2ElementSize();
103 s += klass.getArrayHeaderInBytes();
|