937 assert(!CompilationPolicy::can_be_osr_compiled(this, comp_level), "sanity check");
938 }
939
940 // Revert to using the interpreter and clear out the nmethod
941 void Method::clear_code() {
942 // this may be NULL if c2i adapters have not been made yet
943 // Only should happen at allocate time.
944 if (adapter() == NULL) {
945 _from_compiled_entry = NULL;
946 } else {
947 _from_compiled_entry = adapter()->get_c2i_entry();
948 }
949 OrderAccess::storestore();
950 _from_interpreted_entry = _i2i_entry;
951 OrderAccess::storestore();
952 _code = NULL;
953 }
954
955 void Method::unlink_code(CompiledMethod *compare) {
956 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
957 // We need to check if both the _code and _from_compiled_code_entry_point
958 // refer to this nmethod because there is a race in setting these two fields
959 // in Method* as seen in bugid 4947125.
960 // If the vep() points to the zombie nmethod, the memory for the nmethod
961 // could be flushed and the compiler and vtable stubs could still call
962 // through it.
963 if (code() == compare ||
964 from_compiled_entry() == compare->verified_entry_point()) {
965 clear_code();
966 }
967 }
968
969 void Method::unlink_code() {
970 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
971 clear_code();
972 }
973
974 #if INCLUDE_CDS
975 // Called by class data sharing to remove any entry points (which are not shared)
976 void Method::unlink_method() {
977 _code = NULL;
|
937 assert(!CompilationPolicy::can_be_osr_compiled(this, comp_level), "sanity check");
938 }
939
940 // Revert to using the interpreter and clear out the nmethod
941 void Method::clear_code() {
942 // this may be NULL if c2i adapters have not been made yet
943 // Only should happen at allocate time.
944 if (adapter() == NULL) {
945 _from_compiled_entry = NULL;
946 } else {
947 _from_compiled_entry = adapter()->get_c2i_entry();
948 }
949 OrderAccess::storestore();
950 _from_interpreted_entry = _i2i_entry;
951 OrderAccess::storestore();
952 _code = NULL;
953 }
954
955 void Method::unlink_code(CompiledMethod *compare) {
956 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
957 // We need to check if either the _code or _from_compiled_code_entry_point
958 // refer to this nmethod because there is a race in setting these two fields
959 // in Method* as seen in bugid 4947125.
960 // If the vep() points to the zombie nmethod, the memory for the nmethod
961 // could be flushed and the compiler and vtable stubs could still call
962 // through it.
963 if (code() == compare ||
964 from_compiled_entry() == compare->verified_entry_point()) {
965 clear_code();
966 }
967 }
968
969 void Method::unlink_code() {
970 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
971 clear_code();
972 }
973
974 #if INCLUDE_CDS
975 // Called by class data sharing to remove any entry points (which are not shared)
976 void Method::unlink_method() {
977 _code = NULL;
|