Commit 4d7e6f4c authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by V8 LUCI CQ

[test] Make cctest/test-spaces/OldLargeObjectSpace more robust

The test has a loop that allocates large objects until it gets an
allocation failure. The test then asserts that the subsequent allocation
should also fail. That however does not necessarily hold because the
previously allocated objects may be collected to free up the space.

This change creates a handle for each allocated object. It also
restricts the size of the heap to 20MB to reduce memory consumption.

Bug: v8:11172
Change-Id: Ic3dc1a0f5f235b0313bab2071546b59a77bd55e5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2912884
Auto-Submit: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74728}
parent fc29fa8f
...@@ -310,6 +310,7 @@ TEST(OldLargeObjectSpace) { ...@@ -310,6 +310,7 @@ TEST(OldLargeObjectSpace) {
// This test does not initialize allocated objects, which confuses the // This test does not initialize allocated objects, which confuses the
// incremental marker. // incremental marker.
FLAG_incremental_marking = false; FLAG_incremental_marking = false;
FLAG_max_heap_size = 20;
v8::V8::Initialize(); v8::V8::Initialize();
OldLargeObjectSpace* lo = CcTest::heap()->lo_space(); OldLargeObjectSpace* lo = CcTest::heap()->lo_space();
...@@ -335,16 +336,18 @@ TEST(OldLargeObjectSpace) { ...@@ -335,16 +336,18 @@ TEST(OldLargeObjectSpace) {
ho.address(), ho.address(),
HeapObject::RequiredAlignment( HeapObject::RequiredAlignment(
ReadOnlyRoots(CcTest::i_isolate()).fixed_double_array_map()))); ReadOnlyRoots(CcTest::i_isolate()).fixed_double_array_map())));
Isolate* isolate = CcTest::i_isolate();
HandleScope handle_scope(isolate);
while (true) { while (true) {
{ {
AllocationResult allocation = lo->AllocateRaw(lo_size); AllocationResult allocation = lo->AllocateRaw(lo_size);
if (allocation.IsRetry()) break; if (allocation.IsRetry()) break;
HeapObject ho = HeapObject::cast(allocation.ToObjectChecked());
Handle<HeapObject> keep_alive(ho, isolate);
} }
} }
CHECK(!lo->IsEmpty()); CHECK(!lo->IsEmpty());
CHECK(lo->AllocateRaw(lo_size).IsRetry()); CHECK(lo->AllocateRaw(lo_size).IsRetry());
} }
......
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