709 }
710 if (highest_lock != NULL) {
711 // Fix up highest lock to contain displaced header and point
712 // object at it
713 highest_lock->set_displaced_header(unbiased_prototype);
714 // Reset object header to point to displaced mark.
715 // Must release store the lock address for platforms without TSO
716 // ordering (e.g. ppc).
717 obj->release_set_mark(markWord::encode(highest_lock));
718 assert(!obj->mark().has_bias_pattern(), "illegal mark state: stack lock used bias bit");
719 log_info(biasedlocking)(" Revoked bias of currently-locked object");
720 } else {
721 log_info(biasedlocking)(" Revoked bias of currently-unlocked object");
722 // Store the unlocked value into the object's header.
723 obj->set_mark(unbiased_prototype);
724 }
725
726 assert(!obj->mark().has_bias_pattern(), "must not be biased");
727 }
728
729
730 void BiasedLocking::revoke(Handle obj, TRAPS) {
731 assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint");
732
733 while (true) {
734 // We can revoke the biases of anonymously-biased objects
735 // efficiently enough that we should not cause these revocations to
736 // update the heuristics because doing so may cause unwanted bulk
737 // revocations (which are expensive) to occur.
738 markWord mark = obj->mark();
739
740 if (!mark.has_bias_pattern()) {
741 return;
742 }
743
744 if (mark.is_biased_anonymously()) {
745 // We are probably trying to revoke the bias of this object due to
746 // an identity hash code computation. Try to revoke the bias
747 // without a safepoint. This is possible if we can successfully
748 // compare-and-exchange an unbiased header into the mark word of
|
709 }
710 if (highest_lock != NULL) {
711 // Fix up highest lock to contain displaced header and point
712 // object at it
713 highest_lock->set_displaced_header(unbiased_prototype);
714 // Reset object header to point to displaced mark.
715 // Must release store the lock address for platforms without TSO
716 // ordering (e.g. ppc).
717 obj->release_set_mark(markWord::encode(highest_lock));
718 assert(!obj->mark().has_bias_pattern(), "illegal mark state: stack lock used bias bit");
719 log_info(biasedlocking)(" Revoked bias of currently-locked object");
720 } else {
721 log_info(biasedlocking)(" Revoked bias of currently-unlocked object");
722 // Store the unlocked value into the object's header.
723 obj->set_mark(unbiased_prototype);
724 }
725
726 assert(!obj->mark().has_bias_pattern(), "must not be biased");
727 }
728
729 void BiasedLocking::revoke_own_locks(Handle obj, TRAPS) {
730 markWord mark = obj->mark();
731
732 if (!mark.has_bias_pattern()) {
733 return;
734 }
735
736 Klass *k = obj->klass();
737 markWord prototype_header = k->prototype_header();
738 assert(mark.biased_locker() == THREAD &&
739 prototype_header.bias_epoch() == mark.bias_epoch(), "Revoke failed, unhandled biased lock state");
740 ResourceMark rm;
741 log_info(biasedlocking)("Revoking bias by walking my own stack:");
742 EventBiasedLockSelfRevocation event;
743 BiasedLocking::walk_stack_and_revoke(obj(), (JavaThread*) THREAD);
744 ((JavaThread*) THREAD)->set_cached_monitor_info(NULL);
745 assert(!obj->mark().has_bias_pattern(), "invariant");
746 if (event.should_commit()) {
747 post_self_revocation_event(&event, k);
748 }
749 }
750
751 void BiasedLocking::revoke(Handle obj, TRAPS) {
752 assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint");
753
754 while (true) {
755 // We can revoke the biases of anonymously-biased objects
756 // efficiently enough that we should not cause these revocations to
757 // update the heuristics because doing so may cause unwanted bulk
758 // revocations (which are expensive) to occur.
759 markWord mark = obj->mark();
760
761 if (!mark.has_bias_pattern()) {
762 return;
763 }
764
765 if (mark.is_biased_anonymously()) {
766 // We are probably trying to revoke the bias of this object due to
767 // an identity hash code computation. Try to revoke the bias
768 // without a safepoint. This is possible if we can successfully
769 // compare-and-exchange an unbiased header into the mark word of
|