Skip to content

Commit

Permalink
Update Wasmtime and Wizer (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles authored May 2, 2024
1 parent 800c51e commit 5295a90
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 454 deletions.
391 changes: 183 additions & 208 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ edition = "2021"
license = "Apache-2.0 WITH LLVM-exception"

[workspace.dependencies]
wizer = "4.0.0"
wasmtime = "16"
wasmtime-wasi = "16"
wasi-common = "16"
wizer = "6.0.0"
wasmtime = "19"
wasmtime-wasi = "19"
wasi-common = "19"
anyhow = "1.0"
once_cell = "1.19"
javy = { path = "crates/javy", version = "3.0.0-alpha.1" }
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use num_format::{Locale, ToFormattedString};
use std::{fmt::Display, fs, path::Path, process::Command};
use wasi_common::{
pipe::{ReadPipe, WritePipe},
sync::WasiCtxBuilder,
WasiCtx,
};
use wasmtime::{Engine, Linker, Module, Store};
use wasmtime_wasi::sync::WasiCtxBuilder;

struct FunctionCase {
name: String,
Expand Down Expand Up @@ -110,7 +110,7 @@ impl FunctionCase {
.stdout(Box::new(WritePipe::new_in_memory()))
.stderr(Box::new(WritePipe::new_in_memory()))
.build();
wasmtime_wasi::add_to_linker(&mut linker, |s| s).unwrap();
wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap();
let mut store = Store::new(&self.engine, wasi);

if let Linking::Dynamic = self.linking {
Expand Down
7 changes: 5 additions & 2 deletions crates/cli/src/bytecode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use wasi_common::{sync::WasiCtxBuilder, WasiCtx};
use wasmtime::{Engine, Instance, Linker, Memory, Module, Store};
use wasmtime_wasi::{WasiCtx, WasiCtxBuilder};

pub const QUICKJS_PROVIDER_MODULE: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/provider.wasm"));
Expand All @@ -18,7 +18,10 @@ fn create_wasm_env() -> Result<(Store<WasiCtx>, Instance, Memory)> {
let engine = Engine::default();
let module = Module::new(&engine, QUICKJS_PROVIDER_MODULE)?;
let mut linker = Linker::new(&engine);
wasmtime_wasi::snapshots::preview_1::add_wasi_snapshot_preview1_to_linker(&mut linker, |s| s)?;
wasi_common::sync::snapshots::preview_1::add_wasi_snapshot_preview1_to_linker(
&mut linker,
|s| s,
)?;
let wasi = WasiCtxBuilder::new().inherit_stderr().build();
let mut store = Store::new(&engine, wasi);
let instance = linker.instantiate(&mut store, &module)?;
Expand Down
5 changes: 2 additions & 3 deletions crates/cli/src/wasm_generator/static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use std::{collections::HashMap, fs, rc::Rc, sync::OnceLock};

use anyhow::{anyhow, Result};
use walrus::{DataKind, ExportItem, FunctionBuilder, FunctionId, MemoryId, ValType};
use wasi_common::{pipe::ReadPipe, WasiCtx};
use wasi_common::{pipe::ReadPipe, sync::WasiCtxBuilder, WasiCtx};
use wasm_opt::{OptimizationOptions, ShrinkLevel};
use wasmtime::Linker;
use wasmtime_wasi::WasiCtxBuilder;
use wizer::Wizer;

use crate::{exports::Export, js::JS};
Expand Down Expand Up @@ -34,7 +33,7 @@ pub fn generate(js: &JS, exports: Vec<Export>, no_source_compression: bool) -> R
let wasm = Wizer::new()
.make_linker(Some(Rc::new(|engine| {
let mut linker = Linker::new(engine);
wasmtime_wasi::add_to_linker(&mut linker, |_ctx: &mut Option<WasiCtx>| {
wasi_common::sync::add_to_linker(&mut linker, |_ctx: &mut Option<WasiCtx>| {
unsafe { WASI.get_mut() }.unwrap()
})?;
Ok(linker)
Expand Down
5 changes: 2 additions & 3 deletions crates/cli/tests/dylib_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use anyhow::Result;
use std::boxed::Box;
use std::str;
use wasi_common::{pipe::WritePipe, WasiFile};
use wasi_common::{pipe::WritePipe, sync::WasiCtxBuilder, WasiCtx, WasiFile};
use wasmtime::{Engine, Instance, Linker, Store};
use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx};

mod common;

Expand Down Expand Up @@ -78,7 +77,7 @@ fn create_wasm_env<T: WasiFile + Clone + 'static>(
) -> Result<(Instance, Store<WasiCtx>)> {
let engine = Engine::default();
let mut linker = Linker::new(&engine);
wasmtime_wasi::add_to_linker(&mut linker, |s| s)?;
wasi_common::sync::add_to_linker(&mut linker, |s| s)?;
let wasi = WasiCtxBuilder::new()
.stderr(Box::new(stderr.clone()))
.build();
Expand Down
26 changes: 12 additions & 14 deletions crates/cli/tests/dynamic_linking_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use std::process::Command;
use std::str;
use uuid::Uuid;
use wasi_common::pipe::WritePipe;
use wasmtime::{Config, Engine, ExternType, Linker, Module, Store, ValType};
use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx};
use wasi_common::sync::WasiCtxBuilder;
use wasi_common::WasiCtx;
use wasmtime::{Config, Engine, ExternType, Linker, Module, Store};

mod common;

Expand Down Expand Up @@ -54,11 +55,10 @@ pub fn check_for_new_imports() -> Result<()> {
for import in module.imports() {
match (import.module(), import.name(), import.ty()) {
("javy_quickjs_provider_v1", "canonical_abi_realloc", ExternType::Func(f))
if f.params()
.eq([ValType::I32, ValType::I32, ValType::I32, ValType::I32])
&& f.results().eq([ValType::I32]) => {}
if f.params().map(|t| t.is_i32()).eq([true, true, true, true])
&& f.results().map(|t| t.is_i32()).eq([true]) => {}
("javy_quickjs_provider_v1", "eval_bytecode", ExternType::Func(f))
if f.params().eq([ValType::I32, ValType::I32]) && f.results().eq([]) => {}
if f.params().map(|t| t.is_i32()).eq([true, true]) && f.results().len() == 0 => {}
("javy_quickjs_provider_v1", "memory", ExternType::Memory(_)) => (),
_ => panic!("Unknown import {:?}", import),
}
Expand All @@ -83,15 +83,13 @@ pub fn check_for_new_imports_for_exports() -> Result<()> {
for import in module.imports() {
match (import.module(), import.name(), import.ty()) {
("javy_quickjs_provider_v1", "canonical_abi_realloc", ExternType::Func(f))
if f.params()
.eq([ValType::I32, ValType::I32, ValType::I32, ValType::I32])
&& f.results().eq([ValType::I32]) => {}
if f.params().map(|t| t.is_i32()).eq([true, true, true, true])
&& f.results().map(|t| t.is_i32()).eq([true]) => {}
("javy_quickjs_provider_v1", "eval_bytecode", ExternType::Func(f))
if f.params().eq([ValType::I32, ValType::I32]) && f.results().eq([]) => {}
if f.params().map(|t| t.is_i32()).eq([true, true]) && f.results().len() == 0 => {}
("javy_quickjs_provider_v1", "invoke", ExternType::Func(f))
if f.params()
.eq([ValType::I32, ValType::I32, ValType::I32, ValType::I32])
&& f.results().eq([]) => {}
if f.params().map(|t| t.is_i32()).eq([true, true, true, true])
&& f.results().len() == 0 => {}
("javy_quickjs_provider_v1", "memory", ExternType::Memory(_)) => (),
_ => panic!("Unknown import {:?}", import),
}
Expand Down Expand Up @@ -195,7 +193,7 @@ fn create_wasm_env(
) -> Result<(Engine, Linker<WasiCtx>, Store<WasiCtx>)> {
let engine = Engine::new(Config::new().wasm_multi_memory(true))?;
let mut linker = Linker::new(&engine);
wasmtime_wasi::add_to_linker(&mut linker, |s| s)?;
wasi_common::sync::add_to_linker(&mut linker, |s| s)?;
let wasi = WasiCtxBuilder::new().stderr(Box::new(stderr)).build();
let store = Store::new(&engine, wasi);
Ok((engine, linker, store))
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/tests/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::{cmp, fs};
use wasi_common::pipe::{ReadPipe, WritePipe};
use wasi_common::sync::WasiCtxBuilder;
use wasi_common::WasiCtx;
use wasmtime::{Config, Engine, Linker, Module, OptLevel, Store};
use wasmtime_wasi::sync::WasiCtxBuilder;
use wasmtime_wasi::WasiCtx;

pub struct Runner {
pub wasm: Vec<u8>,
Expand Down Expand Up @@ -194,7 +194,7 @@ fn setup_engine() -> Engine {
fn setup_linker(engine: &Engine) -> Linker<StoreContext> {
let mut linker = Linker::new(engine);

wasmtime_wasi::sync::add_to_linker(&mut linker, |ctx: &mut StoreContext| &mut ctx.wasi)
wasi_common::sync::add_to_linker(&mut linker, |ctx: &mut StoreContext| &mut ctx.wasi)
.expect("failed to add wasi context");

linker
Expand Down
42 changes: 42 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ user-id = 3618 # David Tolnay (dtolnay)
start = "2019-02-28"
end = "2024-07-12"

[[trusted.serde_spanned]]
criteria = "safe-to-deploy"
user-id = 6743 # Ed Page (epage)
start = "2023-01-20"
end = "2025-05-02"

[[trusted.smallvec]]
criteria = "safe-to-deploy"
user-id = 2017 # Matt Brubeck (mbrubeck)
Expand Down Expand Up @@ -477,6 +483,24 @@ user-id = 10 # Carl Lerche (carllerche)
start = "2019-04-24"
end = "2024-12-04"

[[trusted.toml]]
criteria = "safe-to-deploy"
user-id = 6743 # Ed Page (epage)
start = "2022-12-14"
end = "2025-05-02"

[[trusted.toml_datetime]]
criteria = "safe-to-deploy"
user-id = 6743 # Ed Page (epage)
start = "2022-10-21"
end = "2025-05-02"

[[trusted.toml_edit]]
criteria = "safe-to-deploy"
user-id = 6743 # Ed Page (epage)
start = "2021-09-13"
end = "2025-05-02"

[[trusted.unicode-ident]]
criteria = "safe-to-deploy"
user-id = 3618 # David Tolnay (dtolnay)
Expand Down Expand Up @@ -519,6 +543,12 @@ user-id = 1 # Alex Crichton (alexcrichton)
start = "2019-03-04"
end = "2025-01-03"

[[trusted.wasm-encoder]]
criteria = "safe-to-deploy"
user-id = 73222 # wasmtime-publish
start = "2024-02-15"
end = "2025-05-02"

[[trusted.wasmparser]]
criteria = "safe-to-deploy"
user-id = 73222 # wasmtime-publish
Expand All @@ -531,6 +561,12 @@ user-id = 73222 # wasmtime-publish
start = "2024-02-15"
end = "2025-03-01"

[[trusted.wasmtime-slab]]
criteria = "safe-to-deploy"
user-id = 73222 # wasmtime-publish
start = "2024-03-20"
end = "2025-05-02"

[[trusted.wasmtime-versioned-export-macros]]
criteria = "safe-to-deploy"
user-id = 73222 # wasmtime-publish
Expand Down Expand Up @@ -609,6 +645,12 @@ user-id = 64539 # Kenny Kerr (kennykerr)
start = "2021-10-27"
end = "2025-01-02"

[[trusted.winnow]]
criteria = "safe-to-deploy"
user-id = 6743 # Ed Page (epage)
start = "2023-02-22"
end = "2025-05-02"

[[trusted.winx]]
criteria = "safe-to-deploy"
user-id = 6825 # Dan Gohman (sunfishcode)
Expand Down
24 changes: 2 additions & 22 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -654,18 +654,6 @@ criteria = "safe-to-deploy"
version = "0.1.1"
criteria = "safe-to-deploy"

[[exemptions.toml]]
version = "0.5.7"
criteria = "safe-to-deploy"

[[exemptions.toml_datetime]]
version = "0.6.5"
criteria = "safe-to-deploy"

[[exemptions.toml_edit]]
version = "0.19.15"
criteria = "safe-to-deploy"

[[exemptions.tower]]
version = "0.4.13"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -742,10 +730,6 @@ criteria = "safe-to-deploy"
version = "0.2.92"
criteria = "safe-to-deploy"

[[exemptions.wasm-encoder]]
version = "0.202.0"
criteria = "safe-to-deploy"

[[exemptions.wasm-opt]]
version = "0.116.1"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -782,10 +766,6 @@ criteria = "safe-to-deploy"
version = "0.4.0"
criteria = "safe-to-deploy"

[[exemptions.winnow]]
version = "0.5.40"
criteria = "safe-to-deploy"

[[exemptions.witx]]
version = "0.9.1"
criteria = "safe-to-deploy"
Expand All @@ -803,11 +783,11 @@ version = "0.7.32"
criteria = "safe-to-deploy"

[[exemptions.zstd]]
version = "0.11.2+zstd.1.5.2"
version = "0.13.1"
criteria = "safe-to-deploy"

[[exemptions.zstd-safe]]
version = "5.0.2+zstd.1.5.2"
version = "7.1.0"
criteria = "safe-to-deploy"

[[exemptions.zstd-sys]]
Expand Down
Loading

0 comments on commit 5295a90

Please sign in to comment.