< prev index next >
src/hotspot/share/gc/g1/g1FreeIdSet.cpp
Print this page
rev 53151 : [mq]: tschatzl_review
@@ -28,12 +28,10 @@
#include "runtime/atomic.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
-const uint claimed = UINT_MAX;
-
G1FreeIdSet::G1FreeIdSet(uint start, uint size) :
_sem(size), // counting semaphore for available ids
_next(NULL), // array of "next" indices
_start(start), // first id value
_size(size), // number of available ids
@@ -66,10 +64,12 @@
uintx G1FreeIdSet::make_head(uint index, uintx old_head) const {
// Include incremented old update counter to avoid ABA problem.
return index | ((old_head & ~_head_index_mask) + 1 + _head_index_mask);
}
+const uint Claimed = UINT_MAX;
+
uint G1FreeIdSet::claim_par_id() {
_sem.wait();
// Semaphore gate permits passage by no more than the number of
// available ids, so there must be one that we can claim. But there
// may be multiple threads trying to claim ids at the same time.
@@ -81,18 +81,18 @@
uintx new_head = make_head(_next[index], old_head);
new_head = Atomic::cmpxchg(new_head, &_head, old_head);
if (new_head == old_head) break;
old_head = new_head;
}
- DEBUG_ONLY(_next[index] = claimed;)
+ DEBUG_ONLY(_next[index] = Claimed;)
return _start + index;
}
void G1FreeIdSet::release_par_id(uint id) {
uint index = id - _start;
assert(index < _size, "invalid id %u", id);
- assert(_next[index] == claimed, "precondition");
+ assert(_next[index] == Claimed, "precondition");
uintx old_head = Atomic::load(&_head);
while (true) {
_next[index] = head_index(old_head);
uintx new_head = make_head(index, old_head);
new_head = Atomic::cmpxchg(new_head, &_head, old_head);
< prev index next >