< prev index next >

src/hotspot/share/aot/aotCompiledMethod.cpp

Print this page
rev 56251 : imported patch 8226705-v1
rev 56252 : imported patch 8226705-v2


 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 
 210   // Make sure the method is not flushed in case of a safepoint in code below.
 211   methodHandle the_method(method());
 212   NoSafepointVerifier nsv;
 213 
 214   {
 215     // Enter critical section.  Does not block for safepoint.
 216     MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
 217 
 218     if (*_state_adr == in_use || *_state_adr == not_entrant) {
 219       // another thread already performed this transition so nothing
 220       // to do, but return false to indicate this.
 221       return false;
 222     }
 223 
 224     // Change state
 225     OrderAccess::storestore();
 226     *_state_adr = in_use;
 227 
 228     // Log the transition once
 229     log_state_change();
 230   } // leave critical region under CompiledMethod_lock
 231 
 232 
 233   if (TraceCreateZombies) {
 234     ResourceMark m;
 235     tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made entrant", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null");
 236   }
 237 
 238   return true;
 239 }
 240 #endif // TIERED
 241 
 242 // Iterate over metadata calling this function.   Used by RedefineClasses
 243 // Copied from nmethod::metadata_do
 244 void AOTCompiledMethod::metadata_do(MetadataClosure* f) {
 245   address low_boundary = verified_entry_point();
 246   {
 247     // Visit all immediate references that are embedded in the instruction stream.
 248     RelocIterator iter(this, low_boundary);
 249     while (iter.next()) {
 250       if (iter.type() == relocInfo::metadata_type ) {


< prev index next >