cppgc: Fix bug in reporting allcoated bytes to v8
In crrev.com/c/3056970 I merged reporting allocated bytes from CppHeap to v8 with reporting from cppgc to CppHeap. The reporting handler assumed in_no_gc_scope() is false. Unfortunately this breaks. On heap termination, cppgc will report to CppHeap but CppHeap will have entered a no gc scope when it detached from the isolate. We could adjust the DCHECK, but I think it's simpler to revert to the previous unmerged state and simply port the bug fix from crrev.com/c/3056970 (i.e. lines 484-486 in cpp-heap.cc in this CL). Bug: chromium:1056170 Change-Id: I5aa953c31388f7b3bb3326ff10d5a33961be2aa1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3067227 Reviewed-by: Anton Bikineev <bikineev@chromium.org> Commit-Queue: Omer Katz <omerkatz@chromium.org> Cr-Commit-Position: refs/heads/master@{#76088}
This commit is contained in:
parent
7a2b7597c1
commit
ed75c0ad2b
@ -474,6 +474,16 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
|
||||
marker_->LeaveAtomicPause();
|
||||
}
|
||||
marker_.reset();
|
||||
if (isolate_) {
|
||||
auto* tracer = isolate_->heap()->local_embedder_heap_tracer();
|
||||
DCHECK_NOT_NULL(tracer);
|
||||
tracer->UpdateRemoteStats(
|
||||
stats_collector_->marked_bytes(),
|
||||
stats_collector_->marking_time().InMillisecondsF());
|
||||
}
|
||||
// The allocated bytes counter in v8 was reset to the current marked bytes, so
|
||||
// any pending allocated bytes updates should be discarded.
|
||||
buffered_allocated_bytes_ = 0;
|
||||
ExecutePreFinalizers();
|
||||
// TODO(chromium:1056170): replace build flag with dedicated flag.
|
||||
#if DEBUG
|
||||
@ -521,20 +531,6 @@ void CppHeap::AllocatedObjectSizeDecreased(size_t bytes) {
|
||||
ReportBufferedAllocationSizeIfPossible();
|
||||
}
|
||||
|
||||
void CppHeap::ResetAllocatedObjectSize(size_t bytes) {
|
||||
DCHECK(!sweeper().IsSweepingOnMutatorThread());
|
||||
DCHECK(!in_no_gc_scope());
|
||||
buffered_allocated_bytes_ = 0;
|
||||
if (isolate_) {
|
||||
auto* tracer = isolate_->heap()->local_embedder_heap_tracer();
|
||||
DCHECK_NOT_NULL(tracer);
|
||||
DCHECK_EQ(bytes, stats_collector_->marked_bytes());
|
||||
tracer->UpdateRemoteStats(
|
||||
stats_collector_->marked_bytes(),
|
||||
stats_collector_->marking_time().InMillisecondsF());
|
||||
}
|
||||
}
|
||||
|
||||
void CppHeap::ReportBufferedAllocationSizeIfPossible() {
|
||||
// Avoid reporting to V8 in the following conditions as that may trigger GC
|
||||
// finalizations where not allowed.
|
||||
|
@ -114,7 +114,7 @@ class V8_EXPORT_PRIVATE CppHeap final
|
||||
// StatsCollector::AllocationObserver interface.
|
||||
void AllocatedObjectSizeIncreased(size_t) final;
|
||||
void AllocatedObjectSizeDecreased(size_t) final;
|
||||
void ResetAllocatedObjectSize(size_t) final;
|
||||
void ResetAllocatedObjectSize(size_t) final {}
|
||||
|
||||
MetricRecorderAdapter* GetMetricRecorder() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user