< prev index next >

src/hotspot/share/aot/aotCompiledMethod.cpp

Print this page
rev 54621 : imported patch 8221734-v1


 150       }
 151       meta = ((intptr_t)m) | 1;
 152       *entry = (Metadata*)meta; // Should be atomic on x64
 153       return (Metadata*)m;
 154     }
 155   }
 156   ShouldNotReachHere(); return NULL;
 157 }
 158 
 159 void AOTCompiledMethod::do_unloading(bool unloading_occurred) {
 160   unload_nmethod_caches(unloading_occurred);
 161 }
 162 
 163 bool AOTCompiledMethod::make_not_entrant_helper(int new_state) {
 164   // Make sure the method is not flushed in case of a safepoint in code below.
 165   methodHandle the_method(method());
 166   NoSafepointVerifier nsv;
 167 
 168   {
 169     // Enter critical section.  Does not block for safepoint.
 170     MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
 171 
 172     if (*_state_adr == new_state) {
 173       // another thread already performed this transition so nothing
 174       // to do, but return false to indicate this.
 175       return false;
 176     }
 177 
 178     // Change state
 179     OrderAccess::storestore();
 180     *_state_adr = new_state;
 181 
 182     // Log the transition once
 183     log_state_change();
 184 
 185 #ifdef TIERED
 186     // Remain non-entrant forever
 187     if (new_state == not_entrant && method() != NULL) {
 188         method()->set_aot_code(NULL);
 189     }
 190 #endif
 191 
 192     // Remove AOTCompiledMethod from method.
 193     if (method() != NULL && (method()->code() == this ||
 194                              method()->from_compiled_entry() == verified_entry_point())) {
 195       HandleMark hm;
 196       method()->clear_code(false /* already owns Patching_lock */);
 197     }
 198   } // leave critical region under Patching_lock
 199 
 200 
 201   if (TraceCreateZombies) {
 202     ResourceMark m;
 203     const char *new_state_str = (new_state == not_entrant) ? "not entrant" : "not used";
 204     tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made %s", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null", new_state_str);
 205   }
 206 
 207   return true;
 208 }
 209 
 210 #ifdef TIERED
 211 bool AOTCompiledMethod::make_entrant() {
 212   assert(!method()->is_old(), "reviving evolved method!");
 213   assert(*_state_adr != not_entrant, "%s", method()->has_aot_code() ? "has_aot_code() not cleared" : "caller didn't check has_aot_code()");
 214 
 215   // Make sure the method is not flushed in case of a safepoint in code below.
 216   methodHandle the_method(method());
 217   NoSafepointVerifier nsv;
 218 
 219   {
 220     // Enter critical section.  Does not block for safepoint.
 221     MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
 222 
 223     if (*_state_adr == in_use) {
 224       // another thread already performed this transition so nothing
 225       // to do, but return false to indicate this.
 226       return false;
 227     }
 228 
 229     // Change state
 230     OrderAccess::storestore();
 231     *_state_adr = in_use;
 232 
 233     // Log the transition once
 234     log_state_change();
 235   } // leave critical region under Patching_lock
 236 
 237 
 238   if (TraceCreateZombies) {
 239     ResourceMark m;
 240     tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made entrant", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null");
 241   }
 242 
 243   return true;
 244 }
 245 #endif // TIERED
 246 
 247 // Iterate over metadata calling this function.   Used by RedefineClasses
 248 // Copied from nmethod::metadata_do
 249 void AOTCompiledMethod::metadata_do(MetadataClosure* f) {
 250   address low_boundary = verified_entry_point();
 251   {
 252     // Visit all immediate references that are embedded in the instruction stream.
 253     RelocIterator iter(this, low_boundary);
 254     while (iter.next()) {
 255       if (iter.type() == relocInfo::metadata_type ) {




 150       }
 151       meta = ((intptr_t)m) | 1;
 152       *entry = (Metadata*)meta; // Should be atomic on x64
 153       return (Metadata*)m;
 154     }
 155   }
 156   ShouldNotReachHere(); return NULL;
 157 }
 158 
 159 void AOTCompiledMethod::do_unloading(bool unloading_occurred) {
 160   unload_nmethod_caches(unloading_occurred);
 161 }
 162 
 163 bool AOTCompiledMethod::make_not_entrant_helper(int new_state) {
 164   // Make sure the method is not flushed in case of a safepoint in code below.
 165   methodHandle the_method(method());
 166   NoSafepointVerifier nsv;
 167 
 168   {
 169     // Enter critical section.  Does not block for safepoint.
 170     MutexLockerEx pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
 171 
 172     if (*_state_adr == new_state) {
 173       // another thread already performed this transition so nothing
 174       // to do, but return false to indicate this.
 175       return false;
 176     }
 177 
 178     // Change state
 179     OrderAccess::storestore();
 180     *_state_adr = new_state;
 181 
 182     // Log the transition once
 183     log_state_change();
 184 
 185 #ifdef TIERED
 186     // Remain non-entrant forever
 187     if (new_state == not_entrant && method() != NULL) {
 188         method()->set_aot_code(NULL);
 189     }
 190 #endif
 191 
 192     // Remove AOTCompiledMethod from method.
 193     Method::unlink_code(method(), this);
 194   } // leave critical region under CompiledMethod_lock




 195 
 196 
 197   if (TraceCreateZombies) {
 198     ResourceMark m;
 199     const char *new_state_str = (new_state == not_entrant) ? "not entrant" : "not used";
 200     tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made %s", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null", new_state_str);
 201   }
 202 
 203   return true;
 204 }
 205 
 206 #ifdef TIERED
 207 bool AOTCompiledMethod::make_entrant() {
 208   assert(!method()->is_old(), "reviving evolved method!");
 209   assert(*_state_adr != not_entrant, "%s", method()->has_aot_code() ? "has_aot_code() not cleared" : "caller didn't check has_aot_code()");
 210 
 211   // Make sure the method is not flushed in case of a safepoint in code below.
 212   methodHandle the_method(method());
 213   NoSafepointVerifier nsv;
 214 
 215   {
 216     // Enter critical section.  Does not block for safepoint.
 217     MutexLockerEx pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
 218 
 219     if (*_state_adr == in_use) {
 220       // another thread already performed this transition so nothing
 221       // to do, but return false to indicate this.
 222       return false;
 223     }
 224 
 225     // Change state
 226     OrderAccess::storestore();
 227     *_state_adr = in_use;
 228 
 229     // Log the transition once
 230     log_state_change();
 231   } // leave critical region under CompiledMethod_lock
 232 
 233 
 234   if (TraceCreateZombies) {
 235     ResourceMark m;
 236     tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made entrant", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null");
 237   }
 238 
 239   return true;
 240 }
 241 #endif // TIERED
 242 
 243 // Iterate over metadata calling this function.   Used by RedefineClasses
 244 // Copied from nmethod::metadata_do
 245 void AOTCompiledMethod::metadata_do(MetadataClosure* f) {
 246   address low_boundary = verified_entry_point();
 247   {
 248     // Visit all immediate references that are embedded in the instruction stream.
 249     RelocIterator iter(this, low_boundary);
 250     while (iter.next()) {
 251       if (iter.type() == relocInfo::metadata_type ) {


< prev index next >