Commit Graph

14576 Commits

Author SHA1 Message Date
Feoramund
e038c3cf4e Make superpage caching linear time instead of quadratic 2025-05-08 11:06:03 -04:00
Feoramund
dcd9bd7888 Make slab map caching linear time instead of quadratic 2025-05-08 11:06:03 -04:00
Feoramund
fa1f6abe78 Don't atomically subtract zero from remote_free_count 2025-05-08 11:06:03 -04:00
Feoramund
a0425ca220 Do not return superpages that had remote frees to the OS 2025-05-08 11:06:03 -04:00
Feoramund
5e773aaf56 Adjust heap allocator benchmarks 2025-05-08 11:06:03 -04:00
Feoramund
acd5d0d40b Fix slab iteration bug in the remote free collection phase
Previously, a wide slab could be freed during this phase which could
trigger the superpage itself to be freed, resulting in iteration across
potentially invalid memory if the superpage was returned to the host and
not placed in the orphanage.

`heap_free_wide_slab` has had its responsibilities reduced to just
freeing the wide slab, and `heap_free_superpage_if_empty_and_unused` has
been added to better clarify what is happening where.
2025-05-08 11:06:02 -04:00
Feoramund
2d0547dcaf Remove unneeded call to min
At this point, we know we're expanding the wide slab, so `old_size` will
always be the right size.
2025-05-08 11:06:02 -04:00
Feoramund
44a7015609 Fix in-place expansion of wide slabs 2025-05-08 11:06:02 -04:00
Feoramund
8638bd3b89 Fix slab iteration bug in heap_cache_register_superpage
Increment of `i` is handled near the start of this loop.
2025-05-08 11:06:02 -04:00
Feoramund
ee3d859c6b Remove HEAP_PANIC_ON_FREE_NIL 2025-05-08 11:06:02 -04:00
Feoramund
f5226d01f7 Revert to unoptimized behavior on Darwin 2025-05-08 11:06:02 -04:00
Feoramund
4a31e1f635 Ensure remapped memory has desired protection on Darwin 2025-05-08 11:06:02 -04:00
Feoramund
0947914e0d Use mach_task_self_ global instead 2025-05-08 11:06:02 -04:00
Feoramund
247ce3cc97 Favor rescheduling superpage cache entry instead
This should be more robust during merges that happen simultaneously with
remote frees.

Previously, we would preserve the cache entry, but there is an edge case
where a slab of a lower index could be remotely freed and missed during
a merge.
2025-05-08 11:06:02 -04:00
Feoramund
e86bd35387 Optimize virtual memory resizing on Darwin 2025-05-08 11:06:02 -04:00
Feoramund
c52c29856c Unify heap allocators
- Simplify the malloc-based allocator
- Correct the type signatures on malloc/calloc/realloc
- Make `heap_alloc/heap_free/heap_resize` API consistent across platforms
2025-05-08 11:06:02 -04:00
Feoramund
30e600699d Strengthen order to prevent reordering 2025-05-08 11:06:01 -04:00
Feoramund
0532b73563 Simplify loop 2025-05-08 11:06:01 -04:00
Feoramund
541443fe33 Don't build feoramalloc on web platforms
Their allocation pathways are already tuned for their respective
platforms.
2025-05-08 11:06:01 -04:00
Feoramund
e9bf350cca Add heap allocator exception for Orca
This is a copy of the libc malloc-based allocator that we previously
had. It's preferable to use the Orca runtime allocator over our own.
2025-05-08 11:06:01 -04:00
Feoramund
ef72a373b2 Use VM_INHERIT_COPY instead
This aligns with the use of `MAP_PRIVATE` in `mmap`-based
implementations.
2025-05-08 11:06:01 -04:00
Feoramund
4c59019a57 Restrict superpage allocation on Darwin to AMD64 and 2MiB
There's a possibility that Darwin does not support anything else, in
terms of size or architecture.
2025-05-08 11:06:01 -04:00
Feoramund
1e62f2c8c4 Rearrange slab iteration conditionals 2025-05-08 11:06:01 -04:00
Feoramund
76a2877d7d Hoist reused calculations out into variables 2025-05-08 11:06:01 -04:00
Feoramund
17b38c1bca Strengthen Consume to Acquire in heap allocator 2025-05-08 11:06:01 -04:00
Feoramund
6d99d9571c Fix indentation 2025-05-08 11:06:01 -04:00
Feoramund
102fc3f058 Add heap allocator tests to CI 2025-05-08 11:06:00 -04:00
Feoramund
a4a776634c Add native heap allocator
- Add the test bench for the allocator
- Move old allocator code to the test bench
- Fix `heap_resize` usage in `os2/env_linux.odin` to fit new API
  requiring `old_size`
