267 // invocations so divide the remaining number of nmethods by the |
267 // invocations so divide the remaining number of nmethods by the |
268 // remaining number of invocations. This is only an estimate since |
268 // remaining number of invocations. This is only an estimate since |
269 // the number of nmethods changes during the sweep so the final |
269 // the number of nmethods changes during the sweep so the final |
270 // stage must iterate until it there are no more nmethods. |
270 // stage must iterate until it there are no more nmethods. |
271 int todo = (CodeCache::nof_nmethods() - _seen) / _invocations; |
271 int todo = (CodeCache::nof_nmethods() - _seen) / _invocations; |
|
272 int swept_count = 0; |
272 |
273 |
273 assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here"); |
274 assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here"); |
274 assert(!CodeCache_lock->owned_by_self(), "just checking"); |
275 assert(!CodeCache_lock->owned_by_self(), "just checking"); |
275 |
276 |
276 { |
277 { |
277 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
278 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
278 |
279 |
279 // The last invocation iterates until there are no more nmethods |
280 // The last invocation iterates until there are no more nmethods |
280 for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { |
281 for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { |
|
282 swept_count++; |
281 if (SafepointSynchronize::is_synchronizing()) { // Safepoint request |
283 if (SafepointSynchronize::is_synchronizing()) { // Safepoint request |
282 if (PrintMethodFlushing && Verbose) { |
284 if (PrintMethodFlushing && Verbose) { |
283 tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); |
285 tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); |
284 } |
286 } |
285 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
287 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
329 if (event.should_commit()) { |
331 if (event.should_commit()) { |
330 event.set_starttime(sweep_start_counter); |
332 event.set_starttime(sweep_start_counter); |
331 event.set_endtime(sweep_end_counter); |
333 event.set_endtime(sweep_end_counter); |
332 event.set_sweepIndex(_traversals); |
334 event.set_sweepIndex(_traversals); |
333 event.set_sweepFractionIndex(NmethodSweepFraction - _invocations + 1); |
335 event.set_sweepFractionIndex(NmethodSweepFraction - _invocations + 1); |
334 event.set_sweptCount(todo); |
336 event.set_sweptCount(swept_count); |
335 event.set_flushedCount(_flushed_count); |
337 event.set_flushedCount(_flushed_count); |
336 event.set_markedCount(_marked_count); |
338 event.set_markedCount(_marked_count); |
337 event.set_zombifiedCount(_zombified_count); |
339 event.set_zombifiedCount(_zombified_count); |
338 event.commit(); |
340 event.commit(); |
339 } |
341 } |