33 #include "runtime/biasedLocking.hpp" |
33 #include "runtime/biasedLocking.hpp" |
34 #include "runtime/task.hpp" |
34 #include "runtime/task.hpp" |
35 #include "runtime/vframe.hpp" |
35 #include "runtime/vframe.hpp" |
36 #include "runtime/vmThread.hpp" |
36 #include "runtime/vmThread.hpp" |
37 #include "runtime/vm_operations.hpp" |
37 #include "runtime/vm_operations.hpp" |
|
38 #include "trace/tracing.hpp" |
38 |
39 |
39 static bool _biased_locking_enabled = false; |
40 static bool _biased_locking_enabled = false; |
40 BiasedLockingCounters BiasedLocking::_counters; |
41 BiasedLockingCounters BiasedLocking::_counters; |
41 |
42 |
42 static GrowableArray<Handle>* _preserved_oop_stack = NULL; |
43 static GrowableArray<Handle>* _preserved_oop_stack = NULL; |
641 // Also check the epoch because even if threads match, another thread |
642 // Also check the epoch because even if threads match, another thread |
642 // can come in with a CAS to steal the bias of an object that has a |
643 // can come in with a CAS to steal the bias of an object that has a |
643 // stale epoch. |
644 // stale epoch. |
644 ResourceMark rm; |
645 ResourceMark rm; |
645 log_info(biasedlocking)("Revoking bias by walking my own stack:"); |
646 log_info(biasedlocking)("Revoking bias by walking my own stack:"); |
|
647 EventBiasedLockSelfRevocation event; |
646 BiasedLocking::Condition cond = revoke_bias(obj(), false, false, (JavaThread*) THREAD); |
648 BiasedLocking::Condition cond = revoke_bias(obj(), false, false, (JavaThread*) THREAD); |
647 ((JavaThread*) THREAD)->set_cached_monitor_info(NULL); |
649 ((JavaThread*) THREAD)->set_cached_monitor_info(NULL); |
648 assert(cond == BIAS_REVOKED, "why not?"); |
650 assert(cond == BIAS_REVOKED, "why not?"); |
|
651 if (event.should_commit()) { |
|
652 event.set_lockClass(k); |
|
653 event.commit(); |
|
654 } |
649 return cond; |
655 return cond; |
650 } else { |
656 } else { |
|
657 EventBiasedLockRevocation event; |
651 VM_RevokeBias revoke(&obj, (JavaThread*) THREAD); |
658 VM_RevokeBias revoke(&obj, (JavaThread*) THREAD); |
652 VMThread::execute(&revoke); |
659 VMThread::execute(&revoke); |
|
660 if (event.should_commit() && (revoke.status_code() != NOT_BIASED)) { |
|
661 event.set_lockClass(k); |
|
662 // Subtract 1 to match the id of events committed inside the safepoint |
|
663 event.set_safepointId(SafepointSynchronize::safepoint_counter() - 1); |
|
664 event.commit(); |
|
665 } |
653 return revoke.status_code(); |
666 return revoke.status_code(); |
654 } |
667 } |
655 } |
668 } |
656 |
669 |
657 assert((heuristics == HR_BULK_REVOKE) || |
670 assert((heuristics == HR_BULK_REVOKE) || |
658 (heuristics == HR_BULK_REBIAS), "?"); |
671 (heuristics == HR_BULK_REBIAS), "?"); |
|
672 EventBiasedLockClassRevocation event; |
659 VM_BulkRevokeBias bulk_revoke(&obj, (JavaThread*) THREAD, |
673 VM_BulkRevokeBias bulk_revoke(&obj, (JavaThread*) THREAD, |
660 (heuristics == HR_BULK_REBIAS), |
674 (heuristics == HR_BULK_REBIAS), |
661 attempt_rebias); |
675 attempt_rebias); |
662 VMThread::execute(&bulk_revoke); |
676 VMThread::execute(&bulk_revoke); |
|
677 if (event.should_commit()) { |
|
678 event.set_revokedClass(obj->klass()); |
|
679 event.set_disableBiasing((heuristics != HR_BULK_REBIAS)); |
|
680 // Subtract 1 to match the id of events committed inside the safepoint |
|
681 event.set_safepointId(SafepointSynchronize::safepoint_counter() - 1); |
|
682 event.commit(); |
|
683 } |
663 return bulk_revoke.status_code(); |
684 return bulk_revoke.status_code(); |
664 } |
685 } |
665 |
686 |
666 |
687 |
667 void BiasedLocking::revoke(GrowableArray<Handle>* objs) { |
688 void BiasedLocking::revoke(GrowableArray<Handle>* objs) { |