diff --git a/Cargo.lock b/Cargo.lock index 3dfe339..469f601 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -52,9 +63,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.44" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "arbitrary" @@ -156,6 +167,12 @@ version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "cap-fs-ext" version = "0.24.1" @@ -281,59 +298,60 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" +checksum = "749d0d6022c9038dccf480bdde2a38d435937335bf2bb0f14e815d94517cdce8" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" +checksum = "e94370cc7b37bf652ccd8bb8f09bd900997f7ccf97520edfc75554bb5c4abbea" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", + "cranelift-isle", "gimli 0.26.1", "log", - "regalloc", + "regalloc2", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" +checksum = "e0a3cea8fdab90e44018c5b9a1dfd460d8ee265ac354337150222a354628bdb6" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" +checksum = "5ac72f76f2698598951ab26d8c96eaa854810e693e7dd52523958b5909fde6b2" [[package]] name = "cranelift-entity" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" +checksum = "09eaeacfcd2356fe0e66b295e8f9d59fdd1ac3ace53ba50de14d628ec902f72d" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" +checksum = "dba69c9980d5ffd62c18a2bde927855fcd7c8dc92f29feaf8636052662cbd99c" dependencies = [ "cranelift-codegen", "log", @@ -341,11 +359,17 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "cranelift-isle" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2920dc1e05cac40304456ed3301fde2c09bd6a9b0210bcfa2f101398d628d5b" + [[package]] name = "cranelift-native" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501241b0cdf903412ec9075385ac9f2b1eb18a89044d1538e97fab603231f70c" +checksum = "f04dfa45f9b2a6f587c564d6b63388e00cd6589d2df6ea2758cf79e1a13285e6" dependencies = [ "cranelift-codegen", "libc", @@ -354,9 +378,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d9e4211bbc3268042a96dd4de5bd979cda22434991d035f5f8eacba987fad2" +checksum = "31a46513ae6f26f3f267d8d75b5373d555fbbd1e68681f348d99df43f747ec54" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -364,7 +388,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-types", ] @@ -616,6 +640,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "gcc" version = "0.3.55" @@ -671,6 +704,15 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" @@ -681,6 +723,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -716,12 +764,12 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "1.7.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] @@ -825,9 +873,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.115" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libfuzzer-sys" @@ -848,15 +896,15 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linux-raw-sys" -version = "0.0.40" +version = "0.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bdc16c6ce4c85d9b46b4e66f2a814be5b3f034dbd5131c268a24ca26d970db8" +checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] @@ -946,20 +994,21 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.28.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" dependencies = [ "crc32fast", + "hashbrown 0.11.2", "indexmap", "memchr", ] [[package]] name = "once_cell" -version = "1.9.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "oorandom" @@ -1161,13 +1210,14 @@ dependencies = [ ] [[package]] -name = "regalloc" -version = "0.0.34" +name = "regalloc2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" +checksum = "4a8d23b35d7177df3b9d31ed8a9ab4bf625c668be77a319d4f5efd4a5257701c" dependencies = [ + "fxhash", "log", - "rustc-hash", + "slice-group-by", "smallvec", ] @@ -1226,12 +1276,6 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.4.0" @@ -1243,9 +1287,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.33.2" +version = "0.33.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db890a96e64911e67fa84e58ce061a40a6a65c231e5fad20b190933f8991a27c" +checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" dependencies = [ "bitflags", "errno", @@ -1339,9 +1383,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer", "cfg-if", @@ -1359,6 +1403,12 @@ dependencies = [ "dirs-next", ] +[[package]] +name = "slice-group-by" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" + [[package]] name = "smallvec" version = "1.6.1" @@ -1394,7 +1444,7 @@ version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", @@ -1430,9 +1480,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" [[package]] name = "termcolor" @@ -1588,9 +1638,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9120fdc492d9d95cd7278b34f46fe9122962e4b2476c040f058971ccc00fc4d2" +checksum = "f086c5026d2fc3b268d138e65373f46422cc810f46d6e0776859c5027cb18728" dependencies = [ "anyhow", "async-trait", @@ -1612,14 +1662,15 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab6097a5c8e9a791227a50945b6a891da6d93f518ebfa8716f231dc03f119585" +checksum = "4e8844fede1c3787cc08853872f47e8bd91f6c939c7406bc7a5dba496b260c08" dependencies = [ "anyhow", "bitflags", "cap-rand", "cap-std", + "io-extras", "rustix", "thiserror", "tracing", @@ -1699,6 +1750,15 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05632e0a66a6ed8cca593c24223aabd6262f256c3693ad9822c315285f010614" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-smith" version = "0.4.5" @@ -1725,9 +1785,12 @@ checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" [[package]] name = "wasmparser" -version = "0.83.0" +version = "0.85.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" +checksum = "570460c58b21e9150d2df0eaaedbb7816c34bcec009ae0dcc976e40ba81463e7" +dependencies = [ + "indexmap", +] [[package]] name = "wasmprinter" @@ -1741,9 +1804,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ffb4705016d5ca91e18a72ed6822dab50e6d5ddd7045461b17ef19071cdef1" +checksum = "1f50eadf868ab6a04b7b511460233377d0bfbb92e417b2f6a98b98fef2e098f5" dependencies = [ "anyhow", "async-trait", @@ -1754,7 +1817,7 @@ dependencies = [ "lazy_static", "libc", "log", - "object 0.27.1", + "object 0.28.4", "once_cell", "paste", "psm", @@ -1762,7 +1825,7 @@ dependencies = [ "region", "serde", "target-lexicon", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1775,9 +1838,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c6ab24291fa7cb3a181f5669f6c72599b7ef781669759b45c7828c5999d0c0" +checksum = "d1df23c642e1376892f3b72f311596976979cbf8b85469680cdd3a8a063d12a2" dependencies = [ "anyhow", "base64", @@ -1795,9 +1858,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04c810078a491b7bc4866ebe045f714d2b95e6b539e1f64009a4a7606be11de" +checksum = "f264ff6b4df247d15584f2f53d009fbc90032cfdc2605b52b961bffc71b6eccd" dependencies = [ "anyhow", "cranelift-codegen", @@ -1808,18 +1871,18 @@ dependencies = [ "gimli 0.26.1", "log", "more-asserts", - "object 0.27.1", + "object 0.28.4", "target-lexicon", "thiserror", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61448266ea164b1ac406363cdcfac81c7c44db4d94c7a81c8620ac6c5c6cdf59" +checksum = "839d2820e4b830f4b9e7aa08d4c0acabf4a5036105d639f6dfa1c6891c73bdc6" dependencies = [ "anyhow", "cranelift-entity", @@ -1827,19 +1890,19 @@ dependencies = [ "indexmap", "log", "more-asserts", - "object 0.27.1", + "object 0.28.4", "serde", "target-lexicon", "thiserror", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaaa38c3b48822ab27044e1d4a25a1052157de4c8f27574cb00167e127e320f" +checksum = "3248be3c4911233535356025f6562193614a40155ee9094bb6a2b43f0dc82803" dependencies = [ "cc", "rustix", @@ -1848,9 +1911,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "156b4623c6b0d4b8c24afb846c20525922f538ef464cc024abab7ea8de2109a2" +checksum = "ef0a0bcbfa18b946d890078ba0e1bc76bcc53eccfb40806c0020ec29dcd1bd49" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -1860,7 +1923,7 @@ dependencies = [ "gimli 0.26.1", "ittapi-rs", "log", - "object 0.27.1", + "object 0.28.4", "region", "rustc-demangle", "rustix", @@ -1875,20 +1938,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5dc31f811760a6c76b2672c404866fd19b75e5fb3b0075a3e377a6846490654" +checksum = "4f4779d976206c458edd643d1ac622b6c37e4a0800a8b1d25dfbf245ac2f2cac" dependencies = [ "lazy_static", - "object 0.27.1", + "object 0.28.4", "rustix", ] [[package]] name = "wasmtime-runtime" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f907beaff69d4d920fa4688411ee4cc75c0f01859e424677f9e426e2ef749864" +checksum = "b7eb6ffa169eb5dcd18ac9473c817358cd57bc62c244622210566d473397954a" dependencies = [ "anyhow", "backtrace", @@ -1913,21 +1976,21 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514ef0e5fd197b9609dc9eb74beba0c84d5a12b2417cbae55534633329ba4852" +checksum = "8d932b0ac5336f7308d869703dd225610a6a3aeaa8e968c52b43eed96cefb1c2" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.83.0", + "wasmparser 0.85.0", ] [[package]] name = "wasmtime-wasi" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0633261ad13d93ae84c758ce195c659a0ee57fcdbe724c8976f4b1872cdcde" +checksum = "b68b7d77fb6f2975a6fe6cc4d0015d6b0cebb65c39fce1dd4cc00880dbf7789c" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -1947,20 +2010,23 @@ dependencies = [ [[package]] name = "wast" -version = "38.0.0" +version = "50.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ebc29df4629f497e0893aacd40f13a4a56b85ef6eb4ab6d603f07244f1a7bf2" +checksum = "a2cbb59d4ac799842791fe7e806fa5dbbf6b5554d538e51cc8e176db6ff0ae34" dependencies = [ "leb128", + "memchr", + "unicode-width", + "wasm-encoder 0.20.0", ] [[package]] name = "wat" -version = "1.0.40" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +checksum = "584aaf7a1ecf4d383bbe1a25eeab0cbb8ff96acc6796707ff65cde48f4632f15" dependencies = [ - "wast 38.0.0", + "wast 50.0.0", ] [[package]] @@ -1975,9 +2041,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36fb71c833bf174b1b34979942ff33f525b97311232ef6a0a18bcdf540ae9c91" +checksum = "67dadac11343d2aabc8a906a0db0aaf7cb5046ec3d6fffccdaf2847dccdef8d6" dependencies = [ "anyhow", "async-trait", @@ -1990,12 +2056,12 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d684c4454e953df20b5a1c3e0a8d208ef4d5a768e013f64bebfc9f74a3f739" +checksum = "63a1dccd6b3fbd9a27417f5d30ce9aa3ee9cf529aad453abbf88a49c5d605b79" dependencies = [ "anyhow", - "heck", + "heck 0.4.0", "proc-macro2", "quote", "shellexpand", @@ -2005,9 +2071,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1da6c96c93eced4bf71e59ca1f06f933b84f37544a354646e37c0e5c6d5a262d" +checksum = "f1c368d57d9560c34deaa67e06b0953ccf65edb906c525e5a2c866c849b48ec2" dependencies = [ "proc-macro2", "quote", @@ -2113,18 +2179,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.10.0+zstd.1.5.2" +version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1365becbe415f3f0fcd024e2f7b45bacfb5bdd055f0dc113571394114e7bdd" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "4.1.4+zstd.1.5.2" +version = "5.0.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7cd17c9af1a4d6c24beb1cc54b17e2ef7b593dc92f19e9d9acad8b182bbaee" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" dependencies = [ "libc", "zstd-sys", @@ -2132,9 +2198,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" +version = "2.0.4+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" +checksum = "4fa202f2ef00074143e219d15b62ffc317d17cc33909feac471c044087cad7b0" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 3b77abd..a330400 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,11 +33,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.35.3" +wasi-cap-std-sync = "0.38.0" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.35.3" -wasmtime-wasi = "0.35.3" +wasmtime = "0.38.0" +wasmtime-wasi = "0.38.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 4f8b36a..a6d280c 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.35.3" +wasmtime = "0.38.0" [dependencies.wizer] path = ".." diff --git a/fuzz/fuzz_targets/same_result.rs b/fuzz/fuzz_targets/same_result.rs index f943136..874c018 100644 --- a/fuzz/fuzz_targets/same_result.rs +++ b/fuzz/fuzz_targets/same_result.rs @@ -38,7 +38,6 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { let mut config = Config::new(); config.cache_config_load_default().unwrap(); - config.wasm_module_linking(true); config.wasm_multi_memory(true); config.wasm_multi_value(true); @@ -162,10 +161,7 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { panic!("divergence between snapshot and non-snapshot memories"); } } - Extern::Instance(_) - | Extern::Func(_) - | Extern::Table(_) - | Extern::Module(_) => continue, + Extern::SharedMemory(_) | Extern::Func(_) | Extern::Table(_) => continue, } } } diff --git a/src/dummy.rs b/src/dummy.rs index 0ccc1c7..0a6500a 100644 --- a/src/dummy.rs +++ b/src/dummy.rs @@ -3,7 +3,6 @@ //! Forked from `wasmtime/crates/fuzzing/src/oracles/dummy.rs`. use anyhow::Result; -use std::fmt::Write; use wasmtime::*; /// Create dummy imports for instantiating the module. @@ -15,60 +14,23 @@ pub fn dummy_imports( log::debug!("Creating dummy imports"); for imp in module.imports() { - match imp.name() { - Some(name) => { - if linker.get(&mut *store, imp.module(), Some(name)).is_some() { - // Already defined, must be part of WASI. - continue; - } - - linker - .define( - imp.module(), - name, - dummy_extern( - &mut *store, - imp.ty(), - &format!("'{}' '{}'", imp.module(), name), - )?, - ) - .unwrap(); - } - None => match imp.ty() { - wasmtime::ExternType::Instance(ty) => { - for ty in ty.exports() { - if linker - .get(&mut *store, imp.module(), Some(ty.name())) - .is_some() - { - // Already defined, must be part of WASI. - continue; - } - - linker - .define( - imp.module(), - ty.name(), - dummy_extern(&mut *store, ty.ty(), &format!("'{}'", imp.module()))?, - ) - .unwrap(); - } - } - other => { - if linker.get(&mut *store, imp.module(), None).is_some() { - // Already defined, must be part of WASI. - continue; - } - - linker - .define_name( - imp.module(), - dummy_extern(&mut *store, other, &format!("'{}'", imp.module()))?, - ) - .unwrap(); - } - }, + let name = imp.name(); + if linker.get(&mut *store, imp.module(), name).is_some() { + // Already defined, must be part of WASI. + continue; } + + linker + .define( + imp.module(), + name, + dummy_extern( + &mut *store, + imp.ty(), + &format!("'{}' '{}'", imp.module(), name), + )?, + ) + .unwrap(); } Ok(()) @@ -78,9 +40,6 @@ pub fn dummy_imports( pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Result { Ok(match ty { ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty, name)), - ExternType::Instance(instance_ty) => { - Extern::Instance(dummy_instance(store, instance_ty, name)?) - } ExternType::Global(_) => { anyhow::bail!("Error: attempted to import unknown global: {}", name) } @@ -88,9 +47,6 @@ pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Res ExternType::Memory(_) => { anyhow::bail!("Error: attempted to import unknown memory: {}", name) } - ExternType::Module(_) => { - anyhow::bail!("Error: attempted to import unknown module: {}", name) - } }) } @@ -126,234 +82,3 @@ pub fn dummy_value(val_ty: ValType) -> Val { pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { val_tys.into_iter().map(dummy_value).collect() } - -/// Construct a dummy instance for the given instance type. -/// -/// This is done by using the expected type to generate a module on-the-fly -/// which we the instantiate. -pub fn dummy_instance(store: &mut crate::Store, ty: InstanceType, name: &str) -> Result { - let mut wat = WatGenerator::new(); - for ty in ty.exports() { - wat.export(&ty, name)?; - } - let module = Module::new(store.engine(), &wat.finish()).unwrap(); - Ok(Instance::new(store, &module, &[])?) -} - -struct WatGenerator { - tmp: usize, - dst: String, -} - -impl WatGenerator { - fn new() -> WatGenerator { - WatGenerator { - tmp: 0, - dst: String::from("(module\n"), - } - } - - fn finish(mut self) -> String { - self.dst.push_str(")\n"); - self.dst - } - - fn export(&mut self, ty: &ExportType<'_>, instance_name: &str) -> Result<()> { - let wat_name = format!("item{}", self.tmp); - self.tmp += 1; - let item_ty = ty.ty(); - self.item(&wat_name, &item_ty, instance_name, ty.name())?; - - write!(self.dst, "(export ").unwrap(); - self.str(ty.name()); - write!(self.dst, " (").unwrap(); - match item_ty { - ExternType::Func(_) => write!(self.dst, "func").unwrap(), - ExternType::Instance(_) => write!(self.dst, "instance").unwrap(), - ExternType::Memory(_) => anyhow::bail!( - "Error: attempted to import unknown memory: '{}' '{}'", - instance_name, - ty.name() - ), - ExternType::Global(_) => anyhow::bail!( - "Error: attempted to import unknown global: '{}' '{}'", - instance_name, - ty.name() - ), - ExternType::Table(_) => anyhow::bail!( - "Error: attempted to import unknown table: '{}' '{}'", - instance_name, - ty.name() - ), - ExternType::Module(_) => anyhow::bail!( - "Error: attempted to import unknown module: '{}' '{}'", - instance_name, - ty.name() - ), - } - writeln!(self.dst, " ${}))", wat_name).unwrap(); - Ok(()) - } - - fn item( - &mut self, - name: &str, - ty: &ExternType, - instance_name: &str, - item_name: &str, - ) -> Result<()> { - match ty { - ExternType::Func(ty) => { - write!(self.dst, "(func ${} ", name).unwrap(); - self.func_sig(ty); - for ty in ty.results() { - writeln!(self.dst, "").unwrap(); - self.value(&ty); - } - writeln!(self.dst, ")").unwrap(); - } - ExternType::Instance(ty) => { - writeln!(self.dst, "(module ${}_module", name).unwrap(); - for ty in ty.exports() { - self.export(&ty, instance_name)?; - } - self.dst.push_str(")\n"); - writeln!(self.dst, "(instance ${} (instantiate ${0}_module))", name).unwrap(); - } - ExternType::Memory(_) => anyhow::bail!( - "Error: attempted to import unknown memory: '{}' '{}'", - instance_name, - item_name - ), - ExternType::Global(_) => anyhow::bail!( - "Error: attempted to import unknown global: '{}' '{}'", - instance_name, - item_name - ), - ExternType::Table(_) => anyhow::bail!( - "Error: attempted to import unknown table: '{}' '{}'", - instance_name, - item_name - ), - ExternType::Module(_) => anyhow::bail!( - "Error: attempted to import unknown module: '{}' '{}'", - instance_name, - item_name - ), - } - Ok(()) - } - - fn func_sig(&mut self, ty: &FuncType) { - write!(self.dst, "(param ").unwrap(); - for ty in ty.params() { - write!(self.dst, "{} ", wat_ty(&ty)).unwrap(); - } - write!(self.dst, ") (result ").unwrap(); - for ty in ty.results() { - write!(self.dst, "{} ", wat_ty(&ty)).unwrap(); - } - write!(self.dst, ")").unwrap(); - } - - fn value(&mut self, ty: &ValType) { - match ty { - ValType::I32 => write!(self.dst, "i32.const 0").unwrap(), - ValType::I64 => write!(self.dst, "i64.const 0").unwrap(), - ValType::F32 => write!(self.dst, "f32.const 0").unwrap(), - ValType::F64 => write!(self.dst, "f64.const 0").unwrap(), - ValType::V128 => write!(self.dst, "v128.const i32x4 0 0 0 0").unwrap(), - ValType::ExternRef => write!(self.dst, "ref.null extern").unwrap(), - ValType::FuncRef => write!(self.dst, "ref.null func").unwrap(), - } - } - - fn str(&mut self, name: &str) { - let mut bytes = [0; 4]; - self.dst.push_str("\""); - for c in name.chars() { - let v = c as u32; - if v >= 0x20 && v < 0x7f && c != '"' && c != '\\' && v < 0xff { - self.dst.push(c); - } else { - for byte in c.encode_utf8(&mut bytes).as_bytes() { - self.hex_byte(*byte); - } - } - } - self.dst.push_str("\""); - } - - fn hex_byte(&mut self, byte: u8) { - fn to_hex(b: u8) -> char { - if b < 10 { - (b'0' + b) as char - } else { - (b'a' + b - 10) as char - } - } - self.dst.push('\\'); - self.dst.push(to_hex((byte >> 4) & 0xf)); - self.dst.push(to_hex(byte & 0xf)); - } -} - -fn wat_ty(ty: &ValType) -> &'static str { - match ty { - ValType::I32 => "i32", - ValType::I64 => "i64", - ValType::F32 => "f32", - ValType::F64 => "f64", - ValType::V128 => "v128", - ValType::ExternRef => "externref", - ValType::FuncRef => "funcref", - } -} - -#[cfg(test)] -mod tests { - use super::*; - use std::collections::HashSet; - - fn store() -> crate::Store { - let mut config = Config::default(); - config.wasm_module_linking(true); - config.wasm_multi_memory(true); - let engine = wasmtime::Engine::new(&config).unwrap(); - Store::new(&engine, None) - } - - #[test] - fn dummy_function_import() { - let mut store = store(); - let func_ty = FuncType::new(vec![ValType::I32], vec![ValType::I64]); - let func = dummy_func(&mut store, func_ty.clone(), "f"); - assert_eq!(func.ty(&store), func_ty); - } - - #[test] - fn dummy_instance_import() { - let mut store = store(); - - let mut instance_ty = InstanceType::new(); - - // Functions. - instance_ty.add_named_export("func0", FuncType::new(vec![ValType::I32], vec![]).into()); - instance_ty.add_named_export("func1", FuncType::new(vec![], vec![ValType::I64]).into()); - - // Instances. - instance_ty.add_named_export("instance0", InstanceType::new().into()); - instance_ty.add_named_export("instance1", InstanceType::new().into()); - - let instance = dummy_instance(&mut store, instance_ty.clone(), "instance").unwrap(); - - let mut expected_exports = vec!["func0", "func1", "instance0", "instance1"] - .into_iter() - .collect::>(); - for exp in instance.ty(&store).exports() { - let was_expected = expected_exports.remove(exp.name()); - assert!(was_expected); - } - assert!(expected_exports.is_empty()); - } -} diff --git a/src/lib.rs b/src/lib.rs index c629f33..b2bbe74 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -525,10 +525,6 @@ impl Wizer { // Proposals we support. config.wasm_multi_memory(self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY)); config.wasm_multi_value(self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE)); - config.wasm_module_linking( - self.wasm_module_linking - .unwrap_or(DEFAULT_WASM_MODULE_LINKING), - ); // Note that we only support `memory.copy`, `memory.fill`, and // `memory.init` for the time being: config.wasm_bulk_memory(self.wasm_bulk_memory.unwrap_or(DEFAULT_WASM_BULK_MEMORY)); diff --git a/src/snapshot.rs b/src/snapshot.rs index d2bc3b0..7459c96 100644 --- a/src/snapshot.rs +++ b/src/snapshot.rs @@ -277,14 +277,11 @@ fn snapshot_instantiations( instance: &wasmtime::Instance, ) -> Vec { log::debug!("Snapshotting nested instantiations"); - let mut instantiations = vec![]; + let instantiations = vec![]; loop { let name = format!("__wizer_instance_{}", instantiations.len()); match instance.get_export(&mut *ctx, &name) { None => break, - Some(wasmtime::Extern::Instance(instance)) => { - instantiations.push(snapshot(&mut *ctx, &instance)); - } Some(_) => unreachable!(), } } diff --git a/tests/make_linker.rs b/tests/make_linker.rs index 6cb44c8..ebde070 100644 --- a/tests/make_linker.rs +++ b/tests/make_linker.rs @@ -33,7 +33,6 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.cache_config_load_default().unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); - config.wasm_module_linking(true); let engine = wasmtime::Engine::new(&config)?; let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); diff --git a/tests/tests.rs b/tests/tests.rs index 86dc97a..6cde84a 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -35,7 +35,6 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.cache_config_load_default().unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); - config.wasm_module_linking(true); let engine = wasmtime::Engine::new(&config)?; let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); @@ -51,8 +50,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { .define_name("dummy_func", wasmtime::Func::wrap(&mut store, || {}))? .define("env", "f", wasmtime::Func::wrap(&mut store, || {}))? .define_name("f", wasmtime::Func::wrap(&mut store, || {}))? - .define("x", "f", wasmtime::Func::wrap(&mut store, || {}))? - .define_name("dummy_instance", dummy_instance)?; + .define("x", "f", wasmtime::Func::wrap(&mut store, || {}))?; wasmtime_wasi::add_to_linker(&mut linker, |wasi| wasi)?; @@ -137,32 +135,6 @@ fn basic_memory() -> Result<()> { ) } -#[test] -fn multi_memory() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (memory $m1 1) - (memory $m2 1) - (func (export "wizer.initialize") - i32.const 0 - i32.const 41 - i32.store (memory $m1) offset=1337 - i32.const 0 - i32.const 1 - i32.store (memory $m2) offset=1337) - (func (export "run") (result i32) - i32.const 0 - i32.load (memory $m1) offset=1337 - i32.const 0 - i32.load (memory $m2) offset=1337 - i32.add)) -"#, - ) -} - #[test] fn reject_imported_memory() -> Result<()> { fails_wizening( @@ -347,505 +319,6 @@ fn reject_data_drop() -> Result<()> { Ok(()) } -#[test] -fn accept_module_linking_import_memory() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (memory (export "memory") 1)) - (instance $a (instantiate $A)) - - (module $B - (import "x" (instance $x (export "memory" (memory 1))))) - (instance $b (instantiate $B (import "x" (instance $a)))) - - (func (export "wizer.initialize") - nop) - - (func (export "run") (result i32) - i32.const 42) -) -"#, - ) -} - -#[test] -fn accept_module_linking_import_global() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (global (export "global") i32 (i32.const 1337))) - (instance $a (instantiate $A)) - - (module $B - (import "x" (instance $x (export "global" (global i32))))) - (instance $b (instantiate $B (import "x" (instance $a)))) - - (func (export "wizer.initialize") - nop) - - (func (export "run") (result i32) - i32.const 42) -) -"#, - ) -} - -#[test] -fn accept_module_linking_import_table() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (table (export "table") 0 funcref)) - (instance $a (instantiate $A)) - - (module $B - (import "x" (instance $x (export "table" (table 0 funcref))))) - (instance $b (instantiate $B (import "x" (instance $a)))) - - (func (export "wizer.initialize") - nop) - - (func (export "run") (result i32) - i32.const 42) -) -"#, - ) -} - -#[test] -fn module_linking_actually_works() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $memory-module - (memory (export "memory") 1)) - (instance $memory-instance (instantiate $memory-module)) - - (module $use-memory - (import "x" (instance $m (export "memory" (memory 1)))) - (func (export "init") - i32.const 0 - i32.const 42 - i32.store (memory $m "memory") offset=1337)) - (instance $use-memory-instance - (instantiate $use-memory - (import "x" (instance $memory-instance)))) - - (func (export "wizer.initialize") - (call (func $use-memory-instance "init"))) - - (func (export "run") (result i32) - i32.const 0 - i32.load (memory $memory-instance "memory") offset=1337) -) -"#, - ) -} - -#[test] -fn module_linking_nested_instantiations_1() -> Result<()> { - run_wat( - &[], - 8, - r#" -(module - (module $A - (import "global" (global (mut i32))) - - (module $B - (import "global" (global (mut i32))) - - (module $C - (import "global" (global (mut i32))) - - (func (export "f") - i32.const 1 - global.get 0 - i32.add - global.set 0 - ) - ) - - (instance $c1 (instantiate $C (import "global" (global 0)))) - (instance $c2 (instantiate $C (import "global" (global 0)))) - - (func (export "f") - call (func $c1 "f") - call (func $c2 "f") - ) - ) - - (instance $b1 (instantiate $B (import "global" (global 0)))) - (instance $b2 (instantiate $B (import "global" (global 0)))) - - (func (export "f") - call (func $b1 "f") - call (func $b2 "f") - ) - ) - - (module $DefinesGlobal - (global (export "global") (mut i32) (i32.const 0))) - (instance $global_instance (instantiate $DefinesGlobal)) - - (instance $a1 (instantiate $A (import "global" (global $global_instance "global")))) - (instance $a2 (instantiate $A (import "global" (global $global_instance "global")))) - - (func (export "wizer.initialize") - call (func $a1 "f") - call (func $a2 "f")) - - (func (export "run") (result i32) - global.get (global $global_instance "global")) -) -"#, - ) -} - -#[test] -fn module_linking_nested_instantiations_0() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (import "global" (global (mut i32))) - - (module $B - (import "global" (global (mut i32))) - - (func (export "f") - i32.const 42 - global.set 0 - ) - ) - - (instance $b (instantiate $B (import "global" (global 0)))) - - (func (export "f") - call (func $b "f") - ) - ) - - (module $G - (global (export "global") (mut i32) (i32.const 0))) - - (instance $g (instantiate $G)) - - (instance $a (instantiate $A (import "global" (global $g "global")))) - - (func (export "wizer.initialize") - call (func $a "f") - ) - - (func (export "run") (result i32) - global.get (global $g "global") - ) -) -"#, - ) -} - -// Test that we handle repeated and interleaved initial sections. -#[test] -fn multiple_initial_sections() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - ;; Module section. - (module $A - (memory (export "memory") 1) - ) - - ;; Instance section. - (instance $a (instantiate $A)) - - ;; Alias section. - (alias $a "memory" (memory $memory)) - - ;; Module section. - (module $B - (import "memory" (memory 1)) - (func (export "init") - i32.const 0 - i32.const 42 - i32.store offset=1337 - ) - ) - - ;; Instance section. - (instance $b (instantiate $B (import "memory" (memory $memory)))) - - ;; Alias section. - (alias $b "init" (func $b-init)) - - ;; Module section. - (module $C - (import "memory" (memory 1)) - (func (export "run") (result i32) - i32.const 0 - i32.load offset=1337 - ) - ) - - ;; Instance section. - (instance $c (instantiate $C (import "memory" (memory $memory)))) - - ;; Alias section. - (alias $c "run" (func $c-run)) - - ;; Done with initial sections. - - (func (export "wizer.initialize") - call $b-init - ) - - (func (export "run") (result i32) - call $c-run - ) -) -"#, - ) -} - -#[test] -fn start_sections_in_nested_modules() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (import "global" (global $g (mut i32))) - (func $init - i32.const 41 - global.set $g) - (start $init) - ) - - (module $B - (global (export "global") (mut i32) (i32.const 0)) - ) - - (instance $b (instantiate $B)) - (alias $b "global" (global $g)) - (instance $a (instantiate $A (import "global" (global $g)))) - - (func (export "wizer.initialize") - global.get $g - i32.const 1 - i32.add - global.set $g - ) - (func (export "run") (result i32) - global.get $g - ) -) -"#, - ) -} - -#[test] -fn allow_function_imports_module_linking() -> Result<()> { - // Make sure that the umbrella module passes imports through to its - // instantiation of the root, and that the root can pass them along to its - // nested instantiations as well. - run_wat( - &[], - 42, - r#" -(module - (import "dummy_func" (func $dummy)) - (module $A - (import "dummy_func" (func))) - (instance (instantiate $A (import "dummy_func" (func $dummy)))) - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - i32.const 42 - ) -) -"#, - ) -} - -#[test] -fn outer_module_alias() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (global (export "g") (mut i32) (i32.const 0)) - ) - - (module $B - (alias outer 0 0 (module $A)) - (instance $a (instantiate $A)) - (func (export "init") - i32.const 42 - global.set (global $a "g") - ) - (func (export "run") (result i32) - global.get (global $a "g") - ) - ) - (instance $b (instantiate $B)) - - (func (export "wizer.initialize") - call (func $b "init") - ) - (func (export "run") (result i32) - call (func $b "run") - ) -) -"#, - ) -} - -#[test] -fn instance_alias_without_entry_in_type_section() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $CHILD - (module $a) - (instance $a (instantiate $a)) - (export "a" (instance $a))) - (instance $child (instantiate $CHILD)) - - ;; This root module doesn't ever declare an instance type for this alias. - (alias $child "a" (instance $no_type_for_this_instance)) - - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - i32.const 42 - ) -) -"#, - ) -} - -#[test] -fn two_level_imports_and_implicit_instance_imports() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - ;; First, import an instance to make sure that we are accounting for already - ;; imported instances when forwarding implicit instances and are getting the - ;; index space correct. - (import "dummy_instance" (instance)) - - ;; This implicitly creates an instance import like: - ;; - ;; (import (env (instance (export "f" (func $f))))) - ;; - ;; We will have to forward this implicit instance from the umbrella to the - ;; root instantiation. - (import "env" "f" (func $f)) - - (module $A - (import "env" "f" (func))) - - ;; Pass that implicit instance through when instantiating `$A`. - (instance $a (instantiate $A (import "env" (instance 1)))) - - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - i32.const 42 - ) -) -"#, - ) -} - -#[test] -fn implicit_instance_imports_and_other_instances() -> Result<()> { - // Test how implicit instance import injection interacts with explicit - // instance imports and explicit instantiations. - run_wat( - &[], - 42, - r#" -(module - (module $A - ;; This implicitly creates an instance import like: - ;; - ;; (import (env (instance (export "f" (func $f (result i32)))))) - (import "env" "f" (func $f (result i32))) - - (import "env2" (instance $env2 (export "g" (func (result i32))))) - - (module $B - (func (export "h") (result i32) - i32.const 1 - ) - ) - (instance $b (instantiate $B)) - - (func (export "run") (result i32) - call $f - call (func $env2 "g") - call (func $b "h") - i32.add - i32.add - ) - ) - - (module $Env - (func (export "f") (result i32) - i32.const 2 - ) - ) - (instance $env (instantiate $Env)) - - (module $Env2 - (func (export "g") (result i32) - i32.const 39 - ) - ) - (instance $env2 (instantiate $Env2)) - - (instance $a (instantiate $A - (import "env" (instance $env)) - (import "env2" (instance $env2)))) - - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - call (func $a "run") - ) -) -"#, - ) -} - #[test] fn rust_regex() -> Result<()> { run_wasm( @@ -965,54 +438,6 @@ fn rename_functions() -> Result<()> { Ok(()) } -#[test] -fn renames_and_module_linking() -> Result<()> { - let wat = r#" -(module - (module $A - (func (export "a") (result i32) - i32.const 1) - (func (export "b") (result i32) - i32.const 2) - (func (export "c") (result i32) - i32.const 3) - ) - (instance $a (instantiate $A)) - (func (export "wizer.initialize") - nop - ) - (func (export "a") (result i32) - call (func $a "a") - ) - (func (export "b") (result i32) - call (func $a "b") - ) - (func (export "c") (result i32) - call (func $a "c") - ) -) - "#; - - let wasm = wat_to_wasm(wat)?; - let mut wizer = Wizer::new(); - wizer.wasm_module_linking(true); - wizer.allow_wasi(true).unwrap(); - wizer.func_rename("a", "b"); - wizer.func_rename("b", "c"); - let wasm = wizer.run(&wasm)?; - let wat = wasmprinter::print_bytes(&wasm)?; - - let expected_wat = r#" - (alias 1 "b" (func (;0;))) - (alias 1 "c" (func (;1;))) - (export "a" (func 0)) - (export "b" (func 1))) - "#; - - assert!(wat.trim().ends_with(expected_wat.trim())); - Ok(()) -} - #[test] fn wasi_reactor() -> anyhow::Result<()> { run_wat( @@ -1069,74 +494,6 @@ fn allow_undefined_import_function() -> Result<()> { ) } -#[test] -fn call_undefined_instance_import_function_during_init() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "f" (func)))) - (alias 0 "f" (func $import)) - (func (export "wizer.initialize") - (call $import) - ) - ) - "#, - ) -} - -#[test] -fn allow_undefined_instance_import_function() -> Result<()> { - run_wat( - &[], - 42, - r#" - (module - (import "x" (instance (export "f" (func)))) - (func (export "wizer.initialize")) - (func (export "run") (result i32) - i32.const 42 - ) - ) - "#, - ) -} - -#[test] -fn reject_import_instance_global() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "g" (global i32)))) - (func (export "wizer.initialize")) - ) - "#, - ) -} - -#[test] -fn reject_import_instance_table() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "t" (table 0 externref)))) - (func (export "wizer.initialize")) - ) - "#, - ) -} - -#[test] -fn reject_import_instance_memory() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "m" (memory 0)))) - (func (export "wizer.initialize")) - ) - "#, - ) -} - #[test] fn accept_bulk_memory_copy() -> Result<()> { run_wat(