187 void VM_ZombieAll::doit() { 188 JavaThread *thread = (JavaThread *)calling_thread(); 189 assert(thread->is_Java_thread(), "must be a Java thread"); 190 thread->make_zombies(); 191 } 192 193 #endif // !PRODUCT 194 195 void VM_UnlinkSymbols::doit() { 196 JavaThread *thread = (JavaThread *)calling_thread(); 197 assert(thread->is_Java_thread(), "must be a Java thread"); 198 SymbolTable::unlink(); 199 } 200 201 void VM_Verify::doit() { 202 Universe::heap()->prepare_for_verify(); 203 Universe::verify(); 204 } 205 206 bool VM_PrintThreads::doit_prologue() { 207 // Make sure AbstractOwnableSynchronizer is loaded 208 JavaThread* jt = JavaThread::current(); 209 java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(jt); 210 if (jt->has_pending_exception()) { 211 return false; 212 } 213 214 // Get Heap_lock if concurrent locks will be dumped 215 if (_print_concurrent_locks) { 216 Heap_lock->lock(); 217 } 218 return true; 219 } 220 221 void VM_PrintThreads::doit() { 222 Threads::print_on(_out, true, false, _print_concurrent_locks); 223 } 224 225 void VM_PrintThreads::doit_epilogue() { 226 if (_print_concurrent_locks) { 227 // Release Heap_lock 228 Heap_lock->unlock(); 229 } 230 } 231 232 void VM_PrintJNI::doit() { 233 JNIHandles::print_on(_out); 234 } 235 236 void VM_PrintMetadata::doit() { 237 MetaspaceUtils::print_report(_out, _scale, _flags); 238 } 239 240 VM_FindDeadlocks::~VM_FindDeadlocks() { 241 if (_deadlocks != NULL) { 242 DeadlockCycle* cycle = _deadlocks; 243 while (cycle != NULL) { 244 DeadlockCycle* d = cycle; 245 cycle = cycle->next(); 246 delete d; 247 } 248 } 249 } 250 251 bool VM_FindDeadlocks::doit_prologue() { 252 if (_concurrent_locks) { 253 // Make sure AbstractOwnableSynchronizer is loaded 254 JavaThread* jt = JavaThread::current(); 255 java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(jt); 256 if (jt->has_pending_exception()) { 257 return false; 258 } 259 } 260 261 return true; 262 } 263 264 void VM_FindDeadlocks::doit() { 265 // Update the hazard ptr in the originating thread to the current 266 // list of threads. This VM operation needs the current list of 267 // threads for proper deadlock detection and those are the 268 // JavaThreads we need to be protected when we return info to the 269 // originating thread. 270 _setter.set(); 271 272 _deadlocks = ThreadService::find_deadlocks_at_safepoint(_setter.list(), _concurrent_locks); 273 if (_out != NULL) { 274 int num_deadlocks = 0; 275 for (DeadlockCycle* cycle = _deadlocks; cycle != NULL; cycle = cycle->next()) { 276 num_deadlocks++; 277 cycle->print_on_with(_setter.list(), _out); 278 } 279 280 if (num_deadlocks == 1) { 281 _out->print_cr("\nFound 1 deadlock.\n"); 282 _out->flush(); 283 } else if (num_deadlocks > 1) { 299 _with_locked_monitors = with_locked_monitors; 300 _with_locked_synchronizers = with_locked_synchronizers; 301 } 302 303 VM_ThreadDump::VM_ThreadDump(ThreadDumpResult* result, 304 GrowableArray<instanceHandle>* threads, 305 int num_threads, 306 int max_depth, 307 bool with_locked_monitors, 308 bool with_locked_synchronizers) { 309 _result = result; 310 _num_threads = num_threads; 311 _threads = threads; 312 _result = result; 313 _max_depth = max_depth; 314 _with_locked_monitors = with_locked_monitors; 315 _with_locked_synchronizers = with_locked_synchronizers; 316 } 317 318 bool VM_ThreadDump::doit_prologue() { 319 // Make sure AbstractOwnableSynchronizer is loaded 320 JavaThread* jt = JavaThread::current(); 321 java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(jt); 322 if (jt->has_pending_exception()) { 323 return false; 324 } 325 326 if (_with_locked_synchronizers) { 327 // Acquire Heap_lock to dump concurrent locks 328 Heap_lock->lock(); 329 } 330 331 return true; 332 } 333 334 void VM_ThreadDump::doit_epilogue() { 335 if (_with_locked_synchronizers) { 336 // Release Heap_lock 337 Heap_lock->unlock(); 338 } 339 } 340 341 void VM_ThreadDump::doit() { 342 ResourceMark rm; 343 344 // Set the hazard ptr in the originating thread to protect the 345 // current list of threads. This VM operation needs the current list | 187 void VM_ZombieAll::doit() { 188 JavaThread *thread = (JavaThread *)calling_thread(); 189 assert(thread->is_Java_thread(), "must be a Java thread"); 190 thread->make_zombies(); 191 } 192 193 #endif // !PRODUCT 194 195 void VM_UnlinkSymbols::doit() { 196 JavaThread *thread = (JavaThread *)calling_thread(); 197 assert(thread->is_Java_thread(), "must be a Java thread"); 198 SymbolTable::unlink(); 199 } 200 201 void VM_Verify::doit() { 202 Universe::heap()->prepare_for_verify(); 203 Universe::verify(); 204 } 205 206 bool VM_PrintThreads::doit_prologue() { 207 // Get Heap_lock if concurrent locks will be dumped 208 if (_print_concurrent_locks) { 209 Heap_lock->lock(); 210 } 211 return true; 212 } 213 214 void VM_PrintThreads::doit() { 215 Threads::print_on(_out, true, false, _print_concurrent_locks); 216 } 217 218 void VM_PrintThreads::doit_epilogue() { 219 if (_print_concurrent_locks) { 220 // Release Heap_lock 221 Heap_lock->unlock(); 222 } 223 } 224 225 void VM_PrintJNI::doit() { 226 JNIHandles::print_on(_out); 227 } 228 229 void VM_PrintMetadata::doit() { 230 MetaspaceUtils::print_report(_out, _scale, _flags); 231 } 232 233 VM_FindDeadlocks::~VM_FindDeadlocks() { 234 if (_deadlocks != NULL) { 235 DeadlockCycle* cycle = _deadlocks; 236 while (cycle != NULL) { 237 DeadlockCycle* d = cycle; 238 cycle = cycle->next(); 239 delete d; 240 } 241 } 242 } 243 244 void VM_FindDeadlocks::doit() { 245 // Update the hazard ptr in the originating thread to the current 246 // list of threads. This VM operation needs the current list of 247 // threads for proper deadlock detection and those are the 248 // JavaThreads we need to be protected when we return info to the 249 // originating thread. 250 _setter.set(); 251 252 _deadlocks = ThreadService::find_deadlocks_at_safepoint(_setter.list(), _concurrent_locks); 253 if (_out != NULL) { 254 int num_deadlocks = 0; 255 for (DeadlockCycle* cycle = _deadlocks; cycle != NULL; cycle = cycle->next()) { 256 num_deadlocks++; 257 cycle->print_on_with(_setter.list(), _out); 258 } 259 260 if (num_deadlocks == 1) { 261 _out->print_cr("\nFound 1 deadlock.\n"); 262 _out->flush(); 263 } else if (num_deadlocks > 1) { 279 _with_locked_monitors = with_locked_monitors; 280 _with_locked_synchronizers = with_locked_synchronizers; 281 } 282 283 VM_ThreadDump::VM_ThreadDump(ThreadDumpResult* result, 284 GrowableArray<instanceHandle>* threads, 285 int num_threads, 286 int max_depth, 287 bool with_locked_monitors, 288 bool with_locked_synchronizers) { 289 _result = result; 290 _num_threads = num_threads; 291 _threads = threads; 292 _result = result; 293 _max_depth = max_depth; 294 _with_locked_monitors = with_locked_monitors; 295 _with_locked_synchronizers = with_locked_synchronizers; 296 } 297 298 bool VM_ThreadDump::doit_prologue() { 299 if (_with_locked_synchronizers) { 300 // Acquire Heap_lock to dump concurrent locks 301 Heap_lock->lock(); 302 } 303 304 return true; 305 } 306 307 void VM_ThreadDump::doit_epilogue() { 308 if (_with_locked_synchronizers) { 309 // Release Heap_lock 310 Heap_lock->unlock(); 311 } 312 } 313 314 void VM_ThreadDump::doit() { 315 ResourceMark rm; 316 317 // Set the hazard ptr in the originating thread to protect the 318 // current list of threads. This VM operation needs the current list |