summaryrefslogtreecommitdiff
path: root/AK/BumpAllocator.h
AgeCommit message (Collapse)Author
2021-10-31AK: Make BumpAllocator work in multi-threaded environmentsBen Wiederhake
Fixes #10578.
2021-10-23AK: Prevent accidental misuse of BumpAllocatorBen Wiederhake
In particular, we implicitly required that the caller initializes the returned instances themselves (solved by making UniformBumpAllocator::allocate call the constructor), and BumpAllocator itself cannot handle classes that are not trivially deconstructible (solved by deleting the method). Co-authored-by: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-10-23AK: Fix BumpAllocator iteration if last object doesn't alignBen Wiederhake
This fixes two bugs: 1. `end_offset` was missing the alignment that might have been introduced while computing `base_ptr`. 2. Ignoring point 1, `end_offset` computed the offset of the first byte that is outside the current chunk. However, this might be in the middle of a (hypothetical) object! The loop treats `end_offset` as if it points to the first byte beyond the last (valid) object. So if the last few bytes of the chunk are unused, the loop iterates once too often. Found by OSS Fuzz, long-standing issue (since 2021-07-31) https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38733 (This probably also resolves some other issues that go through RegexMatcher.) See also: 0f1425c895ace40fbb10d68a55eeb3a6354479d3
2021-10-23AK: Check consistency during BumpAllocator allocationBen Wiederhake
2021-09-13AK: Give BumpAllocator a single-block cacheAli Mohammad Pur
This avoid excessive mmap/munmap traffic in normal operation.
2021-08-13AK: Avoid OOB access in UniformBumpAllocator::destroy_all()Ali Mohammad Pur
Otherwise we would end up calling T::~T() on some random memory right after our mapped block, which is most likely a pretty bad thing to do :P
2021-08-08AK: Use `explode_byte` in BumpAllocator.hDaniel Bertalan
When compiling this code with Clang, both branches of the ternary operator get evaluated at compile-time, triggering a warning about a narrowing implicit conversion. We can use `explode_byte` instead.
2021-08-04AK: Allow configuring the BumpAllocator chunk sizeTimothy Flynn
2021-08-02AK: Add a simple bump allocatorAli Mohammad Pur