< prev index next >
src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
Print this page
rev 12906 : [mq]: gc_interface
*** 443,453 ****
_conc_workers(NULL), // may be set later
_abort_preclean(false),
_start_sampling(false),
_between_prologue_and_epilogue(false),
_markBitMap(0, Mutex::leaf + 1, "CMS_markBitMap_lock"),
! _modUnionTable((CardTableModRefBS::card_shift - LogHeapWordSize),
-1 /* lock-free */, "No_lock" /* dummy */),
_modUnionClosurePar(&_modUnionTable),
// Adjust my span to cover old (cms) gen
_span(cmsGen->reserved()),
// Construct the is_alive_closure with _span & markBitMap
--- 443,453 ----
_conc_workers(NULL), // may be set later
_abort_preclean(false),
_start_sampling(false),
_between_prologue_and_epilogue(false),
_markBitMap(0, Mutex::leaf + 1, "CMS_markBitMap_lock"),
! _modUnionTable((CardTable::card_shift - LogHeapWordSize),
-1 /* lock-free */, "No_lock" /* dummy */),
_modUnionClosurePar(&_modUnionTable),
// Adjust my span to cover old (cms) gen
_span(cmsGen->reserved()),
// Construct the is_alive_closure with _span & markBitMap
*** 895,905 ****
// be aligned to the granularity of a bit's representation
// in the heap. In the case of the MUT below, that's a
// card size.
MemRegion mr(start,
(HeapWord*)round_to((intptr_t)(start + obj_size),
! CardTableModRefBS::card_size /* bytes */));
if (par) {
_modUnionTable.par_mark_range(mr);
} else {
_modUnionTable.mark_range(mr);
}
--- 895,905 ----
// be aligned to the granularity of a bit's representation
// in the heap. In the case of the MUT below, that's a
// card size.
MemRegion mr(start,
(HeapWord*)round_to((intptr_t)(start + obj_size),
! CardTable::card_size /* bytes */));
if (par) {
_modUnionTable.par_mark_range(mr);
} else {
_modUnionTable.mark_range(mr);
}
*** 3219,3229 ****
if (sp->used_region().contains(_restart_addr)) {
// Align down to a card boundary for the start of 0th task
// for this space.
aligned_start =
(HeapWord*)align_size_down((uintptr_t)_restart_addr,
! CardTableModRefBS::card_size);
}
size_t chunk_size = sp->marking_task_size();
while (!pst->is_task_claimed(/* reference */ nth_task)) {
// Having claimed the nth task in this space,
--- 3219,3229 ----
if (sp->used_region().contains(_restart_addr)) {
// Align down to a card boundary for the start of 0th task
// for this space.
aligned_start =
(HeapWord*)align_size_down((uintptr_t)_restart_addr,
! CardTable::card_size);
}
size_t chunk_size = sp->marking_task_size();
while (!pst->is_task_claimed(/* reference */ nth_task)) {
// Having claimed the nth task in this space,
*** 4022,4042 ****
stopTimer();
CMSTokenSync x(true); // is cms thread
startTimer();
sample_eden();
// Get and clear dirty region from card table
! dirtyRegion = _ct->ct_bs()->dirty_card_range_after_reset(
! MemRegion(nextAddr, endAddr),
true,
! CardTableModRefBS::precleaned_card_val());
assert(dirtyRegion.start() >= nextAddr,
"returned region inconsistent?");
}
lastAddr = dirtyRegion.end();
numDirtyCards =
! dirtyRegion.word_size()/CardTableModRefBS::card_size_in_words;
if (!dirtyRegion.is_empty()) {
stopTimer();
CMSTokenSyncWithLocks ts(true, old_gen->freelistLock(), bitMapLock());
startTimer();
--- 4022,4041 ----
stopTimer();
CMSTokenSync x(true); // is cms thread
startTimer();
sample_eden();
// Get and clear dirty region from card table
! dirtyRegion = _ct->dirty_card_range_after_reset(MemRegion(nextAddr, endAddr),
true,
! CardTable::precleaned_card_val());
assert(dirtyRegion.start() >= nextAddr,
"returned region inconsistent?");
}
lastAddr = dirtyRegion.end();
numDirtyCards =
! dirtyRegion.word_size()/CardTable::card_size_in_words;
if (!dirtyRegion.is_empty()) {
stopTimer();
CMSTokenSyncWithLocks ts(true, old_gen->freelistLock(), bitMapLock());
startTimer();
*** 4046,4056 ****
HeapWord* stop_point =
old_gen->cmsSpace()->object_iterate_careful_m(dirtyRegion, cl);
if (stop_point != NULL) {
assert((_collectorState == AbortablePreclean && should_abort_preclean()),
"Should only be AbortablePreclean.");
! _ct->ct_bs()->invalidate(MemRegion(stop_point, dirtyRegion.end()));
if (should_abort_preclean()) {
break; // out of preclean loop
} else {
// Compute the next address at which preclean should pick up.
lastAddr = next_card_start_after_block(stop_point);
--- 4045,4055 ----
HeapWord* stop_point =
old_gen->cmsSpace()->object_iterate_careful_m(dirtyRegion, cl);
if (stop_point != NULL) {
assert((_collectorState == AbortablePreclean && should_abort_preclean()),
"Should only be AbortablePreclean.");
! _ct->invalidate(MemRegion(stop_point, dirtyRegion.end()));
if (should_abort_preclean()) {
break; // out of preclean loop
} else {
// Compute the next address at which preclean should pick up.
lastAddr = next_card_start_after_block(stop_point);
*** 4573,4583 ****
sp, bm, work_q, cl);
SequentialSubTasksDone* pst = sp->conc_par_seq_tasks();
assert(pst->valid(), "Uninitialized use?");
uint nth_task = 0;
! const int alignment = CardTableModRefBS::card_size * BitsPerWord;
MemRegion span = sp->used_region();
HeapWord* start_addr = span.start();
HeapWord* end_addr = (HeapWord*)round_to((intptr_t)span.end(),
alignment);
const size_t chunk_size = sp->rescan_task_size(); // in HeapWord units
--- 4572,4582 ----
sp, bm, work_q, cl);
SequentialSubTasksDone* pst = sp->conc_par_seq_tasks();
assert(pst->valid(), "Uninitialized use?");
uint nth_task = 0;
! const int alignment = CardTable::card_size * BitsPerWord;
MemRegion span = sp->used_region();
HeapWord* start_addr = span.start();
HeapWord* end_addr = (HeapWord*)round_to((intptr_t)span.end(),
alignment);
const size_t chunk_size = sp->rescan_task_size(); // in HeapWord units
*** 4602,4612 ****
}
// Iterate over the dirty cards covering this chunk, marking them
// precleaned, and setting the corresponding bits in the mod union
// table. Since we have been careful to partition at Card and MUT-word
// boundaries no synchronization is needed between parallel threads.
! _collector->_ct->ct_bs()->dirty_card_iterate(this_span,
&modUnionClosure);
// Having transferred these marks into the modUnionTable,
// rescan the marked objects on the dirty cards in the modUnionTable.
// Even if this is at a synchronous collection, the initial marking
--- 4601,4611 ----
}
// Iterate over the dirty cards covering this chunk, marking them
// precleaned, and setting the corresponding bits in the mod union
// table. Since we have been careful to partition at Card and MUT-word
// boundaries no synchronization is needed between parallel threads.
! _collector->_ct->dirty_card_iterate(this_span,
&modUnionClosure);
// Having transferred these marks into the modUnionTable,
// rescan the marked objects on the dirty cards in the modUnionTable.
// Even if this is at a synchronous collection, the initial marking
*** 4913,4932 ****
GCTraceTime(Trace, gc, phases) t("Grey Object Rescan", _gc_timer_cm);
// Iterate over the dirty cards, setting the corresponding bits in the
// mod union table.
{
ModUnionClosure modUnionClosure(&_modUnionTable);
! _ct->ct_bs()->dirty_card_iterate(
! _cmsGen->used_region(),
&modUnionClosure);
}
// Having transferred these marks into the modUnionTable, we just need
// to rescan the marked objects on the dirty cards in the modUnionTable.
// The initial marking may have been done during an asynchronous
// collection so there may be dirty bits in the mod-union table.
! const int alignment =
! CardTableModRefBS::card_size * BitsPerWord;
{
// ... First handle dirty cards in CMS gen
markFromDirtyCardsClosure.set_space(_cmsGen->cmsSpace());
MemRegion ur = _cmsGen->used_region();
HeapWord* lb = ur.start();
--- 4912,4929 ----
GCTraceTime(Trace, gc, phases) t("Grey Object Rescan", _gc_timer_cm);
// Iterate over the dirty cards, setting the corresponding bits in the
// mod union table.
{
ModUnionClosure modUnionClosure(&_modUnionTable);
! _ct->dirty_card_iterate(_cmsGen->used_region(),
&modUnionClosure);
}
// Having transferred these marks into the modUnionTable, we just need
// to rescan the marked objects on the dirty cards in the modUnionTable.
// The initial marking may have been done during an asynchronous
// collection so there may be dirty bits in the mod-union table.
! const int alignment = CardTable::card_size * BitsPerWord;
{
// ... First handle dirty cards in CMS gen
markFromDirtyCardsClosure.set_space(_cmsGen->cmsSpace());
MemRegion ur = _cmsGen->used_region();
HeapWord* lb = ur.start();
*** 5627,5639 ****
sz = block_size_using_printezis_bits(addr);
}
assert(sz > 0, "size must be nonzero");
HeapWord* next_block = addr + sz;
HeapWord* next_card = (HeapWord*)round_to((uintptr_t)next_block,
! CardTableModRefBS::card_size);
! assert(round_down((uintptr_t)addr, CardTableModRefBS::card_size) <
! round_down((uintptr_t)next_card, CardTableModRefBS::card_size),
"must be different cards");
return next_card;
}
--- 5624,5636 ----
sz = block_size_using_printezis_bits(addr);
}
assert(sz > 0, "size must be nonzero");
HeapWord* next_block = addr + sz;
HeapWord* next_card = (HeapWord*)round_to((uintptr_t)next_block,
! CardTable::card_size);
! assert(round_down((uintptr_t)addr, CardTable::card_size) <
! round_down((uintptr_t)next_card, CardTable::card_size),
"must be different cards");
return next_card;
}
*** 6289,6299 ****
void MarkFromRootsClosure::reset(HeapWord* addr) {
assert(_markStack->isEmpty(), "would cause duplicates on stack");
assert(_span.contains(addr), "Out of bounds _finger?");
_finger = addr;
_threshold = (HeapWord*)round_to(
! (intptr_t)_finger, CardTableModRefBS::card_size);
}
// Should revisit to see if this should be restructured for
// greater efficiency.
bool MarkFromRootsClosure::do_bit(size_t offset) {
--- 6286,6296 ----
void MarkFromRootsClosure::reset(HeapWord* addr) {
assert(_markStack->isEmpty(), "would cause duplicates on stack");
assert(_span.contains(addr), "Out of bounds _finger?");
_finger = addr;
_threshold = (HeapWord*)round_to(
! (intptr_t)_finger, CardTable::card_size);
}
// Should revisit to see if this should be restructured for
// greater efficiency.
bool MarkFromRootsClosure::do_bit(size_t offset) {
*** 6317,6327 ****
// the _threshold so that we'll come back to scan this object
// during the preclean or remark phase. (CMSCleanOnEnter)
if (CMSCleanOnEnter) {
size_t sz = _collector->block_size_using_printezis_bits(addr);
HeapWord* end_card_addr = (HeapWord*)round_to(
! (intptr_t)(addr+sz), CardTableModRefBS::card_size);
MemRegion redirty_range = MemRegion(addr, end_card_addr);
assert(!redirty_range.is_empty(), "Arithmetical tautology");
// Bump _threshold to end_card_addr; note that
// _threshold cannot possibly exceed end_card_addr, anyhow.
// This prevents future clearing of the card as the scan proceeds
--- 6314,6324 ----
// the _threshold so that we'll come back to scan this object
// during the preclean or remark phase. (CMSCleanOnEnter)
if (CMSCleanOnEnter) {
size_t sz = _collector->block_size_using_printezis_bits(addr);
HeapWord* end_card_addr = (HeapWord*)round_to(
! (intptr_t)(addr+sz), CardTable::card_size);
MemRegion redirty_range = MemRegion(addr, end_card_addr);
assert(!redirty_range.is_empty(), "Arithmetical tautology");
// Bump _threshold to end_card_addr; note that
// _threshold cannot possibly exceed end_card_addr, anyhow.
// This prevents future clearing of the card as the scan proceeds
*** 6405,6418 ****
// with the interval [_threshold, _finger); note that
// _threshold is always kept card-aligned but _finger isn't
// always card-aligned.
HeapWord* old_threshold = _threshold;
assert(old_threshold == (HeapWord*)round_to(
! (intptr_t)old_threshold, CardTableModRefBS::card_size),
"_threshold should always be card-aligned");
_threshold = (HeapWord*)round_to(
! (intptr_t)_finger, CardTableModRefBS::card_size);
MemRegion mr(old_threshold, _threshold);
assert(!mr.is_empty(), "Control point invariant");
assert(_span.contains(mr), "Should clear within span");
_mut->clear_range(mr);
}
--- 6402,6415 ----
// with the interval [_threshold, _finger); note that
// _threshold is always kept card-aligned but _finger isn't
// always card-aligned.
HeapWord* old_threshold = _threshold;
assert(old_threshold == (HeapWord*)round_to(
! (intptr_t)old_threshold, CardTable::card_size),
"_threshold should always be card-aligned");
_threshold = (HeapWord*)round_to(
! (intptr_t)_finger, CardTable::card_size);
MemRegion mr(old_threshold, _threshold);
assert(!mr.is_empty(), "Control point invariant");
assert(_span.contains(mr), "Should clear within span");
_mut->clear_range(mr);
}
*** 6519,6532 ****
// with the interval [_threshold, _finger); note that
// _threshold is always kept card-aligned but _finger isn't
// always card-aligned.
HeapWord* old_threshold = _threshold;
assert(old_threshold == (HeapWord*)round_to(
! (intptr_t)old_threshold, CardTableModRefBS::card_size),
"_threshold should always be card-aligned");
_threshold = (HeapWord*)round_to(
! (intptr_t)_finger, CardTableModRefBS::card_size);
MemRegion mr(old_threshold, _threshold);
assert(!mr.is_empty(), "Control point invariant");
assert(_span.contains(mr), "Should clear within span"); // _whole_span ??
_mut->clear_range(mr);
}
--- 6516,6529 ----
// with the interval [_threshold, _finger); note that
// _threshold is always kept card-aligned but _finger isn't
// always card-aligned.
HeapWord* old_threshold = _threshold;
assert(old_threshold == (HeapWord*)round_to(
! (intptr_t)old_threshold, CardTable::card_size),
"_threshold should always be card-aligned");
_threshold = (HeapWord*)round_to(
! (intptr_t)_finger, CardTable::card_size);
MemRegion mr(old_threshold, _threshold);
assert(!mr.is_empty(), "Control point invariant");
assert(_span.contains(mr), "Should clear within span"); // _whole_span ??
_mut->clear_range(mr);
}
*** 6890,6900 ****
// of dirtying the mod union table, so no locking or atomics
// are required.
if (obj->is_objArray()) {
size_t sz = obj->size();
HeapWord* end_card_addr = (HeapWord*)round_to(
! (intptr_t)(addr+sz), CardTableModRefBS::card_size);
MemRegion redirty_range = MemRegion(addr, end_card_addr);
assert(!redirty_range.is_empty(), "Arithmetical tautology");
_mod_union_table->mark_range(redirty_range);
} else {
_mod_union_table->mark(addr);
--- 6887,6897 ----
// of dirtying the mod union table, so no locking or atomics
// are required.
if (obj->is_objArray()) {
size_t sz = obj->size();
HeapWord* end_card_addr = (HeapWord*)round_to(
! (intptr_t)(addr+sz), CardTable::card_size);
MemRegion redirty_range = MemRegion(addr, end_card_addr);
assert(!redirty_range.is_empty(), "Arithmetical tautology");
_mod_union_table->mark_range(redirty_range);
} else {
_mod_union_table->mark(addr);
*** 7003,7021 ****
}
return _collector->foregroundGCIsActive();
}
void MarkFromDirtyCardsClosure::do_MemRegion(MemRegion mr) {
! assert(((size_t)mr.start())%CardTableModRefBS::card_size_in_words == 0,
"mr should be aligned to start at a card boundary");
// We'd like to assert:
! // assert(mr.word_size()%CardTableModRefBS::card_size_in_words == 0,
// "mr should be a range of cards");
// However, that would be too strong in one case -- the last
// partition ends at _unallocated_block which, in general, can be
// an arbitrary boundary, not necessarily card aligned.
! _num_dirty_cards += mr.word_size()/CardTableModRefBS::card_size_in_words;
_space->object_iterate_mem(mr, &_scan_cl);
}
SweepClosure::SweepClosure(CMSCollector* collector,
ConcurrentMarkSweepGeneration* g,
--- 7000,7018 ----
}
return _collector->foregroundGCIsActive();
}
void MarkFromDirtyCardsClosure::do_MemRegion(MemRegion mr) {
! assert(((size_t)mr.start())%CardTable::card_size_in_words == 0,
"mr should be aligned to start at a card boundary");
// We'd like to assert:
! // assert(mr.word_size()%CardTable::card_size_in_words == 0,
// "mr should be a range of cards");
// However, that would be too strong in one case -- the last
// partition ends at _unallocated_block which, in general, can be
// an arbitrary boundary, not necessarily card aligned.
! _num_dirty_cards += mr.word_size()/CardTable::card_size_in_words;
_space->object_iterate_mem(mr, &_scan_cl);
}
SweepClosure::SweepClosure(CMSCollector* collector,
ConcurrentMarkSweepGeneration* g,
*** 7620,7630 ****
// are needed since no one else can be mutating the mod union
// table.
if (obj->is_objArray()) {
size_t sz = obj->size();
HeapWord* end_card_addr =
! (HeapWord*)round_to((intptr_t)(addr+sz), CardTableModRefBS::card_size);
MemRegion redirty_range = MemRegion(addr, end_card_addr);
assert(!redirty_range.is_empty(), "Arithmetical tautology");
_collector->_modUnionTable.mark_range(redirty_range);
} else {
_collector->_modUnionTable.mark(addr);
--- 7617,7627 ----
// are needed since no one else can be mutating the mod union
// table.
if (obj->is_objArray()) {
size_t sz = obj->size();
HeapWord* end_card_addr =
! (HeapWord*)round_to((intptr_t)(addr+sz), CardTable::card_size);
MemRegion redirty_range = MemRegion(addr, end_card_addr);
assert(!redirty_range.is_empty(), "Arithmetical tautology");
_collector->_modUnionTable.mark_range(redirty_range);
} else {
_collector->_modUnionTable.mark(addr);
< prev index next >