OLD | NEW |
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/Assertions.h" | 10 #include "wtf/Assertions.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 // The CallbackStack contains all the visitor callbacks used to trace and mark | 14 // The CallbackStack contains all the visitor callbacks used to trace and mark |
14 // objects. A specific CallbackStack instance contains at most bufferSize elemen
ts. | 15 // objects. A specific CallbackStack instance contains at most bufferSize elemen
ts. |
15 // If more space is needed a new CallbackStack instance is created and chained | 16 // If more space is needed a new CallbackStack instance is created and chained |
16 // together with the former instance. I.e. a logical CallbackStack can be made o
f | 17 // together with the former instance. I.e. a logical CallbackStack can be made o
f |
17 // multiple chained CallbackStack object instances. | 18 // multiple chained CallbackStack object instances. |
18 class CallbackStack { | 19 class CallbackStack final { |
| 20 USING_FAST_MALLOC(CallbackStack); |
19 public: | 21 public: |
20 class Item { | 22 class Item { |
| 23 DISALLOW_NEW(); |
21 public: | 24 public: |
22 Item() { } | 25 Item() { } |
23 Item(void* object, VisitorCallback callback) | 26 Item(void* object, VisitorCallback callback) |
24 : m_object(object) | 27 : m_object(object) |
25 , m_callback(callback) | 28 , m_callback(callback) |
26 { | 29 { |
27 } | 30 } |
28 void* object() { return m_object; } | 31 void* object() { return m_object; } |
29 VisitorCallback callback() { return m_callback; } | 32 VisitorCallback callback() { return m_callback; } |
30 void call(Visitor* visitor) { m_callback(visitor, m_object); } | 33 void call(Visitor* visitor) { m_callback(visitor, m_object); } |
(...skipping 16 matching lines...) Expand all Loading... |
47 void invokeEphemeronCallbacks(Visitor*); | 50 void invokeEphemeronCallbacks(Visitor*); |
48 | 51 |
49 #if ENABLE(ASSERT) | 52 #if ENABLE(ASSERT) |
50 bool hasCallbackForObject(const void*); | 53 bool hasCallbackForObject(const void*); |
51 #endif | 54 #endif |
52 | 55 |
53 private: | 56 private: |
54 static const size_t blockSize = 8192; | 57 static const size_t blockSize = 8192; |
55 | 58 |
56 class Block { | 59 class Block { |
| 60 USING_FAST_MALLOC(Block); |
57 public: | 61 public: |
58 explicit Block(Block* next) | 62 explicit Block(Block* next) |
59 : m_limit(&(m_buffer[blockSize])) | 63 : m_limit(&(m_buffer[blockSize])) |
60 , m_current(&(m_buffer[0])) | 64 , m_current(&(m_buffer[0])) |
61 , m_next(next) | 65 , m_next(next) |
62 { | 66 { |
63 clearUnused(); | 67 clearUnused(); |
64 } | 68 } |
65 | 69 |
66 ~Block() | 70 ~Block() |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 Item* item = m_first->pop(); | 138 Item* item = m_first->pop(); |
135 if (LIKELY(!!item)) | 139 if (LIKELY(!!item)) |
136 return item; | 140 return item; |
137 | 141 |
138 return popSlow(); | 142 return popSlow(); |
139 } | 143 } |
140 | 144 |
141 } // namespace blink | 145 } // namespace blink |
142 | 146 |
143 #endif // CallbackStack_h | 147 #endif // CallbackStack_h |
OLD | NEW |