src/share/vm/gc_implementation/parNew/parNewGeneration.cpp

changeset 5784
190899198332
parent 5516
330dfb0476f4
child 6131
86e6d691f2e1
equal deleted inserted replaced
5783:c1fbf21c7397 5784:190899198332
1101 for (int i = 0; i < 100; i++) { 1101 for (int i = 0; i < 100; i++) {
1102 sum += i; 1102 sum += i;
1103 } 1103 }
1104 } 1104 }
1105 1105
1106 static const oop ClaimedForwardPtr = oop(0x4); 1106 static const oop ClaimedForwardPtr = cast_to_oop<intptr_t>(0x4);
1107 1107
1108 // Because of concurrency, there are times where an object for which 1108 // Because of concurrency, there are times where an object for which
1109 // "is_forwarded()" is true contains an "interim" forwarding pointer 1109 // "is_forwarded()" is true contains an "interim" forwarding pointer
1110 // value. Such a value will soon be overwritten with a real value. 1110 // value. Such a value will soon be overwritten with a real value.
1111 // This method requires "obj" to have a forwarding pointer, and waits, if 1111 // This method requires "obj" to have a forwarding pointer, and waits, if
1224 // This code must come after the CAS test, or it will print incorrect 1224 // This code must come after the CAS test, or it will print incorrect
1225 // information. 1225 // information.
1226 if (TraceScavenge) { 1226 if (TraceScavenge) {
1227 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 1227 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
1228 is_in_reserved(new_obj) ? "copying" : "tenuring", 1228 is_in_reserved(new_obj) ? "copying" : "tenuring",
1229 new_obj->klass()->internal_name(), old, new_obj, new_obj->size()); 1229 new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size());
1230 } 1230 }
1231 #endif 1231 #endif
1232 1232
1233 if (forward_ptr == NULL) { 1233 if (forward_ptr == NULL) {
1234 oop obj_to_push = new_obj; 1234 oop obj_to_push = new_obj;
1345 // This code must come after the CAS test, or it will print incorrect 1345 // This code must come after the CAS test, or it will print incorrect
1346 // information. 1346 // information.
1347 if (TraceScavenge) { 1347 if (TraceScavenge) {
1348 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 1348 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
1349 is_in_reserved(new_obj) ? "copying" : "tenuring", 1349 is_in_reserved(new_obj) ? "copying" : "tenuring",
1350 new_obj->klass()->internal_name(), old, new_obj, new_obj->size()); 1350 new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size());
1351 } 1351 }
1352 #endif 1352 #endif
1353 1353
1354 // Now attempt to install the forwarding pointer (atomically). 1354 // Now attempt to install the forwarding pointer (atomically).
1355 // We have to copy the mark word before overwriting with forwarding 1355 // We have to copy the mark word before overwriting with forwarding
1434 // overflow stack draining strategy. If/when we start using fat 1434 // overflow stack draining strategy. If/when we start using fat
1435 // stacks here, we can go back to using (fat) pointer chains 1435 // stacks here, we can go back to using (fat) pointer chains
1436 // (although some performance comparisons would be useful since 1436 // (although some performance comparisons would be useful since
1437 // single global lists have their own performance disadvantages 1437 // single global lists have their own performance disadvantages
1438 // as we were made painfully aware not long ago, see 6786503). 1438 // as we were made painfully aware not long ago, see 6786503).
1439 #define BUSY (oop(0x1aff1aff)) 1439 #define BUSY (cast_to_oop<intptr_t>(0x1aff1aff))
1440 void ParNewGeneration::push_on_overflow_list(oop from_space_obj, ParScanThreadState* par_scan_state) { 1440 void ParNewGeneration::push_on_overflow_list(oop from_space_obj, ParScanThreadState* par_scan_state) {
1441 assert(is_in_reserved(from_space_obj), "Should be from this generation"); 1441 assert(is_in_reserved(from_space_obj), "Should be from this generation");
1442 if (ParGCUseLocalOverflow) { 1442 if (ParGCUseLocalOverflow) {
1443 // In the case of compressed oops, we use a private, not-shared 1443 // In the case of compressed oops, we use a private, not-shared
1444 // overflow stack. 1444 // overflow stack.
1510 assert(!UseCompressedOops, "Error"); 1510 assert(!UseCompressedOops, "Error");
1511 assert(par_scan_state->overflow_stack() == NULL, "Error"); 1511 assert(par_scan_state->overflow_stack() == NULL, "Error");
1512 if (_overflow_list == NULL) return false; 1512 if (_overflow_list == NULL) return false;
1513 1513
1514 // Otherwise, there was something there; try claiming the list. 1514 // Otherwise, there was something there; try claiming the list.
1515 oop prefix = (oop)Atomic::xchg_ptr(BUSY, &_overflow_list); 1515 oop prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));
1516 // Trim off a prefix of at most objsFromOverflow items 1516 // Trim off a prefix of at most objsFromOverflow items
1517 Thread* tid = Thread::current(); 1517 Thread* tid = Thread::current();
1518 size_t spin_count = (size_t)ParallelGCThreads; 1518 size_t spin_count = (size_t)ParallelGCThreads;
1519 size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100); 1519 size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100);
1520 for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) { 1520 for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) {
1524 if (_overflow_list == NULL) { 1524 if (_overflow_list == NULL) {
1525 // nothing left to take 1525 // nothing left to take
1526 return false; 1526 return false;
1527 } else if (_overflow_list != BUSY) { 1527 } else if (_overflow_list != BUSY) {
1528 // try and grab the prefix 1528 // try and grab the prefix
1529 prefix = (oop)Atomic::xchg_ptr(BUSY, &_overflow_list); 1529 prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));
1530 } 1530 }
1531 } 1531 }
1532 if (prefix == NULL || prefix == BUSY) { 1532 if (prefix == NULL || prefix == BUSY) {
1533 // Nothing to take or waited long enough 1533 // Nothing to take or waited long enough
1534 if (prefix == NULL) { 1534 if (prefix == NULL) {

mercurial