diff --git a/.github/workflows/compatibility-elixir.yml b/.github/workflows/compatibility-elixir.yml index 8ed50b5a..c6578703 100644 --- a/.github/workflows/compatibility-elixir.yml +++ b/.github/workflows/compatibility-elixir.yml @@ -17,10 +17,10 @@ jobs: strategy: fail-fast: false matrix: - otp: [24.3, 25.2, 26.1] - elixir: [1.13.4, 1.14.5, 1.15.6] + otp: [24.3, 25.2, 26.2] + elixir: [1.13.4, 1.14.5, 1.15.6, 1.16.1] exclude: - - otp: 26.1 + - otp: 26.2 elixir: 1.13.4 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/elixir-ci.yml b/.github/workflows/elixir-ci.yml index 5e415911..3af0dc4a 100644 --- a/.github/workflows/elixir-ci.yml +++ b/.github/workflows/elixir-ci.yml @@ -7,8 +7,8 @@ on: - main env: - ELIXIR_VERSION: 1.15.6 - OTP_VERSION: 26.1 + ELIXIR_VERSION: 1.16.1 + OTP_VERSION: 26.2.1 MIX_ENV: test WASMEX_BUILD: true @@ -76,35 +76,6 @@ jobs: - run: mix format --check-formatted - dialyzer: - needs: deps - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} - - - uses: actions/cache@v2 - id: cache-deps - with: - path: | - deps - _build - key: ${{ needs.deps.outputs.deps-cache-key }} - - - uses: actions/cache@v2 - id: plt-cache - with: - path: priv/plts - key: v2-plt-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }} - - - run: mix dialyzer --plt - if: steps.plt-cache.outputs.cache-hit != 'true' - - - run: mix dialyzer - docs: needs: deps runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 66a77a43..3946b4cd 100644 --- a/.gitignore +++ b/.gitignore @@ -33,10 +33,6 @@ test/wasm_source/target/* wapm_packages/* wapm.lock -# The PLT files for `dialyzer` -/priv/plts/*.plt -/priv/plts/*.plt.hash - # ignore local builds checksum-Elixir.Wasmex.Native.exs *.so diff --git a/.tool-versions b/.tool-versions index 86253ace..3366d0b6 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 26.1 -elixir 1.15.6 +erlang 26.2.1 +elixir 1.16.1-otp-26 diff --git a/README.md b/README.md index 90212410..98bf6c97 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ If you plan to change something on the Rust part of this project, set the follow I´m looking forward to your contributions. Please open a PR containing the motivation of your change. If it is a bigger change or refactoring, consider creating an issue first. We can discuss changes there first which might safe us time down the road :) Any changes should be covered by tests, they can be run with `mix test`. -In addition to tests, we expect the formatters and linters (`cargo fmt`, `cargo clippy`, `mix format`, `mix dialyzer`, `mix credo`) to pass. +In addition to tests, we expect the formatters and linters (`cargo fmt`, `cargo clippy`, `mix format`, `mix credo`) to pass. ### Release diff --git a/mix.exs b/mix.exs index 6d2c56d3..bd739c2e 100644 --- a/mix.exs +++ b/mix.exs @@ -12,10 +12,7 @@ defmodule Wasmex.MixProject do name: "wasmex", description: description(), package: package(), - deps: deps(), - dialyzer: [ - plt_file: {:no_warn, "priv/plts/dialyzer.plt"} - ] + deps: deps() ] end @@ -29,10 +26,9 @@ defmodule Wasmex.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:rustler_precompiled, "~> 0.6.3"}, - {:rustler, "~> 0.29.1"}, + {:rustler_precompiled, "~> 0.7.1"}, + {:rustler, "~> 0.30.0"}, {:ex_doc, "~> 0.30.2", only: [:dev, :test]}, - {:dialyxir, "~> 1.4.1", only: [:dev, :test], runtime: false}, {:credo, "~> 1.6", only: [:dev, :test], runtime: false} ] end diff --git a/mix.lock b/mix.lock index 1c392558..d3f40629 100644 --- a/mix.lock +++ b/mix.lock @@ -1,8 +1,7 @@ %{ "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, - "castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"}, + "castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"}, "credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"}, - "dialyxir": {:hex, :dialyxir, "1.4.1", "a22ed1e7bd3a3e3f197b68d806ef66acb61ee8f57b3ac85fc5d57354c5482a93", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "84b795d6d7796297cca5a3118444b80c7d94f7ce247d49886e7c291e1ae49801"}, "earmark_parser": {:hex, :earmark_parser, "1.4.37", "2ad73550e27c8946648b06905a57e4d454e4d7229c2dafa72a0348c99d8be5f7", [:mix], [], "hexpm", "6b19783f2802f039806f375610faa22da130b8edc21209d0bff47918bb48360e"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "ex_doc": {:hex, :ex_doc, "0.30.9", "d691453495c47434c0f2052b08dd91cc32bc4e1a218f86884563448ee2502dd2", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d7aaaf21e95dc5cddabf89063327e96867d00013963eadf2c6ad135506a8bc10"}, @@ -12,7 +11,7 @@ "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"}, - "rustler": {:hex, :rustler, "0.29.1", "880f20ae3027bd7945def6cea767f5257bc926f33ff50c0d5d5a5315883c084d", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "109497d701861bfcd26eb8f5801fe327a8eef304f56a5b63ef61151ff44ac9b6"}, - "rustler_precompiled": {:hex, :rustler_precompiled, "0.6.3", "f838d94bc35e1844973ee7266127b156fdc962e9e8b7ff666c8fb4fed7964d23", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "e18ecca3669a7454b3a2be75ae6c3ef01d550bc9a8cf5fbddcfff843b881d7c6"}, + "rustler": {:hex, :rustler, "0.30.0", "cefc49922132b072853fa9b0ca4dc2ffcb452f68fb73b779042b02d545e097fb", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "9ef1abb6a7dda35c47cfc649e6a5a61663af6cf842a55814a554a84607dee389"}, + "rustler_precompiled": {:hex, :rustler_precompiled, "0.7.1", "ecadf02cc59a0eccbaed6c1937303a5827fbcf60010c541595e6d3747d3d0f9f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "b9e4657b99a1483ea31502e1d58c464bedebe9028808eda45c3a429af4550c66"}, "toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"}, } diff --git a/native/wasmex/Cargo.lock b/native/wasmex/Cargo.lock index 159efb40..7631b127 100644 --- a/native/wasmex/Cargo.lock +++ b/native/wasmex/Cargo.lock @@ -1196,9 +1196,9 @@ dependencies = [ [[package]] name = "rustler" -version = "0.29.1" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884cb623b9f43d3e2c51f9071c5e96a5acf3e6e6007866812884ff0cb983f1e" +checksum = "c4b4fea69e23de68c42c06769d6624d2d018da550c17244dd4b691f90ced4a7e" dependencies = [ "lazy_static", "rustler_codegen", @@ -1207,9 +1207,9 @@ dependencies = [ [[package]] name = "rustler_codegen" -version = "0.29.1" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e277af754f2560cf4c4ebedb68c1a735292fb354505c6133e47ec406e699cf" +checksum = "406061bd07aaf052c344257afed4988c5ec8efe4d2352b4c2cf27ea7c8575b12" dependencies = [ "heck", "proc-macro2", diff --git a/native/wasmex/Cargo.toml b/native/wasmex/Cargo.toml index e5def6d2..500a6b83 100644 --- a/native/wasmex/Cargo.toml +++ b/native/wasmex/Cargo.toml @@ -15,7 +15,10 @@ path = "src/lib.rs" crate-type = ["dylib"] [dependencies] -rustler = { version = "0.29", default-features = false, features = ["derive", "nif_version_2_15"] } +rustler = { version = "0.30", default-features = false, features = [ + "derive", + "nif_version_2_15", +] } once_cell = "1.19.0" rand = "0.8.5" wasmtime = "12.0.2" diff --git a/native/wasmex/src/environment.rs b/native/wasmex/src/environment.rs index 1b07abcb..9d7cffcf 100644 --- a/native/wasmex/src/environment.rs +++ b/native/wasmex/src/environment.rs @@ -47,7 +47,7 @@ fn link_import( let import_tuple = tuple::get_tuple(definition)?; let import_type = import_tuple - .get(0) + .first() .ok_or(Error::Atom("missing_import_type"))?; let import_type = Atom::from_term(*import_type).map_err(|_| Error::Atom("import type must be an atom"))?; @@ -126,7 +126,7 @@ fn link_imported_function( let caller_token = set_caller(caller); let mut msg_env = OwnedEnv::new(); - msg_env.send_and_clear(&pid.clone(), |env| { + let result = msg_env.send_and_clear(&pid.clone(), |env| { let mut callback_params: Vec = Vec::with_capacity(params.len()); for value in params { callback_params.push(match value { @@ -183,6 +183,8 @@ fn link_imported_function( .encode(env) }); + result.expect("expect no send error"); + // Wait for the thread to start up - `receive_callback_result` is responsible for that. let mut result = callback_token.token.return_values.lock().unwrap(); while result.is_none() { diff --git a/native/wasmex/src/instance.rs b/native/wasmex/src/instance.rs index 889a9d2f..14d1e173 100644 --- a/native/wasmex/src/instance.rs +++ b/native/wasmex/src/instance.rs @@ -244,55 +244,64 @@ pub fn decode_function_param_terms( .enumerate() { let value = match (param, given_param.get_type()) { - (ValType::I32, TermType::Number) => match given_param.decode::() { - Ok(value) => WasmValue::I32(value), - Err(_) => { - return Err(format!( - "Cannot convert argument #{} to a WebAssembly i32 value.", - nth + 1 - )); + (ValType::I32, TermType::Integer | TermType::Float) => { + match given_param.decode::() { + Ok(value) => WasmValue::I32(value), + Err(_) => { + return Err(format!( + "Cannot convert argument #{} to a WebAssembly i32 value.", + nth + 1 + )); + } } - }, - (ValType::I64, TermType::Number) => match given_param.decode::() { - Ok(value) => WasmValue::I64(value), - Err(_) => { - return Err(format!( - "Cannot convert argument #{} to a WebAssembly i64 value.", - nth + 1 - )); + } + (ValType::I64, TermType::Integer | TermType::Float) => { + match given_param.decode::() { + Ok(value) => WasmValue::I64(value), + Err(_) => { + return Err(format!( + "Cannot convert argument #{} to a WebAssembly i64 value.", + nth + 1 + )); + } } - }, - (ValType::F32, TermType::Number) => match given_param.decode::() { - Ok(value) => { - if value.is_finite() { - WasmValue::F32(value) - } else { + } + (ValType::F32, TermType::Integer | TermType::Float) => { + match given_param.decode::() { + Ok(value) => { + if value.is_finite() { + WasmValue::F32(value) + } else { + return Err(format!( + "Cannot convert argument #{} to a WebAssembly f32 value.", + nth + 1 + )); + } + } + Err(_) => { return Err(format!( "Cannot convert argument #{} to a WebAssembly f32 value.", nth + 1 )); } } - Err(_) => { - return Err(format!( - "Cannot convert argument #{} to a WebAssembly f32 value.", - nth + 1 - )); - } - }, - (ValType::F64, TermType::Number) => match given_param.decode::() { - Ok(value) => WasmValue::F64(value), - Err(_) => { - return Err(format!( - "Cannot convert argument #{} to a WebAssembly f64 value.", - nth + 1 - )); + } + (ValType::F64, TermType::Integer | TermType::Float) => { + match given_param.decode::() { + Ok(value) => WasmValue::F64(value), + Err(_) => { + return Err(format!( + "Cannot convert argument #{} to a WebAssembly f64 value.", + nth + 1 + )); + } } - }, - (_, term_type) => { + } + (val_type, term_type) => { return Err(format!( - "Cannot convert argument #{} to a WebAssembly value. Given `{:?}`.", + "Cannot convert argument #{} to a WebAssembly {:?} value. Given `{:?}`.", nth + 1, + val_type, PrintableTermType::PrintTerm(term_type) )); } diff --git a/native/wasmex/src/printable_term_type.rs b/native/wasmex/src/printable_term_type.rs index d98c3f52..400a686b 100644 --- a/native/wasmex/src/printable_term_type.rs +++ b/native/wasmex/src/printable_term_type.rs @@ -12,12 +12,11 @@ impl fmt::Debug for PrintableTermType { match self { PrintTerm(TermType::Atom) => write!(f, "Atom"), PrintTerm(TermType::Binary) => write!(f, "Binary"), - PrintTerm(TermType::EmptyList) => write!(f, "EmptyList"), - PrintTerm(TermType::Exception) => write!(f, "Exception"), PrintTerm(TermType::Fun) => write!(f, "Fun"), PrintTerm(TermType::List) => write!(f, "List"), PrintTerm(TermType::Map) => write!(f, "Map"), - PrintTerm(TermType::Number) => write!(f, "Number"), + PrintTerm(TermType::Integer) => write!(f, "Integer"), + PrintTerm(TermType::Float) => write!(f, "Float"), PrintTerm(TermType::Pid) => write!(f, "Pid"), PrintTerm(TermType::Port) => write!(f, "Port"), PrintTerm(TermType::Ref) => write!(f, "Ref"),