comparison src/share/vm/runtime/biasedLocking.cpp @ 447:2b42b31e7928

6676175: BigApps crash JVM Client VM (build 10.0-b22, mixed mode, sharing) with SIGSEGV (0xb) Summary: Add test for biased locking epoch before walking own thread stack in case of rare race Reviewed-by: phh, never
author coleenp
date Fri, 21 Nov 2008 08:09:11 -0800
parents d1605aabd0a1
children b109e761e927
comparison
equal deleted inserted replaced
423:909cfd030fab 447:2b42b31e7928
580 580
581 HeuristicsResult heuristics = update_heuristics(obj(), attempt_rebias); 581 HeuristicsResult heuristics = update_heuristics(obj(), attempt_rebias);
582 if (heuristics == HR_NOT_BIASED) { 582 if (heuristics == HR_NOT_BIASED) {
583 return NOT_BIASED; 583 return NOT_BIASED;
584 } else if (heuristics == HR_SINGLE_REVOKE) { 584 } else if (heuristics == HR_SINGLE_REVOKE) {
585 if (mark->biased_locker() == THREAD) { 585 Klass *k = Klass::cast(obj->klass());
586 markOop prototype_header = k->prototype_header();
587 if (mark->biased_locker() == THREAD &&
588 prototype_header->bias_epoch() == mark->bias_epoch()) {
586 // A thread is trying to revoke the bias of an object biased 589 // A thread is trying to revoke the bias of an object biased
587 // toward it, again likely due to an identity hash code 590 // toward it, again likely due to an identity hash code
588 // computation. We can again avoid a safepoint in this case 591 // computation. We can again avoid a safepoint in this case
589 // since we are only going to walk our own stack. There are no 592 // since we are only going to walk our own stack. There are no
590 // races with revocations occurring in other threads because we 593 // races with revocations occurring in other threads because we
591 // reach no safepoints in the revocation path. 594 // reach no safepoints in the revocation path.
595 // Also check the epoch because even if threads match, another thread
596 // can come in with a CAS to steal the bias of an object that has a
597 // stale epoch.
592 ResourceMark rm; 598 ResourceMark rm;
593 if (TraceBiasedLocking) { 599 if (TraceBiasedLocking) {
594 tty->print_cr("Revoking bias by walking my own stack:"); 600 tty->print_cr("Revoking bias by walking my own stack:");
595 } 601 }
596 BiasedLocking::Condition cond = revoke_bias(obj(), false, false, (JavaThread*) THREAD); 602 BiasedLocking::Condition cond = revoke_bias(obj(), false, false, (JavaThread*) THREAD);