diff --git a/Cargo.lock b/Cargo.lock index f00e25d..a23d64f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "addr2line" -version = "0.25.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" +checksum = "9698bf0769c641b18618039fe2ebd41eb3541f98433000f64e663fab7cea2c87" dependencies = [ "gimli", ] @@ -138,6 +138,15 @@ version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -164,9 +173,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cap-fs-ext" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e41cc18551193fe8fa6f15c1e3c799bc5ec9e2cfbfaa8ed46f37013e3e6c173c" +checksum = "d5528f85b1e134ae811704e41ef80930f56e795923f866813255bc342cc20654" dependencies = [ "cap-primitives", "cap-std", @@ -176,21 +185,21 @@ dependencies = [ [[package]] name = "cap-net-ext" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f83833816c66c986e913b22ac887cec216ea09301802054316fc5301809702c" +checksum = "20a158160765c6a7d0d8c072a53d772e4cb243f38b04bfcf6b4939cfbe7482e7" dependencies = [ "cap-primitives", "cap-std", - "rustix 1.1.2", + "rustix 1.1.3", "smallvec", ] [[package]] name = "cap-primitives" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e394ed14f39f8bc26f59d4c0c010dbe7f0a1b9bafff451b1f98b67c8af62a" +checksum = "b6cf3aea8a5081171859ef57bc1606b1df6999df4f1110f8eef68b30098d1d3a" dependencies = [ "ambient-authority", "fs-set-times", @@ -198,7 +207,7 @@ dependencies = [ "io-lifetimes", "ipnet", "maybe-owned", - "rustix 1.1.2", + "rustix 1.1.3", "rustix-linux-procfs", "windows-sys 0.59.0", "winx", @@ -206,9 +215,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0acb89ccf798a28683f00089d0630dfaceec087234eae0d308c05ddeaa941b40" +checksum = "d8144c22e24bbcf26ade86cb6501a0916c46b7e4787abdb0045a467eb1645a1d" dependencies = [ "ambient-authority", "rand", @@ -216,27 +225,27 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c0355ca583dd58f176c3c12489d684163861ede3c9efa6fd8bba314c984189" +checksum = "b6dc3090992a735d23219de5c204927163d922f42f575a0189b005c62d37549a" dependencies = [ "cap-primitives", "io-extras", "io-lifetimes", - "rustix 1.1.2", + "rustix 1.1.3", ] [[package]] name = "cap-time-ext" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "491af520b8770085daa0466978c75db90368c71896523f2464214e38359b1a5b" +checksum = "def102506ce40c11710a9b16e614af0cde8e76ae51b1f48c04b8d79f4b671a80" dependencies = [ "ambient-authority", "cap-primitives", "iana-time-zone", "once_cell", - "rustix 1.1.2", + "rustix 1.1.3", "winx", ] @@ -372,41 +381,42 @@ dependencies = [ [[package]] name = "cranelift-assembler-x64" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-assembler-x64-meta", ] [[package]] name = "cranelift-assembler-x64-meta" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-srcgen", ] [[package]] name = "cranelift-bforest" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "serde", "serde_derive", + "wasmtime-internal-core", ] [[package]] name = "cranelift-codegen" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "bumpalo", "cranelift-assembler-x64", @@ -419,6 +429,7 @@ dependencies = [ "cranelift-isle", "gimli", "hashbrown 0.15.5", + "libm", "log", "pulley-interpreter", "regalloc2", @@ -426,13 +437,13 @@ dependencies = [ "serde", "smallvec", "target-lexicon", - "wasmtime-internal-math", + "wasmtime-internal-core", ] [[package]] name = "cranelift-codegen-meta" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-assembler-x64-meta", "cranelift-codegen-shared", @@ -443,31 +454,32 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" [[package]] name = "cranelift-control" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-bitset", "serde", "serde_derive", + "wasmtime-internal-core", ] [[package]] name = "cranelift-frontend" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-codegen", "log", @@ -477,13 +489,13 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" [[package]] name = "cranelift-native" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-codegen", "libc", @@ -492,8 +504,8 @@ dependencies = [ [[package]] name = "cranelift-srcgen" -version = "0.126.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "0.130.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" [[package]] name = "crc32fast" @@ -699,10 +711,10 @@ dependencies = [ ] [[package]] -name = "fallible-iterator" -version = "0.3.0" +name = "fastrand" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fd-lock" @@ -711,7 +723,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78" dependencies = [ "cfg-if", - "rustix 1.1.2", + "rustix 1.1.3", "windows-sys 0.59.0", ] @@ -721,6 +733,18 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foldhash" version = "0.1.5" @@ -743,7 +767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94e7099f6313ecacbe1256e8ff9d617b75d1bcb16a6fddef94866d225a01a14a" dependencies = [ "io-lifetimes", - "rustix 1.1.2", + "rustix 1.1.3", "windows-sys 0.59.0", ] @@ -861,11 +885,12 @@ dependencies = [ [[package]] name = "gimli" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" +checksum = "0bf7f043f89559805f8c7cacc432749b2fa0d0a0a9ee46ce47164ed5ba7f126c" dependencies = [ - "fallible-iterator", + "fnv", + "hashbrown 0.16.0", "indexmap", "stable_deref_trait", ] @@ -1046,6 +1071,20 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "im-rc" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe" +dependencies = [ + "bitmaps", + "rand_core", + "rand_xoshiro", + "sized-chunks", + "typenum", + "version_check", +] + [[package]] name = "indexmap" version = "2.11.4" @@ -1205,9 +1244,9 @@ checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libm" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" @@ -1270,7 +1309,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad38eb12aea514a0466ea40a80fd8cc83637065948eb4a426e4aa46261175227" dependencies = [ - "rustix 1.1.2", + "rustix 1.1.3", ] [[package]] @@ -1329,6 +1368,16 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1431,19 +1480,19 @@ dependencies = [ [[package]] name = "pulley-interpreter" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cranelift-bitset", "log", "pulley-macros", - "wasmtime-internal-math", + "wasmtime-internal-core", ] [[package]] name = "pulley-macros" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "proc-macro2", "quote", @@ -1495,6 +1544,15 @@ dependencies = [ "getrandom 0.2.16", ] +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core", +] + [[package]] name = "rayon" version = "1.11.0" @@ -1528,9 +1586,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.13.2" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd8138ce7c3d7c13be4f61893154b5d711bd798d2d7be3ecb8dcc7e7a06ca98" +checksum = "08effbc1fa53aaebff69521a5c05640523fab037b34a4a2c109506bc938246fa" dependencies = [ "allocator-api2", "bumpalo", @@ -1603,9 +1661,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" dependencies = [ "bitflags", "errno", @@ -1621,7 +1679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fc84bf7e9aa16c4f2c758f27412dc9841341e16aa682d9c7ac308fe3ee12056" dependencies = [ "once_cell", - "rustix 1.1.2", + "rustix 1.1.3", ] [[package]] @@ -1707,6 +1765,19 @@ dependencies = [ "serde_core", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha2" version = "0.10.9" @@ -1724,6 +1795,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] + [[package]] name = "slab" version = "0.4.11" @@ -1805,6 +1886,19 @@ version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c" +[[package]] +name = "tempfile" +version = "3.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix 1.1.3", + "windows-sys 0.61.2", +] + [[package]] name = "termcolor" version = "1.4.1" @@ -1876,18 +1970,30 @@ dependencies = [ [[package]] name = "tokio" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" dependencies = [ "bytes", "libc", "mio", "pin-project-lite", "socket2", + "tokio-macros", "windows-sys 0.61.2", ] +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "toml" version = "0.9.8" @@ -1982,6 +2088,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "url" version = "2.5.7" @@ -2107,43 +2219,41 @@ dependencies = [ ] [[package]] -name = "wasm-encoder" -version = "0.238.1" +name = "wasm-compose" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50d48c31c615f77679b61c607b8151378a5d03159616bf3d17e8e2005afdaf5" +checksum = "92cda9c76ca8dcac01a8b497860c2cb15cd6f216dc07060517df5abbe82512ac" dependencies = [ - "leb128fmt", - "wasmparser 0.238.1", + "anyhow", + "heck", + "im-rc", + "indexmap", + "log", + "petgraph", + "serde", + "serde_derive", + "serde_yaml", + "smallvec", + "wasm-encoder", + "wasmparser", + "wat", ] [[package]] name = "wasm-encoder" -version = "0.240.0" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d642d8c5ecc083aafe9ceb32809276a304547a3a6eeecceb5d8152598bc71f" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" dependencies = [ "leb128fmt", - "wasmparser 0.240.0", -] - -[[package]] -name = "wasmparser" -version = "0.238.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa99c8328024423875ae4a55345cfde8f0371327fb2d0f33b0f52a06fc44408" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", - "semver", - "serde", + "wasmparser", ] [[package]] name = "wasmparser" -version = "0.240.0" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b722dcf61e0ea47440b53ff83ccb5df8efec57a69d150e4f24882e4eba7e24a4" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ "bitflags", "hashbrown 0.15.5", @@ -2154,33 +2264,21 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.238.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd2d53749ac5922bdc60ef3288adc7b45990fb079331d977b25dd7e83c75c810" -dependencies = [ - "anyhow", - "termcolor", - "wasmparser 0.238.1", -] - -[[package]] -name = "wasmprinter" -version = "0.240.0" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84d6e25c198da67d0150ee7c2c62d33d784f0a565d1e670bdf1eeccca8158bc" +checksum = "09390d7b2bd7b938e563e4bff10aa345ef2e27a3bc99135697514ef54495e68f" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.240.0", + "wasmparser", ] [[package]] name = "wasmtime" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "addr2line", - "anyhow", "async-trait", "bitflags", "bumpalo", @@ -2190,8 +2288,6 @@ dependencies = [ "futures", "fxprof-processed-profile", "gimli", - "hashbrown 0.15.5", - "indexmap", "ittapi", "libc", "log", @@ -2202,42 +2298,44 @@ dependencies = [ "postcard", "pulley-interpreter", "rayon", - "rustix 1.1.2", + "rustix 1.1.3", "semver", "serde", "serde_derive", "serde_json", "smallvec", "target-lexicon", - "wasm-encoder 0.240.0", - "wasmparser 0.240.0", + "tempfile", + "wasm-compose", + "wasm-encoder", + "wasmparser", "wasmtime-environ", "wasmtime-internal-cache", "wasmtime-internal-component-macro", "wasmtime-internal-component-util", + "wasmtime-internal-core", "wasmtime-internal-cranelift", "wasmtime-internal-fiber", "wasmtime-internal-jit-debug", "wasmtime-internal-jit-icache-coherence", - "wasmtime-internal-math", - "wasmtime-internal-slab", "wasmtime-internal-unwinder", "wasmtime-internal-versioned-export-macros", "wasmtime-internal-winch", "wat", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "wasmtime-environ" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "anyhow", "cpp_demangle", "cranelift-bitset", "cranelift-entity", "gimli", + "hashbrown 0.15.5", "indexmap", "log", "object", @@ -2248,35 +2346,36 @@ dependencies = [ "serde_derive", "smallvec", "target-lexicon", - "wasm-encoder 0.240.0", - "wasmparser 0.240.0", - "wasmprinter 0.240.0", + "wasm-encoder", + "wasmparser", + "wasmprinter", "wasmtime-internal-component-util", + "wasmtime-internal-core", ] [[package]] name = "wasmtime-internal-cache" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "base64", "directories-next", "log", "postcard", - "rustix 1.1.2", + "rustix 1.1.3", "serde", "serde_derive", "sha2", "toml", - "windows-sys 0.60.2", + "wasmtime-environ", + "windows-sys 0.61.2", "zstd", ] [[package]] name = "wasmtime-internal-component-macro" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "anyhow", "proc-macro2", @@ -2289,15 +2388,24 @@ dependencies = [ [[package]] name = "wasmtime-internal-component-util" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" [[package]] -name = "wasmtime-internal-cranelift" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +name = "wasmtime-internal-core" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "anyhow", + "hashbrown 0.15.5", + "libm", +] + +[[package]] +name = "wasmtime-internal-cranelift" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" +dependencies = [ "cfg-if", "cranelift-codegen", "cranelift-control", @@ -2312,78 +2420,65 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror 2.0.17", - "wasmparser 0.240.0", + "wasmparser", "wasmtime-environ", - "wasmtime-internal-math", + "wasmtime-internal-core", "wasmtime-internal-unwinder", "wasmtime-internal-versioned-export-macros", ] [[package]] name = "wasmtime-internal-fiber" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "cc", "cfg-if", "libc", - "rustix 1.1.2", + "rustix 1.1.3", + "wasmtime-environ", "wasmtime-internal-versioned-export-macros", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "wasmtime-internal-jit-debug" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "cc", "object", - "rustix 1.1.2", + "rustix 1.1.3", "wasmtime-internal-versioned-export-macros", ] [[package]] name = "wasmtime-internal-jit-icache-coherence" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "cfg-if", "libc", - "windows-sys 0.60.2", -] - -[[package]] -name = "wasmtime-internal-math" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" -dependencies = [ - "libm", + "wasmtime-internal-core", + "windows-sys 0.61.2", ] -[[package]] -name = "wasmtime-internal-slab" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" - [[package]] name = "wasmtime-internal-unwinder" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "cfg-if", "cranelift-codegen", "log", "object", + "wasmtime-environ", ] [[package]] name = "wasmtime-internal-versioned-export-macros" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "proc-macro2", "quote", @@ -2392,16 +2487,15 @@ dependencies = [ [[package]] name = "wasmtime-internal-winch" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "cranelift-codegen", "gimli", "log", "object", "target-lexicon", - "wasmparser 0.240.0", + "wasmparser", "wasmtime-environ", "wasmtime-internal-cranelift", "winch-codegen", @@ -2409,8 +2503,8 @@ dependencies = [ [[package]] name = "wasmtime-internal-wit-bindgen" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "anyhow", "bitflags", @@ -2421,10 +2515,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "async-trait", "bitflags", "bytes", @@ -2437,7 +2530,7 @@ dependencies = [ "futures", "io-extras", "io-lifetimes", - "rustix 1.1.2", + "rustix 1.1.3", "system-interface", "thiserror 2.0.17", "tokio", @@ -2446,33 +2539,32 @@ dependencies = [ "wasmtime", "wasmtime-wasi-io", "wiggle", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "wasmtime-wasi-io" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "async-trait", "bytes", "futures", + "tracing", "wasmtime", ] [[package]] name = "wasmtime-wizer" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "clap", "log", "rayon", - "wasm-encoder 0.240.0", - "wasmparser 0.240.0", - "wasmprinter 0.240.0", + "wasm-encoder", + "wasmparser", + "wasmprinter", "wasmtime", ] @@ -2487,24 +2579,24 @@ dependencies = [ [[package]] name = "wast" -version = "240.0.0" +version = "244.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0efe1c93db4ac562b9733e3dca19ed7fc878dba29aef22245acf84f13da4a19" +checksum = "b2e7b9f9e23311275920e3d6b56d64137c160cf8af4f84a7283b36cfecbf4acb" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width", - "wasm-encoder 0.240.0", + "wasm-encoder", ] [[package]] name = "wat" -version = "1.240.0" +version = "1.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec9b6eab7ecd4d639d78515e9ea491c9bacf494aa5eda10823bd35992cf8c1e" +checksum = "bbf35b87ed352f9ab6cd0732abde5a67dd6153dfd02c493e61459218b19456fa" dependencies = [ - "wast 240.0.0", + "wast 244.0.0", ] [[package]] @@ -2519,34 +2611,34 @@ dependencies = [ [[package]] name = "wiggle" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "bitflags", "thiserror 2.0.17", "tracing", "wasmtime", + "wasmtime-environ", "wiggle-macro", ] [[package]] name = "wiggle-generate" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "heck", "proc-macro2", "quote", "syn", + "wasmtime-environ", "witx", ] [[package]] name = "wiggle-macro" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ "proc-macro2", "quote", @@ -2587,10 +2679,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "39.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime#41a695f27cb1d420c6028f1d093777bb27766d9d" +version = "43.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime#f0011184ee537581bd907870798d3b9163fb0909" dependencies = [ - "anyhow", "cranelift-assembler-x64", "cranelift-codegen", "gimli", @@ -2598,10 +2689,10 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror 2.0.17", - "wasmparser 0.240.0", + "wasmparser", "wasmtime-environ", + "wasmtime-internal-core", "wasmtime-internal-cranelift", - "wasmtime-internal-math", ] [[package]] @@ -2843,9 +2934,9 @@ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "wit-parser" -version = "0.240.0" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9875ea3fa272f57cc1fc50f225a7b94021a7878c484b33792bccad0d93223439" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" dependencies = [ "anyhow", "id-arena", @@ -2856,7 +2947,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.240.0", + "wasmparser", ] [[package]] @@ -2880,9 +2971,10 @@ dependencies = [ "criterion", "env_logger", "log", - "wasm-encoder 0.238.1", - "wasmparser 0.238.1", - "wasmprinter 0.238.1", + "tokio", + "wasm-encoder", + "wasmparser", + "wasmprinter", "wasmtime", "wasmtime-wasi", "wasmtime-wizer", diff --git a/Cargo.toml b/Cargo.toml index 2c57580..035e169 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,12 +19,13 @@ name = "wizer" required-features = ["cli"] [dependencies] -anyhow = { version = "1.0.97", optional = true } -env_logger = { version = "0.11.8", optional = true } -clap = { version = "4.5", optional = true, features = ['derive'] } -wasmtime = { workspace = true } -wasmtime-wizer = { workspace = true } +anyhow = { workspace = true, optional = true } +clap = { workspace = true, optional = true, features = ['derive'] } +env_logger = { workspace = true, optional = true } +tokio = { workspace = true, features = ["macros"] } +wasmtime = { workspace = true, features = ["async", "anyhow"] } wasmtime-wasi = { workspace = true, features = ["p1"] } +wasmtime-wizer = { workspace = true, features = ["wasmtime"] } [features] # Enable this dependency to get messages with WAT disassemblies when certain @@ -34,25 +35,39 @@ wasmprinter = ['wasmtime-wizer/wasmprinter'] cli = ['dep:clap', 'dep:env_logger', 'dep:anyhow', 'wasmtime-wizer/clap'] [workspace.dependencies] -wasmprinter = "0.238.0" -wasmtime = { git = 'https://github.com/bytecodealliance/wasmtime' } -wasmtime-wasi = { git = 'https://github.com/bytecodealliance/wasmtime' } -wasmtime-wizer = { git = 'https://github.com/bytecodealliance/wasmtime' } +anyhow = { version = "1.0.97" } +clap = { version = "4.5" } +criterion = { version = "0.5.1" } +env_logger = { version = "0.11.8" } +log = { version = "0.4.27" } +wasm-encoder = { version = "0.244.0" } +wasmparser = { version = "0.244.0" } +wasmprinter = { version = "0.244.0" } + +# TODO: remove once wasmtime releases 42.0.0 +#wasmtime = { version = "42.0.0" } +#wasmtime-wasi = { version = "42.0.0" } +#wasmtime-wizer = { version = "42.0.0" } + +wasmtime = { git = "https://github.com/bytecodealliance/wasmtime" } +wasmtime-wasi = { git = "https://github.com/bytecodealliance/wasmtime" } +wasmtime-wizer = { git = "https://github.com/bytecodealliance/wasmtime" } + +wat = { version = "1.244.0" } +tokio = { version = "1.49.0" } [dev-dependencies] -log = "0.4.27" -anyhow = "1.0.97" -criterion = "0.5.1" -env_logger = "0.11.8" +anyhow = { workspace = true } +criterion = { workspace = true } +env_logger = { workspace = true } +log = { workspace = true } +wasm-encoder = { workspace = true } +wasmparser = { workspace = true } wasmprinter = { workspace = true } -wat = "1.238.0" -wasm-encoder = "0.238.0" -wasmparser = "0.238.0" +wat = { workspace = true } [workspace] -members = [ - "tests/regex-test", -] +members = ["tests/regex-test"] [profile.bench] debug = true diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..0fb71e6 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition = "2024" \ No newline at end of file diff --git a/src/bin/wizer.rs b/src/bin/wizer.rs index 7f882fc..ba8d020 100644 --- a/src/bin/wizer.rs +++ b/src/bin/wizer.rs @@ -1,9 +1,10 @@ -use anyhow::Context; -use anyhow::Result; -use clap::Parser; use std::fs; use std::io::{self, BufRead, Write}; use std::path::PathBuf; + +use anyhow::Result; +use clap::Parser; +use wasmtime::error::Context; use wizer::Wizer; #[derive(Parser)] @@ -168,7 +169,8 @@ fn optional_flag_with_default(flag: Option>, default: bool) -> bool } } -fn main() -> anyhow::Result<()> { +#[tokio::main] +async fn main() -> Result<()> { env_logger::init(); let options = Options::parse(); @@ -262,10 +264,11 @@ fn main() -> anyhow::Result<()> { let output_wasm = options .wizer - .run(&mut store, &input_wasm, |store, module| { + .run(&mut store, &input_wasm, async |store, module| { linker.define_unknown_imports_as_traps(module)?; linker.instantiate(store, module) - })?; + }) + .await?; output .write_all(&output_wasm) diff --git a/tests/make_linker.rs b/tests/make_linker.rs index 4a0f3ec..38e5824 100644 --- a/tests/make_linker.rs +++ b/tests/make_linker.rs @@ -1,13 +1,16 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; +use wasmtime::error::Context as _; use wasmtime_wasi::WasiCtxBuilder; use wat::parse_str as wat_to_wasm; use wizer::Wizer; fn get_wizer() -> Wizer { - Wizer::new() + let mut wizer = Wizer::new(); + wizer.init_func("wizer.initialize"); + wizer } -fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { +async fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { let _ = env_logger::try_init(); let mut config = wasmtime::Config::new(); @@ -21,11 +24,15 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { let wasi_ctx = WasiCtxBuilder::new().build_p1(); let mut store = wasmtime::Store::new(&engine, wasi_ctx); - let wasm = get_wizer().run(&mut store, &wasm, |store, module| { - let mut linker = wasmtime::Linker::new(store.engine()); - linker.func_wrap("foo", "bar", |x: i32| x + 1)?; - linker.instantiate(store, module) - })?; + let wasm = get_wizer() + .run(&mut store, wasm, async |store, module| { + let mut linker = wasmtime::Linker::new(store.engine()); + linker.func_wrap("foo", "bar", |x: i32| x + 1)?; + linker.instantiate(store, module) + }) + .await + .map_err(|e| anyhow!(e))?; + log::debug!( "=== Wizened Wasm ==========================================================\n\ {}\n\ @@ -40,8 +47,8 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; let mut linker = wasmtime::Linker::new(&engine); - linker.func_wrap("foo", "bar", |_: i32| -> Result { - Err(anyhow!("shouldn't be called")) + linker.func_wrap("foo", "bar", |_: i32| -> wasmtime::error::Result { + wasmtime::error::bail!("shouldn't be called") })?; let instance = linker.instantiate(&mut store, &module)?; @@ -51,7 +58,8 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))?; let mut actual = vec![wasmtime::Val::I32(0)]; - run.call(&mut store, args, &mut actual)?; + run.call(&mut store, args, &mut actual) + .context("failed to call wasm run fn")?; anyhow::ensure!(actual.len() == 1, "expected one result"); let actual = match actual[0] { wasmtime::Val::I32(x) => x, @@ -67,14 +75,14 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { Ok(()) } -fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { +async fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; - run_wasm(args, expected, &wasm) + run_wasm(args, expected, &wasm).await } -#[test] -fn custom_linker() -> Result<()> { +#[tokio::test] +async fn custom_linker() -> Result<()> { run_wat( &[], 1, @@ -93,4 +101,5 @@ fn custom_linker() -> Result<()> { ) )"#, ) + .await } diff --git a/tests/preloads.rs b/tests/preloads.rs index cd838bf..3cfb2e9 100644 --- a/tests/preloads.rs +++ b/tests/preloads.rs @@ -1,9 +1,10 @@ use anyhow::Result; +use wasmtime::error::Context as _; use wasmtime::{Instance, Linker, Module}; use wasmtime_wizer::Wizer; use wat::parse_str as wat_to_wasm; -const PRELOAD1: &'static str = r#" +const PRELOAD1: &str = r#" (module (func (export "f") (param i32) (result i32) local.get 0 @@ -11,7 +12,7 @@ const PRELOAD1: &'static str = r#" i32.add)) "#; -const PRELOAD2: &'static str = r#" +const PRELOAD2: &str = r#" (module (func (export "f") (param i32) (result i32) local.get 0 @@ -19,21 +20,25 @@ const PRELOAD2: &'static str = r#" i32.add)) "#; -fn run_with_preloads(args: &[wasmtime::Val], wat: &str) -> Result { +async fn run_with_preloads(args: &[wasmtime::Val], wat: &str) -> Result { let wasm = wat_to_wasm(wat)?; let engine = wasmtime::Engine::default(); let mut store = wasmtime::Store::new(&engine, ()); let mod1 = Module::new(store.engine(), PRELOAD1)?; let mod2 = Module::new(store.engine(), PRELOAD2)?; - let processed = Wizer::new().run(&mut store, &wasm, |store, module| { - let i1 = Instance::new(&mut *store, &mod1, &[])?; - let i2 = Instance::new(&mut *store, &mod2, &[])?; - let mut linker = Linker::new(store.engine()); - linker.instance(&mut *store, "mod1", i1)?; - linker.instance(&mut *store, "mod2", i2)?; - linker.instantiate(store, module) - })?; + let mut wizer = Wizer::new(); + wizer.init_func("wizer.initialize"); + let processed = wizer + .run(&mut store, &wasm, async |mut store, module| { + let i1 = Instance::new(&mut store, &mod1, &[]).context("failed to create instance")?; + let i2 = Instance::new(&mut store, &mod2, &[]).context("failed to create instance")?; + let mut linker = Linker::new(store.engine()); + linker.instance(&mut store, "mod1", i1)?; + linker.instance(&mut store, "mod2", i2)?; + linker.instantiate(store, module) + }) + .await?; let testmod = wasmtime::Module::new(&engine, &processed[..])?; @@ -48,13 +53,14 @@ fn run_with_preloads(args: &[wasmtime::Val], wat: &str) -> Result .get_func(&mut store, "run") .ok_or_else(|| anyhow::anyhow!("no `run` function on test module"))?; let mut returned = vec![wasmtime::Val::I32(0)]; - run.call(&mut store, args, &mut returned)?; + run.call(&mut store, args, &mut returned) + .context("call failed")?; Ok(returned[0]) } -#[test] -fn test_preloads() { - const WAT: &'static str = r#" +#[tokio::test] +async fn test_preloads() -> Result<()> { + const WAT: &str = r#" (module (import "mod1" "f" (func $mod1f (param i32) (result i32))) (import "mod2" "f" (func $mod2f (param i32) (result i32))) @@ -80,6 +86,7 @@ fn test_preloads() { "#; let result = - run_with_preloads(&[wasmtime::Val::I32(200), wasmtime::Val::I32(201)], WAT).unwrap(); + run_with_preloads(&[wasmtime::Val::I32(200), wasmtime::Val::I32(201)], WAT).await?; assert!(matches!(result, wasmtime::Val::I32(607))); + Ok(()) } diff --git a/tests/regex-test/README.md b/tests/regex-test/README.md index 103b4d2..adad68c 100644 --- a/tests/regex-test/README.md +++ b/tests/regex-test/README.md @@ -2,7 +2,7 @@ Source code used to create `/wizer/tests/regex_test.wasm`. Rebuild with: -``` -$ cargo build --release --target wasm32-wasi -p regex-test -$ cp target/wasm32-wasi/release/regex_test.wasm tests/regex_test.wasm +```console +cargo build --release --target wasm32-wasip1 -p regex-test +cp target/wasm32-wasip1/release/regex_test.wasm tests/regex_test.wasm ``` diff --git a/tests/regex-test/src/lib.rs b/tests/regex-test/src/lib.rs index 1d71433..4c682f4 100644 --- a/tests/regex-test/src/lib.rs +++ b/tests/regex-test/src/lib.rs @@ -1,19 +1,20 @@ use regex::Regex; +use std::sync::OnceLock; /// A regex that matches numbers that start with "1". -static mut REGEX: Option = None; +static REGEX: OnceLock = OnceLock::new(); #[export_name = "wizer.initialize"] pub fn init() { - unsafe { - REGEX = Some(Regex::new(r"^1\d*$").unwrap()); - } + REGEX.get_or_init(|| Regex::new(r"^1\d*$").expect("failed to compile regex")); } #[no_mangle] pub fn run(n: i32) -> i32 { let s = format!("{}", n); - let regex = unsafe { REGEX.as_ref().unwrap() }; + let regex = REGEX + .get() + .expect("regex should have been initialized at wizering"); if regex.is_match(&s) { 42 } else { diff --git a/tests/regex_test.wasm b/tests/regex_test.wasm index 004f08e..c60a568 100755 Binary files a/tests/regex_test.wasm and b/tests/regex_test.wasm differ diff --git a/tests/tests.rs b/tests/tests.rs index 4c77c3d..5a19256 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,17 +1,20 @@ -use anyhow::{Context, Result}; +use anyhow::Result; use wasm_encoder::ConstExpr; +use wasmtime::error::Context as _; use wasmtime_wasi::{p1, WasiCtxBuilder}; use wat::parse_str as wat_to_wasm; use wizer::Wizer; -fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { +async fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; - wizen_and_run_wasm(args, expected, &wasm, get_wizer()) + wizen_and_run_wasm(args, expected, &wasm, get_wizer()).await } fn get_wizer() -> Wizer { - Wizer::new() + let mut wizer = Wizer::new(); + wizer.init_func("wizer.initialize"); + wizer } fn store() -> Result> { @@ -22,17 +25,17 @@ fn store() -> Result> { Ok(wasmtime::Store::new(&engine, wasi.build_p1())) } -fn instantiate( +async fn instantiate( store: &mut wasmtime::Store, module: &wasmtime::Module, -) -> Result { +) -> wasmtime::error::Result { let mut linker = wasmtime::Linker::new(store.engine()); p1::add_to_linker_sync(&mut linker, |x| x)?; linker.define_unknown_imports_as_traps(module)?; linker.instantiate(store, module) } -fn wizen_and_run_wasm( +async fn wizen_and_run_wasm( args: &[wasmtime::Val], expected: i32, wasm: &[u8], @@ -55,9 +58,11 @@ fn wizen_and_run_wasm( "=== PreWizened Wasm ==========================================================\n\ {}\n\ ===========================================================================", - wasmprinter::print_bytes(&wasm).unwrap() + wasmprinter::print_bytes(wasm).unwrap() ); - let wasm = wizer.run(&mut store, &wasm, instantiate)?; + + let wasm = wizer.run(&mut store, wasm, instantiate).await?; + log::debug!( "=== Wizened Wasm ==========================================================\n\ {}\n\ @@ -88,7 +93,8 @@ fn wizen_and_run_wasm( .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))?; let mut actual = vec![wasmtime::Val::I32(0)]; - run.call(&mut store, args, &mut actual)?; + run.call(&mut store, args, &mut actual) + .context("call failed")?; anyhow::ensure!(actual.len() == 1, "expected one result"); let actual = match actual[0] { wasmtime::Val::I32(x) => x, @@ -104,7 +110,7 @@ fn wizen_and_run_wasm( Ok(()) } -fn fails_wizening(wat: &str) -> Result<()> { +async fn fails_wizening(wat: &str) -> Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; @@ -118,14 +124,17 @@ fn fails_wizening(wat: &str) -> Result<()> { .context("initial Wasm should be valid")?; anyhow::ensure!( - get_wizer().run(&mut store()?, &wasm, instantiate).is_err(), + get_wizer() + .run(&mut store()?, &wasm, instantiate) + .await + .is_err(), "Expected an error when wizening, but didn't get one" ); Ok(()) } -#[test] -fn basic_global() -> Result<()> { +#[tokio::test] +async fn basic_global() -> Result<()> { run_wat( &[], 42, @@ -139,10 +148,11 @@ fn basic_global() -> Result<()> { global.get $g)) "#, ) + .await } -#[test] -fn basic_memory() -> Result<()> { +#[tokio::test] +async fn basic_memory() -> Result<()> { run_wat( &[], 42, @@ -158,10 +168,11 @@ fn basic_memory() -> Result<()> { i32.load offset=1337)) "#, ) + .await } -#[test] -fn multi_memory() -> Result<()> { +#[tokio::test] +async fn multi_memory() -> Result<()> { run_wat( &[], 42, @@ -184,39 +195,44 @@ fn multi_memory() -> Result<()> { i32.add)) "#, ) + .await } -#[test] -fn reject_imported_memory() -> Result<()> { + +#[tokio::test] +async fn reject_imported_memory() -> Result<()> { fails_wizening( r#" (module (import "" "" (memory 1))) "#, ) + .await } -#[test] -fn reject_imported_global() -> Result<()> { +#[tokio::test] +async fn reject_imported_global() -> Result<()> { fails_wizening( r#" (module (import "" "" (global i32))) "#, ) + .await } -#[test] -fn reject_imported_table() -> Result<()> { +#[tokio::test] +async fn reject_imported_table() -> Result<()> { fails_wizening( r#" (module (import "" "" (table 0 externref))) "#, ) + .await } -#[test] -fn reject_table_copy() -> Result<()> { +#[tokio::test] +async fn reject_table_copy() -> Result<()> { let result = run_wat( &[], 42, @@ -237,7 +253,8 @@ fn reject_table_copy() -> Result<()> { (elem (i32.const 0) $f $g $h) ) "#, - ); + ) + .await; assert!(result.is_err()); let err = result.unwrap_err(); @@ -248,8 +265,8 @@ fn reject_table_copy() -> Result<()> { Ok(()) } -#[test] -fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { +#[tokio::test] +async fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { let result = run_wat( &[], 42, @@ -269,7 +286,8 @@ fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { (elem (i32.const 0) $f $g $h) )"#, - ); + ) + .await; assert!(result.is_err()); let err = result.unwrap_err(); @@ -280,8 +298,8 @@ fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { Ok(()) } -#[test] -fn reject_table_grow_with_reference_types_enabled() -> anyhow::Result<()> { +#[tokio::test] +async fn reject_table_grow_with_reference_types_enabled() -> anyhow::Result<()> { let wat = r#" (module (elem declare func $f) @@ -295,10 +313,9 @@ fn reject_table_grow_with_reference_types_enabled() -> anyhow::Result<()> { )"#; let _ = env_logger::try_init(); - let wizer = Wizer::new(); let wasm = wat_to_wasm(wat)?; - let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); + let result = wizen_and_run_wasm(&[], 42, &wasm, get_wizer()).await; assert!(result.is_err()); @@ -310,8 +327,8 @@ fn reject_table_grow_with_reference_types_enabled() -> anyhow::Result<()> { Ok(()) } -#[test] -fn indirect_call_with_reference_types() -> anyhow::Result<()> { +#[tokio::test] +async fn indirect_call_with_reference_types() -> anyhow::Result<()> { let wat = r#" (module (type $sig (func (result i32))) @@ -329,14 +346,16 @@ fn indirect_call_with_reference_types() -> anyhow::Result<()> { )"#; let _ = env_logger::try_init(); - let wizer = Wizer::new(); - let wasm = wat_to_wasm(wat)?; - wizen_and_run_wasm(&[], 42, &wasm, wizer) + let wasm = tokio::task::spawn_blocking(move || wat_to_wasm(wat)) + .await + .context("failed to run task")? + .context("failed to complete wat to wasm conversion")?; + wizen_and_run_wasm(&[], 42, &wasm, get_wizer()).await } -#[test] -fn reject_table_init() -> Result<()> { +#[tokio::test] +async fn reject_table_init() -> Result<()> { let result = run_wat( &[], 42, @@ -357,7 +376,8 @@ fn reject_table_init() -> Result<()> { table.init $elem) ) "#, - ); + ) + .await; assert!(result.is_err()); let err = result.unwrap_err(); @@ -368,8 +388,8 @@ fn reject_table_init() -> Result<()> { Ok(()) } -#[test] -fn reject_elem_drop() -> Result<()> { +#[tokio::test] +async fn reject_elem_drop() -> Result<()> { let result = run_wat( &[], 42, @@ -387,7 +407,8 @@ fn reject_elem_drop() -> Result<()> { elem.drop $elem) ) "#, - ); + ) + .await; assert!(result.is_err()); let err = result.unwrap_err(); @@ -398,8 +419,8 @@ fn reject_elem_drop() -> Result<()> { Ok(()) } -#[test] -fn reject_data_drop() -> Result<()> { +#[tokio::test] +async fn reject_data_drop() -> Result<()> { let result = run_wat( &[], 42, @@ -412,7 +433,8 @@ fn reject_data_drop() -> Result<()> { data.drop $data) ) "#, - ); + ) + .await; assert!(result.is_err()); let err = result.unwrap_err(); @@ -423,18 +445,19 @@ fn reject_data_drop() -> Result<()> { Ok(()) } -#[test] -fn rust_regex() -> Result<()> { +#[tokio::test] +async fn rust_regex() -> Result<()> { wizen_and_run_wasm( &[wasmtime::Val::I32(13)], 42, &include_bytes!("./regex_test.wasm")[..], get_wizer(), ) + .await } -#[test] -fn data_segment_at_end_of_memory() -> Result<()> { +#[tokio::test] +async fn data_segment_at_end_of_memory() -> Result<()> { // Test that we properly synthesize data segments for data at the end of // memory. run_wat( @@ -456,10 +479,11 @@ fn data_segment_at_end_of_memory() -> Result<()> { ) "#, ) + .await } -#[test] -fn too_many_data_segments_for_engines() -> Result<()> { +#[tokio::test] +async fn too_many_data_segments_for_engines() -> Result<()> { run_wat( &[], 42, @@ -501,10 +525,11 @@ fn too_many_data_segments_for_engines() -> Result<()> { ) "#, ) + .await } -#[test] -fn rename_functions() -> Result<()> { +#[tokio::test] +async fn rename_functions() -> Result<()> { let wat = r#" (module (func (export "wizer.initialize")) @@ -516,11 +541,14 @@ fn rename_functions() -> Result<()> { i32.const 3)) "#; - let wasm = wat_to_wasm(wat)?; - let mut wizer = Wizer::new(); + let wasm = tokio::task::spawn_blocking(move || wat_to_wasm(wat)) + .await + .context("failed to run task")? + .context("failed to convert wat to wasm")?; + let mut wizer = get_wizer(); wizer.func_rename("func_a", "func_b"); wizer.func_rename("func_b", "func_c"); - let wasm = wizer.run(&mut store()?, &wasm, instantiate)?; + let wasm = wizer.run(&mut store()?, &wasm, instantiate).await?; let wat = wasmprinter::print_bytes(&wasm)?; let expected_wat = r#" @@ -546,8 +574,8 @@ fn rename_functions() -> Result<()> { Ok(()) } -#[test] -fn wasi_reactor() -> anyhow::Result<()> { +#[tokio::test] +async fn wasi_reactor() -> anyhow::Result<()> { run_wat( &[], 42, @@ -569,10 +597,11 @@ fn wasi_reactor() -> anyhow::Result<()> { ) "#, ) + .await } -#[test] -fn wasi_reactor_initializer_as_init_func() -> anyhow::Result<()> { +#[tokio::test] +async fn wasi_reactor_initializer_as_init_func() -> anyhow::Result<()> { let wat = r#" (module (global $g (mut i32) i32.const 0) @@ -588,15 +617,15 @@ fn wasi_reactor_initializer_as_init_func() -> anyhow::Result<()> { )"#; let _ = env_logger::try_init(); - let mut wizer = Wizer::new(); + let mut wizer = get_wizer(); wizer.init_func("_initialize"); let wasm = wat_to_wasm(wat)?; // we expect `_initialize` to be called _exactly_ once - wizen_and_run_wasm(&[], 1, &wasm, wizer) + wizen_and_run_wasm(&[], 1, &wasm, wizer).await } -#[test] -fn wasi_reactor_initializer_with_keep_init() -> anyhow::Result<()> { +#[tokio::test] +async fn wasi_reactor_initializer_with_keep_init() -> anyhow::Result<()> { let wat = r#" (module (global $g (mut i32) i32.const 0) @@ -613,15 +642,15 @@ fn wasi_reactor_initializer_with_keep_init() -> anyhow::Result<()> { )"#; let _ = env_logger::try_init(); - let mut wizer = Wizer::new(); + let mut wizer = get_wizer(); wizer.keep_init_func(true); let wasm = wat_to_wasm(wat)?; // we expect `_initialize` to be un-exported and not called at run - wizen_and_run_wasm(&[], 2, &wasm, wizer) + wizen_and_run_wasm(&[], 2, &wasm, wizer).await } -#[test] -fn call_undefined_import_function_during_init() -> Result<()> { +#[tokio::test] +async fn call_undefined_import_function_during_init() -> Result<()> { fails_wizening( r#" (module @@ -632,10 +661,11 @@ fn call_undefined_import_function_during_init() -> Result<()> { ) "#, ) + .await } -#[test] -fn allow_undefined_import_function() -> Result<()> { +#[tokio::test] +async fn allow_undefined_import_function() -> Result<()> { run_wat( &[], 42, @@ -649,10 +679,11 @@ fn allow_undefined_import_function() -> Result<()> { ) "#, ) + .await } -#[test] -fn accept_bulk_memory_copy() -> Result<()> { +#[tokio::test] +async fn accept_bulk_memory_copy() -> Result<()> { run_wat( &[], ('h' as i32) + ('w' as i32), @@ -672,10 +703,11 @@ fn accept_bulk_memory_copy() -> Result<()> { i32.add)) "#, ) + .await } -#[test] -fn accept_bulk_memory_data_count() -> Result<()> { +#[tokio::test] +async fn accept_bulk_memory_data_count() -> Result<()> { let mut module = wasm_encoder::Module::new(); let mut types = wasm_encoder::TypeSection::new(); types.ty().func_type(&wasm_encoder::FuncType::new( @@ -728,12 +760,12 @@ fn accept_bulk_memory_data_count() -> Result<()> { data.active(0, &ConstExpr::i32_const(4), vec![5, 6, 7, 8]); module.section(&data); - wizen_and_run_wasm(&[], 42, &module.finish(), get_wizer()).unwrap(); + wizen_and_run_wasm(&[], 42, &module.finish(), get_wizer()).await?; Ok(()) } -#[test] -fn accept_bulk_memory_fill() -> Result<()> { +#[tokio::test] +async fn accept_bulk_memory_fill() -> Result<()> { run_wat( &[], 77 + 77, @@ -753,10 +785,11 @@ fn accept_bulk_memory_fill() -> Result<()> { i32.add)) "#, ) + .await } -#[test] -fn accept_bulk_memory_init() -> Result<()> { +#[tokio::test] +async fn accept_bulk_memory_init() -> Result<()> { run_wat( &[], ('h' as i32) + ('w' as i32), @@ -777,10 +810,11 @@ fn accept_bulk_memory_init() -> Result<()> { i32.add)) "#, ) + .await } -#[test] -fn accept_simd128() -> Result<()> { +#[tokio::test] +async fn accept_simd128() -> Result<()> { run_wat( &[], 49, @@ -797,13 +831,15 @@ fn accept_simd128() -> Result<()> { i32x4.extract_lane 3)) "#, ) + .await } -#[test] -fn relaxed_simd_deterministic() -> Result<()> { +#[tokio::test] +async fn relaxed_simd_deterministic() -> Result<()> { let _ = env_logger::try_init(); - let wasm = wat_to_wasm( - r#" + let wasm = tokio::task::spawn_blocking(|| { + wat_to_wasm( + r#" (module (global $g (mut i32) i32.const 0) (func (export "wizer.initialize") @@ -819,10 +855,14 @@ fn relaxed_simd_deterministic() -> Result<()> { ) ) "#, - )?; + ) + }) + .await + .context("failed to run task")? + .context("failed to perform wat to wasm conversion")?; let wizer = get_wizer(); // We'll get 0x4b000003 if we have the deterministic `relaxed_madd` // semantics. We might get 0x4b000002 if we don't. - wizen_and_run_wasm(&[], 0x4b800003, &wasm, wizer) + wizen_and_run_wasm(&[], 0x4b800003, &wasm, wizer).await }