Commit 94387f67 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Run prefinalizers in termination GC

Bug: chromium:1056170
Change-Id: Ifb5a2cfa5f3fd2fbfecb84b1bf8f3dc464a823ef
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2711264Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72901}
parent 4cd96259
......@@ -339,10 +339,7 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
marker_->LeaveAtomicPause();
}
marker_.reset();
{
cppgc::subtle::DisallowGarbageCollectionScope disallow_gc_scope(*this);
prefinalizer_handler()->InvokePreFinalizers();
}
ExecutePreFinalizers();
// TODO(chromium:1056170): replace build flag with dedicated flag.
#if DEBUG
UnifiedHeapMarkingVerifier verifier(*this);
......
......@@ -4,6 +4,7 @@
#include "src/heap/cppgc/heap-base.h"
#include "include/cppgc/heap-consistency.h"
#include "src/base/bounded-page-allocator.h"
#include "src/base/platform/platform.h"
#include "src/heap/base/stack.h"
......@@ -91,6 +92,11 @@ size_t HeapBase::ObjectPayloadSize() const {
void HeapBase::AdvanceIncrementalGarbageCollectionOnAllocationIfNeeded() {
if (marker_) marker_->AdvanceMarkingOnAllocation();
}
void HeapBase::ExecutePreFinalizers() {
// Pre finalizers are forbidden from allocating objects.
cppgc::subtle::DisallowGarbageCollectionScope no_gc_scope(*this);
prefinalizer_handler_->InvokePreFinalizers();
}
void HeapBase::Terminate() {
DCHECK(!IsMarking());
......@@ -116,6 +122,7 @@ void HeapBase::Terminate() {
GarbageCollector::Config::IsForcedGC::kForced);
stats_collector()->NotifyMarkingCompleted(0);
object_allocator().ResetLinearAllocationBuffers();
ExecutePreFinalizers();
sweeper().Start(
{Sweeper::SweepingConfig::SweepingType::kAtomic,
Sweeper::SweepingConfig::CompactableSpaceHandling::kSweep});
......
......@@ -169,6 +169,8 @@ class V8_EXPORT_PRIVATE HeapBase : public cppgc::HeapHandle {
bool IsMarking() const { return marker_.get(); }
void ExecutePreFinalizers();
RawHeap raw_heap_;
std::shared_ptr<cppgc::Platform> platform_;
#if defined(CPPGC_CAGED_HEAP)
......
......@@ -184,11 +184,7 @@ void Heap::FinalizeGarbageCollection(Config::StackState stack_state) {
marker_->FinishMarking(config_.stack_state);
}
marker_.reset();
{
// Pre finalizers are forbidden from allocating objects.
cppgc::subtle::DisallowGarbageCollectionScope no_gc_scope(*this);
prefinalizer_handler_->InvokePreFinalizers();
}
ExecutePreFinalizers();
// TODO(chromium:1056170): replace build flag with dedicated flag.
#if DEBUG
MarkingVerifier verifier(*this);
......
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