4641 thread->metadata_handles_do(_f);
4642 }
4643 };
4644
4645 void Threads::metadata_handles_do(void f(Metadata*)) {
4646 // Only walk the Handles in Thread.
4647 ThreadHandlesClosure handles_closure(f);
4648 threads_do(&handles_closure);
4649 }
4650
4651 // Get count Java threads that are waiting to enter the specified monitor.
4652 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4653 int count,
4654 address monitor) {
4655 GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4656
4657 int i = 0;
4658 DO_JAVA_THREADS(t_list, p) {
4659 if (!p->can_call_java()) continue;
4660
4661 address pending = (address)p->current_pending_monitor();
4662 if (pending == monitor) { // found a match
4663 if (i < count) result->append(p); // save the first count matches
4664 i++;
4665 }
4666 }
4667
4668 return result;
4669 }
4670
4671
4672 JavaThread *Threads::owning_thread_from_monitor_owner(ThreadsList * t_list,
4673 address owner) {
4674 // NULL owner means not locked so we can skip the search
4675 if (owner == NULL) return NULL;
4676
4677 DO_JAVA_THREADS(t_list, p) {
4678 // first, see if owner is the address of a Java thread
4679 if (owner == (address)p) return p;
4680 }
4681
|
4641 thread->metadata_handles_do(_f);
4642 }
4643 };
4644
4645 void Threads::metadata_handles_do(void f(Metadata*)) {
4646 // Only walk the Handles in Thread.
4647 ThreadHandlesClosure handles_closure(f);
4648 threads_do(&handles_closure);
4649 }
4650
4651 // Get count Java threads that are waiting to enter the specified monitor.
4652 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4653 int count,
4654 address monitor) {
4655 GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4656
4657 int i = 0;
4658 DO_JAVA_THREADS(t_list, p) {
4659 if (!p->can_call_java()) continue;
4660
4661 ObjectMonitorHandle omh;
4662 address pending = (address)p->current_pending_monitor(&omh);
4663 if (pending == monitor) { // found a match
4664 if (i < count) result->append(p); // save the first count matches
4665 i++;
4666 }
4667 }
4668
4669 return result;
4670 }
4671
4672
4673 JavaThread *Threads::owning_thread_from_monitor_owner(ThreadsList * t_list,
4674 address owner) {
4675 // NULL owner means not locked so we can skip the search
4676 if (owner == NULL) return NULL;
4677
4678 DO_JAVA_THREADS(t_list, p) {
4679 // first, see if owner is the address of a Java thread
4680 if (owner == (address)p) return p;
4681 }
4682
|