< prev index next >

src/hotspot/share/gc/cms/parNewGeneration.cpp

Print this page




1287 // CR 6797058 has been filed to attempt consolidation of
1288 // the common code.
1289 // Because of the common code, if you make any changes in
1290 // the code below, please check the CMS version to see if
1291 // similar changes might be needed.
1292 // See CMSCollector::par_take_from_overflow_list() for
1293 // more extensive documentation comments.
1294 bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan_state) {
1295   ObjToScanQueue* work_q = par_scan_state->work_queue();
1296   // How many to take?
1297   size_t objsFromOverflow = MIN2((size_t)(work_q->max_elems() - work_q->size())/4,
1298                                  (size_t)ParGCDesiredObjsFromOverflowList);
1299 
1300   assert(!UseCompressedOops, "Error");
1301   assert(par_scan_state->overflow_stack() == NULL, "Error");
1302   if (_overflow_list == NULL) return false;
1303 
1304   // Otherwise, there was something there; try claiming the list.
1305   oop prefix = cast_to_oop(Atomic::xchg((oopDesc*)BUSY, &_overflow_list));
1306   // Trim off a prefix of at most objsFromOverflow items
1307   Thread* tid = Thread::current();
1308   size_t spin_count = ParallelGCThreads;
1309   size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100);
1310   for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) {
1311     // someone grabbed it before we did ...
1312     // ... we spin for a short while...
1313     os::sleep(tid, sleep_time_millis, false);
1314     if (_overflow_list == NULL) {
1315       // nothing left to take
1316       return false;
1317     } else if (_overflow_list != BUSY) {
1318      // try and grab the prefix
1319      prefix = cast_to_oop(Atomic::xchg((oopDesc*)BUSY, &_overflow_list));
1320     }
1321   }
1322   if (prefix == NULL || prefix == BUSY) {
1323      // Nothing to take or waited long enough
1324      if (prefix == NULL) {
1325        // Write back the NULL in case we overwrote it with BUSY above
1326        // and it is still the same value.
1327        (void) Atomic::cmpxchg((oopDesc*)NULL, &_overflow_list, (oopDesc*)BUSY);
1328      }
1329      return false;
1330   }
1331   assert(prefix != NULL && prefix != BUSY, "Error");
1332   oop cur = prefix;
1333   for (size_t i = 1; i < objsFromOverflow; ++i) {




1287 // CR 6797058 has been filed to attempt consolidation of
1288 // the common code.
1289 // Because of the common code, if you make any changes in
1290 // the code below, please check the CMS version to see if
1291 // similar changes might be needed.
1292 // See CMSCollector::par_take_from_overflow_list() for
1293 // more extensive documentation comments.
1294 bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan_state) {
1295   ObjToScanQueue* work_q = par_scan_state->work_queue();
1296   // How many to take?
1297   size_t objsFromOverflow = MIN2((size_t)(work_q->max_elems() - work_q->size())/4,
1298                                  (size_t)ParGCDesiredObjsFromOverflowList);
1299 
1300   assert(!UseCompressedOops, "Error");
1301   assert(par_scan_state->overflow_stack() == NULL, "Error");
1302   if (_overflow_list == NULL) return false;
1303 
1304   // Otherwise, there was something there; try claiming the list.
1305   oop prefix = cast_to_oop(Atomic::xchg((oopDesc*)BUSY, &_overflow_list));
1306   // Trim off a prefix of at most objsFromOverflow items

1307   size_t spin_count = ParallelGCThreads;
1308   size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100);
1309   for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) {
1310     // someone grabbed it before we did ...
1311     // ... we spin/block for a short while...
1312     os::naked_sleep(sleep_time_millis);
1313     if (_overflow_list == NULL) {
1314       // nothing left to take
1315       return false;
1316     } else if (_overflow_list != BUSY) {
1317      // try and grab the prefix
1318      prefix = cast_to_oop(Atomic::xchg((oopDesc*)BUSY, &_overflow_list));
1319     }
1320   }
1321   if (prefix == NULL || prefix == BUSY) {
1322      // Nothing to take or waited long enough
1323      if (prefix == NULL) {
1324        // Write back the NULL in case we overwrote it with BUSY above
1325        // and it is still the same value.
1326        (void) Atomic::cmpxchg((oopDesc*)NULL, &_overflow_list, (oopDesc*)BUSY);
1327      }
1328      return false;
1329   }
1330   assert(prefix != NULL && prefix != BUSY, "Error");
1331   oop cur = prefix;
1332   for (size_t i = 1; i < objsFromOverflow; ++i) {


< prev index next >