namespace mirror { class Object;
} // namespace mirror
class MarkObjectVisitor;
namespace gc { namespace space { class ContinuousSpace;
} // namespace space
class Heap;
namespace accounting {
// The mod-union table is the union of modified cards. It is used to allow the card table to be // cleared between GC phases, reducing the number of dirty cards that need to be scanned. class ModUnionTable { public: // A callback for visiting an object in the heap. using ObjectCallback = void (*)(mirror::Object*, void*);
using CardSet = std::set<uint8_t*,
std::less<uint8_t*>,
TrackingAllocator<uint8_t*, kAllocatorTagModUnionCardSet>>; using CardBitmap = MemoryRangeBitmap<CardTable::kCardSize>;
// Process cards for a memory range of a space. This doesn't immediately update the mod-union // table, as updating the mod-union table may have an associated cost, such as determining // references to track. virtualvoid ProcessCards() = 0;
// Set all the cards. virtualvoid SetCards() = 0;
// Clear all of the table. virtualvoid ClearTable() = 0;
// Update the mod-union table using data stored by ProcessCards. There may be multiple // ProcessCards before a call to update, for example, back-to-back sticky GCs. Also mark // references to other spaces which are stored in the mod-union table. virtualvoid UpdateAndMarkReferences(MarkObjectVisitor* visitor) = 0;
// Visit all of the objects that may contain references to other spaces. virtualvoid VisitObjects(ObjectCallback callback, void* arg) = 0;
// Verification: consistency checks that we don't have clean cards which conflict with out // cached data for said cards. Exclusive lock is required since verify sometimes uses // SpaceBitmap::VisitMarkedRange and VisitMarkedRange can't know if the callback will modify the // bitmap or not. virtualvoid Verify() REQUIRES(Locks::heap_bitmap_lock_) = 0;
// Returns true if a card is marked inside the mod union table. Used for testing. The address // doesn't need to be aligned. virtualbool ContainsCardFor(uintptr_t addr) = 0;
// Filter out cards that don't need to be marked. Automatically done with UpdateAndMarkReferences. void FilterCards();
// Reference caching implementation. Caches references pointing to alloc space(s) for each card. class ModUnionTableReferenceCache : public ModUnionTable { public: explicit ModUnionTableReferenceCache(const std::string& name, Heap* heap,
space::ContinuousSpace* space)
: ModUnionTable(name, heap, space) {}
virtual ~ModUnionTableReferenceCache() {}
// Clear and store cards for a space. void ProcessCards() override;
// Update table based on cleared cards and mark all references to the other spaces. void UpdateAndMarkReferences(MarkObjectVisitor* visitor) override
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(Locks::heap_bitmap_lock_);
// Exclusive lock is required since verify uses SpaceBitmap::VisitMarkedRange and // VisitMarkedRange can't know if the callback will modify the bitmap or not. void Verify() override
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(Locks::heap_bitmap_lock_);
// Function that tells whether or not to add a reference to the table. virtualbool ShouldAddReference(const mirror::Object* ref) const = 0;
protected: // Cleared card array, used to update the mod-union table.
ModUnionTable::CardSet cleared_cards_;
// Maps from dirty cards to their corresponding alloc space references.
AllocationTrackingSafeMap<const uint8_t*, std::vector<mirror::HeapReference<mirror::Object>*>,
kAllocatorTagModUnionReferenceArray> references_;
};
// Card caching implementation. Keeps track of which cards we cleared and only this information. class ModUnionTableCardCache : public ModUnionTable { public: // Note: There is assumption that the space End() doesn't change. explicit ModUnionTableCardCache(const std::string& name, Heap* heap,
space::ContinuousSpace* space);
virtual ~ModUnionTableCardCache() {}
// Clear and store cards for a space. void ProcessCards() override;
// Mark all references to the alloc space(s). void UpdateAndMarkReferences(MarkObjectVisitor* visitor) override
REQUIRES(Locks::heap_bitmap_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
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.