hotspot/src/share/vm/runtime/biasedLocking.cpp
changeset 1600 776009a04496
parent 670 ddf3e9583f2f
child 3171 aa289b22b577
equal deleted inserted replaced
1503:295f2d955792 1600:776009a04496
   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);