[heap] Fix --code-stats in debug builds
This CL fixes failing DCHECKs when Heap::CollectCodeStatistics() is invoked in the atomic GC pause. * Heap::CollectGarbage disallows GC, so move CollectCodeStatistics() into Heap::GarbageCollectionEpilogue() where such an exception already exists. * CollectCodeStatistics() also needs to finish sweeping but a DCHECK in GCTracer only allowed this for heap verification. Bug: v8:13267 Change-Id: I6c8e75ad5e78347fc162d3b67be10cb972269a12 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4197335 Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#85513}
This commit is contained in:
parent
02df9f3ef1
commit
2fea89c46c
@ -533,14 +533,10 @@ void GCTracer::NotifyFullSweepingCompleted() {
|
||||
}
|
||||
|
||||
DCHECK(!Event::IsYoungGenerationEvent(current_.type));
|
||||
if (v8_flags.verify_heap) {
|
||||
// If heap verification is enabled, sweeping finalization can also be
|
||||
// triggered from inside a full GC cycle's atomic pause.
|
||||
DCHECK(current_.state == Event::State::SWEEPING ||
|
||||
current_.state == Event::State::ATOMIC);
|
||||
} else {
|
||||
DCHECK(IsSweepingInProgress());
|
||||
}
|
||||
// Sweeping finalization can also be triggered from inside a full GC cycle's
|
||||
// atomic pause.
|
||||
DCHECK(current_.state == Event::State::SWEEPING ||
|
||||
current_.state == Event::State::ATOMIC);
|
||||
|
||||
// Stop a full GC cycle only when both v8 and cppgc (if available) GCs have
|
||||
// finished sweeping. This method is invoked by v8.
|
||||
|
@ -1299,7 +1299,6 @@ void Heap::GarbageCollectionEpilogueInSafepoint(GarbageCollector collector) {
|
||||
|
||||
if (v8_flags.print_global_handles) isolate_->global_handles()->Print();
|
||||
if (v8_flags.print_handles) PrintHandles();
|
||||
if (v8_flags.code_stats) ReportCodeStatistics("After GC");
|
||||
if (v8_flags.check_handle_count) CheckHandleCount();
|
||||
#endif
|
||||
|
||||
@ -1378,6 +1377,7 @@ void Heap::GarbageCollectionEpilogue(GarbageCollector collector) {
|
||||
|
||||
#ifdef DEBUG
|
||||
ReportStatisticsAfterGC();
|
||||
if (v8_flags.code_stats) ReportCodeStatistics("After GC");
|
||||
#endif // DEBUG
|
||||
|
||||
last_gc_time_ = MonotonicallyIncreasingTimeInMs();
|
||||
|
7
test/mjsunit/code-stats-flag.js
Normal file
7
test/mjsunit/code-stats-flag.js
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Flags: --expose-gc --code-stats
|
||||
|
||||
gc();
|
Loading…
Reference in New Issue
Block a user