Commit Graph

205 Commits

Author SHA1 Message Date
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
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
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
46e0c7ad74 Cleanup 2025-05-07 11:30:58 +10:00
Lucas Perlind
fd05f55691 Fix wasi_wasm 2025-05-06 15:23:44 +10:00
Lucas Perlind
83bc2d3c4a Add asan support for various allocators 2025-05-06 14:55:50 +10:00
Harold Brenes
a3de9c8de4 Add initial support for Objective-C class implementation 2025-04-20 21:53:46 -04:00
gingerBill
3dcc22fa6d Change hashing rules for float-like types to make 0 == -0 2025-04-16 10:52:35 +01:00
Jeroen van Rijn
bb38775fb1 Remove Type_Info_Tuple 2025-04-13 21:51:57 +02:00
gingerBill
1f814c33dc Support subtargets in build tags: #build darwin:generic and #build linux:android, darwin:ios 2025-04-10 11:36:03 +01:00
Dave Voutila
18988b5f94 Fix use of errno on OpenBSD. 2025-03-27 10:36:40 -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
gingerBill
21a6648cde Fix #4903 2025-03-03 15:16:50 +00:00
gingerBill
ef016d957b Add @(require_results) to random generator 2025-02-24 13:48:07 +00:00
gingerBill
614c0dd740 Fix typeid size for 32-bit platforms 2025-02-20 17:10:04 +00:00
gingerBill
4ece0617bc Keep -vet happy 2025-02-20 14:18:19 +00:00
gingerBill
5489a88983 Change typeid definition to be based around the canonical type hash
`typeid` used to be a fancy index with extra metadata stored on it. Now it is direct hash of the type.

This is safe to do in practice since any possible collisions are checked at compile time AND the chances of having a 1% collision are around 1 in 600K (see the Birthday Paradox).

Therefore accessing a `^Type_Info` is now a hash table lookup with linear probing. The table is twice the size than necessary so prevent too much probing due to an overly dense hash table.
2025-02-20 14:10:45 +00: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
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
dde3a03022 Add priority_index to Foundation.framework import in base:runtime 2025-01-22 13:03:51 +00:00
Laytan Laats
4de5911a15 fix map_entry sometimes giving wrong key pointer
`map_desired_position` does not return the actual position, probing must
be done afterwards to figure out the real position. `map_entry` did not
do this for the returned key pointer so it could point to the wrong key
if probing was done.
2025-01-18 14:02:27 +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
98efb03934 Merge pull request #4599 from Barinzaya/fix_dynamic_resize_zeroing_on_grow
Fix dynamic array not zeroing when growing
2025-01-06 12:37:05 +00:00
gingerBill
a6f1046fc0 Merge pull request #4533 from laytan/map-entry
add `map_entry` procedure
2025-01-06 12:36:27 +00:00
gingerBill
f160ba4fa6 Merge pull request #4623 from Yawning/feature/rt-assert-ensure
base/runtime: Add `ensure` and `ensure_contextless`
2025-01-06 09:37:57 +00:00
fleandro
c93e096d8f fix N=1 and cleanup tests 2025-01-03 16:50:05 +00:00
fleandro
e3de02eaa8 runtime: map_cell_index_static produced wrong results when the number of elements per cell was a power of 2 2025-01-03 15:33:34 +00:00
Yawning Angel
3a5440e4ed base/runtime: Add ensure and ensure_contextless
This provides an equivalent to `assert` and `assert_contextless` that
are always evaluated, ignoring `ODIN_DISABLE_ASSERT`, which is useful
for enforcing API contracts or "asserting" on conditionals with
side-effects.
2024-12-25 00:08:09 +09:00
Barinzaya
5f46b5ca50 Fixed zeroing in resize_dynamic_array.
When a dynamic array has unused capacity and is resized to a size
greater than its capacity, the unused part of its capacity wasn't being
zeroed.
2024-12-19 17:52:09 -05:00
Laytan Laats
8050622fe6 add map_entry procedure 2024-11-28 20:07:54 +01:00
Jeroen van Rijn
56e4da8546 Fix #4509 2024-11-24 13:08:24 +01:00
Tetralux
2f85257bad [runtime] make(map[K]V) should not allocate any capacity
`make(map[K]V)` was resolving to `make_map_cap()` which allocates initial capacity when it wasn't intended to.
It now calls `make_map()` which doesn't allocate any capacity.

Both `make(map[K]V)` and `make(map[K]V, allocator)` will NOT allocate initial capacity now.
2024-11-16 06:13:12 +00:00
gingerBill
e38a08013e Remove #relative types from the compiler 2024-11-14 16:17:24 +00:00