1385 NMethodSweeper::report_state_change(this); |
1385 NMethodSweeper::report_state_change(this); |
1386 } |
1386 } |
1387 |
1387 |
1388 void nmethod::invalidate_osr_method() { |
1388 void nmethod::invalidate_osr_method() { |
1389 assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); |
1389 assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); |
|
1390 #ifndef ASSERT |
|
1391 // Make sure osr nmethod is invalidated only once |
|
1392 if (!is_in_use()) { |
|
1393 return; |
|
1394 } |
|
1395 #endif |
1390 // Remove from list of active nmethods |
1396 // Remove from list of active nmethods |
1391 if (method() != NULL) |
1397 if (method() != NULL) { |
1392 method()->method_holder()->remove_osr_nmethod(this); |
1398 bool removed = method()->method_holder()->remove_osr_nmethod(this); |
|
1399 assert(!removed || is_in_use(), "unused osr nmethod should be invalidated"); |
|
1400 } |
1393 } |
1401 } |
1394 |
1402 |
1395 void nmethod::log_state_change() const { |
1403 void nmethod::log_state_change() const { |
1396 if (LogCompilation) { |
1404 if (LogCompilation) { |
1397 if (xtty != NULL) { |
1405 if (xtty != NULL) { |
1508 // dependencies must be flushed. nmethods in the not_entrant |
1516 // dependencies must be flushed. nmethods in the not_entrant |
1509 // state will be flushed later when the transition to zombie |
1517 // state will be flushed later when the transition to zombie |
1510 // happens or they get unloaded. |
1518 // happens or they get unloaded. |
1511 if (state == zombie) { |
1519 if (state == zombie) { |
1512 { |
1520 { |
1513 // Flushing dependecies must be done before any possible |
1521 // Flushing dependencies must be done before any possible |
1514 // safepoint can sneak in, otherwise the oops used by the |
1522 // safepoint can sneak in, otherwise the oops used by the |
1515 // dependency logic could have become stale. |
1523 // dependency logic could have become stale. |
1516 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1524 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1517 if (nmethod_needs_unregister) { |
1525 if (nmethod_needs_unregister) { |
1518 Universe::heap()->unregister_nmethod(this); |
1526 Universe::heap()->unregister_nmethod(this); |
1524 flush_dependencies(NULL); |
1532 flush_dependencies(NULL); |
1525 } |
1533 } |
1526 |
1534 |
1527 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload |
1535 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload |
1528 // event and it hasn't already been reported for this nmethod then |
1536 // event and it hasn't already been reported for this nmethod then |
1529 // report it now. The event may have been reported earilier if the GC |
1537 // report it now. The event may have been reported earlier if the GC |
1530 // marked it for unloading). JvmtiDeferredEventQueue support means |
1538 // marked it for unloading). JvmtiDeferredEventQueue support means |
1531 // we no longer go to a safepoint here. |
1539 // we no longer go to a safepoint here. |
1532 post_compiled_method_unload(); |
1540 post_compiled_method_unload(); |
1533 |
1541 |
1534 #ifdef ASSERT |
1542 #ifdef ASSERT |
1552 return true; |
1560 return true; |
1553 } |
1561 } |
1554 |
1562 |
1555 void nmethod::flush() { |
1563 void nmethod::flush() { |
1556 // Note that there are no valid oops in the nmethod anymore. |
1564 // Note that there are no valid oops in the nmethod anymore. |
1557 assert(is_zombie() || (is_osr_method() && is_unloaded()), "must be a zombie method"); |
1565 assert(!is_osr_method() || is_unloaded() || is_zombie(), |
1558 assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation"); |
1566 "osr nmethod must be unloaded or zombie before flushing"); |
|
1567 assert(is_zombie() || is_osr_method(), "must be a zombie method"); |
|
1568 assert(is_marked_for_reclamation() || is_osr_method(), "must be marked for reclamation"); |
1559 |
1569 |
1560 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed"); |
1570 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed"); |
1561 assert_locked_or_safepoint(CodeCache_lock); |
1571 assert_locked_or_safepoint(CodeCache_lock); |
1562 |
1572 |
1563 // completely deallocate this method |
1573 // completely deallocate this method |
1564 Events::log(JavaThread::current(), "flushing nmethod " INTPTR_FORMAT, p2i(this)); |
1574 Events::log(JavaThread::current(), "flushing nmethod " INTPTR_FORMAT, p2i(this)); |
1565 if (PrintMethodFlushing) { |
1575 if (PrintMethodFlushing) { |
1566 tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT |
1576 tty->print_cr("*flushing %s nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT |
1567 "/Free CodeCache:" SIZE_FORMAT "Kb", |
1577 "/Free CodeCache:" SIZE_FORMAT "Kb", |
1568 _compile_id, p2i(this), CodeCache::blob_count(), |
1578 is_osr_method() ? "osr" : "",_compile_id, p2i(this), CodeCache::blob_count(), |
1569 CodeCache::unallocated_capacity(CodeCache::get_code_blob_type(this))/1024); |
1579 CodeCache::unallocated_capacity(CodeCache::get_code_blob_type(this))/1024); |
1570 } |
1580 } |
1571 |
1581 |
1572 // We need to deallocate any ExceptionCache data. |
1582 // We need to deallocate any ExceptionCache data. |
1573 // Note that we do not need to grab the nmethod lock for this, it |
1583 // Note that we do not need to grab the nmethod lock for this, it |
2915 |
2925 |
2916 if (WizardMode) { |
2926 if (WizardMode) { |
2917 tty->print("((nmethod*) " INTPTR_FORMAT ") ", p2i(this)); |
2927 tty->print("((nmethod*) " INTPTR_FORMAT ") ", p2i(this)); |
2918 tty->print(" for method " INTPTR_FORMAT , p2i(method())); |
2928 tty->print(" for method " INTPTR_FORMAT , p2i(method())); |
2919 tty->print(" { "); |
2929 tty->print(" { "); |
2920 if (is_in_use()) tty->print("in_use "); |
2930 tty->print_cr("%s ", state()); |
2921 if (is_not_entrant()) tty->print("not_entrant "); |
|
2922 if (is_zombie()) tty->print("zombie "); |
|
2923 if (is_unloaded()) tty->print("unloaded "); |
|
2924 if (on_scavenge_root_list()) tty->print("scavenge_root "); |
2931 if (on_scavenge_root_list()) tty->print("scavenge_root "); |
2925 tty->print_cr("}:"); |
2932 tty->print_cr("}:"); |
2926 } |
2933 } |
2927 if (size () > 0) tty->print_cr(" total in heap [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d", |
2934 if (size () > 0) tty->print_cr(" total in heap [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d", |
2928 p2i(this), |
2935 p2i(this), |