Repository: bytecodealliance/wasmtime
Pull request #5607 (2023-01-20 15:48:03)

Update tokio to resolve dependabot warning
This doesn't fully update tokio since the update to the latest version has quite a few changes I'd prefer to not audit at the moment, but it updates to a patched version.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

- [ ] This has been discussed in issue #..., or if not, please tell us why
  here.
- [ ] A short description of what this does, why it is needed; if the
  description becomes long, the matter should probably be discussed in an issue
  first.
- [ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
  If you don't know who could review this, please indicate so. The list of
  suggested reviewers on the right can help you.

Please ensure all communication adheres to the [code of
conduct](https://github.com/bytecodealliance/wasmtime/blob/master/CODE_OF_CONDUCT.md).
-->



Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 127fcb9f9..373e4dcd0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2900,16 +2900,15 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
 
 [[package]]
 name = "tokio"
-version = "1.18.1"
+version = "1.18.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dce653fb475565de9f6fb0614b28bca8df2c430c0cf84bcd9c843f15de5414cc"
+checksum = "8bfb875c82dc0a4f1f37a30e720dee181a2b3a06a428b0fc6873ea38d6407850"
 dependencies = [
  "bytes",
  "libc",
  "memchr",
  "mio",
  "num_cpus",
- "once_cell",
  "pin-project-lite",
  "socket2",
  "tokio-macros",
diff --git a/README.md b/README.md
index 3f7c30213..d59c36806 100644
--- a/README.md
+++ b/README.md
@@ -108,7 +108,9 @@ Hello, world!
 ## Language Support
 
 You can use Wasmtime from a variety of different languages through embeddings of
-the implementation:
+the implementation.
+
+Languages supported by the Bytecode Alliance:
 
 * **[Rust]** - the [`wasmtime` crate]
 * **[C]** - the [`wasm.h`, `wasi.h`, and `wasmtime.h` headers][c-headers], [CMake](crates/c-api/CMakeLists.txt) or [`wasmtime` Conan package]
@@ -118,6 +120,10 @@ the implementation:
 * **[Go]** - the [`wasmtime-go` repository]
 * **[Ruby]** - the [`wasmtime` gem]
 
+Languages supported by the community:
+
+* **[Elixir]** - the [`wasmex` hex package]
+
 [Rust]: https://bytecodealliance.github.io/wasmtime/lang-rust.html
 [C]: https://bytecodealliance.github.io/wasmtime/examples-c-embed.html
 [`wasmtime` crate]: https://crates.io/crates/wasmtime
@@ -133,6 +139,8 @@ the implementation:
 [`wasmtime-cpp` Conan package]: https://conan.io/center/wasmtime-cpp
 [Ruby]: https://bytecodealliance.github.io/wasmtime/lang-ruby.html
 [`wasmtime` gem]: https://rubygems.org/gems/wasmtime
+[Elixir]: https://docs.wasmtime.dev/lang-elixir.html
+[`wasmex` hex package]: https://hex.pm/packages/wasmex
 
 ## Documentation
 
diff --git a/cranelift/codegen/src/isa/riscv64/inst.isle b/cranelift/codegen/src/isa/riscv64/inst.isle
index 31fdad31a..2031cf924 100644
--- a/cranelift/codegen/src/isa/riscv64/inst.isle
+++ b/cranelift/codegen/src/isa/riscv64/inst.isle
@@ -1028,7 +1028,7 @@
     ((tmp Reg (gen_extend r $true from_bits 64))
       (tmp2 Reg (alu_rrr (AluOPRRR.Slt) tmp (zero_reg)))
       (high Reg (gen_extend tmp2 $true 1 64)))
-    (value_regs (gen_move2 r $I64 $I64) high)))
+    (value_regs (gen_move2 tmp $I64 $I64) high)))
 
 
 ;;;; for I128 unsigned extend.
