| 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 "platform/wtf/Assertions.h" | 9 #include "platform/wtf/Assertions.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 while (PoolEntry* entry = pool_[index]) { | 21 while (PoolEntry* entry = pool_[index]) { |
| 22 pool_[index] = entry->next; | 22 pool_[index] = entry->next; |
| 23 PageMemory* memory = entry->data; | 23 PageMemory* memory = entry->data; |
| 24 DCHECK(memory); | 24 DCHECK(memory); |
| 25 delete memory; | 25 delete memory; |
| 26 delete entry; | 26 delete entry; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 void PagePool::Add(int index, PageMemory* memory) { | 31 void PagePool::Add(int index, |
| 32 PageMemory* memory, |
| 33 DecommitMemoryTiming decommit_hint) { |
| 32 // When adding a page to the pool we decommit it to ensure it is unused | 34 // When adding a page to the pool we decommit it to ensure it is unused |
| 33 // while in the pool. This also allows the physical memory, backing the | 35 // while in the pool. This also allows the physical memory, backing the |
| 34 // page, to be given back to the OS. | 36 // page, to be given back to the OS. |
| 35 memory->Decommit(); | 37 memory->Decommit(decommit_hint); |
| 36 PoolEntry* entry = new PoolEntry(memory, pool_[index]); | 38 PoolEntry* entry = new PoolEntry(memory, pool_[index]); |
| 37 pool_[index] = entry; | 39 pool_[index] = entry; |
| 38 } | 40 } |
| 39 | 41 |
| 40 PageMemory* PagePool::Take(int index) { | 42 PageMemory* PagePool::Take(int index) { |
| 41 while (PoolEntry* entry = pool_[index]) { | 43 while (PoolEntry* entry = pool_[index]) { |
| 42 pool_[index] = entry->next; | 44 pool_[index] = entry->next; |
| 43 PageMemory* memory = entry->data; | 45 PageMemory* memory = entry->data; |
| 44 DCHECK(memory); | 46 DCHECK(memory); |
| 45 delete entry; | 47 delete entry; |
| 46 if (memory->Commit()) | 48 if (memory->Commit()) |
| 47 return memory; | 49 return memory; |
| 48 | 50 |
| 49 // We got some memory, but failed to commit it, try again. | 51 // We got some memory, but failed to commit it, try again. |
| 50 delete memory; | 52 delete memory; |
| 51 } | 53 } |
| 52 return nullptr; | 54 return nullptr; |
| 53 } | 55 } |
| 54 | 56 |
| 55 } // namespace blink | 57 } // namespace blink |
| OLD | NEW |