summaryrefslogtreecommitdiff
path: root/LibC/malloc.cpp
AgeCommit message (Collapse)Author
2019-05-30LibC: Add malloc_size() to tell you how big an allocation might be.Andreas Kling
It can't be 100% precise but it doesn't really matter. Use this to implement realloc() nicely. This also fixes a bug in realloc() where we didn't take the size of the allocation metadata into account when computing the size of an allocation backed by a BigAllocationBlock.
2019-05-29LibC: realloc() should reuse the existing allocation more often.Andreas Kling
We were only reusing the existing allocation if the new requested size was exactly the same as the fudged size of the block. This meant that realloc() could allocate a new block even though the new block would be identical to the old block.
2019-05-19LibC: Add mmap_with_name() that names the allocation immediately.Andreas Kling
This allows us to skip the separate call to set_mmap_name() in code that we control, e.g malloc() and GraphicsBitmap.
2019-05-18malloc: Use a Vector with inline capacity for the big block recyclers.Andreas Kling
2019-05-14malloc: Make it possible to recycle big allocation blocks as well.Andreas Kling
This patch makes us recycle up to 8 blocks of 4KB size. This should probably be extended to handle other sizes.
2019-05-02LibC: Tune the number of ChunkedBlocks we keep around empty.Andreas Kling
At the moment, both mmap() and munmap() are kind of slow. Compiling with GCC was suffering quite badly from munmap() slowness, so let's keep a few more of the ChunkedBlocks around after they are empty, to avoid having to munmap.
2019-05-02LibC: Move full ChunkedBlocks to a separate list in the allocator.Andreas Kling
This way we only check actually usable blocks when trying to satisfy a new allocation request.
2019-05-02LibC: free() should move kept empty ChunkedBlocks to the end of the list.Andreas Kling
This ensures that we continue allocating from partially-used blocks until they are full.
2019-05-02LibC: free() should return free blocks back to the operating system.Andreas Kling
Okay fine, I'll give them back. But we'll keep 4 blocks per size class on hand, to reduce churn.
2019-05-02LibC: Improve malloc() mmap names somewhat.Andreas Kling
2019-05-02LibC: Implement a simple freelist-based malloc() with size classes.Andreas Kling
It's not thread-safe yet, and there is lots of room for improvement. Still it's a lot faster than the first-fit bitmap-based one it replaces.