cppgc: Add marking on allocation

Perform a small marking step whenever we allocate a new lab.

Bug: chromium:1056170
Change-Id: I2a09480a254ddb1afc95bf5ef9a70ec27f512d79
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2366698
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69507}
This commit is contained in:
Omer Katz 2020-08-20 14:10:39 +02:00 committed by Commit Bot
parent 808a775f97
commit c6fb303f8a
5 changed files with 15 additions and 0 deletions

View File

@ -89,5 +89,9 @@ void HeapBase::VerifyMarking(cppgc::Heap::StackState stack_state) {
MarkingVerifier verifier(*this, stack_state);
}
void HeapBase::AdvanceIncrementalGarbageCollectionOnAllocationIfNeeded() {
if (marker_) marker_->AdvanceMarkingOnAllocation();
}
} // namespace internal
} // namespace cppgc

View File

@ -116,6 +116,8 @@ class V8_EXPORT_PRIVATE HeapBase {
size_t ObjectPayloadSize() const;
void AdvanceIncrementalGarbageCollectionOnAllocationIfNeeded();
protected:
void VerifyMarking(cppgc::Heap::StackState);

View File

@ -288,6 +288,11 @@ bool MarkerBase::IncrementalMarkingStep(MarkingConfig::StackState stack_state,
return AdvanceMarkingWithDeadline(expected_marked_bytes);
}
bool MarkerBase::AdvanceMarkingOnAllocation() {
// Replace with schedule based deadline.
return AdvanceMarkingWithDeadline(kMinimumMarkedBytesPerIncrementalStep);
}
bool MarkerBase::AdvanceMarkingWithDeadline(size_t expected_marked_bytes,
v8::base::TimeDelta max_duration) {
bool is_done =

View File

@ -74,6 +74,9 @@ class V8_EXPORT_PRIVATE MarkerBase {
bool AdvanceMarkingWithDeadline(
size_t, v8::base::TimeDelta = kMaximumIncrementalStepDuration);
// Makes marking progress when allocation a new lab.
bool AdvanceMarkingOnAllocation();
// Signals leaving the atomic marking pause. This method expects no more
// objects to be marked and merely updates marking states if needed.
void LeaveAtomicPause();

View File

@ -110,6 +110,7 @@ void* ObjectAllocator::OutOfLineAllocate(NormalPageSpace* space, size_t size,
GCInfoIndex gcinfo) {
void* memory = OutOfLineAllocateImpl(space, size, gcinfo);
stats_collector_->NotifySafePointForConservativeCollection();
raw_heap_->heap()->AdvanceIncrementalGarbageCollectionOnAllocationIfNeeded();
return memory;
}