< prev index next >

src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp

Print this page




 339 * at this point in order to increase overall success of dumping jfr data:
 340 *
 341 * 1. if the thread state is not "_thread_in_vm", we will quick transition
 342 *    it to "_thread_in_vm".
 343 * 2. the nesting state for both resource and handle areas are unknown,
 344 *    so we allocate new fresh arenas, discarding the old ones.
 345 * 3. if the thread is the owner of some critical lock(s), unlock them.
 346 *
 347 * If we end up deadlocking in the attempt of dumping out jfr data,
 348 * we rely on the WatcherThread task "is_error_reported()",
 349 * to exit the VM after a hard-coded timeout.
 350 * This "safety net" somewhat explains the aggressiveness in this attempt.
 351 *
 352 */
 353 static void prepare_for_emergency_dump(Thread* thread) {
 354   if (thread->is_Java_thread()) {
 355     ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 356   }
 357 
 358 #ifdef ASSERT
 359   Monitor* owned_lock = thread->owned_locks();
 360   while (owned_lock != NULL) {
 361     Monitor* next = owned_lock->next();
 362     owned_lock->unlock();
 363     owned_lock = next;
 364   }
 365 #endif // ASSERT
 366 
 367   if (Threads_lock->owned_by_self()) {
 368     Threads_lock->unlock();
 369   }
 370 
 371   if (Module_lock->owned_by_self()) {
 372     Module_lock->unlock();
 373   }
 374 
 375   if (ClassLoaderDataGraph_lock->owned_by_self()) {
 376     ClassLoaderDataGraph_lock->unlock();
 377   }
 378 
 379   if (Heap_lock->owned_by_self()) {
 380     Heap_lock->unlock();
 381   }




 339 * at this point in order to increase overall success of dumping jfr data:
 340 *
 341 * 1. if the thread state is not "_thread_in_vm", we will quick transition
 342 *    it to "_thread_in_vm".
 343 * 2. the nesting state for both resource and handle areas are unknown,
 344 *    so we allocate new fresh arenas, discarding the old ones.
 345 * 3. if the thread is the owner of some critical lock(s), unlock them.
 346 *
 347 * If we end up deadlocking in the attempt of dumping out jfr data,
 348 * we rely on the WatcherThread task "is_error_reported()",
 349 * to exit the VM after a hard-coded timeout.
 350 * This "safety net" somewhat explains the aggressiveness in this attempt.
 351 *
 352 */
 353 static void prepare_for_emergency_dump(Thread* thread) {
 354   if (thread->is_Java_thread()) {
 355     ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 356   }
 357 
 358 #ifdef ASSERT
 359   Mutex* owned_lock = thread->owned_locks();
 360   while (owned_lock != NULL) {
 361     Mutex* next = owned_lock->next();
 362     owned_lock->unlock();
 363     owned_lock = next;
 364   }
 365 #endif // ASSERT
 366 
 367   if (Threads_lock->owned_by_self()) {
 368     Threads_lock->unlock();
 369   }
 370 
 371   if (Module_lock->owned_by_self()) {
 372     Module_lock->unlock();
 373   }
 374 
 375   if (ClassLoaderDataGraph_lock->owned_by_self()) {
 376     ClassLoaderDataGraph_lock->unlock();
 377   }
 378 
 379   if (Heap_lock->owned_by_self()) {
 380     Heap_lock->unlock();
 381   }


< prev index next >