summaryrefslogtreecommitdiff
path: root/chromium/v8/src/heap/concurrent-allocator.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/heap/concurrent-allocator.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/heap/concurrent-allocator.cc')
-rw-r--r--chromium/v8/src/heap/concurrent-allocator.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/chromium/v8/src/heap/concurrent-allocator.cc b/chromium/v8/src/heap/concurrent-allocator.cc
index 7fd29110215..9625bdb13aa 100644
--- a/chromium/v8/src/heap/concurrent-allocator.cc
+++ b/chromium/v8/src/heap/concurrent-allocator.cc
@@ -4,12 +4,52 @@
#include "src/heap/concurrent-allocator.h"
+#include "src/execution/isolate.h"
+#include "src/handles/persistent-handles.h"
#include "src/heap/concurrent-allocator-inl.h"
#include "src/heap/local-heap.h"
+#include "src/heap/marking.h"
namespace v8 {
namespace internal {
+void StressConcurrentAllocatorTask::RunInternal() {
+ Heap* heap = isolate_->heap();
+ LocalHeap local_heap(heap);
+ ConcurrentAllocator* allocator = local_heap.old_space_allocator();
+
+ const int kNumIterations = 2000;
+ const int kObjectSize = 10 * kTaggedSize;
+ const int kLargeObjectSize = 8 * KB;
+
+ for (int i = 0; i < kNumIterations; i++) {
+ Address address = allocator->AllocateOrFail(
+ kObjectSize, AllocationAlignment::kWordAligned,
+ AllocationOrigin::kRuntime);
+ heap->CreateFillerObjectAtBackground(
+ address, kObjectSize, ClearFreedMemoryMode::kDontClearFreedMemory);
+ address = allocator->AllocateOrFail(kLargeObjectSize,
+ AllocationAlignment::kWordAligned,
+ AllocationOrigin::kRuntime);
+ heap->CreateFillerObjectAtBackground(
+ address, kLargeObjectSize, ClearFreedMemoryMode::kDontClearFreedMemory);
+ if (i % 10 == 0) {
+ local_heap.Safepoint();
+ }
+ }
+
+ Schedule(isolate_);
+}
+
+// static
+void StressConcurrentAllocatorTask::Schedule(Isolate* isolate) {
+ CHECK(FLAG_local_heaps && FLAG_concurrent_allocation);
+ auto task = std::make_unique<StressConcurrentAllocatorTask>(isolate);
+ const double kDelayInSeconds = 0.1;
+ V8::GetCurrentPlatform()->CallDelayedOnWorkerThread(std::move(task),
+ kDelayInSeconds);
+}
+
Address ConcurrentAllocator::PerformCollectionAndAllocateAgain(
int object_size, AllocationAlignment alignment, AllocationOrigin origin) {
Heap* heap = local_heap_->heap();
@@ -39,5 +79,43 @@ void ConcurrentAllocator::MakeLinearAllocationAreaIterable() {
lab_.MakeIterable();
}
+void ConcurrentAllocator::MarkLinearAllocationAreaBlack() {
+ Address top = lab_.top();
+ Address limit = lab_.limit();
+
+ if (top != kNullAddress && top != limit) {
+ Page::FromAllocationAreaAddress(top)->CreateBlackAreaBackground(top, limit);
+ }
+}
+
+void ConcurrentAllocator::UnmarkLinearAllocationArea() {
+ Address top = lab_.top();
+ Address limit = lab_.limit();
+
+ if (top != kNullAddress && top != limit) {
+ Page::FromAllocationAreaAddress(top)->DestroyBlackAreaBackground(top,
+ limit);
+ }
+}
+
+AllocationResult ConcurrentAllocator::AllocateOutsideLab(
+ int object_size, AllocationAlignment alignment, AllocationOrigin origin) {
+ auto result = space_->SlowGetLinearAllocationAreaBackground(
+ local_heap_, object_size, object_size, alignment, origin);
+
+ if (result) {
+ HeapObject object = HeapObject::FromAddress(result->first);
+
+ if (local_heap_->heap()->incremental_marking()->black_allocation()) {
+ local_heap_->heap()->incremental_marking()->MarkBlackBackground(
+ object, object_size);
+ }
+
+ return AllocationResult(object);
+ } else {
+ return AllocationResult::Retry(OLD_SPACE);
+ }
+}
+
} // namespace internal
} // namespace v8