src/hotspot/share/code/nmethod.cpp
changeset 53652 262afafdb266
parent 53641 c572eb605087
parent 53651 0331b08811ad
child 53921 a590b6107ab3
equal deleted inserted replaced
53649:0b959dfdf0d9 53652:262afafdb266
  1097 
  1097 
  1098   // Make the class unloaded - i.e., change state and notify sweeper
  1098   // Make the class unloaded - i.e., change state and notify sweeper
  1099   assert(SafepointSynchronize::is_at_safepoint() || Thread::current()->is_ConcurrentGC_thread(),
  1099   assert(SafepointSynchronize::is_at_safepoint() || Thread::current()->is_ConcurrentGC_thread(),
  1100          "must be at safepoint");
  1100          "must be at safepoint");
  1101 
  1101 
       
  1102   {
       
  1103     // Clear ICStubs and release any CompiledICHolders.
       
  1104     CompiledICLocker ml(this);
       
  1105     clear_ic_callsites();
       
  1106   }
       
  1107 
  1102   // Unregister must be done before the state change
  1108   // Unregister must be done before the state change
  1103   {
  1109   {
  1104     MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock,
  1110     MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock,
  1105                      Mutex::_no_safepoint_check_flag);
  1111                      Mutex::_no_safepoint_check_flag);
  1106     Universe::heap()->unregister_nmethod(this);
  1112     Universe::heap()->unregister_nmethod(this);
  1289       }
  1295       }
  1290       flush_dependencies(/*delete_immediately*/true);
  1296       flush_dependencies(/*delete_immediately*/true);
  1291     }
  1297     }
  1292 
  1298 
  1293     // Clear ICStubs to prevent back patching stubs of zombie or flushed
  1299     // Clear ICStubs to prevent back patching stubs of zombie or flushed
  1294     // nmethods during the next safepoint (see ICStub::finalize).
  1300     // nmethods during the next safepoint (see ICStub::finalize), as well
       
  1301     // as to free up CompiledICHolder resources.
  1295     {
  1302     {
  1296       CompiledICLocker ml(this);
  1303       CompiledICLocker ml(this);
  1297       clear_ic_stubs();
  1304       clear_ic_callsites();
  1298     }
  1305     }
  1299 
  1306 
  1300     // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload
  1307     // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload
  1301     // event and it hasn't already been reported for this nmethod then
  1308     // event and it hasn't already been reported for this nmethod then
  1302     // report it now. The event may have been reported earlier if the GC
  1309     // report it now. The event may have been reported earlier if the GC
  1324   NMethodSweeper::report_state_change(this);
  1331   NMethodSweeper::report_state_change(this);
  1325   return true;
  1332   return true;
  1326 }
  1333 }
  1327 
  1334 
  1328 void nmethod::flush() {
  1335 void nmethod::flush() {
       
  1336   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
  1329   // Note that there are no valid oops in the nmethod anymore.
  1337   // Note that there are no valid oops in the nmethod anymore.
  1330   assert(!is_osr_method() || is_unloaded() || is_zombie(),
  1338   assert(!is_osr_method() || is_unloaded() || is_zombie(),
  1331          "osr nmethod must be unloaded or zombie before flushing");
  1339          "osr nmethod must be unloaded or zombie before flushing");
  1332   assert(is_zombie() || is_osr_method(), "must be a zombie method");
  1340   assert(is_zombie() || is_osr_method(), "must be a zombie method");
  1333   assert (!is_locked_by_vm(), "locked methods shouldn't be flushed");
  1341   assert (!is_locked_by_vm(), "locked methods shouldn't be flushed");