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

@ -618,21 +618,18 @@ nmethod* nmethod::new_nmethod(methodHandle method,
// record this nmethod as dependent on this klass
InstanceKlass::cast(klass)->add_dependent_nmethod(nm);
}
}
NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm));
if (PrintAssembly && nm != NULL) {
Disassembler::decode(nm);
NOT_PRODUCT(nmethod_stats.note_nmethod(nm));
if (PrintAssembly) {
Disassembler::decode(nm);
}
}
}
// verify nmethod
debug_only(if (nm) nm->verify();) // might block
// Do verification and logging outside CodeCache_lock.
if (nm != NULL) {
// Safepoints in nmethod::verify aren't allowed because nm hasn't been installed yet.
DEBUG_ONLY(nm->verify();)
nm->log_new_nmethod();
}
// done
return nm;
}
@ -2395,20 +2392,23 @@ void nmethod::verify() {
void nmethod::verify_interrupt_point(address call_site) {
// This code does not work in release mode since
// owns_lock only is available in debug mode.
CompiledIC* ic = NULL;
Thread *cur = Thread::current();
if (CompiledIC_lock->owner() == cur ||
((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) &&
SafepointSynchronize::is_at_safepoint())) {
ic = CompiledIC_at(this, call_site);
CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
} else {
MutexLocker ml_verify (CompiledIC_lock);
ic = CompiledIC_at(this, call_site);
// Verify IC only when nmethod installation is finished.
bool is_installed = (method()->code() == this) // nmethod is in state 'alive' and installed
|| !this->is_in_use(); // nmethod is installed, but not in 'alive' state
if (is_installed) {
Thread *cur = Thread::current();
if (CompiledIC_lock->owner() == cur ||
((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) &&
SafepointSynchronize::is_at_safepoint())) {
CompiledIC_at(this, call_site);
CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
} else {
MutexLocker ml_verify (CompiledIC_lock);
CompiledIC_at(this, call_site);
}
}
PcDesc* pd = pc_desc_at(ic->end_of_call());
PcDesc* pd = pc_desc_at(nativeCall_at(call_site)->return_address());
assert(pd != NULL, "PcDesc must exist");
for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
pd->obj_decode_offset(), pd->should_reexecute(),