diff --git a/crates/component-macro/src/bindgen.rs b/crates/component-macro/src/bindgen.rs
index 435abbb42..d9caff8f3 100644
--- a/crates/component-macro/src/bindgen.rs
+++ b/crates/component-macro/src/bindgen.rs
@@ -226,9 +226,23 @@ impl Parse for Opt {
 }
 
 fn trappable_error_field_parse(input: ParseStream<'_>) -> Result<(String, String, String)> {
-    let interface = input.parse::<Ident>()?.to_string();
+    // Accept a Rust identifier or a string literal. This is required
+    // because not all wit identifiers are Rust identifiers, so we can
+    // smuggle the invalid ones inside quotes.
+    fn ident_or_str(input: ParseStream<'_>) -> Result<String> {
+        let l = input.lookahead1();
+        if l.peek(syn::LitStr) {
+            Ok(input.parse::<syn::LitStr>()?.value())
+        } else if l.peek(syn::Ident) {
+            Ok(input.parse::<syn::Ident>()?.to_string())
+        } else {
+            Err(l.error())
+        }
+    }
+
+    let interface = ident_or_str(input)?;
     input.parse::<Token![::]>()?;
-    let type_ = input.parse::<Ident>()?.to_string();
+    let type_ = ident_or_str(input)?;
     input.parse::<Token![:]>()?;
     let rust_type = input.parse::<Ident>()?.to_string();
     Ok((interface, type_, rust_type))
diff --git a/docs/lang-elixir.md b/docs/lang-elixir.md
new file mode 100644
index 000000000..d961f2ede
--- /dev/null
+++ b/docs/lang-elixir.md
@@ -0,0 +1,43 @@
+# Using WebAssembly from Elixir
+
+Wasmtime [is available on Hex](https://hex.pm/packages/wasmex) and can
+be used programmatically to interact with Wasm modules. This guide will go over
+installing the wasmex package and running a simple Wasm module from Elixir.
+
+## Getting started and simple example
+
+First, copy this example WebAssembly text module into the current directory. It exports
+a function for calculating the greatest common denominator of two numbers.
+
+```wat
+{{#include ../examples/gcd.wat}}
+```
+
+The library has a Rust-based native extension, but thanks to `rustler_precompiled`, you
+should not have to compile anything. It'll just work!
+
+This WAT file can be executed in `iex`:
+
+```elixir
+Mix.install([:wasmex])
+bytes = File.read!("gcd.wat")
+{:ok, pid} = Wasmex.start_link(%{bytes: bytes}) # starts a GenServer running a WASM instance
+Wasmex.call_function(pid, "gcd", [27, 6])
+```
+
+The last command should output:
+
+```elixir
+iex(5)> Wasmex.call_function(pid, "gcd", [27, 6])
+{:ok, [3]}
+```
+
+If this is the output you see, congrats! You've successfully ran your first
+WebAssembly code in Elixir!
+
+## More examples and contributing
+
+To learn more, check out an [another example](https://github.com/tessi/wasmex#example)
+and the [API documentation](https://hexdocs.pm/wasmex/Wasmex.html).
+If you have any questions, do not hesitate to open an issue on the
+[GitHub repository](https://github.com/tessi/wasmex).
diff --git a/docs/lang.md b/docs/lang.md
index ae3d0a13c..94e38d1b0 100644
--- a/docs/lang.md
+++ b/docs/lang.md
@@ -11,3 +11,4 @@ through a C API for a number of other languages too:
 * [Go](lang-go.md)
 * [Bash](lang-bash.md)
 * [Ruby](lang-ruby.md)
+* [Elixir](lang-elixir.md)
diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml
index 49d0fd477..82a3a59d1 100644
--- a/supply-chain/audits.toml
+++ b/supply-chain/audits.toml
@@ -506,6 +506,16 @@ intended to multiplex across the internal representation of a tinyvec,
 presumably. This trivially doesn't contain anything bad.
 """
 
+[[audits.tokio]]
+who = "Alex Crichton <alex@alexcrichton.com>"
+criteria = "safe-to-deploy"
+delta = "1.18.1 -> 1.18.4"
+notes = """
+This looks to be a minor release primarily to fix a security-related Windows
+issue plus some reorganization around lazy initialization. Altogether nothing
+amiss here.
+"""
+
 [[audits.unicase]]
 who = "Alex Crichton <alex@alexcrichton.com>"
 criteria = "safe-to-deploy"


Test patch:
diff --git a/cranelift/filetests/filetests/isa/riscv64/extend-op.clif b/cranelift/filetests/filetests/isa/riscv64/extend-op.clif
index 595ef6a8d..9dfc4f2c4 100644
--- a/cranelift/filetests/filetests/isa/riscv64/extend-op.clif
+++ b/cranelift/filetests/filetests/isa/riscv64/extend-op.clif
@@ -66,8 +66,8 @@ block0(v0: i32):
 }
 
 ; block0:
-;   sext.w t2,a0
-;   slt a1,t2,zero
+;   sext.w a0,a0
+;   slt a1,a0,zero
 ;   sext.b1 a1,a1
 ;   ret
 
@@ -89,8 +89,8 @@ block0(v0: i16):
 }
 
 ; block0:
-;   sext.h t2,a0
-;   slt a1,t2,zero
+;   sext.h a0,a0
+;   slt a1,a0,zero
 ;   sext.b1 a1,a1
 ;   ret
 
@@ -112,8 +112,8 @@ block0(v0: i8):
 }
 
 ; block0:
-;   sext.b t2,a0
-;   slt a1,t2,zero
+;   sext.b a0,a0
+;   slt a1,a0,zero
 ;   sext.b1 a1,a1
 ;   ret
 
diff --git a/cranelift/filetests/filetests/runtests/issue5525.clif b/cranelift/filetests/filetests/runtests/issue5525.clif
new file mode 100644
index 000000000..1b34da2cb
--- /dev/null
+++ b/cranelift/filetests/filetests/runtests/issue5525.clif
@@ -0,0 +1,12 @@
+test interpret
+test run
+target riscv64
+
+function %a(i16) -> i128 system_v {
+block0(v0: i16):
+    v1 = rotl v0, v0
+    v2 = sextend.i128 v1
+    return v2
+}
+
+; run: %a(-32718) == 202
\ No newline at end of file
diff --git a/tests/all/component_model/bindgen/results.rs b/tests/all/component_model/bindgen/results.rs
index 995a2e528..82e318948 100644
--- a/tests/all/component_model/bindgen/results.rs
+++ b/tests/all/component_model/bindgen/results.rs
@@ -373,7 +373,9 @@ mod record_error {
                 record-error: func(a: float64) -> result<float64, e2>
             }
         }",
-        trappable_error_type: { imports::e2: TrappableE2 }
+        // Literal strings can be used for the interface and typename fields instead of
+        // identifiers, because wit identifiers arent always Rust identifiers.
+        trappable_error_type: { "imports"::"e2": TrappableE2 }
     });
 
     #[test]