-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_allocator: Add static polymorphism to Block
Different consumers have different priorities when it comes to pw_allocator, which is reflected in different feature requests for its central class, Block. For example, some have requested better debug info during development by associating call site metadata, while others have asked for the smallest possible overhead. To be able to accommodate multiple use cases, the Block class needs to become polymorphic. Given its central role, however, it must over the overhead of vtables and dynamic dispatch. This CL accomplishes this by decomposing Block into several largely orthognal "mix-in" types that each use the CRTP: - BasicBlock describes how blocks are made of usable space with overhead. - ContiguousBlock describes how blocks can be split and merged. - Forward- and ReverseIterableBlock describe how to traverse from on block to its neighbors. - AllocatableBlock describes how blocks can be allocated and freed. - AlignableBlock describes how allocations can be constrained so that usable space falls on an alignment boundary. - PoisonableBlock describes how to detect use-after-frees by checking the usable space of free blocks. - BlockWithLayout describes how to retrieve the memory layout originally used to allocated an in-use block. Each mix-in is stateless, and concrete implementations can inherit from several or all of them. In the scope of this CL, they are used to create `DetailedBlock`, which matches the existing legacy block. Change-Id: Id07d9c98299da8c12adeca83b603ad9fdebb7844 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/232214 Reviewed-by: Wyatt Hepler <[email protected]> Pigweed-Auto-Submit: Aaron Green <[email protected]> Reviewed-by: Taylor Cramer <[email protected]> Commit-Queue: Aaron Green <[email protected]> Lint: Lint 🤖 <[email protected]>
- Loading branch information
1 parent
a287811
commit 6417a52
Showing
45 changed files
with
3,205 additions
and
1,355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.