< prev index next >

src/hotspot/share/aot/aotCompiledMethod.cpp

Print this page
rev 54697 : imported patch 8221734-v2-merge


 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     Method::unlink_code(method(), this);
 192   } // leave critical region under CompiledMethod_lock




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


< prev index next >