Commit graph

5620 commits

Author SHA1 Message Date
Folkert
fa57ff88a5 disable list of constants in read-only section 2021-10-03 00:16:52 +02:00
Folkert
7e6a3431e2 trick morphic into updating a value that comes from the host 2021-10-03 00:07:38 +02:00
Folkert
5a8547f2d4 trick morphic into specializing closure callers 2021-10-03 00:05:17 +02:00
Brian Carroll
79a4f2bbf7 Refactor SymbolStorage local_id code, and copy_memory
SymbolStorage had some rather ad-hoc methods for extracting pieces of data.
This change makes that more intentional and organised.

Also cleaned up the API for the related function copy_memory,
as it had lots of positional arguments with the same types.
Created a struct for this just to name them and make the code clearer.
2021-10-02 22:31:48 +01:00
Brian Carroll
6aed70978d Refactor SymbolStorage into two enums instead of one 2021-10-02 16:15:06 +01:00
Richard Feldman
7d6aca5a4e
Merge pull request #1754 from rtfeldman/www
Add 'a taste of roc' link to www
2021-10-02 09:40:19 -05:00
Brian Carroll
ffa6ff0a62 gen_wasm: Get rid of individual locals for values in stack memory
All values in stack memory can share the stack frame pointer,
with different offsets.

This avoids having to generate initialisation code for individual
pointers we used to have. It should also make things more efficient
when the runtime compiles Wasm to machine code. It can just assign
the stack frame pointer to a single CPU register and leave it there.

The original idea was to make params and local variables work the same.
(A struct param will be passed as a pointer to caller stack memory.)
But now I don't think that's worth it. Some match expressions get more
awkward this way but we might be able to refactor that to be nicer.
2021-10-02 15:12:25 +01:00
Brian Carroll
4aa2452e01 gen_wasm: Change some compiler bugs error handling from Result to panic
Result makes sense where I have something meaningful to say to the user like
"X is not implemented yet". And also for public functions that may interface
with other parts of the project like Backend.

But for private functions internal to gen_wasm, it's just unhelpful to get a stack trace
to where the Result is unwrapped! I want a stack trace to the root cause.
I always end up temporarily rewriting Err("oops") to panic!("oops") and then waiting
for it to recompile.

This feels like a more balanced approach, using each technique where it makes sense.
2021-10-02 13:40:44 +01:00
Folkert
f1ec5c30d0 make things compile 2021-10-01 20:33:34 +02:00
Anton-4
f63c276a5f docs flow working with mocked markup to html 2021-10-01 18:22:27 +02:00
Folkert de Vries
a42620ecb5
Merge pull request #1752 from rtfeldman/wasm_stack_memory
Wasm stack memory
2021-09-30 23:53:38 +02:00
Brian Carroll
304e9c904f Formatting 2021-09-30 17:28:02 +01:00
Brian Carroll
92085a0fcb README notes on reducing gets and sets 2021-09-30 17:27:56 +01:00
Brian Carroll
7ac7e16f60 Ensure stack frame is always popped when procedure returns from inside a branch 2021-09-30 17:04:16 +01:00
Brian Carroll
79ac2f04b8 Improve stack allocation code 2021-09-30 17:04:16 +01:00
Brian Carroll
f1b14c14e3 Refactor SymbolStorage to emphasise stack/non-stack params
We don't have much (any) code that cares about the difference between
heap pointers and other primitives, but we have a _lot_ of code that cares
if it's stack memory. So let's encode it that way.
2021-09-30 17:04:16 +01:00
Folkert de Vries
c4c7ecf1bc
Merge pull request #1751 from rtfeldman/str-repeat
Add Str.repeat builtin
2021-09-30 12:47:49 +02:00
Kofi Gumbs
2f574ea75e Remove extraneous .into() 2021-09-29 22:41:30 -04:00
Kofi Gumbs
b2343cb0ad Format zig 2021-09-29 21:54:14 -04:00
Kofi Gumbs
0cdafa1623 Add Str.repeat test for big strings 2021-09-29 21:54:06 -04:00
Kofi Gumbs
b32a42f05a Add Str.repeat builtin 2021-09-29 17:32:42 -04:00
Brian Carroll
7ea59ad9d4 PR tidy-ups 2021-09-29 06:15:58 +01:00
Brian Carroll
93448182e4 Merge branch 'trunk' of github.com:rtfeldman/roc into wasm_stack_memory 2021-09-28 19:08:36 +01:00
Brian Carroll
45c9dc8617 update gen_wasm README 2021-09-28 19:06:47 +01:00
Brian Carroll
02bb9028ef Returning records on the stack from Wasm dev backend! 2021-09-28 08:06:59 +01:00
Anton-4
e0bd644c79 single threaded file loading with env var 2021-09-27 15:16:07 +02:00
Brian Carroll
39fda3e675 Add more information to SymbolStorage
SymbolStorage is function-specific, whereas WasmLayout is function-independent.

