Commit 70a1de97 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Fix flaky test failure in concurrent allocation

Concurrent allocation test was failing flakily. Do not fix this simply
by increasing heap size since this would reduce frequency of GCs.
Instead allow allocations to fail. Even in this case the allocation
code path is still executed which we want to test.

Bug: v8:11084, v8:10315
Change-Id: I0daa9ad9177aab8b02b7decf2ccfd50e0d8ab9b6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2516471Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70946}
parent fd1111a4
...@@ -160,6 +160,11 @@ void LocalHeap::UnmarkLinearAllocationArea() { ...@@ -160,6 +160,11 @@ void LocalHeap::UnmarkLinearAllocationArea() {
old_space_allocator_.UnmarkLinearAllocationArea(); old_space_allocator_.UnmarkLinearAllocationArea();
} }
void LocalHeap::PerformCollection() {
ParkedScope scope(this);
heap_->RequestCollectionBackground(this);
}
Address LocalHeap::PerformCollectionAndAllocateAgain( Address LocalHeap::PerformCollectionAndAllocateAgain(
int object_size, AllocationType type, AllocationOrigin origin, int object_size, AllocationType type, AllocationOrigin origin,
AllocationAlignment alignment) { AllocationAlignment alignment) {
...@@ -167,10 +172,7 @@ Address LocalHeap::PerformCollectionAndAllocateAgain( ...@@ -167,10 +172,7 @@ Address LocalHeap::PerformCollectionAndAllocateAgain(
static const int kMaxNumberOfRetries = 3; static const int kMaxNumberOfRetries = 3;
for (int i = 0; i < kMaxNumberOfRetries; i++) { for (int i = 0; i < kMaxNumberOfRetries; i++) {
{ PerformCollection();
ParkedScope scope(this);
heap_->RequestCollectionBackground(this);
}
AllocationResult result = AllocateRaw(object_size, type, origin, alignment); AllocationResult result = AllocateRaw(object_size, type, origin, alignment);
if (!result.IsRetry()) { if (!result.IsRetry()) {
......
...@@ -128,6 +128,9 @@ class V8_EXPORT_PRIVATE LocalHeap { ...@@ -128,6 +128,9 @@ class V8_EXPORT_PRIVATE LocalHeap {
bool is_main_thread() const { return is_main_thread_; } bool is_main_thread() const { return is_main_thread_; }
// Requests GC and blocks until the collection finishes.
void PerformCollection();
private: private:
enum class ThreadState { enum class ThreadState {
// Threads in this state need to be stopped in a safepoint. // Threads in this state need to be stopped in a safepoint.
......
...@@ -149,10 +149,15 @@ class LargeObjectConcurrentAllocationThread final : public v8::base::Thread { ...@@ -149,10 +149,15 @@ class LargeObjectConcurrentAllocationThread final : public v8::base::Thread {
const size_t kLargeObjectSize = kMaxRegularHeapObjectSize * 2; const size_t kLargeObjectSize = kMaxRegularHeapObjectSize * 2;
for (int i = 0; i < kNumIterations; i++) { for (int i = 0; i < kNumIterations; i++) {
Address address = local_heap.AllocateRawOrFail( AllocationResult result = local_heap.AllocateRaw(
kLargeObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime, kLargeObjectSize, AllocationType::kOld, AllocationOrigin::kRuntime,
AllocationAlignment::kWordAligned); AllocationAlignment::kWordAligned);
if (result.IsRetry()) {
local_heap.PerformCollection();
} else {
Address address = result.ToAddress();
CreateFixedArray(heap_, address, kLargeObjectSize); CreateFixedArray(heap_, address, kLargeObjectSize);
}
local_heap.Safepoint(); local_heap.Safepoint();
} }
......
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