< prev index next >

src/hotspot/share/code/nmethod.cpp

Print this page




1072     }
1073 #ifdef ASSERT
1074     if (method() != NULL) {
1075       // Make sure osr nmethod is invalidated, i.e. not on the list
1076       bool found = method()->method_holder()->remove_osr_nmethod(this);
1077       assert(!found, "osr nmethod should have been invalidated");
1078     }
1079 #endif
1080   }
1081 
1082   // If _method is already NULL the Method* is about to be unloaded,
1083   // so we don't have to break the cycle. Note that it is possible to
1084   // have the Method* live here, in case we unload the nmethod because
1085   // it is pointing to some oop (other than the Method*) being unloaded.
1086   if (_method != NULL) {
1087     // OSR methods point to the Method*, but the Method* does not
1088     // point back!
1089     if (_method->code() == this) {
1090       _method->clear_code(); // Break a cycle
1091     }
1092     _method = NULL;            // Clear the method of this dead nmethod
1093   }
1094 
1095   // Make the class unloaded - i.e., change state and notify sweeper
1096   assert(SafepointSynchronize::is_at_safepoint() || Thread::current()->is_ConcurrentGC_thread(),
1097          "must be at safepoint");
1098 
1099   {
1100     // Clear ICStubs and release any CompiledICHolders.
1101     CompiledICLocker ml(this);
1102     clear_ic_callsites();
1103   }
1104 
1105   // Unregister must be done before the state change
1106   {
1107     MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock,
1108                      Mutex::_no_safepoint_check_flag);
1109     Universe::heap()->unregister_nmethod(this);
1110   }



1111 
1112   // Log the unloading.
1113   log_state_change();
1114 
1115 #if INCLUDE_JVMCI
1116   // The method can only be unloaded after the pointer to the installed code
1117   // Java wrapper is no longer alive. Here we need to clear out this weak
1118   // reference to the dead object.
1119   maybe_invalidate_installed_code();
1120 #endif
1121 
1122   // The Method* is gone at this point
1123   assert(_method == NULL, "Tautology");
1124 
1125   set_osr_link(NULL);
1126   NMethodSweeper::report_state_change(this);
1127 
1128   // The release is only needed for compile-time ordering, as accesses
1129   // into the nmethod after the store are not safe due to the sweeper
1130   // being allowed to free it when the store is observed, during




1072     }
1073 #ifdef ASSERT
1074     if (method() != NULL) {
1075       // Make sure osr nmethod is invalidated, i.e. not on the list
1076       bool found = method()->method_holder()->remove_osr_nmethod(this);
1077       assert(!found, "osr nmethod should have been invalidated");
1078     }
1079 #endif
1080   }
1081 
1082   // If _method is already NULL the Method* is about to be unloaded,
1083   // so we don't have to break the cycle. Note that it is possible to
1084   // have the Method* live here, in case we unload the nmethod because
1085   // it is pointing to some oop (other than the Method*) being unloaded.
1086   if (_method != NULL) {
1087     // OSR methods point to the Method*, but the Method* does not
1088     // point back!
1089     if (_method->code() == this) {
1090       _method->clear_code(); // Break a cycle
1091     }

1092   }
1093 
1094   // Make the class unloaded - i.e., change state and notify sweeper
1095   assert(SafepointSynchronize::is_at_safepoint() || Thread::current()->is_ConcurrentGC_thread(),
1096          "must be at safepoint");
1097 
1098   {
1099     // Clear ICStubs and release any CompiledICHolders.
1100     CompiledICLocker ml(this);
1101     clear_ic_callsites();
1102   }
1103 
1104   // Unregister must be done before the state change
1105   {
1106     MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock,
1107                      Mutex::_no_safepoint_check_flag);
1108     Universe::heap()->unregister_nmethod(this);
1109   }
1110 
1111   // Clear the method of this dead nmethod
1112   set_method(NULL);
1113 
1114   // Log the unloading.
1115   log_state_change();
1116 
1117 #if INCLUDE_JVMCI
1118   // The method can only be unloaded after the pointer to the installed code
1119   // Java wrapper is no longer alive. Here we need to clear out this weak
1120   // reference to the dead object.
1121   maybe_invalidate_installed_code();
1122 #endif
1123 
1124   // The Method* is gone at this point
1125   assert(_method == NULL, "Tautology");
1126 
1127   set_osr_link(NULL);
1128   NMethodSweeper::report_state_change(this);
1129 
1130   // The release is only needed for compile-time ordering, as accesses
1131   // into the nmethod after the store are not safe due to the sweeper
1132   // being allowed to free it when the store is observed, during


< prev index next >