Commit c6fb303f authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

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: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69507}
parent 808a775f
......@@ -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
......@@ -116,6 +116,8 @@ class V8_EXPORT_PRIVATE HeapBase {
size_t ObjectPayloadSize() const;
void AdvanceIncrementalGarbageCollectionOnAllocationIfNeeded();
protected:
void VerifyMarking(cppgc::Heap::StackState);
......
......@@ -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 =
......
......@@ -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();
......
......@@ -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;
}
......
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