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

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

Issue 1689823003: Revert of 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();
45 44
46 Item* allocateEntry(); 45 Item* allocateEntry();
47 Item* pop(); 46 Item* pop();
48 47
49 bool isEmpty() const; 48 bool isEmpty() const;
50 49
51 void invokeEphemeronCallbacks(Visitor*); 50 void invokeEphemeronCallbacks(Visitor*);
52 51
53 #if ENABLE(ASSERT) 52 #if ENABLE(ASSERT)
54 bool hasCallbackForObject(const void*); 53 bool hasCallbackForObject(const void*);
55 #endif 54 #endif
56 55
57 private: 56 private:
58 static const size_t blockSize = (1 << 13); 57 static const size_t blockSize = 8192;
59 58
60 class Block { 59 class Block {
61 USING_FAST_MALLOC(Block); 60 USING_FAST_MALLOC(Block);
62 public: 61 public:
63 explicit Block(Block* next); 62 explicit Block(Block* next)
64 ~Block(); 63 : m_limit(&(m_buffer[blockSize]))
64 , m_current(&(m_buffer[0]))
65 , m_next(next)
66 {
67 clearUnused();
68 }
65 69
66 void decommit(); 70 ~Block()
71 {
72 clearUnused();
73 }
74
75 void clear();
67 76
68 Block* next() const { return m_next; } 77 Block* next() const { return m_next; }
69 void setNext(Block* next) { m_next = next; } 78 void setNext(Block* next) { m_next = next; }
70 79
71 bool isEmptyBlock() const 80 bool isEmptyBlock() const
72 { 81 {
73 return m_current == &(m_buffer[0]); 82 return m_current == &(m_buffer[0]);
74 } 83 }
75 84
85 size_t size() const
86 {
87 return blockSize - (m_limit - m_current);
88 }
89
76 Item* allocateEntry() 90 Item* allocateEntry()
77 { 91 {
78 if (LIKELY(m_current < m_limit)) 92 if (LIKELY(m_current < m_limit))
79 return m_current++; 93 return m_current++;
80 return nullptr; 94 return nullptr;
81 } 95 }
82 96
83 Item* pop() 97 Item* pop()
84 { 98 {
85 if (UNLIKELY(isEmptyBlock())) 99 if (UNLIKELY(isEmptyBlock()))
86 return nullptr; 100 return nullptr;
87 return --m_current; 101 return --m_current;
88 } 102 }
89 103
90 void invokeEphemeronCallbacks(Visitor*); 104 void invokeEphemeronCallbacks(Visitor*);
91 #if ENABLE(ASSERT) 105 #if ENABLE(ASSERT)
92 bool hasCallbackForObject(const void*); 106 bool hasCallbackForObject(const void*);
93 #endif 107 #endif
94 108
95 private: 109 private:
96 Item* m_buffer; 110 void clearUnused();
111
112 Item m_buffer[blockSize];
97 Item* m_limit; 113 Item* m_limit;
98 Item* m_current; 114 Item* m_current;
99 Block* m_next; 115 Block* m_next;
100 }; 116 };
101 117
102 Item* popSlow(); 118 Item* popSlow();
103 Item* allocateEntrySlow(); 119 Item* allocateEntrySlow();
104 void invokeOldestCallbacks(Block*, Block*, Visitor*); 120 void invokeOldestCallbacks(Block*, Block*, Visitor*);
105 bool hasJustOneBlock() const; 121 bool hasJustOneBlock() const;
106 122
(...skipping 15 matching lines...) Expand all
122 Item* item = m_first->pop(); 138 Item* item = m_first->pop();
123 if (LIKELY(!!item)) 139 if (LIKELY(!!item))
124 return item; 140 return item;
125 141
126 return popSlow(); 142 return popSlow();
127 } 143 }
128 144
129 } // namespace blink 145 } // namespace blink
130 146
131 #endif // CallbackStack_h 147 #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