< prev index next >

src/hotspot/share/runtime/sweeper.cpp

Print this page
rev 57079 : [mq]: handshake-logs


 294     return NULL;
 295   }
 296 
 297   // Increase time so that we can estimate when to invoke the sweeper again.
 298   _time_counter++;
 299 
 300   // Check for restart
 301   if (_current.method() != NULL) {
 302     if (_current.method()->is_nmethod()) {
 303       assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid");
 304     } else if (_current.method()->is_aot()) {
 305       assert(CodeCache::find_blob_unsafe(_current.method()->code_begin()) == _current.method(), "Sweeper AOT method cached state invalid");
 306     } else {
 307       ShouldNotReachHere();
 308     }
 309   }
 310 
 311   return &set_hotness_closure;
 312 }
 313 










 314 /**
 315   * This function triggers a VM operation that does stack scanning of active
 316   * methods. Stack scanning is mandatory for the sweeper to make progress.
 317   */
 318 void NMethodSweeper::do_stack_scanning() {
 319   assert(!CodeCache_lock->owned_by_self(), "just checking");
 320   if (wait_for_stack_scanning()) {
 321     if (ThreadLocalHandshakes) {
 322       CodeBlobClosure* code_cl;
 323       {
 324         MutexLocker ccl(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 325         code_cl = prepare_mark_active_nmethods();
 326       }
 327       if (code_cl != NULL) {
 328         NMethodMarkingThreadClosure tcl(code_cl);
 329         Handshake::execute(&tcl);

 330       }
 331     } else {
 332       VM_MarkActiveNMethods op;
 333       VMThread::execute(&op);
 334     }
 335   }
 336 }
 337 
 338 void NMethodSweeper::sweeper_loop() {
 339   bool timeout;
 340   while (true) {
 341     {
 342       ThreadBlockInVM tbivm(JavaThread::current());
 343       MonitorLocker waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 344       const long wait_time = 60*60*24 * 1000;
 345       timeout = waiter.wait(wait_time);
 346     }
 347     if (!timeout) {
 348       possibly_sweep();
 349     }




 294     return NULL;
 295   }
 296 
 297   // Increase time so that we can estimate when to invoke the sweeper again.
 298   _time_counter++;
 299 
 300   // Check for restart
 301   if (_current.method() != NULL) {
 302     if (_current.method()->is_nmethod()) {
 303       assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid");
 304     } else if (_current.method()->is_aot()) {
 305       assert(CodeCache::find_blob_unsafe(_current.method()->code_begin()) == _current.method(), "Sweeper AOT method cached state invalid");
 306     } else {
 307       ShouldNotReachHere();
 308     }
 309   }
 310 
 311   return &set_hotness_closure;
 312 }
 313 
 314 class NMethodMarkingHandshake : public HandshakeOperation {
 315   NMethodMarkingThreadClosure* _cl;
 316  public:
 317   NMethodMarkingHandshake(NMethodMarkingThreadClosure* cl) : _cl(cl) {}
 318   const char* name() { return "NMethodMarking";};
 319   void do_thread(JavaThread* jt) {
 320     _cl->do_thread(jt);
 321   }
 322 };
 323 
 324 /**
 325   * This function triggers a VM operation that does stack scanning of active
 326   * methods. Stack scanning is mandatory for the sweeper to make progress.
 327   */
 328 void NMethodSweeper::do_stack_scanning() {
 329   assert(!CodeCache_lock->owned_by_self(), "just checking");
 330   if (wait_for_stack_scanning()) {
 331     if (ThreadLocalHandshakes) {
 332       CodeBlobClosure* code_cl;
 333       {
 334         MutexLocker ccl(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 335         code_cl = prepare_mark_active_nmethods();
 336       }
 337       if (code_cl != NULL) {
 338         NMethodMarkingThreadClosure tcl(code_cl);
 339         NMethodMarkingHandshake nm_hs(&tcl);
 340         Handshake::execute(&nm_hs);
 341       }
 342     } else {
 343       VM_MarkActiveNMethods op;
 344       VMThread::execute(&op);
 345     }
 346   }
 347 }
 348 
 349 void NMethodSweeper::sweeper_loop() {
 350   bool timeout;
 351   while (true) {
 352     {
 353       ThreadBlockInVM tbivm(JavaThread::current());
 354       MonitorLocker waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 355       const long wait_time = 60*60*24 * 1000;
 356       timeout = waiter.wait(wait_time);
 357     }
 358     if (!timeout) {
 359       possibly_sweep();
 360     }


< prev index next >