Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: third_party/WebKit/Source/platform/heap/PagePool.h

Issue 1754183002: Rename BaseHeap to BaseArena (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 14 class BasePage;
15 class PageMemory; 15 class PageMemory;
16 16
17 template<typename DataType> 17 template<typename DataType>
18 class PagePool { 18 class PagePool {
19 USING_FAST_MALLOC(PagePool); 19 USING_FAST_MALLOC(PagePool);
20 protected: 20 protected:
21 PagePool() 21 PagePool()
22 { 22 {
23 for (int i = 0; i < BlinkGC::NumberOfHeaps; ++i) 23 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i)
24 m_pool[i] = nullptr; 24 m_pool[i] = nullptr;
25 } 25 }
26 26
27 class PoolEntry { 27 class PoolEntry {
28 USING_FAST_MALLOC(PoolEntry); 28 USING_FAST_MALLOC(PoolEntry);
29 public: 29 public:
30 PoolEntry(DataType* data, PoolEntry* next) 30 PoolEntry(DataType* data, PoolEntry* next)
31 : data(data) 31 : data(data)
32 , next(next) 32 , next(next)
33 { } 33 { }
34 34
35 DataType* data; 35 DataType* data;
36 PoolEntry* next; 36 PoolEntry* next;
37 }; 37 };
38 38
39 PoolEntry* m_pool[BlinkGC::NumberOfHeaps]; 39 PoolEntry* m_pool[BlinkGC::NumberOfArenas];
40 }; 40 };
41 41
42 // Once pages have been used for one type of thread heap they will never be 42 // Once pages have been used for one type of thread heap they will never be
43 // reused for another type of thread heap. Instead of unmapping, we add the 43 // reused for another type of thread heap. Instead of unmapping, we add the
44 // pages to a pool of pages to be reused later by a thread heap of the same 44 // pages to a pool of pages to be reused later by a thread heap of the same
45 // type. This is done as a security feature to avoid type confusion. The 45 // type. This is done as a security feature to avoid type confusion. The
46 // heaps are type segregated by having separate thread heaps for different 46 // heaps are type segregated by having separate thread arenas for different
47 // types of objects. Holding on to pages ensures that the same virtual address 47 // types of objects. Holding on to pages ensures that the same virtual address
48 // space cannot be used for objects of another type than the type contained 48 // space cannot be used for objects of another type than the type contained
49 // in this page to begin with. 49 // in this page to begin with.
50 class FreePagePool : public PagePool<PageMemory> { 50 class FreePagePool : public PagePool<PageMemory> {
51 public: 51 public:
52 ~FreePagePool(); 52 ~FreePagePool();
53 void addFreePage(int, PageMemory*); 53 void addFreePage(int, PageMemory*);
54 PageMemory* takeFreePage(int); 54 PageMemory* takeFreePage(int);
55 55
56 private: 56 private:
57 Mutex m_mutex[BlinkGC::NumberOfHeaps]; 57 Mutex m_mutex[BlinkGC::NumberOfArenas];
58 }; 58 };
59 59
60 class OrphanedPagePool : public PagePool<BasePage> { 60 class OrphanedPagePool : public PagePool<BasePage> {
61 public: 61 public:
62 // The orphaned zap value must be zero in the lowest bits to allow for 62 // The orphaned zap value must be zero in the lowest bits to allow for
63 // using the mark bit when tracing. 63 // using the mark bit when tracing.
64 static const uint8_t orphanedZapValue = 0xdc; 64 static const uint8_t orphanedZapValue = 0xdc;
65 65
66 ~OrphanedPagePool(); 66 ~OrphanedPagePool();
67 void addOrphanedPage(int, BasePage*); 67 void addOrphanedPage(int, BasePage*);
68 void decommitOrphanedPages(); 68 void decommitOrphanedPages();
69 #if ENABLE(ASSERT) 69 #if ENABLE(ASSERT)
70 bool contains(void*); 70 bool contains(void*);
71 #endif 71 #endif
72 72
73 // For orphaned pages, we need to memset with ASan disabled, because 73 // For orphaned pages, we need to memset with ASan disabled, because
74 // the orphaned pages can still contain poisoned memory or annotated 74 // the orphaned pages can still contain poisoned memory or annotated
75 // container but we want to forcibly clear the orphaned pages without 75 // container but we want to forcibly clear the orphaned pages without
76 // causing ASan errors. asanDisabledMemset must not be used for 76 // causing ASan errors. asanDisabledMemset must not be used for
77 // non-orphaned pages. 77 // non-orphaned pages.
78 static void asanDisabledMemset(Address, char, size_t); 78 static void asanDisabledMemset(Address, char, size_t);
79 private: 79 private:
80 void clearMemory(PageMemory*); 80 void clearMemory(PageMemory*);
81 }; 81 };
82 82
83 } // namespace blink 83 } // namespace blink
84 84
85 #endif 85 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/MarkingVisitorImpl.h ('k') | third_party/WebKit/Source/platform/heap/PagePool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698