| 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/BlinkGC.h" | 8 #include "platform/heap/BlinkGC.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 void* object() { return m_object; } | 31 void* object() { return m_object; } |
| 32 VisitorCallback callback() { return m_callback; } | 32 VisitorCallback callback() { return m_callback; } |
| 33 void call(Visitor* visitor) { m_callback(visitor, m_object); } | 33 void call(Visitor* visitor) { m_callback(visitor, m_object); } |
| 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 explicit CallbackStack(size_t blockSize = defaultBlockSize); | 40 explicit CallbackStack(size_t blockSize = kDefaultBlockSize); |
| 41 ~CallbackStack(); | 41 ~CallbackStack(); |
| 42 | 42 |
| 43 void clear(); | 43 void clear(); |
| 44 void decommit(); | 44 void decommit(); |
| 45 | 45 |
| 46 Item* allocateEntry(); | 46 Item* allocateEntry(); |
| 47 Item* pop(); | 47 Item* pop(); |
| 48 | 48 |
| 49 bool isEmpty() const; | 49 bool isEmpty() const; |
| 50 | 50 |
| 51 void invokeEphemeronCallbacks(Visitor*); | 51 void invokeEphemeronCallbacks(Visitor*); |
| 52 | 52 |
| 53 #if ENABLE(ASSERT) | 53 #if ENABLE(ASSERT) |
| 54 bool hasCallbackForObject(const void*); | 54 bool hasCallbackForObject(const void*); |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 static const size_t kMinimalBlockSize; | 57 static const size_t kMinimalBlockSize; |
| 58 static const size_t kDefaultBlockSize = (1 << 13); |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 static const size_t defaultBlockSize = (1 << 13); | |
| 61 | |
| 62 class Block { | 61 class Block { |
| 63 USING_FAST_MALLOC(Block); | 62 USING_FAST_MALLOC(Block); |
| 64 public: | 63 public: |
| 65 Block(Block* next, size_t blockSize); | 64 Block(Block* next, size_t blockSize); |
| 66 ~Block(); | 65 ~Block(); |
| 67 | 66 |
| 68 #if ENABLE(ASSERT) | 67 #if ENABLE(ASSERT) |
| 69 void clear(); | 68 void clear(); |
| 70 #endif | 69 #endif |
| 71 void decommit(); | 70 void decommit(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 Item* item = m_first->pop(); | 131 Item* item = m_first->pop(); |
| 133 if (LIKELY(!!item)) | 132 if (LIKELY(!!item)) |
| 134 return item; | 133 return item; |
| 135 | 134 |
| 136 return popSlow(); | 135 return popSlow(); |
| 137 } | 136 } |
| 138 | 137 |
| 139 } // namespace blink | 138 } // namespace blink |
| 140 | 139 |
| 141 #endif // CallbackStack_h | 140 #endif // CallbackStack_h |
| OLD | NEW |