| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 { | 70 { |
| 71 page->markOrphaned(); | 71 page->markOrphaned(); |
| 72 PoolEntry* entry = new PoolEntry(page, m_pool[index]); | 72 PoolEntry* entry = new PoolEntry(page, m_pool[index]); |
| 73 m_pool[index] = entry; | 73 m_pool[index] = entry; |
| 74 } | 74 } |
| 75 | 75 |
| 76 NO_SANITIZE_ADDRESS | 76 NO_SANITIZE_ADDRESS |
| 77 void OrphanedPagePool::decommitOrphanedPages() | 77 void OrphanedPagePool::decommitOrphanedPages() |
| 78 { | 78 { |
| 79 ASSERT(ThreadState::current()->isInGC()); | 79 ASSERT(ThreadState::current()->isInGC()); |
| 80 | 80 ASSERT(ThreadState::current()->heap().isAtSafePoint()); |
| 81 #if ENABLE(ASSERT) | |
| 82 // No locking needed as all threads are at safepoints at this point in time. | |
| 83 for (ThreadState* state : ThreadState::attachedThreads()) | |
| 84 ASSERT(state->isAtSafePoint()); | |
| 85 #endif | |
| 86 | 81 |
| 87 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) { | 82 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) { |
| 88 PoolEntry* entry = m_pool[index]; | 83 PoolEntry* entry = m_pool[index]; |
| 89 PoolEntry** prevNext = &m_pool[index]; | 84 PoolEntry** prevNext = &m_pool[index]; |
| 90 while (entry) { | 85 while (entry) { |
| 91 BasePage* page = entry->data; | 86 BasePage* page = entry->data; |
| 92 // Check if we should reuse the memory or just free it. | 87 // Check if we should reuse the memory or just free it. |
| 93 // Large object memory is not reused but freed, normal blink heap | 88 // Large object memory is not reused but freed, normal blink heap |
| 94 // pages are reused. | 89 // pages are reused. |
| 95 // NOTE: We call the destructor before freeing or adding to the | 90 // NOTE: We call the destructor before freeing or adding to the |
| 96 // free page pool. | 91 // free page pool. |
| 97 PageMemory* memory = page->storage(); | 92 PageMemory* memory = page->storage(); |
| 98 if (page->isLargeObjectPage()) { | 93 if (page->isLargeObjectPage()) { |
| 99 page->~BasePage(); | 94 page->~BasePage(); |
| 100 delete memory; | 95 delete memory; |
| 101 } else { | 96 } else { |
| 102 page->~BasePage(); | 97 page->~BasePage(); |
| 103 clearMemory(memory); | 98 clearMemory(memory); |
| 104 ThreadHeap::getFreePagePool()->addFreePage(index, memory); | 99 ThreadHeap::mainThreadHeap()->getFreePagePool()->addFreePage(ind
ex, memory); |
| 105 } | 100 } |
| 106 | 101 |
| 107 PoolEntry* deadEntry = entry; | 102 PoolEntry* deadEntry = entry; |
| 108 entry = entry->next; | 103 entry = entry->next; |
| 109 *prevNext = entry; | 104 *prevNext = entry; |
| 110 delete deadEntry; | 105 delete deadEntry; |
| 111 } | 106 } |
| 112 } | 107 } |
| 113 } | 108 } |
| 114 | 109 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 144 BasePage* page = entry->data; | 139 BasePage* page = entry->data; |
| 145 if (page->contains(reinterpret_cast<Address>(object))) | 140 if (page->contains(reinterpret_cast<Address>(object))) |
| 146 return true; | 141 return true; |
| 147 } | 142 } |
| 148 } | 143 } |
| 149 return false; | 144 return false; |
| 150 } | 145 } |
| 151 #endif | 146 #endif |
| 152 | 147 |
| 153 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |