Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 1666083002: Oilpan: Discard unused system pages when sweeping NormalPageHeaps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | third_party/WebKit/Source/platform/testing/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/HeapPage.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapPage.cpp b/third_party/WebKit/Source/platform/heap/HeapPage.cpp
index 637100d5f8eb42d30327a9ce160010aaeeb1702a..f1b08ed21445652c2e29eae641ec83ee68d152d2 100644
--- a/third_party/WebKit/Source/platform/heap/HeapPage.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapPage.cpp
@@ -1104,19 +1104,29 @@ void NormalPage::removeFromHeap()
heapForNormalPage()->freePage(this);
}
+#if !ENABLE(ASSERT) && !defined(LEAK_SANITIZER) && !defined(ADDRESS_SANITIZER)
+static void discardPages(Address begin, Address end)
+{
+ uintptr_t beginAddress = WTF::roundUpToSystemPage(reinterpret_cast<uintptr_t>(begin));
+ uintptr_t endAddress = WTF::roundDownToSystemPage(reinterpret_cast<uintptr_t>(end));
+ if (beginAddress < endAddress)
+ WTF::discardSystemPages(reinterpret_cast<void*>(beginAddress), endAddress - beginAddress);
+}
+#endif
+
void NormalPage::sweep()
{
size_t markedObjectSize = 0;
Address startOfGap = payload();
for (Address headerAddress = startOfGap; headerAddress < payloadEnd(); ) {
HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAddress);
- ASSERT(header->size() > 0);
- ASSERT(header->size() < blinkPagePayloadSize());
+ size_t size = header->size();
+ ASSERT(size > 0);
+ ASSERT(size < blinkPagePayloadSize());
if (header->isPromptlyFreed())
- heapForNormalPage()->decreasePromptlyFreedSize(header->size());
+ heapForNormalPage()->decreasePromptlyFreedSize(size);
if (header->isFree()) {
- size_t size = header->size();
// Zero the memory in the free list header to maintain the
// invariant that memory on the free list is zero filled.
// The rest of the memory is already on the free list and is
@@ -1129,7 +1139,6 @@ void NormalPage::sweep()
ASSERT(header->checkHeader());
if (!header->isMarked()) {
- size_t size = header->size();
// This is a fast version of header->payloadSize().
size_t payloadSize = size - sizeof(HeapObjectHeader);
Address payload = header->payload();
@@ -1146,15 +1155,27 @@ void NormalPage::sweep()
headerAddress += size;
continue;
}
- if (startOfGap != headerAddress)
+ if (startOfGap != headerAddress) {
heapForNormalPage()->addToFreeList(startOfGap, headerAddress - startOfGap);
+#if !ENABLE(ASSERT) && !defined(LEAK_SANITIZER) && !defined(ADDRESS_SANITIZER)
+ // Discarding pages increases page faults and may regress performance.
+ // So we enable this only on low-RAM devices.
+ if (Heap::isLowEndDevice())
+ discardPages(startOfGap + sizeof(FreeListEntry), headerAddress);
+#endif
+ }
header->unmark();
- headerAddress += header->size();
- markedObjectSize += header->size();
+ headerAddress += size;
+ markedObjectSize += size;
startOfGap = headerAddress;
}
- if (startOfGap != payloadEnd())
+ if (startOfGap != payloadEnd()) {
heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap);
+#if !ENABLE(ASSERT) && !defined(LEAK_SANITIZER) && !defined(ADDRESS_SANITIZER)
+ if (Heap::isLowEndDevice())
+ discardPages(startOfGap + sizeof(FreeListEntry), payloadEnd());
+#endif
+ }
if (markedObjectSize)
Heap::increaseMarkedObjectSize(markedObjectSize);
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | third_party/WebKit/Source/platform/testing/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698