--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Instance.java Fri Apr 11 09:56:35 2008 -0400
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Instance.java Sun Apr 13 17:43:42 2008 -0400
@@ -40,15 +40,26 @@
}
});
}
+ private static long typeSize;
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("instanceOopDesc");
+ typeSize = type.getSize();
}
Instance(OopHandle handle, ObjectHeap heap) {
super(handle, heap);
}
+ // Returns header size in bytes.
+ public static long getHeaderSize() {
+ if (VM.getVM().isCompressedOopsEnabled()) {
+ return typeSize - VM.getVM().getIntSize();
+ } else {
+ return typeSize;
+ }
+ }
+
public boolean isInstance() { return true; }
public void iterateFields(OopVisitor visitor, boolean doVMFields) {