Commit 6fff5758 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Let --stress-concurrent-allocation allocate large objects

Let StressConcurrentAllocatorTask allocate small, medium and large
objects to test different code paths.

Bug: v8:10315
Change-Id: Ifff7e91bc95f0d926a58321b481183e9acf8bd32
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2335182
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69217}
parent 9fff9a73
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/heap/concurrent-allocator.h" #include "src/heap/concurrent-allocator.h"
#include "src/common/globals.h"
#include "src/execution/isolate.h" #include "src/execution/isolate.h"
#include "src/handles/persistent-handles.h" #include "src/handles/persistent-handles.h"
#include "src/heap/concurrent-allocator-inl.h" #include "src/heap/concurrent-allocator-inl.h"
...@@ -18,24 +19,33 @@ void StressConcurrentAllocatorTask::RunInternal() { ...@@ -18,24 +19,33 @@ void StressConcurrentAllocatorTask::RunInternal() {
LocalHeap local_heap(heap); LocalHeap local_heap(heap);
const int kNumIterations = 2000; const int kNumIterations = 2000;
const int kObjectSize = 10 * kTaggedSize; const int kSmallObjectSize = 10 * kTaggedSize;
const int kLargeObjectSize = 8 * KB; const int kMediumObjectSize = 8 * KB;
const int kLargeObjectSize = kMaxRegularHeapObjectSize * 2;
for (int i = 0; i < kNumIterations; i++) { for (int i = 0; i < kNumIterations; i++) {
Address address = local_heap.AllocateRawOrFail( Address address = local_heap.AllocateRawOrFail(
kObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime, kSmallObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime,
AllocationAlignment::kWordAligned); AllocationAlignment::kWordAligned);
heap->CreateFillerObjectAtBackground( heap->CreateFillerObjectAtBackground(
address, kObjectSize, ClearFreedMemoryMode::kDontClearFreedMemory); address, kSmallObjectSize, ClearFreedMemoryMode::kDontClearFreedMemory);
local_heap.Safepoint();
address = local_heap.AllocateRawOrFail(
kMediumObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime,
AllocationAlignment::kWordAligned);
heap->CreateFillerObjectAtBackground(
address, kMediumObjectSize,
ClearFreedMemoryMode::kDontClearFreedMemory);
local_heap.Safepoint();
address = local_heap.AllocateRawOrFail( address = local_heap.AllocateRawOrFail(
kLargeObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime, kLargeObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime,
AllocationAlignment::kWordAligned); AllocationAlignment::kWordAligned);
heap->CreateFillerObjectAtBackground( heap->CreateFillerObjectAtBackground(
address, kLargeObjectSize, ClearFreedMemoryMode::kDontClearFreedMemory); address, kLargeObjectSize, ClearFreedMemoryMode::kDontClearFreedMemory);
if (i % 10 == 0) {
local_heap.Safepoint(); local_heap.Safepoint();
} }
}
Schedule(isolate_); Schedule(isolate_);
} }
......
...@@ -33,7 +33,8 @@ AllocationResult LocalHeap::AllocateRaw(int size_in_bytes, AllocationType type, ...@@ -33,7 +33,8 @@ AllocationResult LocalHeap::AllocateRaw(int size_in_bytes, AllocationType type,
DCHECK(AllowHeapAllocation::IsAllowed()); DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK_IMPLIES(type == AllocationType::kCode, DCHECK_IMPLIES(type == AllocationType::kCode,
alignment == AllocationAlignment::kCodeAligned); alignment == AllocationAlignment::kCodeAligned);
DCHECK_EQ(heap()->gc_state(), Heap::HeapState::NOT_IN_GC); DCHECK(heap()->gc_state() == Heap::TEAR_DOWN ||
heap()->gc_state() == Heap::NOT_IN_GC);
bool large_object = size_in_bytes > kMaxRegularHeapObjectSize; bool large_object = size_in_bytes > kMaxRegularHeapObjectSize;
CHECK_EQ(type, AllocationType::kOld); CHECK_EQ(type, AllocationType::kOld);
......
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