1283 } else {
1284 xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s",
1285 os::current_thread_id(),
1286 (_state == zombie ? " zombie='1'" : ""));
1287 }
1288 log_identity(xtty);
1289 xtty->stamp();
1290 xtty->end_elem();
1291 }
1292 }
1293 if (PrintCompilation && _state != unloaded) {
1294 print_on(tty, _state == zombie ? "made zombie" : "made not entrant");
1295 }
1296 }
1297
1298 // Common functionality for both make_not_entrant and make_zombie
1299 bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
1300 assert(state == zombie || state == not_entrant, "must be zombie or not_entrant");
1301 assert(!is_zombie(), "should not already be a zombie");
1302
1303 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
1304 nmethodLocker nml(this);
1305 methodHandle the_method(method());
1306 No_Safepoint_Verifier nsv;
1307
1308 // during patching, depending on the nmethod state we must notify the GC that
1309 // code has been unloaded, unregistering it. We cannot do this right while
1310 // holding the Patching_lock because we need to use the CodeCache_lock. This
1311 // would be prone to deadlocks.
1312 // This flag is used to remember whether we need to later lock and unregister.
1313 bool nmethod_needs_unregister = false;
1314
1315 {
1316 // invalidate osr nmethod before acquiring the patching lock since
1317 // they both acquire leaf locks and we don't want a deadlock.
1318 // This logic is equivalent to the logic below for patching the
1319 // verified entry point of regular methods.
1320 if (is_osr_method()) {
1321 // this effectively makes the osr nmethod not entrant
1322 invalidate_osr_method();
1400 post_compiled_method_unload();
1401
1402 #ifdef ASSERT
1403 // It's no longer safe to access the oops section since zombie
1404 // nmethods aren't scanned for GC.
1405 _oops_are_stale = true;
1406 #endif
1407 // the Method may be reclaimed by class unloading now that the
1408 // nmethod is in zombie state
1409 set_method(NULL);
1410 } else {
1411 assert(state == not_entrant, "other cases may need to be handled differently");
1412 }
1413
1414 if (TraceCreateZombies) {
1415 tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie");
1416 }
1417
1418 // Make sweeper aware that there is a zombie method that needs to be removed
1419 NMethodSweeper::notify(this);
1420
1421 return true;
1422 }
1423
1424 void nmethod::flush() {
1425 // Note that there are no valid oops in the nmethod anymore.
1426 assert(is_zombie() || (is_osr_method() && is_unloaded()), "must be a zombie method");
1427 assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation");
1428
1429 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed");
1430 assert_locked_or_safepoint(CodeCache_lock);
1431
1432 // completely deallocate this method
1433 Events::log(JavaThread::current(), "flushing nmethod " INTPTR_FORMAT, this);
1434 if (PrintMethodFlushing) {
1435 tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb",
1436 _compile_id, this, CodeCache::nof_blobs(), CodeCache::unallocated_capacity()/1024);
1437 }
1438
1439 // We need to deallocate any ExceptionCache data.
1440 // Note that we do not need to grab the nmethod lock for this, it
|
1283 } else {
1284 xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s",
1285 os::current_thread_id(),
1286 (_state == zombie ? " zombie='1'" : ""));
1287 }
1288 log_identity(xtty);
1289 xtty->stamp();
1290 xtty->end_elem();
1291 }
1292 }
1293 if (PrintCompilation && _state != unloaded) {
1294 print_on(tty, _state == zombie ? "made zombie" : "made not entrant");
1295 }
1296 }
1297
1298 // Common functionality for both make_not_entrant and make_zombie
1299 bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
1300 assert(state == zombie || state == not_entrant, "must be zombie or not_entrant");
1301 assert(!is_zombie(), "should not already be a zombie");
1302
1303 // The state of nmethods that are currently locked by the VM must not change.
1304 // Some operations such as setting ICs (e.g., SharedRuntime::resolve_sub_helper())
1305 // rely on this fact.
1306 if (is_locked_by_vm()) {
1307 return false;
1308 }
1309
1310 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
1311 nmethodLocker nml(this);
1312 methodHandle the_method(method());
1313 No_Safepoint_Verifier nsv;
1314
1315 // during patching, depending on the nmethod state we must notify the GC that
1316 // code has been unloaded, unregistering it. We cannot do this right while
1317 // holding the Patching_lock because we need to use the CodeCache_lock. This
1318 // would be prone to deadlocks.
1319 // This flag is used to remember whether we need to later lock and unregister.
1320 bool nmethod_needs_unregister = false;
1321
1322 {
1323 // invalidate osr nmethod before acquiring the patching lock since
1324 // they both acquire leaf locks and we don't want a deadlock.
1325 // This logic is equivalent to the logic below for patching the
1326 // verified entry point of regular methods.
1327 if (is_osr_method()) {
1328 // this effectively makes the osr nmethod not entrant
1329 invalidate_osr_method();
1407 post_compiled_method_unload();
1408
1409 #ifdef ASSERT
1410 // It's no longer safe to access the oops section since zombie
1411 // nmethods aren't scanned for GC.
1412 _oops_are_stale = true;
1413 #endif
1414 // the Method may be reclaimed by class unloading now that the
1415 // nmethod is in zombie state
1416 set_method(NULL);
1417 } else {
1418 assert(state == not_entrant, "other cases may need to be handled differently");
1419 }
1420
1421 if (TraceCreateZombies) {
1422 tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie");
1423 }
1424
1425 // Make sweeper aware that there is a zombie method that needs to be removed
1426 NMethodSweeper::notify(this);
1427 return true;
1428 }
1429
1430 void nmethod::flush() {
1431 // Note that there are no valid oops in the nmethod anymore.
1432 assert(is_zombie() || (is_osr_method() && is_unloaded()), "must be a zombie method");
1433 assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation");
1434
1435 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed");
1436 assert_locked_or_safepoint(CodeCache_lock);
1437
1438 // completely deallocate this method
1439 Events::log(JavaThread::current(), "flushing nmethod " INTPTR_FORMAT, this);
1440 if (PrintMethodFlushing) {
1441 tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb",
1442 _compile_id, this, CodeCache::nof_blobs(), CodeCache::unallocated_capacity()/1024);
1443 }
1444
1445 // We need to deallocate any ExceptionCache data.
1446 // Note that we do not need to grab the nmethod lock for this, it
|