comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 6010:720b6a76dd9d

7157073: G1: type change size_t -> uint for region counts / indexes Summary: Change the type of fields / variables / etc. that represent region counts and indeces from size_t to uint. Reviewed-by: iveresov, brutisso, jmasa, jwilhelm
author tonyp
date Wed, 18 Apr 2012 07:21:15 -0400
parents b632e80fc9dc
children f7a8920427a6
comparison
equal deleted inserted replaced
6009:dde53abda3d6 6010:720b6a76dd9d
401 401
402 uint ConcurrentMark::scale_parallel_threads(uint n_par_threads) { 402 uint ConcurrentMark::scale_parallel_threads(uint n_par_threads) {
403 return MAX2((n_par_threads + 2) / 4, 1U); 403 return MAX2((n_par_threads + 2) / 4, 1U);
404 } 404 }
405 405
406 ConcurrentMark::ConcurrentMark(ReservedSpace rs, 406 ConcurrentMark::ConcurrentMark(ReservedSpace rs, uint max_regions) :
407 int max_regions) :
408 _markBitMap1(rs, MinObjAlignment - 1), 407 _markBitMap1(rs, MinObjAlignment - 1),
409 _markBitMap2(rs, MinObjAlignment - 1), 408 _markBitMap2(rs, MinObjAlignment - 1),
410 409
411 _parallel_marking_threads(0), 410 _parallel_marking_threads(0),
412 _max_parallel_marking_threads(0), 411 _max_parallel_marking_threads(0),
413 _sleep_factor(0.0), 412 _sleep_factor(0.0),
414 _marking_task_overhead(1.0), 413 _marking_task_overhead(1.0),
415 _cleanup_sleep_factor(0.0), 414 _cleanup_sleep_factor(0.0),
416 _cleanup_task_overhead(1.0), 415 _cleanup_task_overhead(1.0),
417 _cleanup_list("Cleanup List"), 416 _cleanup_list("Cleanup List"),
418 _region_bm(max_regions, false /* in_resource_area*/), 417 _region_bm((BitMap::idx_t) max_regions, false /* in_resource_area*/),
419 _card_bm((rs.size() + CardTableModRefBS::card_size - 1) >> 418 _card_bm((rs.size() + CardTableModRefBS::card_size - 1) >>
420 CardTableModRefBS::card_shift, 419 CardTableModRefBS::card_shift,
421 false /* in_resource_area*/), 420 false /* in_resource_area*/),
422 421
423 _prevMarkBitMap(&_markBitMap1), 422 _prevMarkBitMap(&_markBitMap1),
495 CMTaskQueue* task_queue = new CMTaskQueue(); 494 CMTaskQueue* task_queue = new CMTaskQueue();
496 task_queue->initialize(); 495 task_queue->initialize();
497 _task_queues->register_queue(i, task_queue); 496 _task_queues->register_queue(i, task_queue);
498 497
499 _count_card_bitmaps[i] = BitMap(card_bm_size, false); 498 _count_card_bitmaps[i] = BitMap(card_bm_size, false);
500 _count_marked_bytes[i] = NEW_C_HEAP_ARRAY(size_t, max_regions); 499 _count_marked_bytes[i] = NEW_C_HEAP_ARRAY(size_t, (size_t) max_regions);
501 500
502 _tasks[i] = new CMTask(i, this, 501 _tasks[i] = new CMTask(i, this,
503 _count_marked_bytes[i], 502 _count_marked_bytes[i],
504 &_count_card_bitmaps[i], 503 &_count_card_bitmaps[i],
505 task_queue, _task_queues); 504 task_queue, _task_queues);
1226 // to 1 the bits on the region bitmap that correspond to its 1225 // to 1 the bits on the region bitmap that correspond to its
1227 // associated "continues humongous" regions. 1226 // associated "continues humongous" regions.
1228 void set_bit_for_region(HeapRegion* hr) { 1227 void set_bit_for_region(HeapRegion* hr) {
1229 assert(!hr->continuesHumongous(), "should have filtered those out"); 1228 assert(!hr->continuesHumongous(), "should have filtered those out");
1230 1229
1231 size_t index = hr->hrs_index(); 1230 BitMap::idx_t index = (BitMap::idx_t) hr->hrs_index();
1232 if (!hr->startsHumongous()) { 1231 if (!hr->startsHumongous()) {
1233 // Normal (non-humongous) case: just set the bit. 1232 // Normal (non-humongous) case: just set the bit.
1234 _region_bm->par_at_put((BitMap::idx_t) index, true); 1233 _region_bm->par_at_put(index, true);
1235 } else { 1234 } else {
1236 // Starts humongous case: calculate how many regions are part of 1235 // Starts humongous case: calculate how many regions are part of
1237 // this humongous region and then set the bit range. 1236 // this humongous region and then set the bit range.
1238 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 1237 G1CollectedHeap* g1h = G1CollectedHeap::heap();
1239 HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1); 1238 HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1);
1240 size_t end_index = last_hr->hrs_index() + 1; 1239 BitMap::idx_t end_index = (BitMap::idx_t) last_hr->hrs_index() + 1;
1241 _region_bm->par_at_put_range((BitMap::idx_t) index, 1240 _region_bm->par_at_put_range(index, end_index, true);
1242 (BitMap::idx_t) end_index, true);
1243 } 1241 }
1244 } 1242 }
1245 1243
1246 bool doHeapRegion(HeapRegion* hr) { 1244 bool doHeapRegion(HeapRegion* hr) {
1247 1245
1416 Mutex::_no_safepoint_check_flag); 1414 Mutex::_no_safepoint_check_flag);
1417 1415
1418 // Verify that _top_at_conc_count == ntams 1416 // Verify that _top_at_conc_count == ntams
1419 if (hr->top_at_conc_mark_count() != hr->next_top_at_mark_start()) { 1417 if (hr->top_at_conc_mark_count() != hr->next_top_at_mark_start()) {
1420 if (_verbose) { 1418 if (_verbose) {
1421 gclog_or_tty->print_cr("Region " SIZE_FORMAT ": top at conc count incorrect: " 1419 gclog_or_tty->print_cr("Region %u: top at conc count incorrect: "
1422 "expected " PTR_FORMAT ", actual: " PTR_FORMAT, 1420 "expected " PTR_FORMAT ", actual: " PTR_FORMAT,
1423 hr->hrs_index(), hr->next_top_at_mark_start(), 1421 hr->hrs_index(), hr->next_top_at_mark_start(),
1424 hr->top_at_conc_mark_count()); 1422 hr->top_at_conc_mark_count());
1425 } 1423 }
1426 failures += 1; 1424 failures += 1;
1432 1430
1433 // We're not OK if expected marked bytes > actual marked bytes. It means 1431 // We're not OK if expected marked bytes > actual marked bytes. It means
1434 // we have missed accounting some objects during the actual marking. 1432 // we have missed accounting some objects during the actual marking.
1435 if (exp_marked_bytes > act_marked_bytes) { 1433 if (exp_marked_bytes > act_marked_bytes) {
1436 if (_verbose) { 1434 if (_verbose) {
1437 gclog_or_tty->print_cr("Region " SIZE_FORMAT ": marked bytes mismatch: " 1435 gclog_or_tty->print_cr("Region %u: marked bytes mismatch: "
1438 "expected: " SIZE_FORMAT ", actual: " SIZE_FORMAT, 1436 "expected: " SIZE_FORMAT ", actual: " SIZE_FORMAT,
1439 hr->hrs_index(), exp_marked_bytes, act_marked_bytes); 1437 hr->hrs_index(), exp_marked_bytes, act_marked_bytes);
1440 } 1438 }
1441 failures += 1; 1439 failures += 1;
1442 } 1440 }
1443 1441
1444 // Verify the bit, for this region, in the actual and expected 1442 // Verify the bit, for this region, in the actual and expected
1445 // (which was just calculated) region bit maps. 1443 // (which was just calculated) region bit maps.
1446 // We're not OK if the bit in the calculated expected region 1444 // We're not OK if the bit in the calculated expected region
1447 // bitmap is set and the bit in the actual region bitmap is not. 1445 // bitmap is set and the bit in the actual region bitmap is not.
1448 BitMap::idx_t index = (BitMap::idx_t)hr->hrs_index(); 1446 BitMap::idx_t index = (BitMap::idx_t) hr->hrs_index();
1449 1447
1450 bool expected = _exp_region_bm->at(index); 1448 bool expected = _exp_region_bm->at(index);
1451 bool actual = _region_bm->at(index); 1449 bool actual = _region_bm->at(index);
1452 if (expected && !actual) { 1450 if (expected && !actual) {
1453 if (_verbose) { 1451 if (_verbose) {
1454 gclog_or_tty->print_cr("Region " SIZE_FORMAT ": region bitmap mismatch: " 1452 gclog_or_tty->print_cr("Region %u: region bitmap mismatch: "
1455 "expected: %d, actual: %d", 1453 "expected: %s, actual: %s",
1456 hr->hrs_index(), expected, actual); 1454 hr->hrs_index(),
1455 BOOL_TO_STR(expected), BOOL_TO_STR(actual));
1457 } 1456 }
1458 failures += 1; 1457 failures += 1;
1459 } 1458 }
1460 1459
1461 // Verify that the card bit maps for the cards spanned by the current 1460 // Verify that the card bit maps for the cards spanned by the current
1469 expected = _exp_card_bm->at(i); 1468 expected = _exp_card_bm->at(i);
1470 actual = _card_bm->at(i); 1469 actual = _card_bm->at(i);
1471 1470
1472 if (expected && !actual) { 1471 if (expected && !actual) {
1473 if (_verbose) { 1472 if (_verbose) {
1474 gclog_or_tty->print_cr("Region " SIZE_FORMAT ": card bitmap mismatch at " SIZE_FORMAT ": " 1473 gclog_or_tty->print_cr("Region %u: card bitmap mismatch at " SIZE_FORMAT ": "
1475 "expected: %d, actual: %d", 1474 "expected: %s, actual: %s",
1476 hr->hrs_index(), i, expected, actual); 1475 hr->hrs_index(), i,
1476 BOOL_TO_STR(expected), BOOL_TO_STR(actual));
1477 } 1477 }
1478 failures += 1; 1478 failures += 1;
1479 } 1479 }
1480 } 1480 }
1481 1481
1601 // to 1 the bits on the region bitmap that correspond to its 1601 // to 1 the bits on the region bitmap that correspond to its
1602 // associated "continues humongous" regions. 1602 // associated "continues humongous" regions.
1603 void set_bit_for_region(HeapRegion* hr) { 1603 void set_bit_for_region(HeapRegion* hr) {
1604 assert(!hr->continuesHumongous(), "should have filtered those out"); 1604 assert(!hr->continuesHumongous(), "should have filtered those out");
1605 1605
1606 size_t index = hr->hrs_index(); 1606 BitMap::idx_t index = (BitMap::idx_t) hr->hrs_index();
1607 if (!hr->startsHumongous()) { 1607 if (!hr->startsHumongous()) {
1608 // Normal (non-humongous) case: just set the bit. 1608 // Normal (non-humongous) case: just set the bit.
1609 _region_bm->par_set_bit((BitMap::idx_t) index); 1609 _region_bm->par_set_bit(index);
1610 } else { 1610 } else {
1611 // Starts humongous case: calculate how many regions are part of 1611 // Starts humongous case: calculate how many regions are part of
1612 // this humongous region and then set the bit range. 1612 // this humongous region and then set the bit range.
1613 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 1613 G1CollectedHeap* g1h = G1CollectedHeap::heap();
1614 HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1); 1614 HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1);
1615 size_t end_index = last_hr->hrs_index() + 1; 1615 BitMap::idx_t end_index = (BitMap::idx_t) last_hr->hrs_index() + 1;
1616 _region_bm->par_at_put_range((BitMap::idx_t) index, 1616 _region_bm->par_at_put_range(index, end_index, true);
1617 (BitMap::idx_t) end_index, true);
1618 } 1617 }
1619 } 1618 }
1620 1619
1621 public: 1620 public:
1622 FinalCountDataUpdateClosure(ConcurrentMark* cm, 1621 FinalCountDataUpdateClosure(ConcurrentMark* cm,
1716 _n_workers = _g1h->workers()->active_workers(); 1715 _n_workers = _g1h->workers()->active_workers();
1717 } else { 1716 } else {
1718 _n_workers = 1; 1717 _n_workers = 1;
1719 } 1718 }
1720 1719
1721 _live_bytes = NEW_C_HEAP_ARRAY(size_t, _n_workers); 1720 _live_bytes = NEW_C_HEAP_ARRAY(size_t, (size_t) _n_workers);
1722 _used_bytes = NEW_C_HEAP_ARRAY(size_t, _n_workers); 1721 _used_bytes = NEW_C_HEAP_ARRAY(size_t, (size_t) _n_workers);
1723 } 1722 }
1724 1723
1725 ~G1ParFinalCountTask() { 1724 ~G1ParFinalCountTask() {
1726 FREE_C_HEAP_ARRAY(size_t, _live_bytes); 1725 FREE_C_HEAP_ARRAY(size_t, _live_bytes);
1727 FREE_C_HEAP_ARRAY(size_t, _used_bytes); 1726 FREE_C_HEAP_ARRAY(size_t, _used_bytes);
1766 1765
1767 class G1NoteEndOfConcMarkClosure : public HeapRegionClosure { 1766 class G1NoteEndOfConcMarkClosure : public HeapRegionClosure {
1768 G1CollectedHeap* _g1; 1767 G1CollectedHeap* _g1;
1769 int _worker_num; 1768 int _worker_num;
1770 size_t _max_live_bytes; 1769 size_t _max_live_bytes;
1771 size_t _regions_claimed; 1770 uint _regions_claimed;
1772 size_t _freed_bytes; 1771 size_t _freed_bytes;
1773 FreeRegionList* _local_cleanup_list; 1772 FreeRegionList* _local_cleanup_list;
1774 OldRegionSet* _old_proxy_set; 1773 OldRegionSet* _old_proxy_set;
1775 HumongousRegionSet* _humongous_proxy_set; 1774 HumongousRegionSet* _humongous_proxy_set;
1776 HRRSCleanupTask* _hrrs_cleanup_task; 1775 HRRSCleanupTask* _hrrs_cleanup_task;
1819 } 1818 }
1820 return false; 1819 return false;
1821 } 1820 }
1822 1821
1823 size_t max_live_bytes() { return _max_live_bytes; } 1822 size_t max_live_bytes() { return _max_live_bytes; }
1824 size_t regions_claimed() { return _regions_claimed; } 1823 uint regions_claimed() { return _regions_claimed; }
1825 double claimed_region_time_sec() { return _claimed_region_time; } 1824 double claimed_region_time_sec() { return _claimed_region_time; }
1826 double max_region_time_sec() { return _max_region_time; } 1825 double max_region_time_sec() { return _max_region_time; }
1827 }; 1826 };
1828 1827
1829 class G1ParNoteEndTask: public AbstractGangTask { 1828 class G1ParNoteEndTask: public AbstractGangTask {
2144 _cleanup_list.verify_optional(); 2143 _cleanup_list.verify_optional();
2145 FreeRegionList tmp_free_list("Tmp Free List"); 2144 FreeRegionList tmp_free_list("Tmp Free List");
2146 2145
2147 if (G1ConcRegionFreeingVerbose) { 2146 if (G1ConcRegionFreeingVerbose) {
2148 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : " 2147 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
2149 "cleanup list has "SIZE_FORMAT" entries", 2148 "cleanup list has %u entries",
2150 _cleanup_list.length()); 2149 _cleanup_list.length());
2151 } 2150 }
2152 2151
2153 // Noone else should be accessing the _cleanup_list at this point, 2152 // Noone else should be accessing the _cleanup_list at this point,
2154 // so it's not necessary to take any locks 2153 // so it's not necessary to take any locks
2166 // region from the _cleanup_list). 2165 // region from the _cleanup_list).
2167 if ((tmp_free_list.length() % G1SecondaryFreeListAppendLength == 0) || 2166 if ((tmp_free_list.length() % G1SecondaryFreeListAppendLength == 0) ||
2168 _cleanup_list.is_empty()) { 2167 _cleanup_list.is_empty()) {
2169 if (G1ConcRegionFreeingVerbose) { 2168 if (G1ConcRegionFreeingVerbose) {
2170 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : " 2169 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
2171 "appending "SIZE_FORMAT" entries to the " 2170 "appending %u entries to the secondary_free_list, "
2172 "secondary_free_list, clean list still has " 2171 "cleanup list still has %u entries",
2173 SIZE_FORMAT" entries",
2174 tmp_free_list.length(), 2172 tmp_free_list.length(),
2175 _cleanup_list.length()); 2173 _cleanup_list.length());
2176 } 2174 }
2177 2175
2178 { 2176 {
3138 } 3136 }
3139 3137
3140 assert(limit_idx <= end_idx, "or else use atomics"); 3138 assert(limit_idx <= end_idx, "or else use atomics");
3141 3139
3142 // Aggregate the "stripe" in the count data associated with hr. 3140 // Aggregate the "stripe" in the count data associated with hr.
3143 size_t hrs_index = hr->hrs_index(); 3141 uint hrs_index = hr->hrs_index();
3144 size_t marked_bytes = 0; 3142 size_t marked_bytes = 0;
3145 3143
3146 for (int i = 0; (size_t)i < _max_task_num; i += 1) { 3144 for (int i = 0; (size_t)i < _max_task_num; i += 1) {
3147 size_t* marked_bytes_array = _cm->count_marked_bytes_array_for(i); 3145 size_t* marked_bytes_array = _cm->count_marked_bytes_array_for(i);
3148 BitMap* task_card_bm = _cm->count_card_bitmap_for(i); 3146 BitMap* task_card_bm = _cm->count_card_bitmap_for(i);
3246 3244
3247 // Clear the global region bitmap - it will be filled as part 3245 // Clear the global region bitmap - it will be filled as part
3248 // of the final counting task. 3246 // of the final counting task.
3249 _region_bm.clear(); 3247 _region_bm.clear();
3250 3248
3251 size_t max_regions = _g1h->max_regions(); 3249 uint max_regions = _g1h->max_regions();
3252 assert(_max_task_num != 0, "unitialized"); 3250 assert(_max_task_num != 0, "unitialized");
3253 3251
3254 for (int i = 0; (size_t) i < _max_task_num; i += 1) { 3252 for (int i = 0; (size_t) i < _max_task_num; i += 1) {
3255 BitMap* task_card_bm = count_card_bitmap_for(i); 3253 BitMap* task_card_bm = count_card_bitmap_for(i);
3256 size_t* marked_bytes_array = count_marked_bytes_array_for(i); 3254 size_t* marked_bytes_array = count_marked_bytes_array_for(i);
3257 3255
3258 assert(task_card_bm->size() == _card_bm.size(), "size mismatch"); 3256 assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
3259 assert(marked_bytes_array != NULL, "uninitialized"); 3257 assert(marked_bytes_array != NULL, "uninitialized");
3260 3258
3261 memset(marked_bytes_array, 0, (max_regions * sizeof(size_t))); 3259 memset(marked_bytes_array, 0, (size_t) max_regions * sizeof(size_t));
3262 task_card_bm->clear(); 3260 task_card_bm->clear();
3263 } 3261 }
3264 } 3262 }
3265 3263
3266 void ConcurrentMark::print_stats() { 3264 void ConcurrentMark::print_stats() {