1011 // is plenty.
1012 address current = *native_function;
1013 if (current == function) return;
1014 if (post_event_flag && JvmtiExport::should_post_native_method_bind() &&
1015 function != nullptr) {
1016 // native_method_throw_unsatisfied_link_error_entry() should only
1017 // be passed when post_event_flag is false.
1018 assert(function !=
1019 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
1020 "post_event_flag mismatch");
1021
1022 // post the bind event, and possible change the bind function
1023 JvmtiExport::post_native_method_bind(this, &function);
1024 }
1025 *native_function = function;
1026 // This function can be called more than once. We must make sure that we always
1027 // use the latest registered method -> check if a stub already has been generated.
1028 // If so, we have to make it not_entrant.
1029 nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
1030 if (nm != nullptr) {
1031 nm->make_not_entrant(nmethod::ChangeReason::set_native_function);
1032 }
1033 }
1034
1035
1036 bool Method::has_native_function() const {
1037 if (is_special_native_intrinsic())
1038 return false; // special-cased in SharedRuntime::generate_native_wrapper
1039 address func = native_function();
1040 return (func != nullptr && func != SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
1041 }
1042
1043
1044 void Method::clear_native_function() {
1045 // Note: is_method_handle_intrinsic() is allowed here.
1046 set_native_function(
1047 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
1048 !native_bind_event_is_interesting);
1049 this->unlink_code();
1050 }
1051
|
1011 // is plenty.
1012 address current = *native_function;
1013 if (current == function) return;
1014 if (post_event_flag && JvmtiExport::should_post_native_method_bind() &&
1015 function != nullptr) {
1016 // native_method_throw_unsatisfied_link_error_entry() should only
1017 // be passed when post_event_flag is false.
1018 assert(function !=
1019 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
1020 "post_event_flag mismatch");
1021
1022 // post the bind event, and possible change the bind function
1023 JvmtiExport::post_native_method_bind(this, &function);
1024 }
1025 *native_function = function;
1026 // This function can be called more than once. We must make sure that we always
1027 // use the latest registered method -> check if a stub already has been generated.
1028 // If so, we have to make it not_entrant.
1029 nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
1030 if (nm != nullptr) {
1031 nm->make_not_entrant(nmethod::InvalidationReason::SET_NATIVE_FUNCTION);
1032 }
1033 }
1034
1035
1036 bool Method::has_native_function() const {
1037 if (is_special_native_intrinsic())
1038 return false; // special-cased in SharedRuntime::generate_native_wrapper
1039 address func = native_function();
1040 return (func != nullptr && func != SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
1041 }
1042
1043
1044 void Method::clear_native_function() {
1045 // Note: is_method_handle_intrinsic() is allowed here.
1046 set_native_function(
1047 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
1048 !native_bind_event_is_interesting);
1049 this->unlink_code();
1050 }
1051
|