DiscontinuousSpace::DiscontinuousSpace(const std::string& name,
GcRetentionPolicy gc_retention_policy) :
Space(name, gc_retention_policy) { // TODO: Fix this if we ever support objects not in the low 32 bit. const size_t capacity = static_cast<size_t>(std::numeric_limits<uint32_t>::max());
live_bitmap_ = accounting::LargeObjectBitmap::Create("large live objects", nullptr, capacity);
CHECK(live_bitmap_.IsValid());
mark_bitmap_ = accounting::LargeObjectBitmap::Create("large marked objects", nullptr, capacity);
CHECK(mark_bitmap_.IsValid());
}
collector::ObjectBytePair ContinuousMemMapAllocSpace::Sweep(bool swap_bitmaps) {
accounting::ContinuousSpaceBitmap* live_bitmap = GetLiveBitmap();
accounting::ContinuousSpaceBitmap* mark_bitmap = GetMarkBitmap(); // If the bitmaps are bound then sweeping this space clearly won't do anything. if (live_bitmap == mark_bitmap) { return collector::ObjectBytePair(0, 0);
}
SweepCallbackContext scc(swap_bitmaps, this); if (swap_bitmaps) {
std::swap(live_bitmap, mark_bitmap);
} // Bitmaps are pre-swapped for optimization which enables sweeping with the heap unlocked.
accounting::ContinuousSpaceBitmap::SweepWalk(
*live_bitmap, *mark_bitmap, reinterpret_cast<uintptr_t>(Begin()), reinterpret_cast<uintptr_t>(End()), GetSweepCallback(), reinterpret_cast<void*>(&scc)); return scc.freed;
}
bool ContinuousSpace::HasBoundBitmaps() {
DCHECK(GetLiveBitmap() != nullptr);
DCHECK(GetMarkBitmap() != nullptr); // Check if the bitmaps are pointing to the same underlying data. return GetLiveBitmap()->Begin() == GetMarkBitmap()->Begin();
}
void ContinuousMemMapAllocSpace::UnBindBitmaps() {
CHECK(HasBoundBitmaps()); // At this point, `temp_bitmap_` holds our old mark bitmap.
mark_bitmap_ = std::move(temp_bitmap_);
}
void ContinuousMemMapAllocSpace::SwapBitmaps() {
CHECK(!HasBoundBitmaps());
std::swap(live_bitmap_, mark_bitmap_); // Preserve names to get more descriptive diagnostics.
std::string temp_name(live_bitmap_.GetName());
live_bitmap_.SetName(mark_bitmap_.GetName());
mark_bitmap_.SetName(temp_name);
}
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.