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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/PageAllocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 { 1097 {
1098 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(payload()); 1098 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(payload());
1099 return header->isFree() && header->size() == payloadSize(); 1099 return header->isFree() && header->size() == payloadSize();
1100 } 1100 }
1101 1101
1102 void NormalPage::removeFromHeap() 1102 void NormalPage::removeFromHeap()
1103 { 1103 {
1104 heapForNormalPage()->freePage(this); 1104 heapForNormalPage()->freePage(this);
1105 } 1105 }
1106 1106
1107 static void discardPages(Address begin, Address end)
1108 {
1109 uintptr_t beginAddress = WTF::roundUpToSystemPage(reinterpret_cast<uintptr_t >(begin));
1110 uintptr_t endAddress = WTF::roundDownToSystemPage(reinterpret_cast<uintptr_t >(end));
1111 if (beginAddress < endAddress)
sof 2016/02/04 10:20:04 I understand the concern; for other live objects o
Yuta Kitamura 2016/02/04 10:50:11 We could make the condition a little bit tighter,
1112 WTF::discardSystemPages(reinterpret_cast<void*>(beginAddress), endAddres s - beginAddress);
1113 }
1114
1107 void NormalPage::sweep() 1115 void NormalPage::sweep()
1108 { 1116 {
1109 size_t markedObjectSize = 0; 1117 size_t markedObjectSize = 0;
1110 Address startOfGap = payload(); 1118 Address startOfGap = payload();
1111 for (Address headerAddress = startOfGap; headerAddress < payloadEnd(); ) { 1119 for (Address headerAddress = startOfGap; headerAddress < payloadEnd(); ) {
1112 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); 1120 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress);
1113 ASSERT(header->size() > 0); 1121 ASSERT(header->size() > 0);
1114 ASSERT(header->size() < blinkPagePayloadSize()); 1122 ASSERT(header->size() < blinkPagePayloadSize());
1115 1123
1116 if (header->isPromptlyFreed()) 1124 if (header->isPromptlyFreed())
(...skipping 22 matching lines...) Expand all
1139 // an error if the finalizer touches any other on-heap object that 1147 // an error if the finalizer touches any other on-heap object that
1140 // die at the same GC cycle. 1148 // die at the same GC cycle.
1141 ASAN_UNPOISON_MEMORY_REGION(payload, payloadSize); 1149 ASAN_UNPOISON_MEMORY_REGION(payload, payloadSize);
1142 header->finalize(payload, payloadSize); 1150 header->finalize(payload, payloadSize);
1143 // This memory will be added to the freelist. Maintain the invariant 1151 // This memory will be added to the freelist. Maintain the invariant
1144 // that memory on the freelist is zero filled. 1152 // that memory on the freelist is zero filled.
1145 SET_MEMORY_INACCESSIBLE(headerAddress, size); 1153 SET_MEMORY_INACCESSIBLE(headerAddress, size);
1146 headerAddress += size; 1154 headerAddress += size;
1147 continue; 1155 continue;
1148 } 1156 }
1149 if (startOfGap != headerAddress) 1157 if (startOfGap != headerAddress) {
1150 heapForNormalPage()->addToFreeList(startOfGap, headerAddress - start OfGap); 1158 heapForNormalPage()->addToFreeList(startOfGap, headerAddress - start OfGap);
1159 #if !ENABLE(ASSERT) && !defined(LEAK_SANITIZER) && !defined(ADDRESS_SANITIZER)
1160 discardPages(startOfGap, headerAddress);
1161 #endif
1162 }
1151 header->unmark(); 1163 header->unmark();
1152 headerAddress += header->size(); 1164 headerAddress += header->size();
1153 markedObjectSize += header->size(); 1165 markedObjectSize += header->size();
1154 startOfGap = headerAddress; 1166 startOfGap = headerAddress;
1155 } 1167 }
1156 if (startOfGap != payloadEnd()) 1168 if (startOfGap != payloadEnd()) {
1157 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap ); 1169 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap );
1170 #if !ENABLE(ASSERT) && !defined(LEAK_SANITIZER) && !defined(ADDRESS_SANITIZER)
1171 discardPages(startOfGap, payloadEnd());
1172 #endif
1173 }
1158 1174
1159 if (markedObjectSize) 1175 if (markedObjectSize)
1160 Heap::increaseMarkedObjectSize(markedObjectSize); 1176 Heap::increaseMarkedObjectSize(markedObjectSize);
1161 } 1177 }
1162 1178
1163 void NormalPage::makeConsistentForGC() 1179 void NormalPage::makeConsistentForGC()
1164 { 1180 {
1165 size_t markedObjectSize = 0; 1181 size_t markedObjectSize = 0;
1166 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { 1182 for (Address headerAddress = payload(); headerAddress < payloadEnd();) {
1167 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); 1183 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1590
1575 m_hasEntries = true; 1591 m_hasEntries = true;
1576 size_t index = hash(address); 1592 size_t index = hash(address);
1577 ASSERT(!(index & 1)); 1593 ASSERT(!(index & 1));
1578 Address cachePage = roundToBlinkPageStart(address); 1594 Address cachePage = roundToBlinkPageStart(address);
1579 m_entries[index + 1] = m_entries[index]; 1595 m_entries[index + 1] = m_entries[index];
1580 m_entries[index] = cachePage; 1596 m_entries[index] = cachePage;
1581 } 1597 }
1582 1598
1583 } // namespace blink 1599 } // namespace blink
OLDNEW
« 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