Commit graph

107 commits

Author SHA1 Message Date
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
Brian Carroll
20e46fbda4 wasm: address PR feedback 2022-03-04 19:12:18 +00:00
Brian Carroll
5882ee4af0 wasm: add comment on why DataSection::bytes is public 2022-03-02 08:03:00 +00:00
Brian Carroll
9bf0fdb808 Fix clippy errors 2022-03-01 22:04:29 +00:00
Brian Carroll
21a3ed4258 wasm: fix dead code elimination in the case where there are live imports 2022-02-28 21:51:07 +00:00
Brian Carroll
4e7c1fe5e1 wasm: simplify ElementSection 2022-02-27 23:58:02 +00:00
Brian Carroll
7958158d89 wasm: comments & renaming 2022-02-27 23:42:05 +00:00
Brian Carroll
4c7be277c2 wasm: Keep exported global variables from the preloaded object file 2022-02-14 08:45:46 +00:00
Brian Carroll
b46690ecf2 wasm: Custom Debug impl for NameSection 2022-02-13 12:42:50 +00:00
Brian Carroll
63c33d82e3 wasm: Improve dead code elimination to handle indirect calls 2022-02-12 00:09:35 +00:00
Brian Carroll
54788b0357 wasm: Create a full model of the ElementSection 2022-02-11 18:44:47 +00:00
Brian Carroll
55465d15a0 wasm: include Name section in output binary, for debugging 2022-02-10 10:15:19 +00:00
Brian Carroll
8c5fe2ae22 wasm: implement Stmt::RuntimeError 2022-02-10 10:13:54 +00: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
Jan Van Bruggen
c1dc0226f6 Fix a lint error by simplifying an if/else block
From `cargo clippy -- -D warnings`:
```
error: all if blocks contain the same code at the start
   --> compiler/gen_wasm/src/wasm_module/sections.rs:478:9
    |
478 | /         if bytes[*cursor] == 0 {
479 | |             u8::skip_bytes(bytes, cursor);
480 | |             u32::skip_bytes(bytes, cursor);
    | |___________________________________________^
    |
    = note: `-D clippy::branches-sharing-code` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
help: consider moving the start statements out like this
    |
478 ~         u8::skip_bytes(bytes, cursor);
479 +         u32::skip_bytes(bytes, cursor);
480 +         if bytes[*cursor] == 0 {
    |

error: could not compile `roc_gen_wasm` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
```
2022-01-16 06:14:10 -07:00
Brian Carroll
6bdc27a49e Wasm: Use Vec instead of MutSet for called preloads 2022-01-15 15:35:42 +00:00
Brian Carroll
94ea50f56a Wasm: Clarify some more magic numbers 2022-01-15 15:35:42 +00:00
Brian Carroll
9290d3ad5c Wasm: Clarify where magic constant 5 comes from 2022-01-15 15:35:42 +00:00
Brian Carroll
e37ca971bd Wasm: Simplify CodeBuilder serialization, based on Richard's suggestion 2022-01-15 15:35:37 +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
f4137013cb Wasm: tweaks from self-review 2022-01-14 18:50:52 +00:00
Brian Carroll
c5134fa015 Wasm: rename DeadCodeMetadata to PreloadsCallGraph 2022-01-14 18:37:52 +00:00
Brian Carroll
4311b5a410 Wasm: Make dead functions unreachable, and the same for all return types 2022-01-14 18:21:13 +00:00
Brian Carroll
e7dc442af0 Wasm: fix double-counting bug in dead function replacement 2022-01-14 18:20:52 +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
22d7ccfbd7 Wasm: Comment explaining DCE 2022-01-14 18:20:52 +00:00
Brian Carroll
6b204d11a2 Wasm: sort and deduplicate on each round of live function tracing 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
ca2597973e Wasm: store function_count on the ImportSection 2022-01-14 18:20:52 +00:00
Brian Carroll
7a4593170c Wasm: reuse existing SkipBytes code for opcodes 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
98400cae1b Wasm: Move code around 2022-01-14 18:20:52 +00:00
Brian Carroll
61d46be923 Wasm: Parse the Code section to collect metadata for dead function elimination 2022-01-14 18:20:52 +00:00
Brian Carroll
48f14f9a83 Wasm: Implement SkipBytes for OpCode 2022-01-14 18:20:52 +00:00
Brian Carroll
2ade357ea9 Wasm: Specify the format of immediate operands for each opcode 2022-01-14 18:20:52 +00:00
Brian Carroll
dd79a9b35a Clippy fixes 2022-01-13 05:41:52 +00:00
Brian Carroll
8a384ffa88 Wasm: parse just enough of the Import section to count functions 2022-01-13 05:41:52 +00:00
Brian Carroll
9f0e0d5099 Wasm: create a hashmap of exported functions 2022-01-13 05:41:52 +00:00
Brian Carroll
fa46ab95fc Wasm: rename some constants 2022-01-13 05:41:52 +00:00
Brian Carroll
f9fbe461d1 Wasm: Fix section parsing bug 2022-01-13 05:41:52 +00:00
Brian Carroll
3067358a33 Wasm: test for LEB-128 decoder 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
d3554b2ac0 Wasm: Create Section trait for common functionality between module sections 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
5a39002e8b Wasm: Serialize WasmModule without linking info 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
d88b86e884 Wasm: change TypeSection tests to unit tests rather than integration tests 2022-01-13 05:41:52 +00:00
Brian Carroll
8e7f398e50 Wasm: Remove code to adjust function indices based on imports
With pre-linking we don't need this anymore. Pure Roc code can't add Imports.
2022-01-13 05:41:52 +00:00
Brian Carroll
c5653951a4 Wasm: improve the TypeSection preload test 2022-01-10 10:26:43 +00:00
Brian Carroll
8f73b722ff Wasm: fix release build 2022-01-10 10:26:43 +00:00