8166229: Eliminate ParNew's use of klass_or_null()

Use list_ptr_from_klass instead of klass_or_null.

Reviewed-by: mgerdin, jmasa
This commit is contained in:
Kim Barrett 2016-09-19 13:12:26 -04:00
parent eb52950704
commit 8617484bde

@ -1366,22 +1366,25 @@ bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan
return false;
}
assert(prefix != NULL && prefix != BUSY, "Error");
size_t i = 1;
oop cur = prefix;
while (i < objsFromOverflow && cur->klass_or_null() != NULL) {
i++; cur = cur->list_ptr_from_klass();
for (size_t i = 1; i < objsFromOverflow; ++i) {
oop next = cur->list_ptr_from_klass();
if (next == NULL) break;
cur = next;
}
assert(cur != NULL, "Loop postcondition");
// Reattach remaining (suffix) to overflow list
if (cur->klass_or_null() == NULL) {
oop suffix = cur->list_ptr_from_klass();
if (suffix == NULL) {
// Write back the NULL in lieu of the BUSY we wrote
// above and it is still the same value.
if (_overflow_list == BUSY) {
(void) Atomic::cmpxchg_ptr(NULL, &_overflow_list, BUSY);
}
} else {
assert(cur->klass_or_null() != (Klass*)(address)BUSY, "Error");
oop suffix = cur->list_ptr_from_klass(); // suffix will be put back on global list
assert(suffix != BUSY, "Error");
// suffix will be put back on global list
cur->set_klass_to_list_ptr(NULL); // break off suffix
// It's possible that the list is still in the empty(busy) state
// we left it in a short while ago; in that case we may be
@ -1401,8 +1404,10 @@ bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan
// Too bad, someone else got in in between; we'll need to do a splice.
// Find the last item of suffix list
oop last = suffix;
while (last->klass_or_null() != NULL) {
last = last->list_ptr_from_klass();
while (true) {
oop next = last->list_ptr_from_klass();
if (next == NULL) break;
last = next;
}
// Atomically prepend suffix to current overflow list
observed_overflow_list = _overflow_list;