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

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

Issue 1686943002: Oilpan: Decommit backing storage of CallbackStacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/CallbackStack.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CallbackStack_h 5 #ifndef CallbackStack_h
6 #define CallbackStack_h 6 #define CallbackStack_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/Assertions.h" 10 #include "wtf/Assertions.h"
(...skipping 23 matching lines...) Expand all
34 34
35 private: 35 private:
36 void* m_object; 36 void* m_object;
37 VisitorCallback m_callback; 37 VisitorCallback m_callback;
38 }; 38 };
39 39
40 CallbackStack(); 40 CallbackStack();
41 ~CallbackStack(); 41 ~CallbackStack();
42 42
43 void clear(); 43 void clear();
44 void decommit();
44 45
45 Item* allocateEntry(); 46 Item* allocateEntry();
46 Item* pop(); 47 Item* pop();
47 48
48 bool isEmpty() const; 49 bool isEmpty() const;
49 50
50 void invokeEphemeronCallbacks(Visitor*); 51 void invokeEphemeronCallbacks(Visitor*);
51 52
52 #if ENABLE(ASSERT) 53 #if ENABLE(ASSERT)
53 bool hasCallbackForObject(const void*); 54 bool hasCallbackForObject(const void*);
54 #endif 55 #endif
55 56
56 private: 57 private:
57 static const size_t blockSize = 8192; 58 static const size_t blockSize = (1 << 13);
58 59
59 class Block { 60 class Block {
60 USING_FAST_MALLOC(Block); 61 USING_FAST_MALLOC(Block);
61 public: 62 public:
62 explicit Block(Block* next) 63 explicit Block(Block* next);
63 : m_limit(&(m_buffer[blockSize])) 64 ~Block();
64 , m_current(&(m_buffer[0]))
65 , m_next(next)
66 {
67 clearUnused();
68 }
69 65
70 ~Block() 66 #if ENABLE(ASSERT)
71 {
72 clearUnused();
73 }
74
75 void clear(); 67 void clear();
68 #endif
69 void decommit();
76 70
77 Block* next() const { return m_next; } 71 Block* next() const { return m_next; }
78 void setNext(Block* next) { m_next = next; } 72 void setNext(Block* next) { m_next = next; }
79 73
80 bool isEmptyBlock() const 74 bool isEmptyBlock() const
81 { 75 {
82 return m_current == &(m_buffer[0]); 76 return m_current == &(m_buffer[0]);
83 } 77 }
84 78
85 size_t size() const
86 {
87 return blockSize - (m_limit - m_current);
88 }
89
90 Item* allocateEntry() 79 Item* allocateEntry()
91 { 80 {
92 if (LIKELY(m_current < m_limit)) 81 if (LIKELY(m_current < m_limit))
93 return m_current++; 82 return m_current++;
94 return nullptr; 83 return nullptr;
95 } 84 }
96 85
97 Item* pop() 86 Item* pop()
98 { 87 {
99 if (UNLIKELY(isEmptyBlock())) 88 if (UNLIKELY(isEmptyBlock()))
100 return nullptr; 89 return nullptr;
101 return --m_current; 90 return --m_current;
102 } 91 }
103 92
104 void invokeEphemeronCallbacks(Visitor*); 93 void invokeEphemeronCallbacks(Visitor*);
105 #if ENABLE(ASSERT) 94 #if ENABLE(ASSERT)
106 bool hasCallbackForObject(const void*); 95 bool hasCallbackForObject(const void*);
107 #endif 96 #endif
108 97
109 private: 98 private:
110 void clearUnused(); 99 Item* m_buffer;
111
112 Item m_buffer[blockSize];
113 Item* m_limit; 100 Item* m_limit;
114 Item* m_current; 101 Item* m_current;
115 Block* m_next; 102 Block* m_next;
116 }; 103 };
117 104
118 Item* popSlow(); 105 Item* popSlow();
119 Item* allocateEntrySlow(); 106 Item* allocateEntrySlow();
120 void invokeOldestCallbacks(Block*, Block*, Visitor*); 107 void invokeOldestCallbacks(Block*, Block*, Visitor*);
121 bool hasJustOneBlock() const; 108 bool hasJustOneBlock() const;
122 109
(...skipping 15 matching lines...) Expand all
138 Item* item = m_first->pop(); 125 Item* item = m_first->pop();
139 if (LIKELY(!!item)) 126 if (LIKELY(!!item))
140 return item; 127 return item;
141 128
142 return popSlow(); 129 return popSlow();
143 } 130 }
144 131
145 } // namespace blink 132 } // namespace blink
146 133
147 #endif // CallbackStack_h 134 #endif // CallbackStack_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/CallbackStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698