Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/runtime/sweeper.cpp
          +++ new/src/share/vm/runtime/sweeper.cpp
↓ open down ↓ 258 lines elided ↑ open up ↑
 259  259    int todo = (CodeCache::nof_nmethods() - _seen) / _invocations;
 260  260  
 261  261    assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here");
 262  262    assert(!CodeCache_lock->owned_by_self(), "just checking");
 263  263  
 264  264    {
 265  265      MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 266  266  
 267  267      // The last invocation iterates until there are no more nmethods
 268  268      for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) {
      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);
 269  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  280        // Since we will give up the CodeCache_lock, always skip ahead
 271  281        // to the next nmethod.  Other blobs can be deleted by other
 272  282        // threads but nmethods are only reclaimed by the sweeper.
 273  283        nmethod* next = CodeCache::next_nmethod(_current);
 274  284  
 275  285        // Now ready to process nmethod and give up CodeCache_lock
 276  286        {
 277  287          MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 278  288          process_nmethod(_current);
 279  289        }
↓ open down ↓ 298 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX