Commit Graph

47 Commits

Author SHA1 Message Date
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
gingerBill
53d8216311 Reorganize package mem 2019-02-10 22:15:34 +00:00
gingerBill
28583bfff8 Change procedure group syntax from proc[] to proc{}; deprecate proc[] (raises warning currently) 2018-12-02 18:01:03 +00:00
gingerBill
444f4f446a -vet flag to do basic vetting of code 2018-11-25 14:14:58 +00:00
gingerBill
ce2e23849e Fix context initialization 2018-10-20 16:34:56 +01:00
gingerBill
0971a59493 Update runtime printing code 2018-10-11 18:19:29 +01:00
gingerBill
5bdb424c6b context.allocator = a; Remove __ from runtime procs; improve division for complex numbers 2018-09-15 10:14:24 +01:00
Joshua Mark Manton
8cd2797b2e Fixed core library bugs after recent changes. (#257)
* Fix `delete_map` calling `delete_dynamic_array` instead of `delete_slice for its hashes.

* Removed print statements from `__dynamic_map_rehash`
2018-09-02 22:18:32 +02:00
gingerBill
11f5236434 Add $T: typeid/[]$E; Deprecate T: type/[]$E
`type` as a keyword will soon be removed in favour of polymorphic names (identifiers) in procedures
2018-09-02 16:33:54 +01:00
gingerBill
aa542980ce Change memory layout of map to be 3 words smaller 2018-08-30 19:14:10 +01:00
gingerBill
c19ec5d65d Fix delete for dynamic array and map 2018-08-30 12:00:51 +01:00
gingerBill
ae57284912 Add Assertion_Failure_Proc to context 2018-08-29 21:10:13 +01:00
gingerBill
001837e6bb Temporary allocator for context 2018-08-29 19:55:55 +01:00
gingerBill
28523f17e2 Add default allocator to allocation related procedures e.g. alloc, free, delete, make 2018-08-28 20:14:56 +01:00
gingerBill
cbc6c2666b Improve proc group scoring algorithm 2018-08-21 14:11:18 +01:00
gingerBill
0dc29a7208 Implement suggestions from #247 2018-08-20 19:20:28 +01:00
gingerBill
8be9b5082c Fix default make parameters for dynamic arrays 2018-08-09 18:15:49 +01:00
gingerBill
70586b1cf8 auto_cast prefix for procedure parameters 2018-08-09 17:58:11 +01:00
gingerBill
877a78d6ba Fix make error messages 2018-08-08 23:07:51 +01:00
gingerBill
3a1a7b40f9 Add runtime messages for make for the len/cap parameters 2018-08-08 13:04:40 +01:00
gingerBill
835d7dcab2 make as a user-level procedure rather than a built-in procedure 2018-08-08 13:04:40 +01:00
gingerBill
fad3947e26 Add *with_allocator procedures to mem 2018-08-05 23:40:19 +01:00
gingerBill
0e91298fd1 Rename free to delete for non pointer types 2018-07-08 11:03:56 +01:00
gingerBill
ba67e474d3 Make source code compile with 32 bit (but not build 32 bit code) 2018-06-15 21:46:03 +01:00
gingerBill
e9e7ce2606 Allow .allocator for dynamic arrays; Add mem.Pool 2018-06-12 19:10:14 +01:00
Joshua Mark Manton
f0a4526250 Fix alloc.odin using old raw file 2018-06-03 11:22:42 -07:00
gingerBill
d556fa2cd8 Remove special shared scope for runtime stuff 2018-06-03 15:06:40 +01:00
gingerBill
6eb505a677 Comment based build tags for packages (basic and temporary) 2018-05-28 20:59:06 +01:00
gingerBill
547a2831c7 Clean up name mangling by using unique package names per project 2018-05-27 22:09:11 +01:00
gingerBill
5c52ffe24e Reorganize runtime package 2018-05-27 21:22:25 +01:00