Commit 8fe6b87f authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[heap] Tenure large objects based on size (currently 32K).

Bug: chromium:852420
Change-Id: Ibb8cd735036368c5bda83fe60b12b427e8e7ce7f
Reviewed-on: https://chromium-review.googlesource.com/1127887Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54296}
parent cf87e94c
......@@ -251,6 +251,10 @@ constexpr int kExternalAllocationSoftLimit = 64 * MB;
// Current value: Page::kAllocatableMemory (on 32-bit arch) - 512 (slack).
constexpr int kMaxRegularHeapObjectSize = 507136;
// Objects smaller or equal kMaxNewSpaceHeapObjectSize are allocated in the
// new large object space.
constexpr int kMaxNewSpaceHeapObjectSize = 32 * KB;
STATIC_ASSERT(kPointerSize == (1 << kPointerSizeLog2));
constexpr int kBitsPerByte = 8;
......
......@@ -154,13 +154,19 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space,
#endif
bool large_object = size_in_bytes > kMaxRegularHeapObjectSize;
bool new_large_object = FLAG_young_generation_large_objects &&
size_in_bytes > kMaxNewSpaceHeapObjectSize;
HeapObject* object = nullptr;
AllocationResult allocation;
if (NEW_SPACE == space) {
if (large_object) {
space = LO_SPACE;
} else {
if (new_large_object) {
allocation = new_lo_space_->AllocateRaw(size_in_bytes);
} else {
allocation = new_space_->AllocateRaw(size_in_bytes, alignment);
}
if (allocation.To(&object)) {
OnAllocationEvent(object, size_in_bytes);
}
......@@ -183,11 +189,7 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space,
}
} else if (LO_SPACE == space) {
DCHECK(large_object);
if (FLAG_young_generation_large_objects) {
allocation = new_lo_space_->AllocateRaw(size_in_bytes);
} else {
allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
}
} else if (MAP_SPACE == space) {
allocation = map_space_->AllocateRawUnaligned(size_in_bytes);
} else if (RO_SPACE == space) {
......
......@@ -5670,6 +5670,11 @@ TEST(YoungGenerationLargeObjectAllocation) {
Handle<FixedArray> array = isolate->factory()->NewFixedArray(200000);
MemoryChunk* chunk = MemoryChunk::FromAddress(array->address());
CHECK(chunk->owner()->identity() == LO_SPACE);
CHECK(!chunk->IsFlagSet(MemoryChunk::IN_TO_SPACE));
Handle<FixedArray> array_small = isolate->factory()->NewFixedArray(20000);
chunk = MemoryChunk::FromAddress(array_small->address());
CHECK(chunk->owner()->identity() == NEW_LO_SPACE);
CHECK(chunk->IsFlagSet(MemoryChunk::IN_TO_SPACE));
}
......
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