src/hotspot/share/gc/g1/g1FreeIdSet.cpp
changeset 59252 623722a6aeb9
parent 53482 771b50dd0b08
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
    77   uint index;
    77   uint index;
    78   while (true) {
    78   while (true) {
    79     index = head_index(old_head);
    79     index = head_index(old_head);
    80     assert(index < _size, "invariant");
    80     assert(index < _size, "invariant");
    81     uintx new_head = make_head(_next[index], old_head);
    81     uintx new_head = make_head(_next[index], old_head);
    82     new_head = Atomic::cmpxchg(new_head, &_head, old_head);
    82     new_head = Atomic::cmpxchg(&_head, old_head, new_head);
    83     if (new_head == old_head) break;
    83     if (new_head == old_head) break;
    84     old_head = new_head;
    84     old_head = new_head;
    85   }
    85   }
    86   DEBUG_ONLY(_next[index] = Claimed;)
    86   DEBUG_ONLY(_next[index] = Claimed;)
    87   return _start + index;
    87   return _start + index;
    93   assert(_next[index] == Claimed, "precondition");
    93   assert(_next[index] == Claimed, "precondition");
    94   uintx old_head = Atomic::load(&_head);
    94   uintx old_head = Atomic::load(&_head);
    95   while (true) {
    95   while (true) {
    96     _next[index] = head_index(old_head);
    96     _next[index] = head_index(old_head);
    97     uintx new_head = make_head(index, old_head);
    97     uintx new_head = make_head(index, old_head);
    98     new_head = Atomic::cmpxchg(new_head, &_head, old_head);
    98     new_head = Atomic::cmpxchg(&_head, old_head, new_head);
    99     if (new_head == old_head) break;
    99     if (new_head == old_head) break;
   100     old_head = new_head;
   100     old_head = new_head;
   101   }
   101   }
   102   // Now that id has been released, permit another thread through the gate.
   102   // Now that id has been released, permit another thread through the gate.
   103   _sem.signal();
   103   _sem.signal();