Releases: tessi/wasmex
Releases · tessi/wasmex
v0.5.0
Added
- Added WASI support. See Wasmex.start_link/1 for usage instructions and examples.
# after a `wapm install cowsay`
{:ok, bytes } = File.read("wapm_packages/_/[email protected]/target/wasm32-wasi/release/cowsay.wasm")
{:ok, stdout} = Wasmex.Pipe.create()
{:ok, stdin} = Wasmex.Pipe.create()
{:ok, instance } = Wasmex.start_link(%{bytes: bytes, wasi: %{stdout: stdout, stdin: stdin}})
Wasmex.Pipe.write(stdin, "Why do you never see elephants hiding in trees? Because they're really good at it.")
{:ok, _} = Wasmex.call_function(instance, :_start, [])
IO.puts Wasmex.Pipe.read(stdout)
________________________________________
/ Why do you never see elephants hiding \
| in trees? Because they're really good |
\ at it. /
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
:ok
v0.4.0
Added
- added support for OTP 24.0 (by updating rustler)
Changed
- Wasmex.Memory.bytes_per_element changed its signature from
Wasmex.Memory.bytes_per_element(memory, :uint32, 0)
toWasmex.Memory.bytes_per_element(:uint32)
.
The existing signatureWasmex.Memory.bytes_per_element(memory)
still works as before.
Removed
Wasmex.Memory.grow/4
was removed. InsteadWasmex.Memory.grow/2
can be used interchangeably.
v0.3.1
0.3.0
Notable Changes
This release features support for elixir function that can be exported to WASM.
It also supports the latest wasmer v 1.0 🎉.
Wasmer 1.0 is a partial rewrite of the WASM engine we use that promises to be up to 9 times faster module compilation.
Added
- added the instances first memory into the callback context
imports = %{
env: %{
read_and_set_memory:
{:fn, [], [:i32],
fn context, a, b, c ->
memory = Map.get(context, :memory)
42 = Wasmex.Memory.get(memory, :uint8, 0, 0) # assert that the first byte in the memory was set to 42
Wasmex.Memory.set(memory, :uint8, 0, 0, 23)
0
end},
}
}
instance = start_supervised!({Wasmex, %{bytes: @import_test_bytes, imports: imports}})
Wasmex.Memory.set(memory, :uint8, 0, 0, 42)
# asserts that the byte at memory[0] was set to 42 and then sets it to 23
{:ok, _} = Wasmex.call_function(instance, :a_wasm_fn_that_calls_read_and_set_memory, [])
assert 23 == Wasmex.Memory.get(memory, :uint8, 0, 0)
- added support for function imports
imports = %{
env: %{
sum3: {:fn, [:i32, :i32, :i32], [:i32], fn (_context, a, b, c) -> a + b + c end},
}
}
instance = start_supervised!({Wasmex, %{bytes: @import_test_bytes, imports: imports}})
{:ok, [6]} = Wasmex.call_function(instance, "use_the_imported_sum_fn", [1, 2, 3])
Thanks to
- @bamorim for helping me plan and architect,
- @myobie for help in implementation, especially for implementing the function signature checks,
- @rylev for a second eye on our Rust code,
- the @wasmerio team for the recent addition of
DynFunc
which made this feature possible, and - @bitcrowd for sponsoring me to work on this feature
Changed
- Changed writing and reading strings from/to memory to be based on string length and not expect null-byte terminated strings.
This allows for a more flexible memory handling when writing arbitrary data or strings containing null bytes to/from memory.
Thanks @myobie for implementing this feature - Support writing non-string binaries to memory. Before we could only write valid UTF-8 strings to WASM memory.
Thanks again, @myobie, for implementing this feature - Updated the wasmer version, now supporting wasmer 1.0.
- Updated to elixir 1.11 and Erlang OTP 23.2. Older versions might work, but are not officially tested
Fixed
could not convert callback result param to expected return signature
error for a void callback.