< prev index next >
src/share/vm/gc/cms/parNewGeneration.cpp
Print this page
rev 11970 : imported patch overflow_list
*** 1261,1271 ****
// overflow stack draining strategy. If/when we start using fat
// stacks here, we can go back to using (fat) pointer chains
// (although some performance comparisons would be useful since
// single global lists have their own performance disadvantages
// as we were made painfully aware not long ago, see 6786503).
! #define BUSY (cast_to_oop<intptr_t>(0x1aff1aff))
void ParNewGeneration::push_on_overflow_list(oop from_space_obj, ParScanThreadState* par_scan_state) {
assert(is_in_reserved(from_space_obj), "Should be from this generation");
if (ParGCUseLocalOverflow) {
// In the case of compressed oops, we use a private, not-shared
// overflow stack.
--- 1261,1271 ----
// overflow stack draining strategy. If/when we start using fat
// stacks here, we can go back to using (fat) pointer chains
// (although some performance comparisons would be useful since
// single global lists have their own performance disadvantages
// as we were made painfully aware not long ago, see 6786503).
! #define BUSY ((HeapWord*)(0x1aff1aff))
void ParNewGeneration::push_on_overflow_list(oop from_space_obj, ParScanThreadState* par_scan_state) {
assert(is_in_reserved(from_space_obj), "Should be from this generation");
if (ParGCUseLocalOverflow) {
// In the case of compressed oops, we use a private, not-shared
// overflow stack.
*** 1284,1304 ****
if (from_space_obj->forwardee() == from_space_obj) {
oopDesc* listhead = NEW_C_HEAP_ARRAY(oopDesc, 1, mtGC);
listhead->forward_to(from_space_obj);
from_space_obj = listhead;
}
! oop observed_overflow_list = _overflow_list;
! oop cur_overflow_list;
do {
cur_overflow_list = observed_overflow_list;
if (cur_overflow_list != BUSY) {
! from_space_obj->set_klass_to_list_ptr(cur_overflow_list);
} else {
from_space_obj->set_klass_to_list_ptr(NULL);
}
observed_overflow_list =
! (oop)Atomic::cmpxchg_ptr(from_space_obj, &_overflow_list, cur_overflow_list);
} while (cur_overflow_list != observed_overflow_list);
}
}
bool ParNewGeneration::take_from_overflow_list(ParScanThreadState* par_scan_state) {
--- 1284,1304 ----
if (from_space_obj->forwardee() == from_space_obj) {
oopDesc* listhead = NEW_C_HEAP_ARRAY(oopDesc, 1, mtGC);
listhead->forward_to(from_space_obj);
from_space_obj = listhead;
}
! HeapWord* observed_overflow_list = _overflow_list;
! HeapWord* cur_overflow_list;
do {
cur_overflow_list = observed_overflow_list;
if (cur_overflow_list != BUSY) {
! from_space_obj->set_klass_to_list_ptr(cast_to_oop<HeapWord*>(cur_overflow_list));
} else {
from_space_obj->set_klass_to_list_ptr(NULL);
}
observed_overflow_list =
! (HeapWord*)Atomic::cmpxchg_ptr(cast_from_oop<HeapWord*>(from_space_obj), &_overflow_list, cur_overflow_list);
} while (cur_overflow_list != observed_overflow_list);
}
}
bool ParNewGeneration::take_from_overflow_list(ParScanThreadState* par_scan_state) {
*** 1337,1347 ****
assert(!UseCompressedOops, "Error");
assert(par_scan_state->overflow_stack() == NULL, "Error");
if (_overflow_list == NULL) return false;
// Otherwise, there was something there; try claiming the list.
! oop prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));
// Trim off a prefix of at most objsFromOverflow items
Thread* tid = Thread::current();
size_t spin_count = ParallelGCThreads;
size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100);
for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) {
--- 1337,1347 ----
assert(!UseCompressedOops, "Error");
assert(par_scan_state->overflow_stack() == NULL, "Error");
if (_overflow_list == NULL) return false;
// Otherwise, there was something there; try claiming the list.
! HeapWord* prefix = (HeapWord*)Atomic::xchg_ptr(BUSY, &_overflow_list);
// Trim off a prefix of at most objsFromOverflow items
Thread* tid = Thread::current();
size_t spin_count = ParallelGCThreads;
size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100);
for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) {
*** 1351,1361 ****
if (_overflow_list == NULL) {
// nothing left to take
return false;
} else if (_overflow_list != BUSY) {
// try and grab the prefix
! prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));
}
}
if (prefix == NULL || prefix == BUSY) {
// Nothing to take or waited long enough
if (prefix == NULL) {
--- 1351,1361 ----
if (_overflow_list == NULL) {
// nothing left to take
return false;
} else if (_overflow_list != BUSY) {
// try and grab the prefix
! prefix = (HeapWord*)Atomic::xchg_ptr(BUSY, &_overflow_list);
}
}
if (prefix == NULL || prefix == BUSY) {
// Nothing to take or waited long enough
if (prefix == NULL) {
*** 1365,1375 ****
}
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();
}
// Reattach remaining (suffix) to overflow list
--- 1365,1375 ----
}
return false;
}
assert(prefix != NULL && prefix != BUSY, "Error");
size_t i = 1;
! oop cur = cast_to_oop<HeapWord*>(prefix);
while (i < objsFromOverflow && cur->klass_or_null() != NULL) {
i++; cur = cur->list_ptr_from_klass();
}
// Reattach remaining (suffix) to overflow list
*** 1384,1399 ****
oop suffix = cur->list_ptr_from_klass(); // 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
// able to place back the suffix.
! oop observed_overflow_list = _overflow_list;
! oop cur_overflow_list = observed_overflow_list;
bool attached = false;
while (observed_overflow_list == BUSY || observed_overflow_list == NULL) {
observed_overflow_list =
! (oop) Atomic::cmpxchg_ptr(suffix, &_overflow_list, cur_overflow_list);
if (cur_overflow_list == observed_overflow_list) {
attached = true;
break;
} else cur_overflow_list = observed_overflow_list;
}
--- 1384,1399 ----
oop suffix = cur->list_ptr_from_klass(); // 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
// able to place back the suffix.
! HeapWord* observed_overflow_list = _overflow_list;
! HeapWord* cur_overflow_list = observed_overflow_list;
bool attached = false;
while (observed_overflow_list == BUSY || observed_overflow_list == NULL) {
observed_overflow_list =
! (HeapWord*)Atomic::cmpxchg_ptr(suffix, &_overflow_list, cur_overflow_list);
if (cur_overflow_list == observed_overflow_list) {
attached = true;
break;
} else cur_overflow_list = observed_overflow_list;
}
*** 1408,1430 ****
observed_overflow_list = _overflow_list;
do {
cur_overflow_list = observed_overflow_list;
if (cur_overflow_list != BUSY) {
// Do the splice ...
! last->set_klass_to_list_ptr(cur_overflow_list);
} else { // cur_overflow_list == BUSY
last->set_klass_to_list_ptr(NULL);
}
observed_overflow_list =
! (oop)Atomic::cmpxchg_ptr(suffix, &_overflow_list, cur_overflow_list);
} while (cur_overflow_list != observed_overflow_list);
}
}
// Push objects on prefix list onto this thread's work queue
assert(prefix != NULL && prefix != BUSY, "program logic");
! cur = prefix;
ssize_t n = 0;
while (cur != NULL) {
oop obj_to_push = cur->forwardee();
oop next = cur->list_ptr_from_klass();
cur->set_klass(obj_to_push->klass());
--- 1408,1430 ----
observed_overflow_list = _overflow_list;
do {
cur_overflow_list = observed_overflow_list;
if (cur_overflow_list != BUSY) {
// Do the splice ...
! last->set_klass_to_list_ptr(cast_to_oop<HeapWord*>(cur_overflow_list));
} else { // cur_overflow_list == BUSY
last->set_klass_to_list_ptr(NULL);
}
observed_overflow_list =
! (HeapWord*)Atomic::cmpxchg_ptr(cast_from_oop<HeapWord*>(suffix), &_overflow_list, cur_overflow_list);
} while (cur_overflow_list != observed_overflow_list);
}
}
// Push objects on prefix list onto this thread's work queue
assert(prefix != NULL && prefix != BUSY, "program logic");
! cur = cast_to_oop<HeapWord*>(prefix);
ssize_t n = 0;
while (cur != NULL) {
oop obj_to_push = cur->forwardee();
oop next = cur->list_ptr_from_klass();
cur->set_klass(obj_to_push->klass());
< prev index next >