Commit graph

4976 commits

Author SHA1 Message Date
Brian Carroll
6aed70978d Refactor SymbolStorage into two enums instead of one 2021-10-02 16:15:06 +01: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 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 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
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
b7f26baf95 add mono test 2021-09-24 15:44:09 +02:00
Folkert
f43c10373f represent empty closure as unit (not void) 2021-09-24 15:41:00 +02:00
Brendan Hansknecht
a593713800 Fix surgical linking for C hosts with extra arg 2021-09-23 21:29:53 -07:00
Brendan Hansknecht
7d1b88b3fb Merge branch 'trunk' into integrate-linker 2021-09-23 21:12:40 -07:00
Folkert
f3fae8ea61 alias analysis static list 2021-09-23 23:18:05 +02:00
Folkert
cfdda10df4 fix argument passing 2021-09-22 21:23:53 +02:00
Folkert
3c53435e7e properly handle arguments to a closure caller 2021-09-22 21:16:50 +02:00
Folkert
b257a24edf don't canonicalize Apply arguments twice 2021-09-22 21:16:40 +02:00
Folkert
f82c4350fb handle shadowing type names 2021-09-22 21:16:29 +02:00
Folkert de Vries
9fd5ad53b5
Merge pull request #1724 from rtfeldman/gen-dev/joinpoint
Gen dev/joinpoint
2021-09-22 14:16:41 +02:00
Richard Feldman
33d9077989
Merge pull request #1720 from rtfeldman/direct-return-known-types
return values from roc
2021-09-21 21:43:51 -04:00
Brendan Hansknecht
0c6f8f308f Remove f16. It is not really supported by modern CPU hardware. 2021-09-21 16:51:47 -07:00
Brendan Hansknecht
d3c344e4da Add macros for common builtin types 2021-09-21 15:38:46 -07:00
Brendan Hansknecht
1a6ca4be59 Convert layout map to store Layouts in order to avoid unsafe mangling 2021-09-21 15:27:21 -07:00
Brendan Hansknecht
006fe3beff Remove borrow constraint, it is used for refcounting before the backend 2021-09-21 15:09:10 -07:00
Brendan Hansknecht
d710e78ab3
Merge branch 'trunk' into integrate-linker 2021-09-21 09:39:47 -07:00
Brendan Hansknecht
1fb0c8043f Optimize away unnecessary jump right before return 2021-09-21 00:14:13 -07:00
Brendan Hansknecht
54e2792b12 Fix typo 2021-09-20 23:41:20 -07:00