Commit 7a264881 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

cppgc: More live bytes verification

Bug: chromium:1056170
Change-Id: I7d8d27f7497ec403dd463e0e2a5b3d0134cfb637
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2919960Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74817}
parent 64b7d34f
......@@ -42,11 +42,19 @@ void StatsCollector::NotifyAllocation(size_t bytes) {
// The current GC may not have been started. This is ok as recording considers
// the whole time range between garbage collections.
allocated_bytes_since_safepoint_ += bytes;
#ifdef CPPGC_VERIFY_LIVE_BYTES
DCHECK_GE(live_bytes_ + bytes, live_bytes_);
live_bytes_ += bytes;
#endif // CPPGC_VERIFY_LIVE_BYTES
}
void StatsCollector::NotifyExplicitFree(size_t bytes) {
// See IncreaseAllocatedObjectSize for lifetime of the counter.
explicitly_freed_bytes_since_safepoint_ += bytes;
#ifdef CPPGC_VERIFY_LIVE_BYTES
DCHECK_GE(live_bytes_, bytes);
live_bytes_ -= bytes;
#endif // CPPGC_VERIFY_LIVE_BYTES
}
void StatsCollector::NotifySafePointForConservativeCollection() {
......@@ -107,6 +115,9 @@ void StatsCollector::NotifyMarkingCompleted(size_t marked_bytes) {
explicitly_freed_bytes_since_safepoint_;
allocated_bytes_since_safepoint_ = 0;
explicitly_freed_bytes_since_safepoint_ = 0;
#ifdef CPPGC_VERIFY_LIVE_BYTES
live_bytes_ = marked_bytes;
#endif // CPPGC_VERIFY_LIVE_BYTES
DCHECK_LE(memory_freed_bytes_since_end_of_marking_, memory_allocated_bytes_);
memory_allocated_bytes_ -= memory_freed_bytes_since_end_of_marking_;
......
......@@ -326,6 +326,9 @@ class V8_EXPORT_PRIVATE StatsCollector final {
// arithmetic for simplicity.
int64_t allocated_bytes_since_safepoint_ = 0;
int64_t explicitly_freed_bytes_since_safepoint_ = 0;
#ifdef CPPGC_VERIFY_LIVE_BYTES
size_t live_bytes_ = 0;
#endif // CPPGC_VERIFY_LIVE_BYTES
int64_t memory_allocated_bytes_ = 0;
int64_t memory_freed_bytes_since_end_of_marking_ = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment