Brian Carroll
e2b95662a8
Fix wasm linking bugs
2021-11-09 21:22:12 +00:00
Folkert
a9ce02799c
WIP
2021-11-09 21:37:56 +01:00
Brian Carroll
4948cee360
Fix clippy warnings
2021-11-09 15:49:08 +00:00
Brian Carroll
d0ffaabe83
Re-index all internal functions to make room for imported external functions
...
Linked external functions must be declared in the Import section,
and they must come first in the function index space.
In other words, internal function numbers start at the number of imports.
However we don't know in advance how many builtins the code may call,
and we don't want to add more passes over the full IR. Instead we re-index
function references at the end of code generation.
2021-11-09 14:50:53 +00:00
Brian Carroll
a61987e032
Rename CodeBuilder::finalize -> CodeBuilder::build_fn_header
...
We actually have a few more steps to go after this one!
2021-11-09 14:28:15 +00:00
Brian Carroll
1b5740cd5d
Tidy up lowlevel calls and implement a few more
2021-11-09 14:28:15 +00:00
Brian Carroll
5bfc0093ec
Intitialise CodeSection with just the right capacity
2021-11-08 14:59:49 +00:00
Brian Carroll
34b57cf315
Refactor after creating constant linking data
2021-11-07 11:23:20 +00:00
Brian Carroll
38d9fc5bbd
Add linker data for strings, and deduplicate them
...
For references to addresses of constant strings, we make an entry in
reloc.CODE and configure the relocation type to say it points at a
memory address. (At least I think this is right, I can't test it yet!)
The same info can also be used for de-duplication.
It turns out we don't need reloc.DATA. I had misunderstood it.
The use case for that would be constant nested data structures,
where constant data would contain pointers to other constant data.
I don't think we're doing this in Roc at all, but not sure.
2021-11-07 11:20:32 +00:00
Brian Carroll
09f2ce327c
Change some comments after self-review
2021-11-04 21:19:23 +00:00
Brian Carroll
c798c9d444
Implement long string literals
2021-11-04 20:44:29 +00:00
Brian Carroll
414c9e6f86
Move WasmModule initialisation into WasmBackend
...
It helps to coordinate different sections with related values,
based on knowledge of Roc rather than Wasm.
2021-11-04 20:41:23 +00:00
Brian Carroll
46c19b59d4
Add support for small string literals
2021-11-04 14:29:46 +00:00
Brian Carroll
2f430fce86
Refactor literals
2021-11-04 13:40:34 +00:00
Brian Carroll
ad9b761fce
Move wasm file format code into a submodule
2021-11-03 11:20:16 +00:00
Brian Carroll
87f6246851
Remove parity-wasm!
2021-11-03 10:36:08 +00:00
Brian Carroll
59757d638a
Migrate the last sections: Type and Function
2021-11-03 10:24:03 +00:00
Brian Carroll
b0aeafc066
Refactor code section to get rid of a copy
2021-11-02 20:34:57 +00:00
Brian Carroll
edadd4ce13
Temporary setup to gradually migrate sections from parity_wasm to our own module_builder
...
Previously we just had our own code section.
Now we also have export section, and a way of switching them over one by one,
running tests in between.
2021-11-02 12:46:15 +00:00
Brian Carroll
6ab00d164c
Create WasmModule struct
2021-11-01 00:06:25 +00:00
Brian Carroll
49ac08546c
Replace a vector reference with a slice
2021-11-01 00:01:48 +00:00
Brian Carroll
96832ed1e3
self review
2021-10-30 18:22:09 +01:00
Brian Carroll
2da2e51895
Move relocations code into the backend and code builder
2021-10-30 09:20:16 +01:00
Brian Carroll
9780cce4dd
Rough draft of function name relocations
2021-10-30 08:55:33 +01:00
Brian Carroll
2020e89db7
Create reserve_padded_u32, nice for readability
2021-10-28 22:44:33 +01:00
Brian Carroll
82acf55d38
Create serializer module
2021-10-28 11:50:55 +01:00
Brian Carroll
f066adbe05
Adjust relocation offset to account for inserts, preamble, function offset, etc.
2021-10-27 16:50:30 +01:00
Brian Carroll
1def56ea04
Build up a vector of relocations
2021-10-26 23:31:36 +01:00
Brian Carroll
fd3d8f5227
Get rid of procedure sorting
2021-10-26 22:44:28 +01:00
Brian Carroll
6534da5055
Fix LEB encoding and refactor insertions
2021-10-24 11:54:21 +02:00
Brian Carroll
13577aa9ec
Combine our handmade Code section with other sections from parity_wasm (tests compile but fail)
2021-10-23 17:12:49 +02:00
Brian Carroll
973626fe2d
Rename FunctionBuilder back to CodeBuilder
2021-10-23 13:48:20 +02:00
Brian Carroll
74e3239a1c
Switch over to function_builder
2021-10-23 13:39:54 +02:00
Brian Carroll
4563e2af49
Get function_builder compiling
2021-10-22 10:38:53 +02:00
Brian Carroll
5ea313f256
update gen_wasm to use bumpalo::collections::Vec where possible
2021-10-21 21:14:15 +02:00
Brian Carroll
401f2ececd
rename some methods
2021-10-18 21:35:16 +02:00
Brian Carroll
f242aade86
Rename a variable & fix a bug calling functions that return via stack memory
2021-10-18 18:35:48 +02:00
Brian Carroll
1b97675f1f
Refactor the optimisation for immediately-returned Let statements
...
The original intention was to avoid creating a local when we define
and immediately return a primitive value. But now our default path
does avoids unnecessary locals anyway!
For StackMemory values we do need an optimised path but it's nicer
to just pass a flag to Storage::allocate.
2021-10-18 13:18:10 +02:00
Brian Carroll
2daefc8b32
Name a constant
2021-10-18 13:11:05 +02:00
Brian Carroll
6206418b67
Fix clippy warnings
2021-10-14 00:13:47 +02:00
Brian Carroll
5c42455ca7
Rename some values & improve comments
2021-10-13 10:52:51 +02:00
Brian Carroll
472943a068
Refactoring: extract Storage out of WasmBackend
2021-10-12 10:22:38 +01:00
Brian Carroll
d2e01bd10a
rename SymbolStorage -> StoredValue
2021-10-12 10:20:17 +01:00
Brian Carroll
f6685349b3
Batch local declarations to save a few bytes and make some code a little nicer
2021-10-10 22:21:13 +01:00
Brian Carroll
041e26e807
rename CodeBuilder methods
2021-10-10 20:56:39 +01:00
Brian Carroll
c5ee41af25
rename code_builder
2021-10-10 20:56:32 +01:00
Brian Carroll
8164a14dfa
rename module_builder
2021-10-10 20:56:20 +01:00
Brian Carroll
47f93bddea
Fix & refactor create_storage
2021-10-10 10:36:23 +01:00
Brian Carroll
d166f65a31
Fix bug: Forgot to generate a local for the stack frame pointer
2021-10-09 18:16:24 +01:00
Brian Carroll
476c1664ec
Add debug logging to CodeBuilder and fix a minor bug
2021-10-09 17:24:37 +01:00