105 javaVFrame* vframe::java_sender() const {
106 vframe* f = sender();
107 while (f != NULL) {
108 if (f->is_java_frame()) return javaVFrame::cast(f);
109 f = f->sender();
110 }
111 return NULL;
112 }
113
114 // ------------- javaVFrame --------------
115
116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
117 assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
118 "must be at safepoint or it's a java frame of the current thread");
119
120 GrowableArray<MonitorInfo*>* mons = monitors();
121 GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
122 if (mons->is_empty()) return result;
123
124 bool found_first_monitor = false;
125 ObjectMonitor *pending_monitor = thread()->current_pending_monitor();
126 ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor();
127 oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
128 oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
129
130 for (int index = (mons->length()-1); index >= 0; index--) {
131 MonitorInfo* monitor = mons->at(index);
132 if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
133 oop obj = monitor->owner();
134 if (obj == NULL) continue; // skip unowned monitor
135 //
136 // Skip the monitor that the thread is blocked to enter or waiting on
137 //
138 if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
139 continue;
140 }
141 found_first_monitor = true;
142 result->append(monitor);
143 }
144 return result;
145 }
146
214 st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
215 } else {
216 Handle obj(THREAD, monitor->owner());
217 if (obj() != NULL) {
218 print_locked_object_class_name(st, obj, "eliminated");
219 }
220 }
221 continue;
222 }
223 if (monitor->owner() != NULL) {
224 // the monitor is associated with an object, i.e., it is locked
225
226 const char *lock_state = "locked"; // assume we have the monitor locked
227 if (!found_first_monitor && frame_count == 0) {
228 // If this is the first frame and we haven't found an owned
229 // monitor before, then we need to see if we have completed
230 // the lock or if we are blocked trying to acquire it. Only
231 // an inflated monitor that is first on the monitor list in
232 // the first frame can block us on a monitor enter.
233 markWord mark = monitor->owner()->mark();
234 if (mark.has_monitor() &&
235 ( // we have marked ourself as pending on this monitor
236 mark.monitor() == thread()->current_pending_monitor() ||
237 // we are not the owner of this monitor
238 !mark.monitor()->is_entered(thread())
239 )) {
240 lock_state = "waiting to lock";
241 }
242 }
243 print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
244
245 found_first_monitor = true;
246 }
247 }
248 }
249 }
250
251 // ------------- interpretedVFrame --------------
252
253 u_char* interpretedVFrame::bcp() const {
254 return fr().interpreter_frame_bcp();
255 }
256
|
105 javaVFrame* vframe::java_sender() const {
106 vframe* f = sender();
107 while (f != NULL) {
108 if (f->is_java_frame()) return javaVFrame::cast(f);
109 f = f->sender();
110 }
111 return NULL;
112 }
113
114 // ------------- javaVFrame --------------
115
116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
117 assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
118 "must be at safepoint or it's a java frame of the current thread");
119
120 GrowableArray<MonitorInfo*>* mons = monitors();
121 GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
122 if (mons->is_empty()) return result;
123
124 bool found_first_monitor = false;
125 ObjectMonitorHandle omh;
126 ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor(&omh);
127 ObjectMonitor *pending_monitor = NULL;
128 if (waiting_monitor == NULL) {
129 pending_monitor = thread()->current_pending_monitor(&omh);
130 }
131 oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
132 oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
133
134 for (int index = (mons->length()-1); index >= 0; index--) {
135 MonitorInfo* monitor = mons->at(index);
136 if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
137 oop obj = monitor->owner();
138 if (obj == NULL) continue; // skip unowned monitor
139 //
140 // Skip the monitor that the thread is blocked to enter or waiting on
141 //
142 if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
143 continue;
144 }
145 found_first_monitor = true;
146 result->append(monitor);
147 }
148 return result;
149 }
150
218 st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
219 } else {
220 Handle obj(THREAD, monitor->owner());
221 if (obj() != NULL) {
222 print_locked_object_class_name(st, obj, "eliminated");
223 }
224 }
225 continue;
226 }
227 if (monitor->owner() != NULL) {
228 // the monitor is associated with an object, i.e., it is locked
229
230 const char *lock_state = "locked"; // assume we have the monitor locked
231 if (!found_first_monitor && frame_count == 0) {
232 // If this is the first frame and we haven't found an owned
233 // monitor before, then we need to see if we have completed
234 // the lock or if we are blocked trying to acquire it. Only
235 // an inflated monitor that is first on the monitor list in
236 // the first frame can block us on a monitor enter.
237 markWord mark = monitor->owner()->mark();
238 ObjectMonitorHandle omh;
239 if (mark.has_monitor() &&
240 ( // we have marked ourself as pending on this monitor
241 mark.monitor() == thread()->current_pending_monitor(&omh) ||
242 // we are not the owner of this monitor
243 !mark.monitor()->is_entered(thread())
244 )) {
245 lock_state = "waiting to lock";
246 }
247 }
248 print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
249
250 found_first_monitor = true;
251 }
252 }
253 }
254 }
255
256 // ------------- interpretedVFrame --------------
257
258 u_char* interpretedVFrame::bcp() const {
259 return fr().interpreter_frame_bcp();
260 }
261
|