--- old/src/share/vm/oops/method.cpp 2016-10-07 14:39:34.376786453 +0200 +++ new/src/share/vm/oops/method.cpp 2016-10-07 14:39:34.300786456 +0200 @@ -97,7 +97,10 @@ // Fix and bury in Method* set_interpreter_entry(NULL); // sets i2i entry and from_int set_adapter_entry(NULL); - clear_code(); // from_c/from_i get set to c2i/i2i + { + MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); + clear_code(); // from_c/from_i get set to c2i/i2i + } if (access_flags.is_native()) { clear_native_function(); @@ -781,6 +784,7 @@ set_native_function( SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), !native_bind_event_is_interesting); + MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); clear_code(); } @@ -905,7 +909,7 @@ // Revert to using the interpreter and clear out the nmethod void Method::clear_code() { - + assert_locked_or_safepoint(Patching_lock); // this may be NULL if c2i adapters have not been made yet // Only should happen at allocate time. if (adapter() == NULL) { @@ -1074,6 +1078,7 @@ // Install compiled code. Instantly it can execute. void Method::set_code(methodHandle mh, CompiledMethod *code) { + assert_locked_or_safepoint(Patching_lock); assert( code, "use clear_code to remove code" ); assert( mh->check_code(), "" );