comparison agent/src/share/classes/sun/jvm/hotspot/oops/Oop.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 } 45 }
46 46
47 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { 47 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
48 Type type = db.lookupType("oopDesc"); 48 Type type = db.lookupType("oopDesc");
49 mark = new CIntField(type.getCIntegerField("_mark"), 0); 49 mark = new CIntField(type.getCIntegerField("_mark"), 0);
50 klass = new OopField(type.getOopField("_klass"), 0); 50 klass = new OopField(type.getOopField("_metadata._klass"), 0);
51 compressedKlass = new NarrowOopField(type.getOopField("_metadata._compressed_klass"), 0);
51 headerSize = type.getSize(); 52 headerSize = type.getSize();
52 } 53 }
53 54
54 private OopHandle handle; 55 private OopHandle handle;
55 private ObjectHeap heap; 56 private ObjectHeap heap;
65 package; is needed, however, by {@link 66 package; is needed, however, by {@link
66 sun.jvm.hotspot.utilities.MarkBits}. */ 67 sun.jvm.hotspot.utilities.MarkBits}. */
67 public OopHandle getHandle() { return handle; } 68 public OopHandle getHandle() { return handle; }
68 69
69 private static long headerSize; 70 private static long headerSize;
70 public static long getHeaderSize() { return headerSize; } 71 public static long getHeaderSize() { return headerSize; } // Header size in bytes.
71 72
72 private static CIntField mark; 73 private static CIntField mark;
73 private static OopField klass; 74 private static OopField klass;
75 private static NarrowOopField compressedKlass;
74 76
75 public boolean isShared() { 77 public boolean isShared() {
76 return CompactingPermGenGen.isShared(handle); 78 return CompactingPermGenGen.isShared(handle);
77 } 79 }
78 80
84 return CompactingPermGenGen.isSharedReadWrite(handle); 86 return CompactingPermGenGen.isSharedReadWrite(handle);
85 } 87 }
86 88
87 // Accessors for declared fields 89 // Accessors for declared fields
88 public Mark getMark() { return new Mark(getHandle()); } 90 public Mark getMark() { return new Mark(getHandle()); }
89 public Klass getKlass() { return (Klass) klass.getValue(this); } 91 public Klass getKlass() {
92 if (VM.getVM().isCompressedOopsEnabled()) {
93 return (Klass) compressedKlass.getValue(this);
94 } else {
95 return (Klass) klass.getValue(this);
96 }
97 }
90 98
91 public boolean isA(Klass k) { 99 public boolean isA(Klass k) {
92 return getKlass().isSubtypeOf(k); 100 return getKlass().isSubtypeOf(k);
93 } 101 }
94 102
118 public boolean isConstantPoolCache() { return false; } 126 public boolean isConstantPoolCache() { return false; }
119 public boolean isCompiledICHolder() { return false; } 127 public boolean isCompiledICHolder() { return false; }
120 128
121 // Align the object size. 129 // Align the object size.
122 public static long alignObjectSize(long size) { 130 public static long alignObjectSize(long size) {
123 return VM.getVM().alignUp(size, VM.getVM().getMinObjAlignmentInBytes()); 131 return VM.getVM().alignUp(size, VM.getVM().getMinObjAlignment());
124 } 132 }
125 133
126 // All vm's align longs, so pad out certain offsets. 134 // All vm's align longs, so pad out certain offsets.
127 public static long alignObjectOffset(long offset) { 135 public static long alignObjectOffset(long offset) {
128 return VM.getVM().alignUp(offset, VM.getVM().getBytesPerLong()); 136 return VM.getVM().alignUp(offset, VM.getVM().getBytesPerLong());
161 } 169 }
162 170
163 void iterateFields(OopVisitor visitor, boolean doVMFields) { 171 void iterateFields(OopVisitor visitor, boolean doVMFields) {
164 if (doVMFields) { 172 if (doVMFields) {
165 visitor.doCInt(mark, true); 173 visitor.doCInt(mark, true);
166 visitor.doOop(klass, true); 174 if (VM.getVM().isCompressedOopsEnabled()) {
175 visitor.doOop(compressedKlass, true);
176 } else {
177 visitor.doOop(klass, true);
178 }
167 } 179 }
168 } 180 }
169 181
170 public void print() { printOn(System.out); } 182 public void print() { printOn(System.out); }
171 public void printValue() { printValueOn(System.out); } 183 public void printValue() { printValueOn(System.out); }
217 // Package-private routine to speed up ObjectHeap.newOop 229 // Package-private routine to speed up ObjectHeap.newOop
218 static OopHandle getKlassForOopHandle(OopHandle handle) { 230 static OopHandle getKlassForOopHandle(OopHandle handle) {
219 if (handle == null) { 231 if (handle == null) {
220 return null; 232 return null;
221 } 233 }
222 return handle.getOopHandleAt(klass.getOffset()); 234 if (VM.getVM().isCompressedOopsEnabled()) {
235 return handle.getCompOopHandleAt(compressedKlass.getOffset());
236 } else {
237 return handle.getOopHandleAt(klass.getOffset());
238 }
223 } 239 }
224 }; 240 };