| 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 "config.h" |    5 #include "config.h" | 
|    6 #include "platform/heap/PagePool.h" |    6 #include "platform/heap/PagePool.h" | 
|    7  |    7  | 
|    8 #include "platform/heap/Heap.h" |    8 #include "platform/heap/Heap.h" | 
|    9 #include "platform/heap/PageMemory.h" |    9 #include "platform/heap/PageMemory.h" | 
|   10 #include "wtf/Assertions.h" |   10 #include "wtf/Assertions.h" | 
|   11  |   11  | 
|   12 namespace blink { |   12 namespace blink { | 
|   13  |   13  | 
|   14 FreePagePool::~FreePagePool() |   14 FreePagePool::~FreePagePool() | 
|   15 { |   15 { | 
|   16     for (int index = 0; index < ThreadState::NumberOfHeaps; ++index) { |   16     for (int index = 0; index < BlinkGC::NumberOfHeaps; ++index) { | 
|   17         while (PoolEntry* entry = m_pool[index]) { |   17         while (PoolEntry* entry = m_pool[index]) { | 
|   18             m_pool[index] = entry->next; |   18             m_pool[index] = entry->next; | 
|   19             PageMemory* memory = entry->data; |   19             PageMemory* memory = entry->data; | 
|   20             ASSERT(memory); |   20             ASSERT(memory); | 
|   21             delete memory; |   21             delete memory; | 
|   22             delete entry; |   22             delete entry; | 
|   23         } |   23         } | 
|   24     } |   24     } | 
|   25 } |   25 } | 
|   26  |   26  | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|   47             return memory; |   47             return memory; | 
|   48  |   48  | 
|   49         // We got some memory, but failed to commit it, try again. |   49         // We got some memory, but failed to commit it, try again. | 
|   50         delete memory; |   50         delete memory; | 
|   51     } |   51     } | 
|   52     return nullptr; |   52     return nullptr; | 
|   53 } |   53 } | 
|   54  |   54  | 
|   55 OrphanedPagePool::~OrphanedPagePool() |   55 OrphanedPagePool::~OrphanedPagePool() | 
|   56 { |   56 { | 
|   57     for (int index = 0; index < ThreadState::NumberOfHeaps; ++index) { |   57     for (int index = 0; index < BlinkGC::NumberOfHeaps; ++index) { | 
|   58         while (PoolEntry* entry = m_pool[index]) { |   58         while (PoolEntry* entry = m_pool[index]) { | 
|   59             m_pool[index] = entry->next; |   59             m_pool[index] = entry->next; | 
|   60             BasePage* page = entry->data; |   60             BasePage* page = entry->data; | 
|   61             delete entry; |   61             delete entry; | 
|   62             PageMemory* memory = page->storage(); |   62             PageMemory* memory = page->storage(); | 
|   63             ASSERT(memory); |   63             ASSERT(memory); | 
|   64             page->~BasePage(); |   64             page->~BasePage(); | 
|   65             delete memory; |   65             delete memory; | 
|   66         } |   66         } | 
|   67     } |   67     } | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|   78 void OrphanedPagePool::decommitOrphanedPages() |   78 void OrphanedPagePool::decommitOrphanedPages() | 
|   79 { |   79 { | 
|   80     ASSERT(ThreadState::current()->isInGC()); |   80     ASSERT(ThreadState::current()->isInGC()); | 
|   81  |   81  | 
|   82 #if ENABLE(ASSERT) |   82 #if ENABLE(ASSERT) | 
|   83     // No locking needed as all threads are at safepoints at this point in time. |   83     // No locking needed as all threads are at safepoints at this point in time. | 
|   84     for (ThreadState* state : ThreadState::attachedThreads()) |   84     for (ThreadState* state : ThreadState::attachedThreads()) | 
|   85         ASSERT(state->isAtSafePoint()); |   85         ASSERT(state->isAtSafePoint()); | 
|   86 #endif |   86 #endif | 
|   87  |   87  | 
|   88     for (int index = 0; index < ThreadState::NumberOfHeaps; ++index) { |   88     for (int index = 0; index < BlinkGC::NumberOfHeaps; ++index) { | 
|   89         PoolEntry* entry = m_pool[index]; |   89         PoolEntry* entry = m_pool[index]; | 
|   90         PoolEntry** prevNext = &m_pool[index]; |   90         PoolEntry** prevNext = &m_pool[index]; | 
|   91         while (entry) { |   91         while (entry) { | 
|   92             BasePage* page = entry->data; |   92             BasePage* page = entry->data; | 
|   93             // Check if we should reuse the memory or just free it. |   93             // Check if we should reuse the memory or just free it. | 
|   94             // Large object memory is not reused but freed, normal blink heap |   94             // Large object memory is not reused but freed, normal blink heap | 
|   95             // pages are reused. |   95             // pages are reused. | 
|   96             // NOTE: We call the destructor before freeing or adding to the |   96             // NOTE: We call the destructor before freeing or adding to the | 
|   97             // free page pool. |   97             // free page pool. | 
|   98             PageMemory* memory = page->storage(); |   98             PageMemory* memory = page->storage(); | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  133 } |  133 } | 
|  134  |  134  | 
|  135 void OrphanedPagePool::clearMemory(PageMemory* memory) |  135 void OrphanedPagePool::clearMemory(PageMemory* memory) | 
|  136 { |  136 { | 
|  137     asanDisabledMemset(memory->writableStart(), 0, blinkPagePayloadSize()); |  137     asanDisabledMemset(memory->writableStart(), 0, blinkPagePayloadSize()); | 
|  138 } |  138 } | 
|  139  |  139  | 
|  140 #if ENABLE(ASSERT) |  140 #if ENABLE(ASSERT) | 
|  141 bool OrphanedPagePool::contains(void* object) |  141 bool OrphanedPagePool::contains(void* object) | 
|  142 { |  142 { | 
|  143     for (int index = 0; index < ThreadState::NumberOfHeaps; ++index) { |  143     for (int index = 0; index < BlinkGC::NumberOfHeaps; ++index) { | 
|  144         for (PoolEntry* entry = m_pool[index]; entry; entry = entry->next) { |  144         for (PoolEntry* entry = m_pool[index]; entry; entry = entry->next) { | 
|  145             BasePage* page = entry->data; |  145             BasePage* page = entry->data; | 
|  146             if (page->contains(reinterpret_cast<Address>(object))) |  146             if (page->contains(reinterpret_cast<Address>(object))) | 
|  147                 return true; |  147                 return true; | 
|  148         } |  148         } | 
|  149     } |  149     } | 
|  150     return false; |  150     return false; | 
|  151 } |  151 } | 
|  152 #endif |  152 #endif | 
|  153  |  153  | 
|  154 } // namespace blink |  154 } // namespace blink | 
| OLD | NEW |