Chromium Code Reviews| 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 "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/ThreadingPrimitives.h" | 10 #include "wtf/ThreadingPrimitives.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class BasePage; | |
| 15 class PageMemory; | 14 class PageMemory; |
| 16 | 15 |
| 17 template <typename DataType> | 16 template <typename DataType> |
|
sof
2017/02/08 11:58:08
we can drop the parameterization of PagePool<> now
haraken
2017/02/08 11:59:54
Good point. Let me do that in a follow-up.
| |
| 18 class PagePool { | 17 class PagePool { |
| 19 USING_FAST_MALLOC(PagePool); | 18 USING_FAST_MALLOC(PagePool); |
| 20 | 19 |
| 21 protected: | 20 protected: |
| 22 PagePool() { | 21 PagePool() { |
| 23 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) | 22 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) |
| 24 m_pool[i] = nullptr; | 23 m_pool[i] = nullptr; |
| 25 } | 24 } |
| 26 | 25 |
| 27 class PoolEntry { | 26 class PoolEntry { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 48 class FreePagePool : public PagePool<PageMemory> { | 47 class FreePagePool : public PagePool<PageMemory> { |
| 49 public: | 48 public: |
| 50 ~FreePagePool(); | 49 ~FreePagePool(); |
| 51 void addFreePage(int, PageMemory*); | 50 void addFreePage(int, PageMemory*); |
| 52 PageMemory* takeFreePage(int); | 51 PageMemory* takeFreePage(int); |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 Mutex m_mutex[BlinkGC::NumberOfArenas]; | 54 Mutex m_mutex[BlinkGC::NumberOfArenas]; |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 class OrphanedPagePool : public PagePool<BasePage> { | |
| 59 public: | |
| 60 // The orphaned zap value must be zero in the lowest bits to allow for | |
| 61 // using the mark bit when tracing. | |
| 62 static const uint8_t orphanedZapValue = 0xdc; | |
| 63 | |
| 64 ~OrphanedPagePool(); | |
| 65 void addOrphanedPage(int, BasePage*); | |
| 66 void decommitOrphanedPages(); | |
| 67 #if DCHECK_IS_ON() | |
| 68 bool contains(void*); | |
| 69 #endif | |
| 70 | |
| 71 // For orphaned pages, we need to memset with ASan disabled, because | |
| 72 // the orphaned pages can still contain poisoned memory or annotated | |
| 73 // container but we want to forcibly clear the orphaned pages without | |
| 74 // causing ASan errors. asanDisabledMemset must not be used for | |
| 75 // non-orphaned pages. | |
| 76 static void asanDisabledMemset(Address, char, size_t); | |
| 77 | |
| 78 private: | |
| 79 void clearMemory(PageMemory*); | |
| 80 }; | |
| 81 | |
| 82 } // namespace blink | 57 } // namespace blink |
| 83 | 58 |
| 84 #endif | 59 #endif |
| OLD | NEW |