Mercurial > hg > truffle
comparison src/share/vm/code/nmethod.cpp @ 1544:1a88d3c58e1d
Merge
author | jrose |
---|---|
date | Thu, 20 May 2010 01:34:22 -0700 |
parents | bfe29ec02863 |
children | c18cbe5936b8 1a5913bf5e19 |
comparison
equal
deleted
inserted
replaced
1536:892898e961c5 | 1544:1a88d3c58e1d |
---|---|
1012 } | 1012 } |
1013 | 1013 |
1014 | 1014 |
1015 void nmethod::cleanup_inline_caches() { | 1015 void nmethod::cleanup_inline_caches() { |
1016 | 1016 |
1017 assert(SafepointSynchronize::is_at_safepoint() && | 1017 assert_locked_or_safepoint(CompiledIC_lock); |
1018 !CompiledIC_lock->is_locked() && | |
1019 !Patching_lock->is_locked(), "no threads must be updating the inline caches by them selfs"); | |
1020 | 1018 |
1021 // If the method is not entrant or zombie then a JMP is plastered over the | 1019 // If the method is not entrant or zombie then a JMP is plastered over the |
1022 // first few bytes. If an oop in the old code was there, that oop | 1020 // first few bytes. If an oop in the old code was there, that oop |
1023 // should not get GC'd. Skip the first few bytes of oops on | 1021 // should not get GC'd. Skip the first few bytes of oops on |
1024 // not-entrant methods. | 1022 // not-entrant methods. |
1069 } | 1067 } |
1070 | 1068 |
1071 // Tell if a non-entrant method can be converted to a zombie (i.e., there is no activations on the stack) | 1069 // Tell if a non-entrant method can be converted to a zombie (i.e., there is no activations on the stack) |
1072 bool nmethod::can_not_entrant_be_converted() { | 1070 bool nmethod::can_not_entrant_be_converted() { |
1073 assert(is_not_entrant(), "must be a non-entrant method"); | 1071 assert(is_not_entrant(), "must be a non-entrant method"); |
1074 assert(SafepointSynchronize::is_at_safepoint(), "must be called during a safepoint"); | |
1075 | 1072 |
1076 // Since the nmethod sweeper only does partial sweep the sweeper's traversal | 1073 // Since the nmethod sweeper only does partial sweep the sweeper's traversal |
1077 // count can be greater than the stack traversal count before it hits the | 1074 // count can be greater than the stack traversal count before it hits the |
1078 // nmethod for the second time. | 1075 // nmethod for the second time. |
1079 return stack_traversal_mark()+1 < NMethodSweeper::traversal_count(); | 1076 return stack_traversal_mark()+1 < NMethodSweeper::traversal_count(); |
1125 _method->clear_code(); // Break a cycle | 1122 _method->clear_code(); // Break a cycle |
1126 } | 1123 } |
1127 _method = NULL; // Clear the method of this dead nmethod | 1124 _method = NULL; // Clear the method of this dead nmethod |
1128 } | 1125 } |
1129 // Make the class unloaded - i.e., change state and notify sweeper | 1126 // Make the class unloaded - i.e., change state and notify sweeper |
1130 check_safepoint(); | 1127 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
1131 if (is_in_use()) { | 1128 if (is_in_use()) { |
1132 // Transitioning directly from live to unloaded -- so | 1129 // Transitioning directly from live to unloaded -- so |
1133 // we need to force a cache clean-up; remember this | 1130 // we need to force a cache clean-up; remember this |
1134 // for later on. | 1131 // for later on. |
1135 CodeCache::set_needs_cache_clean(true); | 1132 CodeCache::set_needs_cache_clean(true); |
1218 NativeJump::patch_verified_entry(entry_point(), verified_entry_point(), | 1215 NativeJump::patch_verified_entry(entry_point(), verified_entry_point(), |
1219 SharedRuntime::get_handle_wrong_method_stub()); | 1216 SharedRuntime::get_handle_wrong_method_stub()); |
1220 assert (NativeJump::instruction_size == nmethod::_zombie_instruction_size, ""); | 1217 assert (NativeJump::instruction_size == nmethod::_zombie_instruction_size, ""); |
1221 } | 1218 } |
1222 | 1219 |
1223 // When the nmethod becomes zombie it is no longer alive so the | |
1224 // dependencies must be flushed. nmethods in the not_entrant | |
1225 // state will be flushed later when the transition to zombie | |
1226 // happens or they get unloaded. | |
1227 if (state == zombie) { | |
1228 assert(SafepointSynchronize::is_at_safepoint(), "must be done at safepoint"); | |
1229 flush_dependencies(NULL); | |
1230 } else { | |
1231 assert(state == not_entrant, "other cases may need to be handled differently"); | |
1232 } | |
1233 | |
1234 was_alive = is_in_use(); // Read state under lock | 1220 was_alive = is_in_use(); // Read state under lock |
1235 | 1221 |
1236 // Change state | 1222 // Change state |
1237 flags.state = state; | 1223 flags.state = state; |
1238 | 1224 |
1239 // Log the transition once | 1225 // Log the transition once |
1240 log_state_change(); | 1226 log_state_change(); |
1241 | 1227 |
1242 } // leave critical region under Patching_lock | 1228 } // leave critical region under Patching_lock |
1229 | |
1230 // When the nmethod becomes zombie it is no longer alive so the | |
1231 // dependencies must be flushed. nmethods in the not_entrant | |
1232 // state will be flushed later when the transition to zombie | |
1233 // happens or they get unloaded. | |
1234 if (state == zombie) { | |
1235 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
1236 flush_dependencies(NULL); | |
1237 } else { | |
1238 assert(state == not_entrant, "other cases may need to be handled differently"); | |
1239 } | |
1243 | 1240 |
1244 if (state == not_entrant) { | 1241 if (state == not_entrant) { |
1245 Events::log("Make nmethod not entrant " INTPTR_FORMAT, this); | 1242 Events::log("Make nmethod not entrant " INTPTR_FORMAT, this); |
1246 } else { | 1243 } else { |
1247 Events::log("Make nmethod zombie " INTPTR_FORMAT, this); | 1244 Events::log("Make nmethod zombie " INTPTR_FORMAT, this); |
1308 } | 1305 } |
1309 | 1306 |
1310 return true; | 1307 return true; |
1311 } | 1308 } |
1312 | 1309 |
1313 | |
1314 #ifndef PRODUCT | |
1315 void nmethod::check_safepoint() { | |
1316 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | |
1317 } | |
1318 #endif | |
1319 | |
1320 | |
1321 void nmethod::flush() { | 1310 void nmethod::flush() { |
1322 // Note that there are no valid oops in the nmethod anymore. | 1311 // Note that there are no valid oops in the nmethod anymore. |
1323 assert(is_zombie() || (is_osr_method() && is_unloaded()), "must be a zombie method"); | 1312 assert(is_zombie() || (is_osr_method() && is_unloaded()), "must be a zombie method"); |
1324 assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation"); | 1313 assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation"); |
1325 | 1314 |
1326 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed"); | 1315 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed"); |
1327 check_safepoint(); | 1316 assert_locked_or_safepoint(CodeCache_lock); |
1328 | 1317 |
1329 // completely deallocate this method | 1318 // completely deallocate this method |
1330 EventMark m("flushing nmethod " INTPTR_FORMAT " %s", this, ""); | 1319 EventMark m("flushing nmethod " INTPTR_FORMAT " %s", this, ""); |
1331 if (PrintMethodFlushing) { | 1320 if (PrintMethodFlushing) { |
1332 tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb", | 1321 tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb", |
1371 // traversing the dependency information in unsafe. In that case this | 1360 // traversing the dependency information in unsafe. In that case this |
1372 // function is called with a non-NULL argument and this function only | 1361 // function is called with a non-NULL argument and this function only |
1373 // notifies instanceKlasses that are reachable | 1362 // notifies instanceKlasses that are reachable |
1374 | 1363 |
1375 void nmethod::flush_dependencies(BoolObjectClosure* is_alive) { | 1364 void nmethod::flush_dependencies(BoolObjectClosure* is_alive) { |
1376 assert(SafepointSynchronize::is_at_safepoint(), "must be done at safepoint"); | 1365 assert_locked_or_safepoint(CodeCache_lock); |
1377 assert(Universe::heap()->is_gc_active() == (is_alive != NULL), | 1366 assert(Universe::heap()->is_gc_active() == (is_alive != NULL), |
1378 "is_alive is non-NULL if and only if we are called during GC"); | 1367 "is_alive is non-NULL if and only if we are called during GC"); |
1379 if (!has_flushed_dependencies()) { | 1368 if (!has_flushed_dependencies()) { |
1380 set_has_flushed_dependencies(); | 1369 set_has_flushed_dependencies(); |
1381 for (Dependencies::DepStream deps(this); deps.next(); ) { | 1370 for (Dependencies::DepStream deps(this); deps.next(); ) { |
2264 if (WizardMode) { | 2253 if (WizardMode) { |
2265 tty->print("((nmethod*) "INTPTR_FORMAT ") ", this); | 2254 tty->print("((nmethod*) "INTPTR_FORMAT ") ", this); |
2266 tty->print(" for method " INTPTR_FORMAT , (address)method()); | 2255 tty->print(" for method " INTPTR_FORMAT , (address)method()); |
2267 tty->print(" { "); | 2256 tty->print(" { "); |
2268 if (version()) tty->print("v%d ", version()); | 2257 if (version()) tty->print("v%d ", version()); |
2269 if (level()) tty->print("l%d ", level()); | |
2270 if (is_in_use()) tty->print("in_use "); | 2258 if (is_in_use()) tty->print("in_use "); |
2271 if (is_not_entrant()) tty->print("not_entrant "); | 2259 if (is_not_entrant()) tty->print("not_entrant "); |
2272 if (is_zombie()) tty->print("zombie "); | 2260 if (is_zombie()) tty->print("zombie "); |
2273 if (is_unloaded()) tty->print("unloaded "); | 2261 if (is_unloaded()) tty->print("unloaded "); |
2274 if (on_scavenge_root_list()) tty->print("scavenge_root "); | 2262 if (on_scavenge_root_list()) tty->print("scavenge_root "); |