diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:20:33 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:28:57 +0000 |
commit | d17ea114e5ef69ad5d5d7413280a13e6428098aa (patch) | |
tree | 2c01a75df69f30d27b1432467cfe7c1467a498da /chromium/third_party/blink/renderer/platform/heap/page_pool.cc | |
parent | 8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (diff) | |
download | qtwebengine-chromium-d17ea114e5ef69ad5d5d7413280a13e6428098aa.tar.gz |
BASELINE: Update Chromium to 67.0.3396.47
Change-Id: Idcb1341782e417561a2473eeecc82642dafda5b7
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/heap/page_pool.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/heap/page_pool.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/platform/heap/page_pool.cc b/chromium/third_party/blink/renderer/platform/heap/page_pool.cc new file mode 100644 index 00000000000..100a7803614 --- /dev/null +++ b/chromium/third_party/blink/renderer/platform/heap/page_pool.cc @@ -0,0 +1,55 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/platform/heap/page_pool.h" + +#include "third_party/blink/renderer/platform/heap/heap.h" +#include "third_party/blink/renderer/platform/heap/page_memory.h" +#include "third_party/blink/renderer/platform/wtf/assertions.h" + +namespace blink { + +PagePool::PagePool() { + for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i) { + pool_[i] = nullptr; + } +} + +PagePool::~PagePool() { + for (int index = 0; index < BlinkGC::kNumberOfArenas; ++index) { + while (PoolEntry* entry = pool_[index]) { + pool_[index] = entry->next; + PageMemory* memory = entry->data; + DCHECK(memory); + delete memory; + delete entry; + } + } +} + +void PagePool::Add(int index, PageMemory* memory) { + // When adding a page to the pool we decommit it to ensure it is unused + // while in the pool. This also allows the physical memory, backing the + // page, to be given back to the OS. + memory->Decommit(); + PoolEntry* entry = new PoolEntry(memory, pool_[index]); + pool_[index] = entry; +} + +PageMemory* PagePool::Take(int index) { + while (PoolEntry* entry = pool_[index]) { + pool_[index] = entry->next; + PageMemory* memory = entry->data; + DCHECK(memory); + delete entry; + if (memory->Commit()) + return memory; + + // We got some memory, but failed to commit it, try again. + delete memory; + } + return nullptr; +} + +} // namespace blink |