38 VM.registerVMInitializedObserver(new Observer() {
39 public void update(Observable o, Object data) {
40 initialize(VM.getVM().getTypeDataBase());
41 }
42 });
43 }
44
45 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
46 Type objectSynchronizerType = db.lookupType("ObjectSynchronizer");
47 Type monitorListType = db.lookupType("MonitorList");
48 Address monitorListAddr = objectSynchronizerType.getField("_in_use_list").getStaticFieldAddress();
49 inUseListHead = monitorListType.getAddressField("_head").getAddress(monitorListAddr);
50 }
51
52 public long identityHashValueFor(Oop obj) {
53 Mark mark = obj.getMark();
54 if (mark.isUnlocked()) {
55 // FIXME: can not generate marks in debugging system
56 return mark.hash();
57 } else if (mark.hasMonitor()) {
58 ObjectMonitor monitor = mark.monitor();
59 Mark temp = monitor.header();
60 return temp.hash();
61 } else {
62 if (Assert.ASSERTS_ENABLED) {
63 Assert.that(VM.getVM().isDebugging(), "Can not access displaced header otherwise");
64 }
65 if (mark.hasDisplacedMarkHelper()) {
66 Mark temp = mark.displacedMarkHelper();
67 return temp.hash();
68 }
69 // FIXME: can not do anything else here in debugging system
70 return 0;
71 }
72 }
73
74 public static Iterator objectMonitorIterator() {
75 return new ObjectMonitorIterator();
76 }
77
|
38 VM.registerVMInitializedObserver(new Observer() {
39 public void update(Observable o, Object data) {
40 initialize(VM.getVM().getTypeDataBase());
41 }
42 });
43 }
44
45 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
46 Type objectSynchronizerType = db.lookupType("ObjectSynchronizer");
47 Type monitorListType = db.lookupType("MonitorList");
48 Address monitorListAddr = objectSynchronizerType.getField("_in_use_list").getStaticFieldAddress();
49 inUseListHead = monitorListType.getAddressField("_head").getAddress(monitorListAddr);
50 }
51
52 public long identityHashValueFor(Oop obj) {
53 Mark mark = obj.getMark();
54 if (mark.isUnlocked()) {
55 // FIXME: can not generate marks in debugging system
56 return mark.hash();
57 } else if (mark.hasMonitor()) {
58 if (VM.getVM().getCommandLineFlag("UseObjectMonitorTable").getBool()) {
59 return mark.hash();
60 }
61 ObjectMonitor monitor = mark.monitor();
62 Mark temp = monitor.header();
63 return temp.hash();
64 } else {
65 if (Assert.ASSERTS_ENABLED) {
66 Assert.that(VM.getVM().isDebugging(), "Can not access displaced header otherwise");
67 }
68 if (mark.hasDisplacedMarkHelper()) {
69 Mark temp = mark.displacedMarkHelper();
70 return temp.hash();
71 }
72 // FIXME: can not do anything else here in debugging system
73 return 0;
74 }
75 }
76
77 public static Iterator objectMonitorIterator() {
78 return new ObjectMonitorIterator();
79 }
80
|