Commit cab126f9 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

[heap] Do full GC on allocation failure

On allocation failure in new space we used to do at most 2 GCs before
calling the near heap limits callback. The 2 GCs would empty new space,
thus insuring that the current allocation can succeed.
With MinorMC the 2nd GC has no effect and we should do a full GC instead
to empty new space.

Bug: v8:12612
Change-Id: I4f767136283b5d26fee4f4a3998359b3c1e2108b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3879495Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83060}
parent 556e44de
......@@ -92,7 +92,13 @@ AllocationResult HeapAllocator::AllocateRawWithLightRetrySlowPath(
if (IsSharedAllocationType(allocation)) {
heap_->CollectSharedGarbage(GarbageCollectionReason::kAllocationFailure);
} else {
heap_->CollectGarbage(AllocationTypeToGCSpace(allocation),
AllocationSpace space_to_gc = AllocationTypeToGCSpace(allocation);
if (v8_flags.minor_mc && i > 0) {
// Repeated young gen GCs won't have any additional effect. Do a full GC
// instead.
space_to_gc = AllocationSpace::OLD_SPACE;
}
heap_->CollectGarbage(space_to_gc,
GarbageCollectionReason::kAllocationFailure);
}
result = AllocateRaw(size, allocation, origin, alignment);
......
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