hotspot/src/share/vm/memory/referenceProcessor.cpp
// Traverse the list and remove any Refs that are not active, or
// whose referents are either alive or NULL.
void
ReferenceProcessor::pp2_work(DiscoveredList& refs_list,
BoolObjectClosure* is_alive,
OopClosure* keep_alive) {
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(discovery_is_atomic(), "Error");
{- -------------------------------------------
(1) (以下の while 文の中で, (DiscoveredListIterator を使って)
引数で渡された DiscoveredList を最初から最後まで辿って処理を行う)
---------------------------------------- -}
DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
while (iter.has_next()) {
{- -------------------------------------------
(1) もし, 参照オブジェクトの差し先が生きていれば,
その参照オブジェクトはリストから除外する.
(ついでに, DiscoveredListIterator::make_referent_alive() で
(必要に応じて) 差し先へのポインタの修正処理を行っておく)
(ついでに, 除外処理を行う際には(トレース出力)も出している)
---------------------------------------- -}
iter.load_ptrs(DEBUG_ONLY(false /* allow_null_referent */));
DEBUG_ONLY(oop next = java_lang_ref_Reference::next(iter.obj());)
assert(next == NULL, "Should not discover inactive Reference");
if (iter.is_referent_alive()) {
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Dropping strongly reachable reference (" INTPTR_FORMAT ": %s)",
iter.obj(), iter.obj()->blueprint()->internal_name());
}
// The referent is reachable after all.
// Remove Reference object from list.
iter.remove();
// Update the referent pointer as necessary: Note that this
// should not entail any recursive marking because the
// referent must already have been traversed.
iter.make_referent_alive();
iter.move_to_next();
} else {
iter.next();
}
}
{- -------------------------------------------
(1) (トレース出力)
---------------------------------------- -}
NOT_PRODUCT(
if (PrintGCDetails && TraceReferenceGC && (iter.processed() > 0)) {
gclog_or_tty->print_cr(" Dropped %d active Refs out of %d "
"Refs in discovered list " INTPTR_FORMAT,
iter.removed(), iter.processed(), (address)refs_list.head());
}
)
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.