Mercurial > hg > truffle
changeset 4945:cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
Summary: Safepoint in the sweeper loop in necessary
Reviewed-by: kvn, never
author | iveresov |
---|---|
date | Wed, 15 Feb 2012 12:32:03 -0800 |
parents | 09d00c18e323 |
children | 69333a2fbae2 |
files | src/share/vm/runtime/globals.hpp src/share/vm/runtime/sweeper.cpp |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/runtime/globals.hpp Wed Feb 15 10:12:55 2012 -0800 +++ b/src/share/vm/runtime/globals.hpp Wed Feb 15 12:32:03 2012 -0800 @@ -3013,7 +3013,7 @@ product(intx, SafepointTimeoutDelay, 10000, \ "Delay in milliseconds for option SafepointTimeout") \ \ - product(intx, NmethodSweepFraction, 4, \ + product(intx, NmethodSweepFraction, 16, \ "Number of invocations of sweeper to cover all nmethods") \ \ product(intx, NmethodSweepCheckInterval, 5, \
--- a/src/share/vm/runtime/sweeper.cpp Wed Feb 15 10:12:55 2012 -0800 +++ b/src/share/vm/runtime/sweeper.cpp Wed Feb 15 12:32:03 2012 -0800 @@ -266,7 +266,17 @@ // The last invocation iterates until there are no more nmethods for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { + if (SafepointSynchronize::is_synchronizing()) { // Safepoint request + if (PrintMethodFlushing && Verbose) { + tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); + } + MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + assert(Thread::current()->is_Java_thread(), "should be java thread"); + JavaThread* thread = (JavaThread*)Thread::current(); + ThreadBlockInVM tbivm(thread); + thread->java_suspend_self(); + } // Since we will give up the CodeCache_lock, always skip ahead // to the next nmethod. Other blobs can be deleted by other // threads but nmethods are only reclaimed by the sweeper.