comparison agent/src/share/classes/sun/jvm/hotspot/oops/Array.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1
comparison
equal deleted inserted replaced
110:a49a647afe9a 113:ba764ed4b6f2
45 super(handle, heap); 45 super(handle, heap);
46 } 46 }
47 47
48 private static void initialize(TypeDataBase db) throws WrongTypeException { 48 private static void initialize(TypeDataBase db) throws WrongTypeException {
49 Type type = db.lookupType("arrayOopDesc"); 49 Type type = db.lookupType("arrayOopDesc");
50 length = new CIntField(type.getCIntegerField("_length"), 0); 50 typeSize = (int)type.getSize();
51 headerSize = type.getSize();
52 } 51 }
53 52
54 // Size of the arrayOopDesc 53 // Size of the arrayOopDesc
55 private static long headerSize; 54 private static long headerSize=0;
55 private static long lengthOffsetInBytes=0;
56 private static long typeSize;
56 57
57 // Fields 58 private static long headerSizeInBytes() {
58 private static CIntField length; 59 if (headerSize != 0) {
60 return headerSize;
61 }
62 if (VM.getVM().isCompressedOopsEnabled()) {
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().isCompressedOopsEnabled()) {
84 lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
85 } else {
86 lengthOffsetInBytes = typeSize;
87 }
88 return lengthOffsetInBytes;
89 }
59 90
60 // Accessors for declared fields 91 // Accessors for declared fields
61 public long getLength() { return length.getValue(this); } 92 public long getLength() {
93 boolean isUnsigned = true;
94 return this.getHandle().getCIntegerAt(lengthOffsetInBytes(), VM.getVM().getIntSize(), isUnsigned);
95 }
62 96
63 public long getObjectSize() { 97 public long getObjectSize() {
64 ArrayKlass klass = (ArrayKlass) getKlass(); 98 ArrayKlass klass = (ArrayKlass) getKlass();
65 // We have to fetch the length of the array, shift (multiply) it 99 // We have to fetch the length of the array, shift (multiply) it
66 // appropriately, up to wordSize, add the header, and align to 100 // appropriately, up to wordSize, add the header, and align to
70 s = Oop.alignObjectSize(s); 104 s = Oop.alignObjectSize(s);
71 return s; 105 return s;
72 } 106 }
73 107
74 public static long baseOffsetInBytes(BasicType type) { 108 public static long baseOffsetInBytes(BasicType type) {
75 if (Universe.elementTypeShouldBeAligned(type)) { 109 return headerSize(type) * VM.getVM().getHeapWordSize();
76 return (VM.getVM().isLP64()) ? alignObjectSize(headerSize)
77 : VM.getVM().alignUp(headerSize, 8);
78 } else {
79 return headerSize;
80 }
81 } 110 }
82 111
83 public boolean isArray() { return true; } 112 public boolean isArray() { return true; }
84 113
85 public void iterateFields(OopVisitor visitor, boolean doVMFields) { 114 public void iterateFields(OopVisitor visitor, boolean doVMFields) {
86 super.iterateFields(visitor, doVMFields); 115 super.iterateFields(visitor, doVMFields);
87 if (doVMFields) {
88 visitor.doCInt(length, true);
89 }
90 } 116 }
91 } 117 }