comparison src/share/vm/code/nmethod.cpp @ 22643:456800cd1a17

Ensure that not_entrant InstalledCode can still be invalidated
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 30 Sep 2015 15:58:36 -0700
parents 02fc27dc1da7
children eada427470a3
comparison
equal deleted inserted replaced
22642:6b444ec119b8 22643:456800cd1a17
1488 } 1488 }
1489 1489
1490 // Unregister must be done before the state change 1490 // Unregister must be done before the state change
1491 Universe::heap()->unregister_nmethod(this); 1491 Universe::heap()->unregister_nmethod(this);
1492 1492
1493 _state = unloaded;
1494
1493 #if INCLUDE_JVMCI 1495 #if INCLUDE_JVMCI
1494 // The method can only be unloaded after the pointer to the installed code 1496 // The method can only be unloaded after the pointer to the installed code
1495 // Java wrapper is no longer alive. Here we need to clear out this weak 1497 // Java wrapper is no longer alive. Here we need to clear out this weak
1496 // reference to the dead object. Nulling out the reference has to happen 1498 // reference to the dead object. Nulling out the reference has to happen
1497 // after the method is unregistered since the original value may be still 1499 // after the method is unregistered since the original value may be still
1498 // tracked by the rset. 1500 // tracked by the rset.
1499 if (_jvmci_installed_code != NULL) { 1501 maybe_invalidate_installed_code();
1500 InstalledCode::set_address(_jvmci_installed_code, 0); 1502 #endif
1501 _jvmci_installed_code = NULL;
1502 }
1503 #endif
1504
1505 _state = unloaded;
1506 1503
1507 // Log the unloading. 1504 // Log the unloading.
1508 log_state_change(); 1505 log_state_change();
1509 1506
1510 // The Method* is gone at this point 1507 // The Method* is gone at this point
1665 // nmethod is in zombie state 1662 // nmethod is in zombie state
1666 set_method(NULL); 1663 set_method(NULL);
1667 } else { 1664 } else {
1668 assert(state == not_entrant, "other cases may need to be handled differently"); 1665 assert(state == not_entrant, "other cases may need to be handled differently");
1669 } 1666 }
1670 #if INCLUDE_JVMCI 1667
1671 if (_jvmci_installed_code != NULL) { 1668 JVMCI_ONLY(maybe_invalidate_installed_code());
1672 // Break the link between nmethod and InstalledCode such that the nmethod can subsequently be flushed safely.
1673 InstalledCode::set_address(_jvmci_installed_code, 0);
1674 }
1675 #endif
1676 1669
1677 if (TraceCreateZombies) { 1670 if (TraceCreateZombies) {
1678 ResourceMark m; 1671 ResourceMark m;
1679 tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", this, this->method() ? this->method()->name_and_sig_as_C_string() : "null", (state == not_entrant) ? "not entrant" : "zombie"); 1672 tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", this, this->method() ? this->method()->name_and_sig_as_C_string() : "null", (state == not_entrant) ? "not entrant" : "zombie");
1680 } 1673 }
3547 Dependencies::print_statistics(); 3540 Dependencies::print_statistics();
3548 if (xtty != NULL) xtty->tail("statistics"); 3541 if (xtty != NULL) xtty->tail("statistics");
3549 } 3542 }
3550 3543
3551 #if INCLUDE_JVMCI 3544 #if INCLUDE_JVMCI
3545 void nmethod::maybe_invalidate_installed_code() {
3546 if (_jvmci_installed_code != NULL) {
3547 if (!is_alive()) {
3548 // Break the link between nmethod and InstalledCode such that the nmethod
3549 // can subsequently be flushed safely. The link must be maintained while
3550 // the method could have live activations since invalidateInstalledCode
3551 // might want to invalidate all existing activations.
3552 InstalledCode::set_address(_jvmci_installed_code, 0);
3553 InstalledCode::set_entryPoint(_jvmci_installed_code, 0);
3554 _jvmci_installed_code = NULL;
3555 } else if (is_not_entrant()) {
3556 InstalledCode::set_entryPoint(_jvmci_installed_code, 0);
3557 }
3558 }
3559 }
3560
3552 char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) { 3561 char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) {
3553 if (!this->is_compiled_by_jvmci()) { 3562 if (!this->is_compiled_by_jvmci()) {
3554 return NULL; 3563 return NULL;
3555 } 3564 }
3556 oop installedCode = this->jvmci_installed_code(); 3565 oop installedCode = this->jvmci_installed_code();