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
3 // found in the LICENSE file.
5 #ifndef CallbackStack_h
6 #define CallbackStack_h
8 #include "platform/heap/ThreadState.h"
12 // The CallbackStack contains all the visitor callbacks used to trace and mark
13 // objects. A specific CallbackStack instance contains at most bufferSize elements.
14 // If more space is needed a new CallbackStack instance is created and chained
15 // together with the former instance. I.e. a logical CallbackStack can be made of
16 // multiple chained CallbackStack object instances.
22 Item(void* object, VisitorCallback callback)
24 , m_callback(callback)
27 void* object() { return m_object; }
28 VisitorCallback callback() { return m_callback; }
29 void call(Visitor* visitor) { m_callback(visitor, m_object); }
33 VisitorCallback m_callback;
41 Item* allocateEntry();
45 bool sizeExceeds(size_t) const;
47 void append(CallbackStack*);
48 void takeBlockFrom(CallbackStack*);
50 void invokeEphemeronCallbacks(Visitor*);
53 bool hasCallbackForObject(const void*);
56 static const size_t blockSize = 128;
61 void invokeOldestCallbacks(Block*, Block*, Visitor*);
62 bool hasJustOneBlock() const;
63 void swap(CallbackStack* other);
71 #endif // CallbackStack_h