|
Broom 1.0.0
A thread-local C++ Garbage Collector
|
Namespaces | |
| namespace | __impl |
| namespace | platform |
Classes | |
| class | Allocator |
| class | AllocatorCommonMetadata |
| class | AllocatorFrontMetadata |
| class | array |
| struct | Atomic |
| struct | BroomDisableGcScope |
| class | BroomLifetimeAnchor |
| struct | BroomNoDestructorScope |
| struct | BroomScope |
| struct | BroomSharingNoDestructorScope |
| class | BroomSharingPointer |
| struct | BroomSharingScope |
| class | BroomValue |
| class | deque |
| class | ExternalRoot |
| class | forward_list |
| class | FreeListAllocator |
| class | GarbageCollector |
| class | GcNode |
| class | list |
| class | map |
| class | MemoryRegion |
| class | MemorySpace |
| class | multimap |
| class | multiset |
| class | PreciseRoot |
| class | RootVisitor |
| class | set |
| class | unordered_map |
| class | unordered_multimap |
| class | unordered_multiset |
| class | unordered_set |
| class | vector |
| class | Visitor |
Concepts | |
| concept | StaticCastable |
| concept | ReinterpretCastable |
| concept | IsAllocatorMetadata |
Typedefs | |
| using | AllocatorBackMetadata = AllocatorCommonMetadata |
| using | MemoryAddress = uintptr_t |
| using | UintPtr = uintptr_t |
| using | IntPtr = intptr_t |
| template<typename T , typename Compare = std::less<typename broom::vector<T>::value_type>> | |
| using | priority_queue = std::priority_queue< T, broom::vector< T >, Compare > |
| template<typename T > | |
| using | queue = std::queue< T, broom::deque< T > > |
| template<typename T > | |
| using | stack = std::stack< T, broom::deque< T > > |
| using | scope = BroomScope |
| using | sharing_scope = BroomSharingScope |
| using | no_destructor_scope = BroomNoDestructorScope |
| using | sharing_no_destructor_scope = BroomSharingNoDestructorScope |
| using | Destructor = std::add_pointer< void(const void *)>::type |
| using | disable_gc_scope = BroomDisableGcScope |
| using | gc_visitor = Visitor |
| using | gc_root = BroomValue |
| template<typename T > | |
| using | sharing_ptr = BroomSharingPointer< T > |
| template<typename T > | |
| using | lifetime_anchor = BroomLifetimeAnchor< T > |
Enumerations | |
| enum class | MemoryPermissions { kReadOnly , kWriteOnly , kReadWrite , kNone } |
| enum class | MemoryPressure { kLight , kMedium , kCritical } |
| enum class | RootKind { kStack , kExternal , kPrecise , kRegular } |
Functions | |
| void | thread_init (broom_configuration config) |
| void | thread_teardown () |
| void | force_collection () |
| void | force_slow_collection () |
| void | register_external (const void *pointer, size_t size) |
| void | unregister_external (const void *pointer) |
| template<typename T , typename U > requires StaticCastable<U, T> && (!IsAllocatorMetadata<T>) | |
| constexpr T | SafeCast (U v) |
| template<typename T , typename U > requires ReinterpretCastable<U, T> && (!StaticCastable<U, T>) && (!IsAllocatorMetadata<T>) | |
| constexpr T | SafeCast (U v) |
| template<typename T , typename U > | |
| constexpr T | UnsafeCast (U v) |
| template<size_t N, typename T > requires std::is_integral_v<T> && (N > 0) && (N % 2 == 0) | |
| constexpr bool | IsAligned (T value) |
| template<size_t N, typename T > requires (N > 0) && (N % 2 == 0) | |
| constexpr bool | IsAligned (T *value) |
| template<size_t N, typename T > requires std::is_integral_v<T> && (N > 0) && (N % 2 == 0) | |
| constexpr T | RoundDown (T value) |
| template<size_t N, typename T > requires std::is_integral_v<T> && (N > 0) && (N % 2 == 0) | |
| constexpr T | RoundUp (T value) |
| template<typename T > requires std::is_unsigned_v<T> | |
| constexpr bool | AddOverflowChecked (T lhs, T rhs, T &destination) |
| BROOM_NOASAN BROOM_NOTSAN BROOM_NOINLINE void | IterateStackAndVisitRootsImpl (RootVisitor *visitor, const void *const *stack_bottom, const void *const *stack_top) |
| template<typename T , typename... Args> | |
| T * | allocate (size_t count, Args &&... args) |
| template<typename T > | |
| sharing_ptr< T > | share (T *ptr, uint32_t count=1) |
Variables | |
| thread_local GarbageCollector * | t_gc = nullptr |
| constexpr const uintptr_t | kNullUintPtr = 0 |
| constexpr const intptr_t | kNullIntPtr = 0 |
| constexpr const MemoryAddress | kNullMemoryAddress = 0 |
| constexpr const int | kPointerSize = sizeof(void*) |
| constexpr const int | kUintPtrSize = sizeof(UintPtr) |
| constexpr const int | kIntPtrSize = sizeof(IntPtr) |
| constexpr const size_t | KB = 1024 |
| constexpr const size_t | MB = KB * 1024 |
| constexpr const size_t | GB = MB * 1024 |
| constexpr const size_t | TB = GB * 1024 |
| constexpr const int | kPageSize = 4 * KB |
| constexpr const int | kHugePageSize = 2 * MB |
Definition at line 166 of file allocator.h.
A type alias for BroomDisableGcScope.
A type alias for BroomValue.
| using broom::lifetime_anchor = typedef BroomLifetimeAnchor<T> |
A type alias for BroomLifetimeAnchor.
| using broom::MemoryAddress = typedef uintptr_t |
A type alias for BroomNoDestructorScope.
| using broom::priority_queue = typedef std::priority_queue<T, broom::vector<T>, Compare> |
A Broom-aware std::priority_queue adaptor.
Definition at line 13 of file broom-priority-queue.h.
| using broom::queue = typedef std::queue<T, broom::deque<T> > |
A Broom-aware std::queue adaptor.
Definition at line 12 of file broom-queue.h.
A type alias for BroomScope.
A type alias for BroomSharingNoDestructorScope.
| using broom::sharing_ptr = typedef BroomSharingPointer<T> |
A type alias for BroomSharingPointer.
A type alias for BroomSharingScope.
| using broom::stack = typedef std::stack<T, broom::deque<T> > |
A Broom-aware std::stack adaptor.
Definition at line 12 of file broom-stack.h.
| using broom::UintPtr = typedef uintptr_t |
|
strong |
| Enumerator | |
|---|---|
| kReadOnly | |
| kWriteOnly | |
| kReadWrite | |
| kNone | |
Definition at line 111 of file allocator.h.
|
strong |
| Enumerator | |
|---|---|
| kLight | |
| kMedium | |
| kCritical | |
Definition at line 225 of file allocator.h.
|
strong |
Broom's default allocation function. It allocates a memory region of count * sizeof(T) bytes, along with any metadata needed by the garbage collector. If there is a constructor to run for T, broom::allocate() will run it. The object is registered with the garbage collector and becomes managed, meaning that pointers to this object will be scanned during the tracing phase of garbage collection, can be collected if no references were found and if there is a destructor to run during collection, it will run it.
| count | The number of objects of type T to allocate. |
| args | The arguments to forward to the constructor of T. |
| BROOM_EXPORT void broom::force_collection | ( | ) |
As the name of the function suggests, broom::force_collection() forces the garbage collector to trace and collect any objects it couldn't find references for. See also force_slow_collection().
| BROOM_EXPORT void broom::force_slow_collection | ( | ) |
broom::force_slow_collection() will run a full tracing and collection phase across all the known spaces and roots in the garbage collector. This function should be used sparingly, as it can take a long time to complete. Consider using force_collection() instead.
|
inlineconstexpr |
|
inlineconstexpr |
| BROOM_NOASAN BROOM_NOTSAN BROOM_NOINLINE void broom::IterateStackAndVisitRootsImpl | ( | RootVisitor * | visitor, |
| const void *const * | stack_bottom, | ||
| const void *const * | stack_top | ||
| ) |
Definition at line 49 of file root-visitor.cc.
| BROOM_EXPORT void broom::register_external | ( | const void * | pointer, |
| size_t | size | ||
| ) |
broom::register_external() notifies the garbage collector about the presence of a new external root. This function should be called when you wish to store a managed (garbage collected) pointer in unmanaged memory (e.g. an object allocated using a non-Broom allocator). The memory region passed into this function will be scanned for managed pointers by the garbage collector during the tracing phase. See also unregister_external().
| pointer | The pointer to the base of a region to register as an external root. |
| size | The size of the region. |
|
inlineconstexpr |
|
inlineconstexpr |
| sharing_ptr< T > broom::share | ( | T * | ptr, |
| uint32_t | count = 1 |
||
| ) |
broom::share() is the interface for creating BroomSharedPointers. It accepts two arguments, the pointer to share and how many times it should be shared. See BroomSharedPointer and BroomLifetimeAnchor for more details about sharing.
| ptr | The raw pointer to share. |
| count | The count describing how many times the sharing_ptr must be disposed for the garbage collector to unpin the allocation. |
| BROOM_EXPORT void broom::thread_init | ( | broom_configuration | config = {} | ) |
broom::thread_init() provides initialization for the garbage collection state on the current thread. This function should be called before attempting to use Broom APIs on a given thread. Broom also provides a RAII-style scope to automatically initialize and tear down the garbage collector state in a given thread via broom::scope. See also broom::thread_teardown().
| config | The configuration to initialize Broom on this thread with. |
| BROOM_EXPORT void broom::thread_teardown | ( | ) |
broom::thread_teardown() should be called when the thread exits. Broom also provides a RAII-style scope to automatically initialize and tear down the garbage collector state in a given thread via broom::scope. See also broom::thread_init().
| BROOM_EXPORT void broom::unregister_external | ( | const void * | pointer | ) |
broom::unregister_external() notifies the garbage collector that the previously registered unmanaged memory that can contain managed pointers is no longer able to do so. This memory region will no longer be scanned for references to managed memory.
| pointer | The pointer to the base of a region to unregister as an external root. |
| size | The size of the region. |
|
constexpr |
| thread_local GarbageCollector * broom::t_gc = nullptr |