[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/+/3879495 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Omer Katz <omerkatz@chromium.org> Cr-Commit-Position: refs/heads/main@{#83060}
This commit is contained in:
parent
556e44de28
commit
cab126f9ee
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user