void RememberedSet::ClearCards() {
CardTable* card_table = GetHeap()->GetCardTable();
RememberedSetCardVisitor card_visitor(&dirty_cards_); // Clear dirty cards in the space and insert them into the dirty card set.
card_table->ModifyCardsAtomic(space_->Begin(), space_->End(), AgeCardVisitor(), card_visitor);
}
void RememberedSet::UpdateAndMarkReferences(space::ContinuousSpace* target_space,
collector::GarbageCollector* collector) {
CardTable* card_table = heap_->GetCardTable(); bool contains_reference_to_target_space = false;
RememberedSetObjectVisitor obj_visitor(target_space, &contains_reference_to_target_space,
collector);
ContinuousSpaceBitmap* bitmap = space_->GetLiveBitmap();
CardSet remove_card_set; for (uint8_t* const card_addr : dirty_cards_) {
contains_reference_to_target_space = false;
uintptr_t start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr));
DCHECK(space_->HasAddress(reinterpret_cast<mirror::Object*>(start)));
bitmap->VisitMarkedRange(start, start + CardTable::kCardSize, obj_visitor); if (!contains_reference_to_target_space) { // It was in the dirty card set, but it didn't actually contain // a reference to the target space. So, remove it from the dirty // card set so we won't have to scan it again (unless it gets // dirty again.)
remove_card_set.insert(card_addr);
}
}
// Remove the cards that didn't contain a reference to the target // space from the dirty card set. for (uint8_t* const card_addr : remove_card_set) {
DCHECK(dirty_cards_.find(card_addr) != dirty_cards_.end());
dirty_cards_.erase(card_addr);
}
}
void RememberedSet::Dump(std::ostream& os) {
CardTable* card_table = heap_->GetCardTable();
os << "RememberedSet dirty cards: ["; for (const uint8_t* card_addr : dirty_cards_) { auto start = reinterpret_cast<uintptr_t>(card_table->AddrFromCard(card_addr)); auto end = start + CardTable::kCardSize;
os << reinterpret_cast<void*>(start) << "-" << reinterpret_cast<void*>(end) << "\n";
}
os << "]";
}
void RememberedSet::AssertAllDirtyCardsAreWithinSpace() const {
CardTable* card_table = heap_->GetCardTable(); for (const uint8_t* card_addr : dirty_cards_) { auto start = reinterpret_cast<uint8_t*>(card_table->AddrFromCard(card_addr)); auto end = start + CardTable::kCardSize;
DCHECK_LE(space_->Begin(), start);
DCHECK_LE(end, space_->Limit());
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.