[test] Make %SimulateNewspaceFull more robust

GC stress flags (--gc-interval, --random-gc-interval) could trigger
unexpected fake allocation failures while trying to fill up a page.
An AlwaysAllocateScope suppresses that.

Drive-by fix: allocation requests with exactly kMaxRegularHeapObjectSize
can take the fast path.

Bug: v8:9700
Change-Id: I7fa35e56848e74f12d3606da453e1ae7254c268b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1834121
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64079}
This commit is contained in:
Jakob Kummerow 2019-10-01 19:31:37 +02:00 committed by Commit Bot
parent 73811dad38
commit 65d05bef39
2 changed files with 4 additions and 2 deletions

View File

@ -176,8 +176,9 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type,
HeapObject object;
AllocationResult allocation;
if (FLAG_single_generation && type == AllocationType::kYoung)
if (FLAG_single_generation && type == AllocationType::kYoung) {
type = AllocationType::kOld;
}
if (AllocationType::kYoung == type) {
if (large_object) {
@ -250,7 +251,7 @@ HeapObject Heap::AllocateRawWith(int size, AllocationType allocation,
Address* limit = heap->NewSpaceAllocationLimitAddress();
if (allocation == AllocationType::kYoung &&
alignment == AllocationAlignment::kWordAligned &&
size < kMaxRegularHeapObjectSize &&
size <= kMaxRegularHeapObjectSize &&
(*limit - *top >= static_cast<unsigned>(size)) &&
V8_LIKELY(!FLAG_single_generation && FLAG_inline_new &&
FLAG_gc_interval == 0)) {

View File

@ -711,6 +711,7 @@ RUNTIME_FUNCTION(Runtime_SimulateNewspaceFull) {
Heap* heap = isolate->heap();
NewSpace* space = heap->new_space();
PauseAllocationObserversScope pause_observers(heap);
AlwaysAllocateScope always_allocate(heap);
do {
FillUpOneNewSpacePage(isolate, heap);
} while (space->AddFreshPage());