BumpPointerSpace::BumpPointerSpace(const std::string& name, uint8_t* begin, uint8_t* limit)
: ContinuousMemMapAllocSpace(
name, MemMap::Invalid(), begin, begin, limit, kGcRetentionPolicyAlwaysCollect),
growth_end_(limit),
objects_allocated_(0),
bytes_allocated_(0),
lock_("Bump-pointer space lock"),
main_block_size_(0) { // This constructor gets called only from Heap::PreZygoteFork(), which // doesn't require a mark_bitmap.
}
BumpPointerSpace::BumpPointerSpace(const std::string& name, MemMap&& mem_map)
: ContinuousMemMapAllocSpace(name,
std::move(mem_map),
mem_map.Begin(),
mem_map.Begin(),
mem_map.End(),
kGcRetentionPolicyAlwaysCollect),
growth_end_(mem_map_.End()),
objects_allocated_(0),
bytes_allocated_(0),
lock_("Bump-pointer space lock", kBumpPointerSpaceBlockLock),
main_block_size_(0) {
mark_bitmap_ =
accounting::ContinuousSpaceBitmap::Create("bump-pointer space live bitmap",
Begin(),
Capacity());
}
void BumpPointerSpace::Clear() { // Release the pages back to the operating system. if (!kMadviseZeroes) {
memset(Begin(), 0, Limit() - Begin());
}
CHECK_NE(madvise(Begin(), Limit() - Begin(), MADV_DONTNEED), -1) << "madvise failed"; if (GetMarkBitmap() != nullptr) {
GetMarkBitmap()->Clear();
} // Reset the end of the space back to the beginning, we move the end forward as we allocate // objects.
SetEnd(Begin());
objects_allocated_.store(0, std::memory_order_relaxed);
bytes_allocated_.store(0, std::memory_order_relaxed);
{
MutexLock mu(Thread::Current(), lock_);
growth_end_ = Limit();
block_sizes_.clear();
main_block_size_ = 0;
black_dense_region_size_ = 0;
}
}
uint64_t BumpPointerSpace::GetBytesAllocated() { // Start out pre-determined amount (blocks which are not being allocated into).
uint64_t total = static_cast<uint64_t>(bytes_allocated_.load(std::memory_order_relaxed));
Thread* self = Thread::Current();
MutexLock mu(self, *Locks::runtime_shutdown_lock_);
MutexLock mu2(self, *Locks::thread_list_lock_);
std::list<Thread*> thread_list = Runtime::Current()->GetThreadList()->GetList();
MutexLock mu3(Thread::Current(), lock_); // If we don't have any blocks, we don't have any thread local buffers. This check is required // since there can exist multiple bump pointer spaces which exist at the same time. if (!block_sizes_.empty()) { for (Thread* thread : thread_list) {
total += thread->GetThreadLocalBytesAllocated();
}
} return total;
}
uint64_t BumpPointerSpace::GetObjectsAllocated() { // Start out pre-determined amount (blocks which are not being allocated into).
uint64_t total = static_cast<uint64_t>(objects_allocated_.load(std::memory_order_relaxed));
Thread* self = Thread::Current();
MutexLock mu(self, *Locks::runtime_shutdown_lock_);
MutexLock mu2(self, *Locks::thread_list_lock_);
std::list<Thread*> thread_list = Runtime::Current()->GetThreadList()->GetList();
MutexLock mu3(Thread::Current(), lock_); // If we don't have any blocks, we don't have any thread local buffers. This check is required // since there can exist multiple bump pointer spaces which exist at the same time. if (!block_sizes_.empty()) { for (Thread* thread : thread_list) {
total += thread->GetThreadLocalObjectsAllocated();
}
} return total;
}
uint8_t* BumpPointerSpace::AlignEnd(Thread* self, size_t alignment, Heap* heap) {
Locks::mutator_lock_->AssertExclusiveHeld(self);
DCHECK(IsAligned<kAlignment>(alignment));
uint8_t* end = end_.load(std::memory_order_relaxed);
uint8_t* aligned_end = AlignUp(end, alignment);
ptrdiff_t diff = aligned_end - end; if (diff > 0) {
end_.store(aligned_end, std::memory_order_relaxed);
heap->AddBytesAllocated(diff); // If we have blocks after the main one. Then just add the diff to the last // block.
MutexLock mu(self, lock_); if (!block_sizes_.empty()) {
block_sizes_.back() += diff;
}
} return aligned_end;
}
} // namespace space
} // namespace gc
} // namespace art
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.11Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-29)
¤
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.