< prev index next >

src/hotspot/share/aot/aotCompiledMethod.cpp

Print this page
rev 54936 : [mq]: 8221734-v3


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




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


 193     }
 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     MutexLocker 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 >