Commit Graph

26 Commits

Author SHA1 Message Date
Luuk de Gram
adf059f272 wasm: Update wasm stage2 test backend to use 'main' 2021-11-29 08:05:51 +01:00
Luuk de Gram
deb8d0765b wasm: Fix text cases and add pointer test cases
Ensure all previous test cases are still passing, as well as add some basic tests for now
for testing pointers to the stack.

This means we can start implementing wasm's C ABI found at: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md

We also simplified the block logic by always using 'void' block types and instead writing the value to a local,
which can then be referenced by continues instructions, as done currently by AIR.
Besides this, we also no longer need to insert blocks at an offset, as we simply write the saved temporary
after we create the block.
2021-11-21 21:07:55 +01:00
Luuk de Gram
6e139d124b wasm: Resolve feedback (wrapping arbitrary int sizes)
- This ensures we honor the user's integer size when performing wrapping operations.
- Also, instead of using ensureCapacity, we now use ensureUnusedCapacity.
2021-08-01 21:30:06 +02:00
Luuk de Gram
a861b7d160 wasm: Test cases for optionals 2021-08-01 11:07:23 +02:00
Luuk de Gram
e58976542b wasm: Test cases for wrap+intcast instructions 2021-08-01 11:07:23 +02:00
Luuk de Gram
30376a82b2 Re-enable switch test cases and fix regressions 2021-07-24 20:05:41 +02:00
Andrew Kelley
885477e2df stage2: disable wasm switch test case for now
The wasm codegen for switch was using br_if opcodes, but it needs to be
reworked to use a br_table opcode instead.
2021-07-20 19:01:19 -07:00
g-w1
1f0b77b3b8 stage2 type.zig: implement eql of error unions (#9334) 2021-07-08 14:35:43 -04:00
Andrew Kelley
5816997ae7 stage2: get tests passing
* implement enough of ret_err_value to pass wasm tests
 * only do the proper `@panic` implementation for the backends which
   support it, which is currently only the C backend. The other backends
   will see `@breakpoint(); unreachable;` same as before.
   - I plan to do AIR memory layout reworking as a prerequisite to
     fixing other backends, because that will help me put all the
     constants up front, which will allow the codegen to lower to memory
     without jumps.
 * `@panic` is implemented using anon decls for the message. Makes it
   easier on the backends. Might want to look into re-using decls for
   this in the future.
 * implement DWARF .debug_info for pointer-like optionals.
2021-07-07 14:17:04 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
18c1007a34 stage2 tests: remove unused vars 2021-06-21 17:03:03 -07:00
Jakub Konka
b0ee911c23 wasi: always grant fd_readdir right
Since v0.23 release of Wasmtime, if we want to iterate a directory
Y then directory Y needed to have been granted `fd_readdir` right.
However, it is now also required for directory X to carry `fd_readdir`
right, and so on, up-chain all the way until we reach the preopen
(which possesses all rights by default).

This caused problems for us since our libstd implementation is more
fine-grained and allowed for parent dirs not to carry the right while
allow for iterating on its children. My proposal here is to always
grant `fd_readdir` right as part of
`std.fs.Dir.OpenDirOptions.access_sub_paths`. This seems to be the
approach taken by Rust also, plus we should be justified to take this
approach since WASI is experimental and snapshot1 will be discontinued
eventually and replaced with a new approach to access management
that will require a complete rewrite of our libstd anyhow.
2021-06-08 05:48:33 +02:00
Luuk de Gram
5cbe930e36 wasm: Add stage2 tests for error unions 2021-05-28 12:58:17 +02:00
Luuk de Gram
0ac56e7f3a Add test cases for switches 2021-05-20 19:59:37 +02:00
Luuk de Gram
87a9c6946d wasm backend: implement multi_value for WValue
This allows us to differentiate between regular locals and variables that create multiple locals
on the stack such as optionals and structs.
Now `struct_a = struct_b;` works and only updates a reference, rather than update all local's values.

Also created more test cases to test against this.
2021-05-20 09:25:02 +02:00
Luuk de Gram
6962647862 Do not create a local for the struct itself + test cases 2021-05-19 10:37:44 +02:00
Luuk de Gram
141a0cbb5a Explicit return & more complex wasm enum test
- When returning within a block, we must use an explicit return opcode. For now always emit the opcode when calling return, rather than using implicit return statements.
- Also added a more comprehensive test case to test for enum values using conditions
2021-05-19 10:35:45 +02:00
Luuk de Gram
9ddede2950 Add enum test case for wasm backend 2021-05-19 08:59:11 +02:00
Andrew Kelley
b109daacdd stage2: fix test cases to add pub on exported _start fn
This way the start code respects them.
2021-05-12 23:17:24 -07:00
Jakub Konka
53acb54fad Bump zig-bootstrap and wasmtime versions in linux CI (#8738)
* Bump zig-bootstrap and wasmtime versions in linux CI

* Revert wasm stage2 test fixup; point to issue
2021-05-12 09:56:55 +02:00
gracefu
e4a60b63f2 stage2 wasm: Add bitwise/boolean ops &, |, ^, and, or 2021-04-08 05:27:00 +08:00
gracefu
869fc06c57 stage2 wasm: codegen mul op 2021-04-05 14:37:04 +08:00
gracefu
d1244d3608 stage2 wasm: codegen sub op 2021-04-05 14:37:04 +08:00
Luuk de Gram
4b854b75d2 Fix getNot and add test cases 2021-03-22 19:56:38 +01:00
Luuk de Gram
cc46c1b902 Add tests, fix locals that are created in blocks like loops, and handle all breaks correctly 2021-01-26 19:47:15 +01:00
Luuk de Gram
6c19aeddca Add tests and move tests to wasm's own file 2021-01-16 14:58:04 +01:00