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

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 | « no previous file | third_party/WebKit/Source/wtf/PageAllocator.h » ('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..b48a6664253a2995b5cae78020a84df58da1e716 100644
--- a/third_party/WebKit/Source/platform/heap/HeapPage.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapPage.cpp
@@ -99,8 +99,17 @@ void HeapObjectHeader::zapMagic()
void HeapObjectHeader::finalize(Address object, size_t objectSize)
{
const GCInfo* gcInfo = Heap::gcInfo(gcInfoIndex());
- if (gcInfo->hasFinalizer())
+ if (!gcInfo) {
+ fprintf(stderr, "gcInfoIndex = %ld\n", gcInfoIndex());
+ RELEASE_ASSERT(0);
+ }
+ fprintf(stderr, "header=%p gcInfo=%p index=%ld\n", this, gcInfo, gcInfoIndex());
+ if (gcInfo->hasFinalizer()) {
haraken 2016/02/08 08:34:56 I crash here with the following log: header=0x307
+ fprintf(stderr, "hasFinalizer\n");
gcInfo->m_finalize(object);
+ } else {
+ fprintf(stderr, "not hasFinalizer\n");
+ }
ASAN_RETIRE_CONTAINER_ANNOTATION(object, objectSize);
}
@@ -1104,19 +1113,32 @@ 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));
+ fprintf(stderr, "trying to discard %p - %p\n", begin, end);
+ if (beginAddress < endAddress) {
+ WTF::discardSystemPages(reinterpret_cast<void*>(beginAddress), endAddress - beginAddress);
+ fprintf(stderr, "discarded %lx - %lx size=%ld\n", beginAddress, endAddress, 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 +1151,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 +1167,23 @@ 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)
+ discardPages(startOfGap, 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)
+ discardPages(startOfGap, payloadEnd());
+#endif
+ }
if (markedObjectSize)
Heap::increaseMarkedObjectSize(markedObjectSize);
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/PageAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698