Commit Graph

79 Commits

Author SHA1 Message Date
gingerBill
70ddb74e40 Add mem.make_over_aligned 2025-03-31 10:51:02 +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
teapo
4895065afb Add SoA make/delete to core:mem 2025-01-15 20:16:57 +01:00
flysand7
3ed2ab6e2c [mem]: Adjust the docs for calc_padding_with_header 2024-09-14 10:18:51 +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
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
2b9096517c [mem]: Code formatting 2024-09-07 09:20:56 +11:00
Feoramund
d43c6e39f6 Fix #4151
The `core:mem` procs were calling the wrong `runtime` procs for their
number of arguments.
2024-08-26 13:23:04 -04:00
gingerBill
5fe0788cff Minimize code duplication in core:mem by using the base:runtime calls 2024-04-03 11:47:39 +01:00
gingerBill
3e7e779abf Replace core:* to base:* where appropriate 2024-01-28 22:18:51 +00:00
Colin Davidson
b6838731f5 oops, indentation 2024-01-17 13:30:03 -08:00
Colin Davidson
991c1d4446 add resize_non_zeroed to query features 2024-01-17 13:27:19 -08:00
Colin Davidson
58e4a011c7 add non-zeroing append and resize 2023-12-04 00:08:13 -08:00
gingerBill
4a75a1e839 Merge branch 'master' into separate-int-word-sizes 2023-06-06 22:42:04 +01:00
gingerBill
600c97cc0f Add missing Allocator_Error and @(require_results) to many procedures 2023-05-22 11:34:38 +01:00
gingerBill
f5d9ca64f9 Begin work on new pseudo-architecture: wasm64p32 2023-04-20 12:02:32 +01:00
gingerBill
ad0f11668b Correct map_reserve_dynamic caused by an bizarre code generation bug 2022-11-13 14:53:58 +00:00
gingerBill
f2f2d532f5 Add extra calls to Tracking_Allocator 2022-11-09 22:31:49 +00:00
gingerBill
dae299b781 Make map_free_dynamic take the total size of the allocation 2022-11-08 15:40:30 +00:00
gingerBill
c96e0afbf1 Begin work on implementing the new map internals 2022-11-07 23:02:21 +00:00
gingerBill
5cf473b31c Fix typo 2022-09-22 15:19:24 +01:00
gingerBill
7f601c9535 Add Allocator_Mode.Alloc_Non_Zerored 2022-09-22 12:12:57 +01:00
gingerBill
c97a8418dc Clean-up and unification for the allocation procedures 2022-08-08 12:23:19 +01:00
gingerBill
4aca9372a6 Improve resize call 2022-08-08 12:11:30 +01:00
gingerBill
10f1d8c604 Fix typo 2022-05-21 13:38:38 +01:00
gingerBill
3049e07f72 Add mem.DEFAULT_PAGE_SIZE 2022-05-21 13:30:09 +01:00
Jeroen van Rijn
eb9665f836 fix mem.new_clone 2021-09-19 22:19:06 +02:00
Jeroen van Rijn
bf15e63130 Revert "Merge pull request #1177 from Kelimion/new_clone"
This reverts commit efa513262e, reversing
changes made to daccfca11d.
2021-09-19 22:16:02 +02:00
Jeroen van Rijn
64ce55944a fix mem.new_clone 2021-09-19 22:10:19 +02:00
gingerBill
251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill
4ccf135892 Unify new/make the internal logic between runtime and mem 2021-08-23 12:35:29 +01:00
gingerBill
7bbc9a4634 Add #any_int directive to replace auto_cast uses on parameters. 2021-08-15 12:56:59 +01:00
gingerBill
4d00c2b800 Allocator_Error.Mode_Not_Implemented; Minor improvement to map runtime procedures 2021-08-08 14:29:45 +01:00
Jeroen van Rijn
4f51d74fc2 Fix typo in core:mem alloc() comment. 2021-05-06 11:25:41 +02:00
gingerBill
c3b3194a00 Update builtin procedures to support the new allocator features (without breaking other code) 2021-04-19 22:44:20 +01:00
gingerBill
f98c4d6837 Improve the Allocator interface to support returning Allocator_Error to allow for safer calls
Virtually all code (except for user-written custom allocators) should work as normal. Extra features will need to be added to make the current procedures support the `Allocator_Error` return value (akin to #optional_ok)
2021-04-19 12:31:31 +01:00
gingerBill
aa93305015 Replace usage of inline proc with #force_inline proc in the core library 2021-02-23 16:14:47 +00:00
gingerBill
415379e1cf Fix delete_map 2021-02-02 16:30:34 +00:00
gingerBill
fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
gingerBill
e7f54d25d6 Add mem.Allocator_Query_Info and mem.query_info 2020-08-16 23:05:33 +01:00
gingerBill
033b46def8 Add mem.Allocator_Mode.Query_Features, mem.Allocator_Mode_Set, mem.query_features` 2020-08-16 22:07:40 +01:00
gingerBill
1f571f48e5 Add mem.Tracking_Allocator 2020-08-16 21:29:14 +01:00
gingerBill
dbaf8568d6 Fix reflect.length 2020-04-15 18:56:19 +01:00
gingerBill
9e698b720f Change behaviour for zero-sized value types of array-related types; Fix make behaviour to always zero memory 2020-04-12 10:41:44 +01:00
Tetralux
b32ef9e47b Fix make and reserve
- Set the allocator, even if memory allocation fails.
  Right now it doesn't, which means that if allocation fails, it'll use
  the context allocator instead. This memory will be leaked if the user
  doesn't understand that this happened.

- Only set len and cap of the array returned from make iif the memory allocation
  succeeded.
  This means that reserve will return false if you do this:
  ```
  a := make([dynamic]int, failing_allocator);
  if !reserve(&a, 5) do return; // or whatever indicates failure
  ```
2020-01-03 10:40:45 +00:00
gingerBill
b8324b0776 Fix behaviour for make to return nil when alloc returns nil 2020-01-03 10:17:30 +00:00
gingerBill
ab52f8d795 Move definition of mem.Allocator and log.Logger to package runtime, to reduce import cycle magic 2019-12-31 12:15:19 +00:00
Tetralux
99121d6ff2 Implement core:thread and core:sync on Unix using pthreads
Also do some cleanup and refactoring of the thread, sync and time APIs.

- remove 'semaphore_release' because 'post' and 'wait' is easier to understand

- change 'semaphore_wait' to '*_wait_for' to match Condition

- pthreads can be given a stack, but doing so requires the user to set up the guard
  pages manually. BE WARNED. The alignment requirements of the stack are also
  platform-dependant; it may need to be page size aligned on some systems.
  Unclear which systems, however. See 'os.get_page_size', and 'mem.make_aligned'.
  HOWEVER: I was unable to get custom stacks with guard pages working reliably,
  so while you can do it, the API does not support it.

- add 'os.get_page_size', 'mem.make_aligned', and 'mem.new_aligned'.

- removed thread return values because windows and linux are not consistent; windows returns 'i32'
  and pthreads return 'void*'; besides which, if you really wanted to communicate how the
  thread exited, you probably wouldn't do it with the thread's exit code.

- fixed 'thread.is_done' on Windows; it didn't report true immediately after calling 'thread.join'.

- moved time related stuff out of 'core:os' to 'core:time'.

- add 'mem.align_backward'

- fixed default allocator alignment
  The heap on Windows, and calloc on Linux, both have no facility to request alignment.
  It's a bit of hack, but the heap_allocator now overallocates; `size + alignment` bytes,
  and aligns things to at least 2.
  It does both of these things to ensure that there is at least two bytes before the payload,
  which it uses to store how much padding it needed to insert in order to fulfil the alignment
  requested.

- make conditions more sane by matching the Windows behaviour.
  The fact that they were signalled now lingers until a thread tries to wait,
  causing them to just pass by uninterrupted, without sleeping or locking the
  underlying mutex, as it would otherwise need to do.
  This means that a thread no longer has to be waiting in order to be signalled, which
  avoids timing bugs that causes deadlocks that are hard to debug and fix.
  See the comment on the `sync.Condition.flag` field.

- add thread priority: `thread.create(worker_proc, .High)`
2019-12-01 00:46:23 +00:00