OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/PageMemory.h" | 5 #include "platform/heap/PageMemory.h" |
6 | 6 |
7 #include "platform/heap/Heap.h" | 7 #include "platform/heap/Heap.h" |
8 #include "wtf/Assertions.h" | 8 #include "wtf/Assertions.h" |
| 9 #include "wtf/Atomics.h" |
9 #include "wtf/PageAllocator.h" | 10 #include "wtf/PageAllocator.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 void MemoryRegion::release() | 14 void MemoryRegion::release() |
14 { | 15 { |
15 WTF::freePages(m_base, m_size); | 16 WTF::freePages(m_base, m_size); |
16 } | 17 } |
17 | 18 |
18 bool MemoryRegion::commit() | 19 bool MemoryRegion::commit() |
(...skipping 18 matching lines...) Expand all Loading... |
37 for (size_t i = 0; i < blinkPagesPerRegion; ++i) | 38 for (size_t i = 0; i < blinkPagesPerRegion; ++i) |
38 m_inUse[i] = false; | 39 m_inUse[i] = false; |
39 } | 40 } |
40 | 41 |
41 PageMemoryRegion::~PageMemoryRegion() | 42 PageMemoryRegion::~PageMemoryRegion() |
42 { | 43 { |
43 Heap::removePageMemoryRegion(this); | 44 Heap::removePageMemoryRegion(this); |
44 release(); | 45 release(); |
45 } | 46 } |
46 | 47 |
| 48 void PageMemoryRegion::pageDeleted(Address page) |
| 49 { |
| 50 markPageUnused(page); |
| 51 if (!atomicDecrement(&m_numPages)) |
| 52 delete this; |
| 53 } |
| 54 |
47 // TODO(haraken): Like partitionOutOfMemoryWithLotsOfUncommitedPages(), | 55 // TODO(haraken): Like partitionOutOfMemoryWithLotsOfUncommitedPages(), |
48 // we should probably have a way to distinguish physical memory OOM from | 56 // we should probably have a way to distinguish physical memory OOM from |
49 // virtual address space OOM. | 57 // virtual address space OOM. |
50 static NEVER_INLINE void blinkGCOutOfMemory() | 58 static NEVER_INLINE void blinkGCOutOfMemory() |
51 { | 59 { |
52 IMMEDIATE_CRASH(); | 60 IMMEDIATE_CRASH(); |
53 } | 61 } |
54 | 62 |
55 PageMemoryRegion* PageMemoryRegion::allocate(size_t size, unsigned numPages) | 63 PageMemoryRegion* PageMemoryRegion::allocate(size_t size, unsigned numPages) |
56 { | 64 { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Overallocate by 2 times OS page size to have space for a | 164 // Overallocate by 2 times OS page size to have space for a |
157 // guard page at the beginning and end of blink heap page. | 165 // guard page at the beginning and end of blink heap page. |
158 size_t allocationSize = payloadSize + 2 * blinkGuardPageSize; | 166 size_t allocationSize = payloadSize + 2 * blinkGuardPageSize; |
159 PageMemoryRegion* pageMemoryRegion = PageMemoryRegion::allocateLargePage(all
ocationSize); | 167 PageMemoryRegion* pageMemoryRegion = PageMemoryRegion::allocateLargePage(all
ocationSize); |
160 PageMemory* storage = setupPageMemoryInRegion(pageMemoryRegion, 0, payloadSi
ze); | 168 PageMemory* storage = setupPageMemoryInRegion(pageMemoryRegion, 0, payloadSi
ze); |
161 RELEASE_ASSERT(storage->commit()); | 169 RELEASE_ASSERT(storage->commit()); |
162 return storage; | 170 return storage; |
163 } | 171 } |
164 | 172 |
165 } // namespace blink | 173 } // namespace blink |
OLD | NEW |