src/hotspot/share/runtime/thread.cpp
changeset 51702 ebd5b1ad971a
parent 51600 56309b1b9d9b
child 51817 46eac084082d
child 56897 840ad2a9015a
equal deleted inserted replaced
51701:9012aeaf993b 51702:ebd5b1ad971a
  4734   if (Atomic::cmpxchg (1, adr, 0) == 0) {
  4734   if (Atomic::cmpxchg (1, adr, 0) == 0) {
  4735     return;   // normal fast-path return
  4735     return;   // normal fast-path return
  4736   }
  4736   }
  4737 
  4737 
  4738   // Slow-path : We've encountered contention -- Spin/Yield/Block strategy.
  4738   // Slow-path : We've encountered contention -- Spin/Yield/Block strategy.
  4739   TEVENT(SpinAcquire - ctx);
       
  4740   int ctr = 0;
  4739   int ctr = 0;
  4741   int Yields = 0;
  4740   int Yields = 0;
  4742   for (;;) {
  4741   for (;;) {
  4743     while (*adr != 0) {
  4742     while (*adr != 0) {
  4744       ++ctr;
  4743       ++ctr;
  4829   if (w == 0) return;
  4828   if (w == 0) return;
  4830   if ((w & LOCKBIT) == 0 && Atomic::cmpxchg(w|LOCKBIT, Lock, w) == w) {
  4829   if ((w & LOCKBIT) == 0 && Atomic::cmpxchg(w|LOCKBIT, Lock, w) == w) {
  4831     return;
  4830     return;
  4832   }
  4831   }
  4833 
  4832 
  4834   TEVENT(muxAcquire - Contention);
       
  4835   ParkEvent * const Self = Thread::current()->_MuxEvent;
  4833   ParkEvent * const Self = Thread::current()->_MuxEvent;
  4836   assert((intptr_t(Self) & LOCKBIT) == 0, "invariant");
  4834   assert((intptr_t(Self) & LOCKBIT) == 0, "invariant");
  4837   for (;;) {
  4835   for (;;) {
  4838     int its = (os::is_MP() ? 100 : 0) + 1;
  4836     int its = (os::is_MP() ? 100 : 0) + 1;
  4839 
  4837 
  4875   if (w == 0) return;
  4873   if (w == 0) return;
  4876   if ((w & LOCKBIT) == 0 && Atomic::cmpxchg(w|LOCKBIT, Lock, w) == w) {
  4874   if ((w & LOCKBIT) == 0 && Atomic::cmpxchg(w|LOCKBIT, Lock, w) == w) {
  4877     return;
  4875     return;
  4878   }
  4876   }
  4879 
  4877 
  4880   TEVENT(muxAcquire - Contention);
       
  4881   ParkEvent * ReleaseAfter = NULL;
  4878   ParkEvent * ReleaseAfter = NULL;
  4882   if (ev == NULL) {
  4879   if (ev == NULL) {
  4883     ev = ReleaseAfter = ParkEvent::Allocate(NULL);
  4880     ev = ReleaseAfter = ParkEvent::Allocate(NULL);
  4884   }
  4881   }
  4885   assert((intptr_t(ev) & LOCKBIT) == 0, "invariant");
  4882   assert((intptr_t(ev) & LOCKBIT) == 0, "invariant");