38 static {
39 VM.registerVMInitializedObserver(new Observer() {
40 public void update(Observable o, Object data) {
41 initialize(VM.getVM().getTypeDataBase());
42 }
43 });
44 }
45 private static long typeSize;
46
47 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
48 Type type = db.lookupType("instanceOopDesc");
49 typeSize = type.getSize();
50 }
51
52 Instance(OopHandle handle, ObjectHeap heap) {
53 super(handle, heap);
54 }
55
56 // Returns header size in bytes.
57 public static long getHeaderSize() {
58 if (VM.getVM().isCompressedKlassPointersEnabled()) {
59 return typeSize - VM.getVM().getIntSize();
60 } else {
61 return typeSize;
62 }
63 }
64
65 public boolean isInstance() { return true; }
66
67 public void iterateFields(OopVisitor visitor, boolean doVMFields) {
68 super.iterateFields(visitor, doVMFields);
69 ((InstanceKlass) getKlass()).iterateNonStaticFields(visitor, this);
70 }
71
72 public void printValueOn(PrintStream tty) {
73 // Special-case strings.
74 // FIXME: would like to do this in more type-safe fashion (need
75 // SystemDictionary analogue)
76 if (getKlass().getName().asString().equals("java/lang/String")) {
77 tty.print("\"" + OopUtilities.stringOopToString(this) + "\"");
|
38 static {
39 VM.registerVMInitializedObserver(new Observer() {
40 public void update(Observable o, Object data) {
41 initialize(VM.getVM().getTypeDataBase());
42 }
43 });
44 }
45 private static long typeSize;
46
47 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
48 Type type = db.lookupType("instanceOopDesc");
49 typeSize = type.getSize();
50 }
51
52 Instance(OopHandle handle, ObjectHeap heap) {
53 super(handle, heap);
54 }
55
56 // Returns header size in bytes.
57 public static long getHeaderSize() {
58 if (VM.getVM().isCompactObjectHeadersEnabled()) {
59 return Oop.getHeaderSize();
60 }
61 if (VM.getVM().isCompressedKlassPointersEnabled()) {
62 return typeSize - VM.getVM().getIntSize();
63 } else {
64 return typeSize;
65 }
66 }
67
68 public boolean isInstance() { return true; }
69
70 public void iterateFields(OopVisitor visitor, boolean doVMFields) {
71 super.iterateFields(visitor, doVMFields);
72 ((InstanceKlass) getKlass()).iterateNonStaticFields(visitor, this);
73 }
74
75 public void printValueOn(PrintStream tty) {
76 // Special-case strings.
77 // FIXME: would like to do this in more type-safe fashion (need
78 // SystemDictionary analogue)
79 if (getKlass().getName().asString().equals("java/lang/String")) {
80 tty.print("\"" + OopUtilities.stringOopToString(this) + "\"");
|