8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie

Reviewed-by: kvn, iveresov
This commit is contained in:
Vladimir Ivanov 2013-11-08 01:13:11 -08:00
parent e80dce6a4d
commit 505ac76763
4 changed files with 28 additions and 52 deletions

View file

@ -935,7 +935,9 @@ void ciEnv::register_method(ciMethod* target,
// Prevent SystemDictionary::add_to_hierarchy from running
// and invalidating our dependencies until we install this method.
// No safepoints are allowed. Otherwise, class redefinition can occur in between.
MutexLocker ml(Compile_lock);
No_Safepoint_Verifier nsv;
// Change in Jvmti state may invalidate compilation.
if (!failing() &&
@ -1001,16 +1003,6 @@ void ciEnv::register_method(ciMethod* target,
// Free codeBlobs
code_buffer->free_blob();
// stress test 6243940 by immediately making the method
// non-entrant behind the system's back. This has serious
// side effects on the code cache and is not meant for
// general stress testing
if (nm != NULL && StressNonEntrant) {
MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
NativeJump::patch_verified_entry(nm->entry_point(), nm->verified_entry_point(),
SharedRuntime::get_handle_wrong_method_stub());
}
if (nm == NULL) {
// The CodeCache is full. Print out warning and disable compilation.
record_failure("code cache is full");
@ -1036,11 +1028,11 @@ void ciEnv::register_method(ciMethod* target,
char *method_name = method->name_and_sig_as_C_string();
tty->print_cr("Replacing method %s", method_name);
}
if (old != NULL ) {
if (old != NULL) {
old->make_not_entrant();
}
}
if (TraceNMethodInstalls ) {
if (TraceNMethodInstalls) {
ResourceMark rm;
char *method_name = method->name_and_sig_as_C_string();
ttyLocker ttyl;
@ -1051,7 +1043,7 @@ void ciEnv::register_method(ciMethod* target,
// Allow the code to be executed
method->set_code(method, nm);
} else {
if (TraceNMethodInstalls ) {
if (TraceNMethodInstalls) {
ResourceMark rm;
char *method_name = method->name_and_sig_as_C_string();
ttyLocker ttyl;
@ -1061,7 +1053,6 @@ void ciEnv::register_method(ciMethod* target,
entry_bci);
}
method->method_holder()->add_osr_nmethod(nm);
}
}
}