src/hotspot/share/runtime/sweeper.cpp
changeset 54645 05aaccf7d558
parent 54623 1126f0607c70
child 57891 460f412c1358
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54644:8d52b4c6f9d8 54645:05aaccf7d558
   339 void NMethodSweeper::sweeper_loop() {
   339 void NMethodSweeper::sweeper_loop() {
   340   bool timeout;
   340   bool timeout;
   341   while (true) {
   341   while (true) {
   342     {
   342     {
   343       ThreadBlockInVM tbivm(JavaThread::current());
   343       ThreadBlockInVM tbivm(JavaThread::current());
   344       MutexLocker waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   344       MonitorLocker waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   345       const long wait_time = 60*60*24 * 1000;
   345       const long wait_time = 60*60*24 * 1000;
   346       timeout = CodeCache_lock->wait_without_safepoint_check(wait_time);
   346       timeout = waiter.wait(wait_time);
   347     }
   347     }
   348     if (!timeout) {
   348     if (!timeout) {
   349       possibly_sweep();
   349       possibly_sweep();
   350     }
   350     }
   351   }
   351   }
   367 /**
   367 /**
   368   * Wakes up the sweeper thread and forces a sweep. Blocks until it finished.
   368   * Wakes up the sweeper thread and forces a sweep. Blocks until it finished.
   369   */
   369   */
   370 void NMethodSweeper::force_sweep() {
   370 void NMethodSweeper::force_sweep() {
   371   ThreadBlockInVM tbivm(JavaThread::current());
   371   ThreadBlockInVM tbivm(JavaThread::current());
   372   MutexLocker waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   372   MonitorLocker waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   373   // Request forced sweep
   373   // Request forced sweep
   374   _force_sweep = true;
   374   _force_sweep = true;
   375   while (_force_sweep) {
   375   while (_force_sweep) {
   376     // Notify sweeper that we want to force a sweep and wait for completion.
   376     // Notify sweeper that we want to force a sweep and wait for completion.
   377     // In case a sweep currently takes place we timeout and try again because
   377     // In case a sweep currently takes place we timeout and try again because
   378     // we want to enforce a full sweep.
   378     // we want to enforce a full sweep.
   379     CodeCache_lock->notify();
   379     CodeCache_lock->notify();
   380     CodeCache_lock->wait_without_safepoint_check(1000);
   380     waiter.wait(1000);
   381   }
   381   }
   382 }
   382 }
   383 
   383 
   384 /**
   384 /**
   385  * Handle a safepoint request
   385  * Handle a safepoint request