Commit graph

13 commits

Author SHA1 Message Date
Andreas Kling
8c0ae711d8 Kernel+LibC: Make page fault crashes a bit more readable.
We'll now try to detect crashes that were due to dereferencing nullptr,
uninitialized malloc() memory, or recently free()'d memory.
It's not perfect but I think it's pretty good. :^)

Also added some color to the most important parts of the crash log,
and added some more modes to /bin/crash for exercising this code.

Fixes #243.
2019-06-19 20:52:12 +02:00
Andreas Kling
46527b72d7 LibC: Run clang-format on everything. 2019-06-07 11:49:03 +02:00
Andreas Kling
b160677e9e LibC: Add malloc_size() to tell you how big an allocation might be.
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-30 02:37:40 +02:00
Andreas Kling
6785250f8c LibC: realloc() should reuse the existing allocation more often.
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-29 06:31:28 +02:00
Andreas Kling
189b342e6f LibC: Add mmap_with_name() that names the allocation immediately.
This allows us to skip the separate call to set_mmap_name() in code that
we control, e.g malloc() and GraphicsBitmap.
2019-05-19 15:54:56 +02:00
Andreas Kling
f5234660f6 malloc: Use a Vector with inline capacity for the big block recyclers. 2019-05-18 22:26:01 +02:00
Andreas Kling
5f7bb9d072 malloc: Make it possible to recycle big allocation blocks as well.
This patch makes us recycle up to 8 blocks of 4KB size. This should
probably be extended to handle other sizes.
2019-05-14 16:38:06 +02:00
Andreas Kling
66e401d668 LibC: Tune the number of ChunkedBlocks we keep around empty.
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-02 18:11:36 +02:00
Andreas Kling
b4e7925e31 LibC: Move full ChunkedBlocks to a separate list in the allocator.
This way we only check actually usable blocks when trying to satisfy a new
allocation request.
2019-05-02 17:06:05 +02:00
Andreas Kling
60023ff70b LibC: free() should move kept empty ChunkedBlocks to the end of the list.
This ensures that we continue allocating from partially-used blocks until
they are full.
2019-05-02 16:35:57 +02:00
Andreas Kling
658fff195c LibC: free() should return free blocks back to the operating system.
Okay fine, I'll give them back. But we'll keep 4 blocks per size class on
hand, to reduce churn.
2019-05-02 15:58:10 +02:00
Andreas Kling
2dc72bb297 LibC: Improve malloc() mmap names somewhat. 2019-05-02 02:58:06 +02:00
Andreas Kling
4291e96991 LibC: Implement a simple freelist-based malloc() with size classes.
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.
2019-05-02 02:35:29 +02:00