38 public void update(Observable o, Object data) {
39 initialize(VM.getVM().getTypeDataBase());
40 }
41 });
42 }
43
44 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
45 heap = VM.getVM().getObjectHeap();
46 Type type = db.lookupType("ObjectMonitor");
47 sun.jvm.hotspot.types.Field f = type.getField("_header");
48 headerFieldOffset = f.getOffset();
49 f = type.getField("_object");
50 objectFieldOffset = f.getOffset();
51 f = type.getField("_owner");
52 ownerFieldOffset = f.getOffset();
53 f = type.getField("_next_om");
54 nextOMFieldOffset = f.getOffset();
55 contentionsField = type.getJIntField("_contentions");
56 waitersField = type.getJIntField("_waiters");
57 recursionsField = type.getCIntegerField("_recursions");
58 }
59
60 public ObjectMonitor(Address addr) {
61 super(addr);
62 }
63
64 public Mark header() {
65 return new Mark(addr.addOffsetTo(headerFieldOffset));
66 }
67
68 // FIXME
69 // void set_header(markWord hdr);
70
71 // FIXME: must implement and delegate to platform-dependent implementation
72 // public boolean isBusy();
73 public boolean isEntered(sun.jvm.hotspot.runtime.Thread current) {
74 Address o = owner();
75 if (current.threadObjectAddress().equals(o) ||
76 current.isLockOwned(o)) {
77 return true;
78 }
79 return false;
80 }
81
82 public Address owner() { return addr.getAddressAt(ownerFieldOffset); }
83 // FIXME
84 // void set_owner(void* owner);
85
86 public int waiters() { return waitersField.getValue(addr); }
87
88 public Address nextOM() { return addr.getAddressAt(nextOMFieldOffset); }
89 // FIXME
90 // void set_queue(void* owner);
91
92 public long recursions() { return recursionsField.getValue(addr); }
93
94 public OopHandle object() {
95 Address objAddr = addr.getAddressAt(objectFieldOffset);
96 if (objAddr == null) {
97 return null;
98 }
99 return objAddr.getOopHandleAt(0);
100 }
101
102 public int contentions() {
103 return contentionsField.getValue(addr);
104 }
105
106 // The following four either aren't expressed as typed fields in
107 // vmStructs.cpp because they aren't strongly typed in the VM, or
108 // would confuse the SA's type system.
109 private static ObjectHeap heap;
110 private static long headerFieldOffset;
111 private static long objectFieldOffset;
112 private static long ownerFieldOffset;
113 private static long nextOMFieldOffset;
114 private static JIntField contentionsField;
115 private static JIntField waitersField;
116 private static CIntegerField recursionsField;
117 // FIXME: expose platform-dependent stuff
118 }
|
38 public void update(Observable o, Object data) {
39 initialize(VM.getVM().getTypeDataBase());
40 }
41 });
42 }
43
44 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
45 heap = VM.getVM().getObjectHeap();
46 Type type = db.lookupType("ObjectMonitor");
47 sun.jvm.hotspot.types.Field f = type.getField("_header");
48 headerFieldOffset = f.getOffset();
49 f = type.getField("_object");
50 objectFieldOffset = f.getOffset();
51 f = type.getField("_owner");
52 ownerFieldOffset = f.getOffset();
53 f = type.getField("_next_om");
54 nextOMFieldOffset = f.getOffset();
55 contentionsField = type.getJIntField("_contentions");
56 waitersField = type.getJIntField("_waiters");
57 recursionsField = type.getCIntegerField("_recursions");
58
59 ANONYMOUS_OWNER = db.lookupLongConstant("ObjectMonitor::ANONYMOUS_OWNER").longValue();
60 }
61
62 public ObjectMonitor(Address addr) {
63 super(addr);
64 }
65
66 public Mark header() {
67 return new Mark(addr.addOffsetTo(headerFieldOffset));
68 }
69
70 // FIXME
71 // void set_header(markWord hdr);
72
73 // FIXME: must implement and delegate to platform-dependent implementation
74 // public boolean isBusy();
75 public boolean isEntered(sun.jvm.hotspot.runtime.Thread current) {
76 Address o = owner();
77 if (current.threadObjectAddress().equals(o) ||
78 current.isLockOwned(o)) {
79 return true;
80 }
81 return false;
82 }
83
84 public boolean isOwnedAnonymous() {
85 return addr.getAddressAt(ownerFieldOffset).asLongValue() == ANONYMOUS_OWNER;
86 }
87
88 public Address owner() { return addr.getAddressAt(ownerFieldOffset); }
89 // FIXME
90 // void set_owner(void* owner);
91
92 public int waiters() { return waitersField.getValue(addr); }
93
94 public Address nextOM() { return addr.getAddressAt(nextOMFieldOffset); }
95 // FIXME
96 // void set_queue(void* owner);
97
98 public long recursions() { return recursionsField.getValue(addr); }
99
100 public OopHandle object() {
101 Address objAddr = addr.getAddressAt(objectFieldOffset);
102 if (objAddr == null) {
103 return null;
104 }
105 return objAddr.getOopHandleAt(0);
106 }
107
108 public int contentions() {
109 return contentionsField.getValue(addr);
110 }
111
112 // The following four either aren't expressed as typed fields in
113 // vmStructs.cpp because they aren't strongly typed in the VM, or
114 // would confuse the SA's type system.
115 private static ObjectHeap heap;
116 private static long headerFieldOffset;
117 private static long objectFieldOffset;
118 private static long ownerFieldOffset;
119 private static long nextOMFieldOffset;
120 private static JIntField contentionsField;
121 private static JIntField waitersField;
122 private static CIntegerField recursionsField;
123 private static long ANONYMOUS_OWNER;
124
125 // FIXME: expose platform-dependent stuff
126 }
|