| 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 #ifndef PagePool_h | 5 #ifndef PagePool_h |
| 6 #define PagePool_h | 6 #define PagePool_h |
| 7 | 7 |
| 8 #include "platform/heap/ThreadState.h" | 8 #include "platform/heap/ThreadState.h" |
| 9 #include "platform/wtf/Allocator.h" | 9 #include "platform/wtf/Allocator.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class PageMemory; | 13 class PageMemory; |
| 14 | 14 |
| 15 enum class DecommitMemoryTiming { DecommitAsAppropriate, DecommitPromptly }; |
| 16 |
| 15 // Once pages have been used for one type of thread heap they will never be | 17 // Once pages have been used for one type of thread heap they will never be |
| 16 // reused for another type of thread heap. Instead of unmapping, we add the | 18 // reused for another type of thread heap. Instead of unmapping, we add the |
| 17 // pages to a pool of pages to be reused later by a thread heap of the same | 19 // pages to a pool of pages to be reused later by a thread heap of the same |
| 18 // type. This is done as a security feature to avoid type confusion. The | 20 // type. This is done as a security feature to avoid type confusion. The |
| 19 // heaps are type segregated by having separate thread arenas for different | 21 // heaps are type segregated by having separate thread arenas for different |
| 20 // types of objects. Holding on to pages ensures that the same virtual address | 22 // types of objects. Holding on to pages ensures that the same virtual address |
| 21 // space cannot be used for objects of another type than the type contained | 23 // space cannot be used for objects of another type than the type contained |
| 22 // in this page to begin with. | 24 // in this page to begin with. |
| 23 class PagePool { | 25 class PagePool { |
| 24 USING_FAST_MALLOC(PagePool); | 26 USING_FAST_MALLOC(PagePool); |
| 25 | 27 |
| 26 public: | 28 public: |
| 27 PagePool(); | 29 PagePool(); |
| 28 ~PagePool(); | 30 ~PagePool(); |
| 29 void Add(int, PageMemory*); | 31 |
| 32 void Add(int, |
| 33 PageMemory*, |
| 34 DecommitMemoryTiming = DecommitMemoryTiming::DecommitAsAppropriate); |
| 30 PageMemory* Take(int); | 35 PageMemory* Take(int); |
| 31 | 36 |
| 32 private: | 37 private: |
| 33 class PoolEntry { | 38 class PoolEntry { |
| 34 USING_FAST_MALLOC(PoolEntry); | 39 USING_FAST_MALLOC(PoolEntry); |
| 35 | 40 |
| 36 public: | 41 public: |
| 37 PoolEntry(PageMemory* data, PoolEntry* next) : data(data), next(next) {} | 42 PoolEntry(PageMemory* data, PoolEntry* next) : data(data), next(next) {} |
| 38 | 43 |
| 39 PageMemory* data; | 44 PageMemory* data; |
| 40 PoolEntry* next; | 45 PoolEntry* next; |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 PoolEntry* pool_[BlinkGC::kNumberOfArenas]; | 48 PoolEntry* pool_[BlinkGC::kNumberOfArenas]; |
| 44 }; | 49 }; |
| 45 | 50 |
| 46 } // namespace blink | 51 } // namespace blink |
| 47 | 52 |
| 48 #endif | 53 #endif |
| OLD | NEW |