Commit Graph

383 Commits

Author SHA1 Message Date
gingerBill
70ddb74e40 Add mem.make_over_aligned 2025-03-31 10:51:02 +01:00
gingerBill
dcb683927e Fix indentation 2025-03-31 10:40:03 +01:00
Barinzaya
7819797a03 Split mem.make_map to match the runtime procs.
The existing `mem.make_map` passes a capacity, but the builtin
`make_map` no longer takes a capacity--it was separated to
`make_map_cap` to allow for making a map without an allocation (#4340).

`core:mem` was not updated to reflect this, so any usage of `mem.make`
to make a map will currently result in a compile error.
2025-03-22 11:03:04 -04:00
gingerBill
539e9bd2e3 Merge pull request #4836 from laytan/fix-wrong-out-of-memory
fix wrong out of memory in edge cases, just try allocate from block for one source of truth
2025-03-20 17:20:26 +00:00
alektron
fd539b5e81 Fix: When resizing a virtual arena by commiting more of the already reserved memory, the total_used field of the arena was not updated; 2025-03-02 17:46:39 +01:00
Githubaccountlol
88f423a38b Update doc.odin 2025-02-26 03:04:54 -06:00
Laytan Laats
cae3f13d9f mem/virtual: specify max protection on mmap call in NetBSD and FreeBSD 2025-02-18 18:33:19 +01:00
Laytan Laats
7df5be2131 fix wrong out of memory in edge cases, just try allocate from block for one source of truth 2025-02-12 19:09:21 +01:00
Lucas Perlind
88a5817134 Fix tlsf block adjustment 2025-02-10 13:01:16 +11:00
Barinzaya
98b3a9eacd Added support for growing in place to some arenas.
This affects `runtime.Arena` and `virtual.Arena`, but not currently
`mem.Arena`. These changes allow the last allocation that has been
made to be resized to a larger size by just extending their
allocation in-place, when there's sufficient room in the memory block to
do so.

Shrinking in place and re-using the rest of the allocation can be
supported using almost the same logic, but would require the memory to
be zeroed. Since this would add a additional cost that isn't currently
present, shrinking has not been changed.
2025-01-24 10:13:46 -05:00
gingerBill
328d70e244 Merge pull request #4696 from alektron/ArenaBug
Non-zeroed memory after Arena free
2025-01-17 14:20:28 +00:00
teapo
4895065afb Add SoA make/delete to core:mem 2025-01-15 20:16:57 +01:00
alektron
a0c20023fc Fix: Issue with non-zeroed memory after arena_temp_and;
Fix: total_used field of growing Arena was not decremented correctly in arena_temp_end;
2025-01-15 17:59:30 +01:00
gingerBill
2a29322c91 Merge pull request #4605 from karl-zylinski/tracking-allocator-bad-free-default-to-crash
Make tracking allocator default to crashing on a bad free instead of adding to bad_free_array
2025-01-08 16:24:20 +00:00
gingerBill
16acb342d1 Merge pull request #4617 from gorevojd/free_bootstrapped_arena_crash
Fixed crash in arena_free_all() for bootstrapped growing arenas.
2025-01-06 09:33:23 +00:00
gingerBill
1cf7a56ba7 General clean up of code 2025-01-01 15:13:46 +00:00
dmitriy.gorevoy
e82a0c8fc7 Fixed crash in arena_free_all() for bootstrapped growing arenas.
When trying to set arena.curr_block.used = 0 after mem.zero() caused a crash because if the arena is bootstrapped its memory will be zeroed out after mem.zero() thus making arena.cur_block point to zero.
2024-12-23 09:25:18 +01:00
Karl Zylinski
e5f32e1455 Makes tracking allocator default to crashing on a bad free instead of add to bad_free_array. The bad_free_array remains to not break old code. The new default behavior is implemented in a callback that you can override, there's a second provided callback that provides the old behavior where an element was added to bad_free_array. Rationale: Many people are just checking the allocation_map, but don't check the bad free array. Several examples throughout core that use tracking allocator don't check bad_free_array either, so people have been taught not to check it. 2024-12-21 15:49:48 +01:00
Laytan Laats
20f4f378b2 sys/posix: add MAP_ANONYMOUS 2024-11-17 13:52:08 +01:00
Jeroen van Rijn
c33d2ff96b Missing paren. 2024-11-03 14:10:29 +01:00
Jeroen van Rijn
9199c6df34 mem.is_aligned is in bytes, not log2 bytes
Fix formula and clarify comment
2024-11-03 14:07:31 +01:00
Laytan Laats
1dd9b8560d build mutex allocator code on freestanding wasm 2024-10-14 16:11:25 +02:00
Laytan Laats
b746e5287e build tracking allocator code on freestanding wasm 2024-10-14 16:06:16 +02:00
gingerBill
8006ba919e Improve formatting 2024-10-11 14:48:55 +01:00
Karl Zylinski
093ade0504 Merge branch 'master' into file-tags-without-comments 2024-09-17 19:36:17 +02:00
gingerBill
0d33df15b4 Merge pull request #4208 from laytan/more-wasm-vendor-support
wasm: support more vendor libraries
2024-09-17 11:37:10 +01:00
Karl Zylinski
19f0127e55 Moved all packages in core, base, vendor, tests and examples to use new #+ file tag syntax. 2024-09-14 18:27:49 +02:00
flysand7
466e29bb38 [mem]: Rollback allocator API consistency 2024-09-14 13:15:02 +11:00
flysand7
016d1a84d4 [mem]: Document mutex, rollback stack and tracking allocators 2024-09-14 10:46:35 +11:00
flysand7
3ed2ab6e2c [mem]: Adjust the docs for calc_padding_with_header 2024-09-14 10:18:51 +11:00
flysand7
e90f5d2528 [mem]: Adjust the docs on the buddy allocator 2024-09-14 10:03:04 +11:00
flysand7
f16ed256ea [mem]: Fix handling of default resize to check alignment 2024-09-11 08:00:27 +11:00
flysand7
fdd4882568 [mem]: Adjust docs for alloc 2024-09-10 19:51:20 +11:00
Laytan Laats
5ae27c6ebc wasm: support more vendor libraries
Adds support for:
- box2d
- cgltf
- stb image
- stb rect pack
2024-09-09 18:49:13 +02:00
flysand7
167ced8ad1 [mem]: Don't use named params for dynamic pool in tests 2024-09-08 18:52:55 +11:00
flysand7
05df34f99c [mem]: Start documenting allocators.odin 2024-09-08 18:44:33 +11:00
flysand7
299accb717 [mem]: Put panic allocator after nil allocator, adjust @require_results 2024-09-08 14:17:32 +11:00
flysand7
3b30bc305c [mem]: Document raw.odin 2024-09-08 14:13:03 +11:00
flysand7
f1f5dc614e [mem]: Remove old comments 2024-09-08 11:17:27 +11:00
flysand7
6eb80831b5 [mem]: Panic when allocator is not initialized 2024-09-08 11:12:28 +11:00
flysand7
b78d546010 [mem]: Add non_zeroed versions of resize 2024-09-08 11:02:17 +11:00
flysand7
c719a86312 [mem]: Document alloc.odin 2024-09-08 10:58:40 +11:00
flysand7
1842cd6297 Fix typo
Co-authored-by: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com>
2024-09-08 00:09:18 +11:00
flysand7
f8cd13767e [mem]: Fix the issue with unbranched version of ptr align 2024-09-07 18:08:11 +11:00
flysand7
3a351ec407 [mem]: Document mem.odin 2024-09-07 18:01:41 +11:00
flysand7
7c9d2f61f5 [mem]: Update package documentation 2024-09-07 15:16:20 +11:00
flysand7
6017a20e1c [mem]: Make resize_bytes take a slice for the old memory 2024-09-07 15:11:04 +11:00
flysand7
2d988bbc5f [mem]: Rename alloc to alloc_bytes and add alloc 2024-09-07 14:45:15 +11:00
flysand7
64814f4199 [mem]: Document the package 2024-09-07 14:19:50 +11:00
flysand7
c0112d1c70 [mem]: Add free_all for buddy allocator 2024-09-07 13:27:17 +11:00