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/Atomics.h" |
10 #include "wtf/allocator/PageAllocator.h" | 10 #include "wtf/allocator/PageAllocator.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 markPageUnused(page); | 52 markPageUnused(page); |
53 if (!atomicDecrement(&m_numPages)) | 53 if (!atomicDecrement(&m_numPages)) |
54 delete this; | 54 delete this; |
55 } | 55 } |
56 | 56 |
57 // TODO(haraken): Like partitionOutOfMemoryWithLotsOfUncommitedPages(), | 57 // TODO(haraken): Like partitionOutOfMemoryWithLotsOfUncommitedPages(), |
58 // we should probably have a way to distinguish physical memory OOM from | 58 // we should probably have a way to distinguish physical memory OOM from |
59 // virtual address space OOM. | 59 // virtual address space OOM. |
60 static NEVER_INLINE void blinkGCOutOfMemory() | 60 static NEVER_INLINE void blinkGCOutOfMemory() |
61 { | 61 { |
62 IMMEDIATE_CRASH(); | 62 OOM_CRASH(); |
63 } | 63 } |
64 | 64 |
65 PageMemoryRegion* PageMemoryRegion::allocate(size_t size, unsigned numPages, Reg
ionTree* regionTree) | 65 PageMemoryRegion* PageMemoryRegion::allocate(size_t size, unsigned numPages, Reg
ionTree* regionTree) |
66 { | 66 { |
67 // Round size up to the allocation granularity. | 67 // Round size up to the allocation granularity. |
68 size = (size + WTF::kPageAllocationGranularityOffsetMask) & WTF::kPageAlloca
tionGranularityBaseMask; | 68 size = (size + WTF::kPageAllocationGranularityOffsetMask) & WTF::kPageAlloca
tionGranularityBaseMask; |
69 Address base = static_cast<Address>(WTF::allocPages(nullptr, size, blinkPage
Size, WTF::PageInaccessible)); | 69 Address base = static_cast<Address>(WTF::allocPages(nullptr, size, blinkPage
Size, WTF::PageInaccessible)); |
70 if (!base) | 70 if (!base) |
71 blinkGCOutOfMemory(); | 71 blinkGCOutOfMemory(); |
72 return new PageMemoryRegion(base, size, numPages, regionTree); | 72 return new PageMemoryRegion(base, size, numPages, regionTree); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Overallocate by 2 times OS page size to have space for a | 180 // Overallocate by 2 times OS page size to have space for a |
181 // guard page at the beginning and end of blink heap page. | 181 // guard page at the beginning and end of blink heap page. |
182 size_t allocationSize = payloadSize + 2 * blinkGuardPageSize; | 182 size_t allocationSize = payloadSize + 2 * blinkGuardPageSize; |
183 PageMemoryRegion* pageMemoryRegion = PageMemoryRegion::allocateLargePage(all
ocationSize, regionTree); | 183 PageMemoryRegion* pageMemoryRegion = PageMemoryRegion::allocateLargePage(all
ocationSize, regionTree); |
184 PageMemory* storage = setupPageMemoryInRegion(pageMemoryRegion, 0, payloadSi
ze); | 184 PageMemory* storage = setupPageMemoryInRegion(pageMemoryRegion, 0, payloadSi
ze); |
185 RELEASE_ASSERT(storage->commit()); | 185 RELEASE_ASSERT(storage->commit()); |
186 return storage; | 186 return storage; |
187 } | 187 } |
188 | 188 |
189 } // namespace blink | 189 } // namespace blink |
OLD | NEW |