< prev index next >

src/hotspot/share/runtime/vmOperations.cpp

Print this page

351     assert(monitor->has_owner(), "Expects only owned monitors");
352 
353     if (monitor->is_owner_anonymous()) {
354       // There's no need to collect anonymous owned monitors
355       // because the caller of this code is only interested
356       // in JNI owned monitors.
357       return;
358     }
359 
360     if (monitor->object_peek() == nullptr) {
361       // JNI code doesn't necessarily keep the monitor object
362       // alive. Filter out monitors with dead objects.
363       return;
364     }
365 
366     add(monitor);
367   }
368 
369   // Implements the ObjectMonitorsView interface
370   void visit(MonitorClosure* closure, JavaThread* thread) override {
371     ObjectMonitorLinkedList* list = get_list(thread);

372     LinkedListIterator<ObjectMonitor*> iter(list != nullptr ? list->head() : nullptr);
373     while (!iter.is_empty()) {
374       ObjectMonitor* monitor = *iter.next();
375       closure->do_monitor(monitor);
376     }
377   }
378 
379   size_t key_count() { return _key_count; }
380   size_t om_count() { return _om_count; }
381 };
382 
383 void VM_ThreadDump::doit() {
384   ResourceMark rm;
385 
386   // Set the hazard ptr in the originating thread to protect the
387   // current list of threads. This VM operation needs the current list
388   // of threads for a proper dump and those are the JavaThreads we need
389   // to be protected when we return info to the originating thread.
390   _result->set_t_list();
391 

351     assert(monitor->has_owner(), "Expects only owned monitors");
352 
353     if (monitor->is_owner_anonymous()) {
354       // There's no need to collect anonymous owned monitors
355       // because the caller of this code is only interested
356       // in JNI owned monitors.
357       return;
358     }
359 
360     if (monitor->object_peek() == nullptr) {
361       // JNI code doesn't necessarily keep the monitor object
362       // alive. Filter out monitors with dead objects.
363       return;
364     }
365 
366     add(monitor);
367   }
368 
369   // Implements the ObjectMonitorsView interface
370   void visit(MonitorClosure* closure, JavaThread* thread) override {
371     void* key = (void*)java_lang_Thread::thread_id(thread->threadObj());
372     ObjectMonitorLinkedList* list = get_list(key);
373     LinkedListIterator<ObjectMonitor*> iter(list != nullptr ? list->head() : nullptr);
374     while (!iter.is_empty()) {
375       ObjectMonitor* monitor = *iter.next();
376       closure->do_monitor(monitor);
377     }
378   }
379 
380   size_t key_count() { return _key_count; }
381   size_t om_count() { return _om_count; }
382 };
383 
384 void VM_ThreadDump::doit() {
385   ResourceMark rm;
386 
387   // Set the hazard ptr in the originating thread to protect the
388   // current list of threads. This VM operation needs the current list
389   // of threads for a proper dump and those are the JavaThreads we need
390   // to be protected when we return info to the originating thread.
391   _result->set_t_list();
392 
< prev index next >