equal
deleted
inserted
replaced
420 _rtm_state = NoRTM; |
420 _rtm_state = NoRTM; |
421 #endif |
421 #endif |
422 #if INCLUDE_JVMCI |
422 #if INCLUDE_JVMCI |
423 _jvmci_installed_code = NULL; |
423 _jvmci_installed_code = NULL; |
424 _speculation_log = NULL; |
424 _speculation_log = NULL; |
425 _jvmci_installed_code_triggers_unloading = false; |
425 _jvmci_installed_code_triggers_invalidation = false; |
426 #endif |
426 #endif |
427 } |
427 } |
428 |
428 |
429 nmethod* nmethod::new_native_nmethod(const methodHandle& method, |
429 nmethod* nmethod::new_native_nmethod(const methodHandle& method, |
430 int compile_id, |
430 int compile_id, |
688 #if INCLUDE_JVMCI |
688 #if INCLUDE_JVMCI |
689 _jvmci_installed_code = installed_code; |
689 _jvmci_installed_code = installed_code; |
690 _speculation_log = speculation_log; |
690 _speculation_log = speculation_log; |
691 oop obj = JNIHandles::resolve(installed_code); |
691 oop obj = JNIHandles::resolve(installed_code); |
692 if (obj == NULL || (obj->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(obj))) { |
692 if (obj == NULL || (obj->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(obj))) { |
693 _jvmci_installed_code_triggers_unloading = false; |
693 _jvmci_installed_code_triggers_invalidation = false; |
694 } else { |
694 } else { |
695 _jvmci_installed_code_triggers_unloading = true; |
695 _jvmci_installed_code_triggers_invalidation = true; |
696 } |
696 } |
697 |
697 |
698 if (compiler->is_jvmci()) { |
698 if (compiler->is_jvmci()) { |
699 // JVMCI might not produce any stub sections |
699 // JVMCI might not produce any stub sections |
700 if (offsets->value(CodeOffsets::Exceptions) != -1) { |
700 if (offsets->value(CodeOffsets::Exceptions) != -1) { |
784 if (nm_kind != NULL) log->print(" compile_kind='%s'", nm_kind); |
784 if (nm_kind != NULL) log->print(" compile_kind='%s'", nm_kind); |
785 log->print(" compiler='%s'", compiler_name()); |
785 log->print(" compiler='%s'", compiler_name()); |
786 if (TieredCompilation) { |
786 if (TieredCompilation) { |
787 log->print(" level='%d'", comp_level()); |
787 log->print(" level='%d'", comp_level()); |
788 } |
788 } |
|
789 #if INCLUDE_JVMCI |
|
790 char buffer[O_BUFLEN]; |
|
791 char* jvmci_name = jvmci_installed_code_name(buffer, O_BUFLEN); |
|
792 if (jvmci_name != NULL) { |
|
793 log->print(" jvmci_installed_code_name='%s'", jvmci_name); |
|
794 } |
|
795 #endif |
789 } |
796 } |
790 |
797 |
791 |
798 |
792 #define LOG_OFFSET(log, name) \ |
799 #define LOG_OFFSET(log, name) \ |
793 if (p2i(name##_end()) - p2i(name##_begin())) \ |
800 if (p2i(name##_end()) - p2i(name##_begin())) \ |
1081 Universe::heap()->unregister_nmethod(this); |
1088 Universe::heap()->unregister_nmethod(this); |
1082 |
1089 |
1083 _state = unloaded; |
1090 _state = unloaded; |
1084 |
1091 |
1085 // Log the unloading. |
1092 // Log the unloading. |
1086 log_state_change(); |
1093 log_state_change(cause); |
1087 |
1094 |
1088 #if INCLUDE_JVMCI |
1095 #if INCLUDE_JVMCI |
1089 // The method can only be unloaded after the pointer to the installed code |
1096 // The method can only be unloaded after the pointer to the installed code |
1090 // Java wrapper is no longer alive. Here we need to clear out this weak |
1097 // Java wrapper is no longer alive. Here we need to clear out this weak |
1091 // reference to the dead object. |
1098 // reference to the dead object. |
1105 if (method() != NULL) { |
1112 if (method() != NULL) { |
1106 method()->method_holder()->remove_osr_nmethod(this); |
1113 method()->method_holder()->remove_osr_nmethod(this); |
1107 } |
1114 } |
1108 } |
1115 } |
1109 |
1116 |
1110 void nmethod::log_state_change() const { |
1117 void nmethod::log_state_change(oop cause) const { |
1111 if (LogCompilation) { |
1118 if (LogCompilation) { |
1112 if (xtty != NULL) { |
1119 if (xtty != NULL) { |
1113 ttyLocker ttyl; // keep the following output all in one block |
1120 ttyLocker ttyl; // keep the following output all in one block |
1114 if (_state == unloaded) { |
1121 if (_state == unloaded) { |
1115 xtty->begin_elem("make_unloaded thread='" UINTX_FORMAT "'", |
1122 xtty->begin_elem("make_unloaded thread='" UINTX_FORMAT "'", |
1118 xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s", |
1125 xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s", |
1119 os::current_thread_id(), |
1126 os::current_thread_id(), |
1120 (_state == zombie ? " zombie='1'" : "")); |
1127 (_state == zombie ? " zombie='1'" : "")); |
1121 } |
1128 } |
1122 log_identity(xtty); |
1129 log_identity(xtty); |
|
1130 if (cause != NULL) { |
|
1131 xtty->print(" cause='%s'", cause->klass()->external_name()); |
|
1132 } |
1123 xtty->stamp(); |
1133 xtty->stamp(); |
1124 xtty->end_elem(); |
1134 xtty->end_elem(); |
1125 } |
1135 } |
1126 } |
1136 } |
1127 |
1137 |
1148 } |
1158 } |
1149 |
1159 |
1150 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. |
1160 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. |
1151 nmethodLocker nml(this); |
1161 nmethodLocker nml(this); |
1152 methodHandle the_method(method()); |
1162 methodHandle the_method(method()); |
1153 NoSafepointVerifier nsv; |
1163 // This can be called while the system is already at a safepoint which is ok |
|
1164 NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint()); |
1154 |
1165 |
1155 // during patching, depending on the nmethod state we must notify the GC that |
1166 // during patching, depending on the nmethod state we must notify the GC that |
1156 // code has been unloaded, unregistering it. We cannot do this right while |
1167 // code has been unloaded, unregistering it. We cannot do this right while |
1157 // holding the Patching_lock because we need to use the CodeCache_lock. This |
1168 // holding the Patching_lock because we need to use the CodeCache_lock. This |
1158 // would be prone to deadlocks. |
1169 // would be prone to deadlocks. |
1505 |
1516 |
1506 #if INCLUDE_JVMCI |
1517 #if INCLUDE_JVMCI |
1507 bool nmethod::do_unloading_jvmci() { |
1518 bool nmethod::do_unloading_jvmci() { |
1508 if (_jvmci_installed_code != NULL) { |
1519 if (_jvmci_installed_code != NULL) { |
1509 if (JNIHandles::is_global_weak_cleared(_jvmci_installed_code)) { |
1520 if (JNIHandles::is_global_weak_cleared(_jvmci_installed_code)) { |
1510 if (_jvmci_installed_code_triggers_unloading) { |
1521 if (_jvmci_installed_code_triggers_invalidation) { |
1511 // jweak reference processing has already cleared the referent |
1522 // The reference to the installed code has been dropped so invalidate |
1512 make_unloaded(NULL); |
1523 // this nmethod and allow the sweeper to reclaim it. |
1513 return true; |
1524 make_not_entrant(); |
1514 } else { |
1525 } |
1515 clear_jvmci_installed_code(); |
1526 clear_jvmci_installed_code(); |
1516 } |
|
1517 } |
1527 } |
1518 } |
1528 } |
1519 return false; |
1529 return false; |
1520 } |
1530 } |
1521 #endif |
1531 #endif |
2946 |
2956 |
2947 oop nmethod::speculation_log() { |
2957 oop nmethod::speculation_log() { |
2948 return JNIHandles::resolve(_speculation_log); |
2958 return JNIHandles::resolve(_speculation_log); |
2949 } |
2959 } |
2950 |
2960 |
2951 char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) { |
2961 char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) const { |
2952 if (!this->is_compiled_by_jvmci()) { |
2962 if (!this->is_compiled_by_jvmci()) { |
2953 return NULL; |
2963 return NULL; |
2954 } |
2964 } |
2955 oop installed_code = JNIHandles::resolve(_jvmci_installed_code); |
2965 oop installed_code = JNIHandles::resolve(_jvmci_installed_code); |
2956 if (installed_code != NULL) { |
2966 if (installed_code != NULL) { |