equal
deleted
inserted
replaced
101 set_vtable_index(Method::garbage_vtable_index); |
101 set_vtable_index(Method::garbage_vtable_index); |
102 |
102 |
103 // Fix and bury in Method* |
103 // Fix and bury in Method* |
104 set_interpreter_entry(NULL); // sets i2i entry and from_int |
104 set_interpreter_entry(NULL); // sets i2i entry and from_int |
105 set_adapter_entry(NULL); |
105 set_adapter_entry(NULL); |
106 Method::clear_code(); // from_c/from_i get set to c2i/i2i |
106 clear_code(false /* don't need a lock */); // from_c/from_i get set to c2i/i2i |
107 |
107 |
108 if (access_flags.is_native()) { |
108 if (access_flags.is_native()) { |
109 clear_native_function(); |
109 clear_native_function(); |
110 set_signature_handler(NULL); |
110 set_signature_handler(NULL); |
111 } |
111 } |
817 void Method::clear_native_function() { |
817 void Method::clear_native_function() { |
818 // Note: is_method_handle_intrinsic() is allowed here. |
818 // Note: is_method_handle_intrinsic() is allowed here. |
819 set_native_function( |
819 set_native_function( |
820 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), |
820 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), |
821 !native_bind_event_is_interesting); |
821 !native_bind_event_is_interesting); |
822 this->unlink_code(); |
822 clear_code(); |
823 } |
823 } |
824 |
824 |
825 address Method::critical_native_function() { |
825 address Method::critical_native_function() { |
826 methodHandle mh(this); |
826 methodHandle mh(this); |
827 return NativeLookup::lookup_critical_entry(mh); |
827 return NativeLookup::lookup_critical_entry(mh); |
941 CompilationPolicy::policy()->disable_compilation(this); |
941 CompilationPolicy::policy()->disable_compilation(this); |
942 assert(!CompilationPolicy::can_be_osr_compiled(this, comp_level), "sanity check"); |
942 assert(!CompilationPolicy::can_be_osr_compiled(this, comp_level), "sanity check"); |
943 } |
943 } |
944 |
944 |
945 // Revert to using the interpreter and clear out the nmethod |
945 // Revert to using the interpreter and clear out the nmethod |
946 void Method::clear_code() { |
946 void Method::clear_code(bool acquire_lock /* = true */) { |
|
947 MutexLocker pl(acquire_lock ? Patching_lock : NULL, Mutex::_no_safepoint_check_flag); |
947 // this may be NULL if c2i adapters have not been made yet |
948 // this may be NULL if c2i adapters have not been made yet |
948 // Only should happen at allocate time. |
949 // Only should happen at allocate time. |
949 if (adapter() == NULL) { |
950 if (adapter() == NULL) { |
950 _from_compiled_entry = NULL; |
951 _from_compiled_entry = NULL; |
951 } else { |
952 } else { |
953 } |
954 } |
954 OrderAccess::storestore(); |
955 OrderAccess::storestore(); |
955 _from_interpreted_entry = _i2i_entry; |
956 _from_interpreted_entry = _i2i_entry; |
956 OrderAccess::storestore(); |
957 OrderAccess::storestore(); |
957 _code = NULL; |
958 _code = NULL; |
958 } |
|
959 |
|
960 void Method::unlink_code(CompiledMethod *compare) { |
|
961 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag); |
|
962 // We need to check if either the _code or _from_compiled_code_entry_point |
|
963 // refer to this nmethod because there is a race in setting these two fields |
|
964 // in Method* as seen in bugid 4947125. |
|
965 // If the vep() points to the zombie nmethod, the memory for the nmethod |
|
966 // could be flushed and the compiler and vtable stubs could still call |
|
967 // through it. |
|
968 if (code() == compare || |
|
969 from_compiled_entry() == compare->verified_entry_point()) { |
|
970 clear_code(); |
|
971 } |
|
972 } |
|
973 |
|
974 void Method::unlink_code() { |
|
975 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag); |
|
976 clear_code(); |
|
977 } |
959 } |
978 |
960 |
979 #if INCLUDE_CDS |
961 #if INCLUDE_CDS |
980 // Called by class data sharing to remove any entry points (which are not shared) |
962 // Called by class data sharing to remove any entry points (which are not shared) |
981 void Method::unlink_method() { |
963 void Method::unlink_method() { |
1200 return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method()); |
1182 return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method()); |
1201 } |
1183 } |
1202 |
1184 |
1203 // Install compiled code. Instantly it can execute. |
1185 // Install compiled code. Instantly it can execute. |
1204 void Method::set_code(const methodHandle& mh, CompiledMethod *code) { |
1186 void Method::set_code(const methodHandle& mh, CompiledMethod *code) { |
1205 MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); |
1187 MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
1206 assert( code, "use clear_code to remove code" ); |
1188 assert( code, "use clear_code to remove code" ); |
1207 assert( mh->check_code(), "" ); |
1189 assert( mh->check_code(), "" ); |
1208 |
1190 |
1209 guarantee(mh->adapter() != NULL, "Adapter blob must already exist!"); |
1191 guarantee(mh->adapter() != NULL, "Adapter blob must already exist!"); |
1210 |
1192 |