264 { |
264 { |
265 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
265 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
266 |
266 |
267 // The last invocation iterates until there are no more nmethods |
267 // The last invocation iterates until there are no more nmethods |
268 for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { |
268 for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { |
269 |
269 if (SafepointSynchronize::is_synchronizing()) { // Safepoint request |
|
270 if (PrintMethodFlushing && Verbose) { |
|
271 tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); |
|
272 } |
|
273 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
274 |
|
275 assert(Thread::current()->is_Java_thread(), "should be java thread"); |
|
276 JavaThread* thread = (JavaThread*)Thread::current(); |
|
277 ThreadBlockInVM tbivm(thread); |
|
278 thread->java_suspend_self(); |
|
279 } |
270 // Since we will give up the CodeCache_lock, always skip ahead |
280 // Since we will give up the CodeCache_lock, always skip ahead |
271 // to the next nmethod. Other blobs can be deleted by other |
281 // to the next nmethod. Other blobs can be deleted by other |
272 // threads but nmethods are only reclaimed by the sweeper. |
282 // threads but nmethods are only reclaimed by the sweeper. |
273 nmethod* next = CodeCache::next_nmethod(_current); |
283 nmethod* next = CodeCache::next_nmethod(_current); |
274 |
284 |