< prev index next >

src/hotspot/share/runtime/biasedLocking.cpp

Print this page
rev 56251 : imported patch 8226705-v1
rev 56253 : [mq]: 8226705-v3-pat


 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 




 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_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 }
 752 
 753 void BiasedLocking::revoke(Handle obj, TRAPS) {
 754   assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint");
 755 
 756   while (true) {
 757     // We can revoke the biases of anonymously-biased objects
 758     // efficiently enough that we should not cause these revocations to
 759     // update the heuristics because doing so may cause unwanted bulk
 760     // revocations (which are expensive) to occur.
 761     markWord mark = obj->mark();
 762 
 763     if (!mark.has_bias_pattern()) {
 764       return;
 765     }
 766 


< prev index next >