hotspot/src/share/vm/memory/space.cpp
// We get called with "mr" representing the dirty region
// that we want to process. Because of imprecise marking,
// we may need to extend the incoming "mr" to the right,
// and scan more. However, because we may already have
// scanned some of that extended region, we may need to
// trim its right-end back some so we do not scan what
// we (or another worker thread) may already have scanned
// or planning to scan.
void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) {
{- -------------------------------------------
(1)
---------------------------------------- -}
// Some collectors need to do special things whenever their dirty
// cards are processed. For instance, CMS must remember mutator updates
// (i.e. dirty cards) so as to re-scan mutated objects.
// Such work can be piggy-backed here on dirty card scanning, so as to make
// it slightly more efficient than doing a complete non-detructive pre-scan
// of the card table.
MemRegionClosure* pCl = _sp->preconsumptionDirtyCardClosure();
if (pCl != NULL) {
pCl->do_MemRegion(mr);
}
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
HeapWord* bottom = mr.start();
HeapWord* last = mr.last();
HeapWord* top = mr.end();
HeapWord* bottom_obj;
HeapWord* top_obj;
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(_precision == CardTableModRefBS::ObjHeadPreciseArray ||
_precision == CardTableModRefBS::Precise,
"Only ones we deal with for now.");
assert(_precision != CardTableModRefBS::ObjHeadPreciseArray ||
_cl->idempotent() || _last_bottom == NULL ||
top <= _last_bottom,
"Not decreasing");
NOT_PRODUCT(_last_bottom = mr.start());
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
bottom_obj = _sp->block_start(bottom);
top_obj = _sp->block_start(last);
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(bottom_obj <= bottom, "just checking");
assert(top_obj <= top, "just checking");
{- -------------------------------------------
(1) DirtyCardToOopClosure::get_actual_top(あるいはそれをサブクラスがオーバーライドしたもの)を呼んで,
top 変数の値を微調整しておく.
---------------------------------------- -}
// Given what we think is the top of the memory region and
// the start of the object at the top, get the actual
// value of the top.
top = get_actual_top(top, top_obj);
// If the previous call did some part of this region, don't redo.
if (_precision == CardTableModRefBS::ObjHeadPreciseArray &&
_min_done != NULL &&
_min_done < top) {
top = _min_done;
}
{- -------------------------------------------
(1) (変数宣言など)
(extended_mr が実際の処理範囲を示す)
---------------------------------------- -}
// Top may have been reset, and in fact may be below bottom,
// e.g. the dirty card region is entirely in a now free object
// -- something that could happen with a concurrent sweeper.
bottom = MIN2(bottom, top);
MemRegion extended_mr = MemRegion(bottom, top);
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(bottom <= top &&
(_precision != CardTableModRefBS::ObjHeadPreciseArray ||
_min_done == NULL ||
top <= _min_done),
"overlap!");
{- -------------------------------------------
(1) DirtyCardToOopClosure::walk_mem_region() を呼んで,
処理範囲内のポインタフィールドに対して
コンストラクタ引数で指定された OopClosure を適用する.
(ただし, 処理範囲(extended_mr)が空の場合には,
特にすることはないので, 何もしない).
---------------------------------------- -}
// Walk the region if it is not empty; otherwise there is nothing to do.
if (!extended_mr.is_empty()) {
walk_mem_region(extended_mr, bottom_obj, top);
}
{- -------------------------------------------
(1)
---------------------------------------- -}
// An idempotent closure might be applied in any order, so we don't
// record a _min_done for it.
if (!_cl->idempotent()) {
_min_done = bottom;
} else {
assert(_min_done == _last_explicit_min_done,
"Don't update _min_done for idempotent cl");
}
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.