894 // The [par_]mark_range() method expects mr.end() below to |
894 // The [par_]mark_range() method expects mr.end() below to |
895 // be aligned to the granularity of a bit's representation |
895 // be aligned to the granularity of a bit's representation |
896 // in the heap. In the case of the MUT below, that's a |
896 // in the heap. In the case of the MUT below, that's a |
897 // card size. |
897 // card size. |
898 MemRegion mr(start, |
898 MemRegion mr(start, |
899 (HeapWord*)round_to((intptr_t)(start + obj_size), |
899 align_up(start + obj_size, |
900 CardTableModRefBS::card_size /* bytes */)); |
900 CardTableModRefBS::card_size /* bytes */)); |
901 if (par) { |
901 if (par) { |
902 _modUnionTable.par_mark_range(mr); |
902 _modUnionTable.par_mark_range(mr); |
903 } else { |
903 } else { |
904 _modUnionTable.mark_range(mr); |
904 _modUnionTable.mark_range(mr); |
4574 assert(pst->valid(), "Uninitialized use?"); |
4574 assert(pst->valid(), "Uninitialized use?"); |
4575 uint nth_task = 0; |
4575 uint nth_task = 0; |
4576 const int alignment = CardTableModRefBS::card_size * BitsPerWord; |
4576 const int alignment = CardTableModRefBS::card_size * BitsPerWord; |
4577 MemRegion span = sp->used_region(); |
4577 MemRegion span = sp->used_region(); |
4578 HeapWord* start_addr = span.start(); |
4578 HeapWord* start_addr = span.start(); |
4579 HeapWord* end_addr = (HeapWord*)round_to((intptr_t)span.end(), |
4579 HeapWord* end_addr = align_up(span.end(), alignment); |
4580 alignment); |
|
4581 const size_t chunk_size = sp->rescan_task_size(); // in HeapWord units |
4580 const size_t chunk_size = sp->rescan_task_size(); // in HeapWord units |
4582 assert((HeapWord*)round_to((intptr_t)start_addr, alignment) == |
4581 assert(is_aligned(start_addr, alignment), "Check alignment"); |
4583 start_addr, "Check alignment"); |
4582 assert(is_aligned(chunk_size, alignment), "Check alignment"); |
4584 assert((size_t)round_to((intptr_t)chunk_size, alignment) == |
|
4585 chunk_size, "Check alignment"); |
|
4586 |
4583 |
4587 while (!pst->is_task_claimed(/* reference */ nth_task)) { |
4584 while (!pst->is_task_claimed(/* reference */ nth_task)) { |
4588 // Having claimed the nth_task, compute corresponding mem-region, |
4585 // Having claimed the nth_task, compute corresponding mem-region, |
4589 // which is a-fortiori aligned correctly (i.e. at a MUT boundary). |
4586 // which is a-fortiori aligned correctly (i.e. at a MUT boundary). |
4590 // The alignment restriction ensures that we do not need any |
4587 // The alignment restriction ensures that we do not need any |
4926 { |
4923 { |
4927 // ... First handle dirty cards in CMS gen |
4924 // ... First handle dirty cards in CMS gen |
4928 markFromDirtyCardsClosure.set_space(_cmsGen->cmsSpace()); |
4925 markFromDirtyCardsClosure.set_space(_cmsGen->cmsSpace()); |
4929 MemRegion ur = _cmsGen->used_region(); |
4926 MemRegion ur = _cmsGen->used_region(); |
4930 HeapWord* lb = ur.start(); |
4927 HeapWord* lb = ur.start(); |
4931 HeapWord* ub = (HeapWord*)round_to((intptr_t)ur.end(), alignment); |
4928 HeapWord* ub = align_up(ur.end(), alignment); |
4932 MemRegion cms_span(lb, ub); |
4929 MemRegion cms_span(lb, ub); |
4933 _modUnionTable.dirty_range_iterate_clear(cms_span, |
4930 _modUnionTable.dirty_range_iterate_clear(cms_span, |
4934 &markFromDirtyCardsClosure); |
4931 &markFromDirtyCardsClosure); |
4935 verify_work_stacks_empty(); |
4932 verify_work_stacks_empty(); |
4936 log_trace(gc)(" (re-scanned " SIZE_FORMAT " dirty cards in cms gen) ", markFromDirtyCardsClosure.num_dirty_cards()); |
4933 log_trace(gc)(" (re-scanned " SIZE_FORMAT " dirty cards in cms gen) ", markFromDirtyCardsClosure.num_dirty_cards()); |
5623 } else { |
5620 } else { |
5624 sz = block_size_using_printezis_bits(addr); |
5621 sz = block_size_using_printezis_bits(addr); |
5625 } |
5622 } |
5626 assert(sz > 0, "size must be nonzero"); |
5623 assert(sz > 0, "size must be nonzero"); |
5627 HeapWord* next_block = addr + sz; |
5624 HeapWord* next_block = addr + sz; |
5628 HeapWord* next_card = (HeapWord*)round_to((uintptr_t)next_block, |
5625 HeapWord* next_card = align_up(next_block, CardTableModRefBS::card_size); |
5629 CardTableModRefBS::card_size); |
5626 assert(align_down((uintptr_t)addr, CardTableModRefBS::card_size) < |
5630 assert(round_down((uintptr_t)addr, CardTableModRefBS::card_size) < |
5627 align_down((uintptr_t)next_card, CardTableModRefBS::card_size), |
5631 round_down((uintptr_t)next_card, CardTableModRefBS::card_size), |
|
5632 "must be different cards"); |
5628 "must be different cards"); |
5633 return next_card; |
5629 return next_card; |
5634 } |
5630 } |
5635 |
5631 |
5636 |
5632 |
5730 assert(!mr.is_empty(), "unexpected empty region"); |
5726 assert(!mr.is_empty(), "unexpected empty region"); |
5731 assert(covers(mr), "mr should be covered by bit map"); |
5727 assert(covers(mr), "mr should be covered by bit map"); |
5732 // convert address range into offset range |
5728 // convert address range into offset range |
5733 size_t start_ofs = heapWordToOffset(mr.start()); |
5729 size_t start_ofs = heapWordToOffset(mr.start()); |
5734 // Make sure that end() is appropriately aligned |
5730 // Make sure that end() is appropriately aligned |
5735 assert(mr.end() == (HeapWord*)round_to((intptr_t)mr.end(), |
5731 assert(mr.end() == align_up(mr.end(), (1 << (_shifter+LogHeapWordSize))), |
5736 (1 << (_shifter+LogHeapWordSize))), |
|
5737 "Misaligned mr.end()"); |
5732 "Misaligned mr.end()"); |
5738 size_t end_ofs = heapWordToOffset(mr.end()); |
5733 size_t end_ofs = heapWordToOffset(mr.end()); |
5739 assert(end_ofs > start_ofs, "Should mark at least one bit"); |
5734 assert(end_ofs > start_ofs, "Should mark at least one bit"); |
5740 } |
5735 } |
5741 |
5736 |
6285 |
6280 |
6286 void MarkFromRootsClosure::reset(HeapWord* addr) { |
6281 void MarkFromRootsClosure::reset(HeapWord* addr) { |
6287 assert(_markStack->isEmpty(), "would cause duplicates on stack"); |
6282 assert(_markStack->isEmpty(), "would cause duplicates on stack"); |
6288 assert(_span.contains(addr), "Out of bounds _finger?"); |
6283 assert(_span.contains(addr), "Out of bounds _finger?"); |
6289 _finger = addr; |
6284 _finger = addr; |
6290 _threshold = (HeapWord*)round_to( |
6285 _threshold = align_up(_finger, CardTableModRefBS::card_size); |
6291 (intptr_t)_finger, CardTableModRefBS::card_size); |
|
6292 } |
6286 } |
6293 |
6287 |
6294 // Should revisit to see if this should be restructured for |
6288 // Should revisit to see if this should be restructured for |
6295 // greater efficiency. |
6289 // greater efficiency. |
6296 bool MarkFromRootsClosure::do_bit(size_t offset) { |
6290 bool MarkFromRootsClosure::do_bit(size_t offset) { |
6313 // We re-dirty the cards on which this object lies and increase |
6307 // We re-dirty the cards on which this object lies and increase |
6314 // the _threshold so that we'll come back to scan this object |
6308 // the _threshold so that we'll come back to scan this object |
6315 // during the preclean or remark phase. (CMSCleanOnEnter) |
6309 // during the preclean or remark phase. (CMSCleanOnEnter) |
6316 if (CMSCleanOnEnter) { |
6310 if (CMSCleanOnEnter) { |
6317 size_t sz = _collector->block_size_using_printezis_bits(addr); |
6311 size_t sz = _collector->block_size_using_printezis_bits(addr); |
6318 HeapWord* end_card_addr = (HeapWord*)round_to( |
6312 HeapWord* end_card_addr = align_up(addr + sz, CardTableModRefBS::card_size); |
6319 (intptr_t)(addr+sz), CardTableModRefBS::card_size); |
|
6320 MemRegion redirty_range = MemRegion(addr, end_card_addr); |
6313 MemRegion redirty_range = MemRegion(addr, end_card_addr); |
6321 assert(!redirty_range.is_empty(), "Arithmetical tautology"); |
6314 assert(!redirty_range.is_empty(), "Arithmetical tautology"); |
6322 // Bump _threshold to end_card_addr; note that |
6315 // Bump _threshold to end_card_addr; note that |
6323 // _threshold cannot possibly exceed end_card_addr, anyhow. |
6316 // _threshold cannot possibly exceed end_card_addr, anyhow. |
6324 // This prevents future clearing of the card as the scan proceeds |
6317 // This prevents future clearing of the card as the scan proceeds |
6401 // The set of cards to be cleared is all those that overlap |
6394 // The set of cards to be cleared is all those that overlap |
6402 // with the interval [_threshold, _finger); note that |
6395 // with the interval [_threshold, _finger); note that |
6403 // _threshold is always kept card-aligned but _finger isn't |
6396 // _threshold is always kept card-aligned but _finger isn't |
6404 // always card-aligned. |
6397 // always card-aligned. |
6405 HeapWord* old_threshold = _threshold; |
6398 HeapWord* old_threshold = _threshold; |
6406 assert(old_threshold == (HeapWord*)round_to( |
6399 assert(is_aligned(old_threshold, CardTableModRefBS::card_size), |
6407 (intptr_t)old_threshold, CardTableModRefBS::card_size), |
|
6408 "_threshold should always be card-aligned"); |
6400 "_threshold should always be card-aligned"); |
6409 _threshold = (HeapWord*)round_to( |
6401 _threshold = align_up(_finger, CardTableModRefBS::card_size); |
6410 (intptr_t)_finger, CardTableModRefBS::card_size); |
|
6411 MemRegion mr(old_threshold, _threshold); |
6402 MemRegion mr(old_threshold, _threshold); |
6412 assert(!mr.is_empty(), "Control point invariant"); |
6403 assert(!mr.is_empty(), "Control point invariant"); |
6413 assert(_span.contains(mr), "Should clear within span"); |
6404 assert(_span.contains(mr), "Should clear within span"); |
6414 _mut->clear_range(mr); |
6405 _mut->clear_range(mr); |
6415 } |
6406 } |
6515 // The set of cards to be cleared is all those that overlap |
6506 // The set of cards to be cleared is all those that overlap |
6516 // with the interval [_threshold, _finger); note that |
6507 // with the interval [_threshold, _finger); note that |
6517 // _threshold is always kept card-aligned but _finger isn't |
6508 // _threshold is always kept card-aligned but _finger isn't |
6518 // always card-aligned. |
6509 // always card-aligned. |
6519 HeapWord* old_threshold = _threshold; |
6510 HeapWord* old_threshold = _threshold; |
6520 assert(old_threshold == (HeapWord*)round_to( |
6511 assert(is_aligned(old_threshold, CardTableModRefBS::card_size), |
6521 (intptr_t)old_threshold, CardTableModRefBS::card_size), |
|
6522 "_threshold should always be card-aligned"); |
6512 "_threshold should always be card-aligned"); |
6523 _threshold = (HeapWord*)round_to( |
6513 _threshold = align_up(_finger, CardTableModRefBS::card_size); |
6524 (intptr_t)_finger, CardTableModRefBS::card_size); |
|
6525 MemRegion mr(old_threshold, _threshold); |
6514 MemRegion mr(old_threshold, _threshold); |
6526 assert(!mr.is_empty(), "Control point invariant"); |
6515 assert(!mr.is_empty(), "Control point invariant"); |
6527 assert(_span.contains(mr), "Should clear within span"); // _whole_span ?? |
6516 assert(_span.contains(mr), "Should clear within span"); // _whole_span ?? |
6528 _mut->clear_range(mr); |
6517 _mut->clear_range(mr); |
6529 } |
6518 } |
6886 // Note that no one can be interfering with us in this action |
6875 // Note that no one can be interfering with us in this action |
6887 // of dirtying the mod union table, so no locking or atomics |
6876 // of dirtying the mod union table, so no locking or atomics |
6888 // are required. |
6877 // are required. |
6889 if (obj->is_objArray()) { |
6878 if (obj->is_objArray()) { |
6890 size_t sz = obj->size(); |
6879 size_t sz = obj->size(); |
6891 HeapWord* end_card_addr = (HeapWord*)round_to( |
6880 HeapWord* end_card_addr = align_up(addr + sz, CardTableModRefBS::card_size); |
6892 (intptr_t)(addr+sz), CardTableModRefBS::card_size); |
|
6893 MemRegion redirty_range = MemRegion(addr, end_card_addr); |
6881 MemRegion redirty_range = MemRegion(addr, end_card_addr); |
6894 assert(!redirty_range.is_empty(), "Arithmetical tautology"); |
6882 assert(!redirty_range.is_empty(), "Arithmetical tautology"); |
6895 _mod_union_table->mark_range(redirty_range); |
6883 _mod_union_table->mark_range(redirty_range); |
6896 } else { |
6884 } else { |
6897 _mod_union_table->mark(addr); |
6885 _mod_union_table->mark(addr); |
7616 // the cards that the object spans. No locking or atomics |
7604 // the cards that the object spans. No locking or atomics |
7617 // are needed since no one else can be mutating the mod union |
7605 // are needed since no one else can be mutating the mod union |
7618 // table. |
7606 // table. |
7619 if (obj->is_objArray()) { |
7607 if (obj->is_objArray()) { |
7620 size_t sz = obj->size(); |
7608 size_t sz = obj->size(); |
7621 HeapWord* end_card_addr = |
7609 HeapWord* end_card_addr = align_up(addr + sz, CardTableModRefBS::card_size); |
7622 (HeapWord*)round_to((intptr_t)(addr+sz), CardTableModRefBS::card_size); |
|
7623 MemRegion redirty_range = MemRegion(addr, end_card_addr); |
7610 MemRegion redirty_range = MemRegion(addr, end_card_addr); |
7624 assert(!redirty_range.is_empty(), "Arithmetical tautology"); |
7611 assert(!redirty_range.is_empty(), "Arithmetical tautology"); |
7625 _collector->_modUnionTable.mark_range(redirty_range); |
7612 _collector->_modUnionTable.mark_range(redirty_range); |
7626 } else { |
7613 } else { |
7627 _collector->_modUnionTable.mark(addr); |
7614 _collector->_modUnionTable.mark(addr); |