Commit graph

238 commits

Author SHA1 Message Date
Brian Carroll
1afada4075 wasm: fix panic on empty Struct expression 2022-03-12 09:30:27 +00:00
Folkert
574f14522d
placeholders in the wasm code 2022-03-09 00:04:23 +01:00
Brian Carroll
70804e9bec Merge branch 'trunk' of github.com:rtfeldman/roc into wasm-runtime-error 2022-03-08 08:58:15 +00:00
Brian Carroll
9ae26c5aac wasm: use __data_end to account for all constant data including zero (bss) data 2022-03-08 08:56:34 +00:00
Derek Gustafson
ba6b225761
Hide RocDec implemntation details. 2022-03-07 15:34:02 -05:00
Brian Carroll
7958158d89 wasm: comments & renaming 2022-02-27 23:42:05 +00:00
Brian Carroll
7ccc5ec768 Merge branch 'trunk' of github.com:rtfeldman/roc into wasm-runtime-error 2022-02-27 22:57:23 +00:00
Brian Carroll
89b8926d27 gen_wasm: fix bug choosing the right proc specialization (#2549) 2022-02-21 22:52:45 +00:00
ayazhafiz
e52d427ac8 Hash record field name order in generated layouts
Closes #2535

See the referenced issue for longer discussion - here's the synopsis.
Consider this program

```
app "test" provides [ nums ] to "./platform"

alpha = { a: 1, b: 2 }

nums : List U8
nums =
    [
        alpha.a,
        alpha.b,
    ]
```

Here's its IR:

```
procedure : `#UserApp.alpha` {I64, U8}
procedure = `#UserApp.alpha` ():
    let `#UserApp.5` : Builtin(Int(I64)) = 1i64;
    let `#UserApp.6` : Builtin(Int(U8)) = 2i64;
    let `#UserApp.4` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = Struct {`#UserApp.5`, `#UserApp.6`};
    ret `#UserApp.4`;

procedure : `#UserApp.nums` List U8
procedure = `#UserApp.nums` ():
    let `#UserApp.7` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = CallByName `#UserApp.alpha`;
    let `#UserApp.1` : Builtin(Int(U8)) = StructAtIndex 1 `#UserApp.7`;
    let `#UserApp.3` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = CallByName `#UserApp.alpha`;
    let `#UserApp.2` : Builtin(Int(U8)) = StructAtIndex 1 `#UserApp.3`;
    let `#UserApp.0` : Builtin(List(Builtin(Int(U8)))) = Array [`#UserApp.1`, `#UserApp.2`];
    ret `#UserApp.0`;
```

What's happening is that we need to specialize `alpha` twice - once for the
type of a narrowed to a U8, another time for the type of b narrowed to a U8.

We do the specialization for alpha.b first - record fields are sorted by
layout, so we generate a record of type {i64, u8}. But then we go to
specialize alpha.a, but this has the same layout - {i64, u8} - so we reuse
the existing one! So (at least for records), we need to include record field
order associated with the sorted layout fields, so that we don't reuse
monomorphizations like this incorrectly!
2022-02-21 14:10:45 -05:00
Brian Carroll
8c5fe2ae22 wasm: implement Stmt::RuntimeError 2022-02-10 10:13:54 +00:00
Brian Carroll
4b585cc6c6 wasm: More explicit todo! statements 2022-02-09 17:23:36 +00:00
Folkert
c663a35e16 final phase 2022-01-26 15:44:24 +01:00
Mats Sigge
71f359fbdc Move macros from roc_reporting to new roc_error_macros module
The `internal_error!` and `user_error!´ macros can't be used everywhere
when they live in `roc_reporting` due to circular dependencies.
2022-01-23 18:40:04 +01:00
Brian Carroll
f354b4842b Wasm: Move Eq/NotEq into LowLevelCall 2022-01-17 09:35:08 +00:00
Brian Carroll
f635dd8776 Wasm: Refactor lowlevels to get more flexibility without increasing boilerplate. 2022-01-17 09:33:06 +00:00
Brian Carroll
5e68f298df Wasm: Reorganise Stmt and Expr methods 2022-01-15 15:53:41 +00:00
Brian Carroll
6bdc27a49e Wasm: Use Vec instead of MutSet for called preloads 2022-01-15 15:35:42 +00:00
Brian Carroll
8c4fd93b07 Wasm: Remove old debug code that's never used. We have the HTML debugger now. 2022-01-15 13:27:34 +00:00
Brian Carroll
8d5a1cb661 Wasm: Replace _ todo with RuntimeError todo 2022-01-15 13:27:34 +00:00
Brian Carroll
c38134bdc0 Wasm: remove legacy unused ret_layout 2022-01-15 13:27:34 +00:00
Brian Carroll
bafb6e54d0 Wasm: Change panic for literals todo -> internal_error 2022-01-15 13:27:34 +00:00
Brian Carroll
91a0b21e70 Wasm: Get rid of some Backend compatibility code 2022-01-15 13:27:34 +00:00
Brian Carroll
c7da7ca689 Wasm: Parse the Name section, export init_refcount_test, and don't DCE exports 2022-01-14 18:20:52 +00:00
Brian Carroll
9dabc2db15 Wasm: adjust dead code elimination to account for import function indices 2022-01-14 18:20:52 +00:00
Brian Carroll
8a01c3f98a Wasm: implement dead code elimination 2022-01-14 18:20:52 +00:00
Brian Carroll
dd79a9b35a Clippy fixes 2022-01-13 05:41:52 +00:00
Brian Carroll
c8181c3a19 Wasm: use parsed data from object file in the backend 2022-01-13 05:41:52 +00:00
Brian Carroll
9f8f31b2b6 Wasm: adjust function indices for preloading 2022-01-13 05:41:52 +00:00
Brian Carroll
9c0abcd0da Wasm: Preload WasmModule from object file bytes 2022-01-13 05:41:52 +00:00
Brian Carroll
5d5e0eca96 Wasm: Convert remaining sections to store bytes, and add .size() methods 2022-01-13 05:41:52 +00:00
Brian Carroll
f4ac5bffa3 Wasm: replace builtins imports with a hashmap 2022-01-13 05:41:52 +00:00
Brian Carroll
b8ab6af203 Wasm: move WasmModule definition to mod.rs 2022-01-13 05:41:52 +00:00
Brian Carroll
59278a02d6 Wasm: Create a LinkingSegment to keep string data aligned correctly 2022-01-10 10:26:43 +00:00
Brian Carroll
a1f737d6d8 Wasm: Create OpaqueSection for sections that may be used in builtins but not by us 2022-01-10 10:26:43 +00:00
Brian Carroll
738434329e Wasm: refactor the model of the Linking section 2022-01-10 10:26:42 +00:00
Brian Carroll
6db7dbed1c Wasm: Store DataSection as bytes and segment count 2022-01-10 10:26:42 +00:00
Brian Carroll
265171ad17 Wasm: Make sure string constants are placed at a properly aligned offset 2022-01-10 10:26:42 +00:00
Brian Carroll
b8f51fb1bb Wasm: add preloaded_bytes and preloaded_count to Code section 2022-01-10 10:26:42 +00:00
Brian Carroll
aec8d1bf3d Merge branch 'trunk' of github.com:rtfeldman/roc into str_to_num 2022-01-02 12:31:59 +00:00
Brian Carroll
f767014f30
Merge pull request #2301 from rtfeldman/wasm-refcount-list
Wasm refcounting for lists
2021-12-31 13:25:38 +00:00
Brian Carroll
0912f8fd45 Wasm: replace a local.set/get pair with a local.tee 2021-12-30 15:40:00 +00:00
Brian Carroll
acade33497 Wasm bugfix: allocate using the heap alignment, not the stack alignment 2021-12-30 15:37:09 +00:00
rvcas
e7825127d6 Merge branch 'trunk' into str_to_num 2021-12-29 18:17:33 -05:00
Brian Carroll
6b932f9743 Clarify some lowlevel code to make it clearer what to do when adding new ones 2021-12-29 22:11:33 +00:00
rvcas
0d187fb53c feat(wasm): use mono layout to figure out the correct intrinsic 2021-12-28 21:38:43 -05:00
Folkert de Vries
249878cbd9
Merge pull request #2281 from rtfeldman/i/2149
(llvm) Generate code for tag unions less than 64 bits in size correctly
2021-12-27 22:38:08 +01:00
Brian Carroll
0d8a2c8a49 Use tail call elimination where possible in == for tag unions 2021-12-27 18:08:43 +00:00
ayazhafiz
326bfe9aa3 Ensure WASM code gen uses proper tag ID alignment
We should use the alignment of the tag ID layout, not the alignment of
the rest of the data in the tag union. The reason is that the tag ID may
be smaller than the data.
2021-12-26 17:45:05 -06:00
Brian Carroll
e10acd59ee Debug config for Wasm backend 2021-12-26 10:45:18 +00:00
Brian Carroll
da4cf721cc Fix equality on empty structures 2021-12-26 10:40:45 +00:00