SymbolStorage used to be a single-variant enum with a LocalId and a WasmLayout,
but now we need more variants, so we can handle stack memory allocation..

- For values in stack memory, the storage needs to include an offset within the
  stack frame, but we don't need that for primitive values.

- For function parameters, the allocated stack memory is in the caller's frame
  rather than the current frame, so we don't want size or offset.

We could have kept a WasmLayout inside of SymbolStorage but that would have made
possible a lot of invalid combinations. It seemed better to copy the fields we need.
2021-09-26 20:52:17 +01:00
Brian Carroll
ecece45a83 Add a helper method local_id_from_symbol 2021-09-26 20:52:17 +01:00
Brian Carroll
ae6cfe1992 Moree implementations for Wasm32TestResult 2021-09-26 20:52:16 +01:00
Brian Carroll
286ca680e0 Tidy up load_literal 2021-09-26 20:52:16 +01:00
Brian Carroll
ab4f28fd69 Comment out a test that isn't working 2021-09-26 20:52:16 +01:00
Brian Carroll
92b1d73bd6 Refactor build_proc into smaller helpers 2021-09-26 20:52:10 +01:00
Folkert
bd6e966833 clippy 2021-09-26 13:28:03 +02:00
Folkert
e9f2fb6193 actually define the arguments 2021-09-26 13:06:06 +02:00
Folkert
ed658ca2aa ugly but working fix for passing the closure env to a function 2021-09-26 13:05:58 +02:00
Folkert
267f88626f add failing test 2021-09-26 13:05:45 +02:00
Folkert de Vries
f7c1a6e952
Merge pull request #1734 from rtfeldman/alias-analysis-const-list
alias analysis static list
2021-09-26 12:43:28 +02:00
Folkert de Vries
a263d57e62
Merge pull request #1738 from rtfeldman/list-function-unit
empty list of functions
2021-09-26 12:43:06 +02:00
Brendan Hansknecht
d9e28ed4b1 Merge branch 'trunk' into test-linker 2021-09-25 12:21:05 -07:00
Brendan Hansknecht
e6c137889a Just disable gc-sections with surgical linker for rust hosts for now 2021-09-25 12:19:56 -07:00
Brendan Hansknecht
411ed58eec Fix rust host with surgical linking 2021-09-24 21:37:58 -07:00
Folkert
72194b87df fix typo 2021-09-24 21:58:25 +02:00
Folkert
23e8f6c687 only introduce rigid once! 2021-09-24 21:53:41 +02:00
Brendan Hansknecht
c334e4d3e5 Export zig builtin version of __muloti4 as weak so it doesn't conflict if it already exists 2021-09-24 08:54:41 -07:00
Brendan Hansknecht
95f29c4d5b Remove stale comment about F16 2021-09-24 08:35:34 -07:00
Brendan Hansknecht
e546ec0c37 Add builtins to precompiled host 2021-09-24 08:31:31 -07:00
Brendan Hansknecht
d1021d652d Add StrCat support and update hello-zig to support dev backend 2021-09-24 08:31:31 -07:00
Brendan Hansknecht
2f24067267 Add small string support to the dev backend 2021-09-24 08:12:42 -07:00
Folkert
c11d89c4bf fix typo 2021-09-24 15:47:53 +02:00
Folkert
b7f26baf95 add mono test 2021-09-24 15:44:09 +02:00