2025-05-08 11:06:00 -04:00
Feoramund
f142043db9 Add virtual memory procedures to base 2025-05-08 11:06:00 -04:00
Feoramund
13dca77d3d Add get_current_thread_id to base 2025-05-08 11:06:00 -04:00
gingerBill
4a4294c2af Merge pull request #5095 from Lperlind/temp-collisions
os2: Resolve temp allocator collisions
2025-05-08 15:11:51 +01:00
gingerBill
204c6f514a Remove use of do 2025-05-08 14:03:17 +01:00
gingerBill
0ce8373528 Formatting Fix 2025-05-08 13:23:22 +01:00
gingerBill
d7fc3d1770 Merge pull request #5121 from Badaxis/badaxis/xaudio2
XAudio2 Implementation
2025-05-08 13:11:51 +01:00
gingerBill
92df892f25 Merge pull request #5064 from harold-b/hb/objc-classes
Add support for Objective-C class implementation
2025-05-08 12:58:33 +01:00
Lucas Perlind
f5b947ea73 Fix linux 2025-05-08 17:45:29 +10:00
Lucas Perlind
14c5096b81 Improve assert information 2025-05-08 17:41:03 +10:00
Lucas Perlind
9f2d008a8a Remove TEMP_ALLOCATOR_GUARD wrapper 2025-05-08 17:41:03 +10:00
Lucas Perlind
5292a7f4f3 Fix posix 2025-05-08 17:41:03 +10:00
Lucas Perlind
1bea59ee68 Fix linux 2025-05-08 17:41:03 +10:00
Lucas Perlind
190960e103 fix -vet 2025-05-08 17:41:03 +10:00
Lucas Perlind
b9db1dd3e0 os2: Resolve temp allocator collisions 2025-05-08 17:41:01 +10:00
gingerBill
4a709086a4 Merge pull request #5131 from laytan/fix-builder-dispose
fix disposing builder when not created
2025-05-07 14:03:42 +01:00
Laytan Laats
ad4866653a fix disposing builder when not created
Fixes #5128

p->builder is created in lb_begin_procedure_body, but that isn't called
if there is no body, and we were still calling dispose at that point.

Moved it into lb_end_procedure_body to match.
2025-05-07 14:39:51 +02:00
gingerBill
90a30a145a Merge pull request #5122 from Lperlind/asan-allocators
Add asan support for various allocators and stack unpoisoning
2025-05-07 10:21:16 +01:00
Lucas Perlind
46e0c7ad74 Cleanup 2025-05-07 11:30:58 +10:00
Laytan
7c1a9f1e7a Merge pull request #5127 from laytan/fix-process-windows-handles-handling
Fix process windows handles handling
2025-05-06 22:31:54 +02:00
laytan
9b218a2922 don't need to hang on to the null handle 2025-05-06 19:42:52 +02:00
Laytan
bf5206968a close null_handle 2025-05-06 20:57:26 +02:00
Laytan
2bce446d08 ifs wrong way around 2025-05-06 20:47:51 +02:00