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

Side by Side Diff: third_party/WebKit/Source/platform/heap/PagePool.cpp

Issue 2684633004: Remove orphaned pages from Oilpan (Closed)
Patch Set: temp Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/heap/PagePool.h" 5 #include "platform/heap/PagePool.h"
6 6
7 #include "platform/heap/Heap.h" 7 #include "platform/heap/Heap.h"
8 #include "platform/heap/PageMemory.h" 8 #include "platform/heap/PageMemory.h"
9 #include "wtf/Assertions.h" 9 #include "wtf/Assertions.h"
10 10
(...skipping 30 matching lines...) Expand all
41 delete entry; 41 delete entry;
42 if (memory->commit()) 42 if (memory->commit())
43 return memory; 43 return memory;
44 44
45 // We got some memory, but failed to commit it, try again. 45 // We got some memory, but failed to commit it, try again.
46 delete memory; 46 delete memory;
47 } 47 }
48 return nullptr; 48 return nullptr;
49 } 49 }
50 50
51 OrphanedPagePool::~OrphanedPagePool() {
52 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) {
53 while (PoolEntry* entry = m_pool[index]) {
54 m_pool[index] = entry->next;
55 BasePage* page = entry->data;
56 delete entry;
57 PageMemory* memory = page->storage();
58 ASSERT(memory);
59 page->~BasePage();
60 delete memory;
61 }
62 }
63 }
64
65 void OrphanedPagePool::addOrphanedPage(int index, BasePage* page) {
66 page->markOrphaned();
67 PoolEntry* entry = new PoolEntry(page, m_pool[index]);
68 m_pool[index] = entry;
69 }
70
71 NO_SANITIZE_ADDRESS
72 void OrphanedPagePool::decommitOrphanedPages() {
73 ASSERT(ThreadState::current()->isInGC());
74 ASSERT(ThreadState::current()->heap().isAtSafePoint());
75
76 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) {
77 PoolEntry* entry = m_pool[index];
78 PoolEntry** prevNext = &m_pool[index];
79 while (entry) {
80 BasePage* page = entry->data;
81 // Check if we should reuse the memory or just free it.
82 // Large object memory is not reused but freed, normal blink heap
83 // pages are reused.
84 // NOTE: We call the destructor before freeing or adding to the
85 // free page pool.
86 PageMemory* memory = page->storage();
87 if (page->isLargeObjectPage()) {
88 page->~BasePage();
89 delete memory;
90 } else {
91 page->~BasePage();
92 clearMemory(memory);
93 ThreadHeap::mainThreadHeap()->getFreePagePool()->addFreePage(index,
94 memory);
95 }
96
97 PoolEntry* deadEntry = entry;
98 entry = entry->next;
99 *prevNext = entry;
100 delete deadEntry;
101 }
102 }
103 }
104
105 // Make the compiler think that something is going on there.
106 static inline void breakOptimization(void* arg) {
107 #if !defined(_WIN32) || defined(__clang__)
108 __asm__ __volatile__("" : : "r"(arg) : "memory");
109 #endif
110 }
111
112 NO_SANITIZE_ADDRESS
113 void OrphanedPagePool::asanDisabledMemset(Address address,
114 char value,
115 size_t size) {
116 // Don't use memset when running with ASan since this needs to zap
117 // poisoned memory as well and the NO_SANITIZE_ADDRESS annotation
118 // only works for code in this method and not for calls to memset.
119 for (Address current = address; current < address + size; ++current) {
120 breakOptimization(current);
121 *current = value;
122 }
123 }
124
125 void OrphanedPagePool::clearMemory(PageMemory* memory) {
126 asanDisabledMemset(memory->writableStart(), 0, blinkPagePayloadSize());
127 }
128
129 #if DCHECK_IS_ON()
130 bool OrphanedPagePool::contains(void* object) {
131 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) {
132 for (PoolEntry* entry = m_pool[index]; entry; entry = entry->next) {
133 BasePage* page = entry->data;
134 if (page->contains(reinterpret_cast<Address>(object)))
135 return true;
136 }
137 }
138 return false;
139 }
140 #endif
141
142 } // namespace blink 51 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/PagePool.h ('k') | third_party/WebKit/Source/platform/heap/PersistentNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698