Commit cbcbb059 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Fix tests for young large objects

Some tests assume that kMaxRegularHeapObjectSize is close to the
page size. They break if the constant is decreased to 16KB to stress
young large objects.

Bug: chromium:852420
Change-Id: I2542878810823f7a73019b1e451a080fcfc1f78f
Reviewed-on: https://chromium-review.googlesource.com/c/1456043Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59430}
parent 0999709c
......@@ -1939,7 +1939,6 @@ Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors,
// Zero-length case must be handled outside.
DCHECK_LT(0, number_of_all_descriptors);
int size = DescriptorArray::SizeFor(number_of_all_descriptors);
DCHECK_LT(size, kMaxRegularHeapObjectSize);
AllocationSpace space = Heap::SelectSpace(pretenure);
HeapObject obj = isolate()->heap()->AllocateRawWithRetryOrFail(size, space);
obj->set_map_after_allocation(*descriptor_array_map(), SKIP_WRITE_BARRIER);
......
......@@ -30,7 +30,8 @@ void SealCurrentObjects(Heap* heap) {
}
int FixedArrayLenFromSize(int size) {
return (size - FixedArray::kHeaderSize) / kTaggedSize;
return Min((size - FixedArray::kHeaderSize) / kTaggedSize,
FixedArray::kMaxRegularLength);
}
std::vector<Handle<FixedArray>> FillOldSpacePageWithFixedArrays(Heap* heap,
......@@ -107,7 +108,7 @@ std::vector<Handle<FixedArray>> CreatePadding(Heap* heap, int padding_size,
handles.push_back(isolate->factory()->NewFixedArray(length, tenure));
CHECK((tenure == NOT_TENURED && Heap::InNewSpace(*handles.back())) ||
(tenure == TENURED && heap->InOldSpace(*handles.back())));
free_memory -= allocate_memory;
free_memory -= handles.back()->Size();
}
return handles;
}
......
......@@ -96,8 +96,9 @@ HEAP_TEST(CompactionPartiallyAbortedPage) {
const int objects_per_page = 10;
const int object_size =
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
objects_per_page;
Min(kMaxRegularHeapObjectSize,
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
objects_per_page);
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
......@@ -175,8 +176,9 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) {
const int objects_per_page = 10;
const int object_size =
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
objects_per_page;
Min(kMaxRegularHeapObjectSize,
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
objects_per_page);
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
......@@ -267,8 +269,9 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) {
const int objects_per_page = 10;
const int object_size =
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
objects_per_page;
Min(kMaxRegularHeapObjectSize,
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
objects_per_page);
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
......
......@@ -5330,7 +5330,8 @@ TEST(Regress598319) {
Heap* heap = CcTest::heap();
Isolate* isolate = heap->isolate();
const int kNumberOfObjects = kMaxRegularHeapObjectSize / kTaggedSize;
// The size of the array should be larger than kProgressBarScanningChunk.
const int kNumberOfObjects = Max(FixedArray::kMaxRegularLength + 1, 128 * KB);
struct Arr {
Arr(Isolate* isolate, int number_of_objects) {
......
......@@ -67,6 +67,11 @@ UNINITIALIZED_TEST(PagePromotion_NewToOld) {
v8::Context::New(isolate)->Enter();
Heap* heap = i_isolate->heap();
// Ensure that the new space is empty so that the page to be promoted
// does not contain the age mark.
heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting);
heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting);
std::vector<Handle<FixedArray>> handles;
heap::SimulateFullSpace(heap->new_space(), &handles);
heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting);
......
......@@ -1927,21 +1927,25 @@ TEST(CodeSerializerThreeBigStrings) {
v8::HandleScope scope(CcTest::isolate());
const int32_t length_of_a = kMaxRegularHeapObjectSize * 2;
const int32_t length_of_b = kMaxRegularHeapObjectSize / 2;
const int32_t length_of_c = kMaxRegularHeapObjectSize / 2;
Vector<const uint8_t> source_a =
ConstructSource(StaticCharVector("var a = \""), StaticCharVector("a"),
StaticCharVector("\";"), 700000);
StaticCharVector("\";"), length_of_a);
Handle<String> source_a_str =
f->NewStringFromOneByte(source_a).ToHandleChecked();
Vector<const uint8_t> source_b =
ConstructSource(StaticCharVector("var b = \""), StaticCharVector("b"),
StaticCharVector("\";"), 400000);
StaticCharVector("\";"), length_of_b);
Handle<String> source_b_str =
f->NewStringFromOneByte(source_b).ToHandleChecked();
Vector<const uint8_t> source_c =
ConstructSource(StaticCharVector("var c = \""), StaticCharVector("c"),
StaticCharVector("\";"), 400000);
StaticCharVector("\";"), length_of_c);
Handle<String> source_c_str =
f->NewStringFromOneByte(source_c).ToHandleChecked();
......@@ -1974,10 +1978,10 @@ TEST(CodeSerializerThreeBigStrings) {
v8::Maybe<int32_t> result =
CompileRun("(a + b).length")
->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext());
CHECK_EQ(400000 + 700000, result.FromJust());
CHECK_EQ(length_of_a + length_of_b, result.FromJust());
result = CompileRun("(b + c).length")
->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext());
CHECK_EQ(400000 + 400000, result.FromJust());
CHECK_EQ(length_of_b + length_of_c, result.FromJust());
Heap* heap = isolate->heap();
v8::Local<v8::String> result_str =
CompileRun("a")
......@@ -1987,20 +1991,12 @@ TEST(CodeSerializerThreeBigStrings) {
result_str = CompileRun("b")
->ToString(CcTest::isolate()->GetCurrentContext())
.ToLocalChecked();
#if V8_HOST_ARCH_PPC
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), LO_SPACE));
#else
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), OLD_SPACE));
#endif
result_str = CompileRun("c")
->ToString(CcTest::isolate()->GetCurrentContext())
.ToLocalChecked();
#if V8_HOST_ARCH_PPC
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), LO_SPACE));
#else
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), OLD_SPACE));
#endif
delete cache;
source_a.Dispose();
......
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