724 } |
724 } |
725 |
725 |
726 assert(!obj->mark().has_bias_pattern(), "must not be biased"); |
726 assert(!obj->mark().has_bias_pattern(), "must not be biased"); |
727 } |
727 } |
728 |
728 |
|
729 void BiasedLocking::revoke_own_lock(Handle obj, TRAPS) { |
|
730 assert(THREAD->is_Java_thread(), "must be called by a JavaThread"); |
|
731 JavaThread* thread = (JavaThread*)THREAD; |
|
732 |
|
733 markWord mark = obj->mark(); |
|
734 |
|
735 if (!mark.has_bias_pattern()) { |
|
736 return; |
|
737 } |
|
738 |
|
739 Klass *k = obj->klass(); |
|
740 assert(mark.biased_locker() == thread && |
|
741 k->prototype_header().bias_epoch() == mark.bias_epoch(), "Revoke failed, unhandled biased lock state"); |
|
742 ResourceMark rm; |
|
743 log_info(biasedlocking)("Revoking bias by walking my own stack:"); |
|
744 EventBiasedLockSelfRevocation event; |
|
745 BiasedLocking::walk_stack_and_revoke(obj(), (JavaThread*) thread); |
|
746 thread->set_cached_monitor_info(NULL); |
|
747 assert(!obj->mark().has_bias_pattern(), "invariant"); |
|
748 if (event.should_commit()) { |
|
749 post_self_revocation_event(&event, k); |
|
750 } |
|
751 } |
729 |
752 |
730 void BiasedLocking::revoke(Handle obj, TRAPS) { |
753 void BiasedLocking::revoke(Handle obj, TRAPS) { |
731 assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint"); |
754 assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint"); |
732 |
755 |
733 while (true) { |
756 while (true) { |
862 clean_up_cached_monitor_info(); |
885 clean_up_cached_monitor_info(); |
863 } |
886 } |
864 } |
887 } |
865 |
888 |
866 |
889 |
867 void BiasedLocking::revoke_at_safepoint(GrowableArray<Handle>* objs) { |
|
868 assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint"); |
|
869 int len = objs->length(); |
|
870 for (int i = 0; i < len; i++) { |
|
871 oop obj = (objs->at(i))(); |
|
872 HeuristicsResult heuristics = update_heuristics(obj); |
|
873 if (heuristics == HR_SINGLE_REVOKE) { |
|
874 single_revoke_at_safepoint(obj, false, NULL, NULL); |
|
875 } else if ((heuristics == HR_BULK_REBIAS) || |
|
876 (heuristics == HR_BULK_REVOKE)) { |
|
877 bulk_revoke_at_safepoint(obj, (heuristics == HR_BULK_REBIAS), NULL); |
|
878 } |
|
879 } |
|
880 clean_up_cached_monitor_info(); |
|
881 } |
|
882 |
|
883 |
|
884 void BiasedLocking::preserve_marks() { |
890 void BiasedLocking::preserve_marks() { |
885 if (!UseBiasedLocking) |
891 if (!UseBiasedLocking) |
886 return; |
892 return; |
887 |
893 |
888 assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint"); |
894 assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint"); |