diff --git a/Cargo.lock b/Cargo.lock index 2c01b53179..cc9a9b75e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arbitrary" @@ -147,9 +147,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "base64" @@ -208,9 +208,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cap-fs-ext" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb23061fc1c4ead4e45ca713080fe768e6234e959f5a5c399c39eb41aa34e56e" +checksum = "712695628f77a28acd7c9135b9f05f9c1563f8eb91b317f63876bac550032403" dependencies = [ "cap-primitives", "cap-std", @@ -220,9 +220,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d00bd8d26c4270d950eaaa837387964a2089a1c3c349a690a1fa03221d29531" +checksum = "ff5bcbaf57897c8f14098cc9ad48a78052930a9948119eea01b80ca224070fa6" dependencies = [ "ambient-authority", "fs-set-times", @@ -237,9 +237,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb16a619d8b8211ed61f42bd290d2a1ac71277a69cf8417ec0996fa92f5211" +checksum = "e7c780812948b31f362c3bab82d23b902529c26705d0e094888bc7fdb9656908" dependencies = [ "ambient-authority", "rand", @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19eb8e3d71996828751c1ed3908a439639752ac6bdc874e41469ef7fc15fbd7f" +checksum = "e6cf1a22e6eab501e025a9953532b1e95efb8a18d6364bf8a4a7547b30c49186" dependencies = [ "cap-primitives", "io-extras", @@ -259,9 +259,9 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61142dc51e25b7acc970ca578ce2c3695eac22bbba46c1073f5f583e78957725" +checksum = "1e1547a95cd071db92382c649260bcc6721879ef5d1f0f442af33bff75003dd7" dependencies = [ "ambient-authority", "cap-primitives", @@ -279,9 +279,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.13" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ "jobserver", "libc", @@ -323,9 +323,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -333,9 +333,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -345,9 +345,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -381,18 +381,18 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpp_demangle" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" +checksum = "96e58d342ad113c2b878f16d5d034c03be492ae460cdbc02b7f0f2284d310c7d" dependencies = [ "cfg-if", ] [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -503,7 +503,7 @@ dependencies = [ "itertools 0.12.1", "log", "smallvec", - "wasmparser", + "wasmparser 0.207.0", "wasmtime-types", ] @@ -839,6 +839,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.4.1" @@ -871,9 +877,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -900,12 +906,12 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "indexmap" -version = "2.4.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", "serde", ] @@ -933,9 +939,9 @@ checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c" [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -1030,9 +1036,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libm" @@ -1139,9 +1145,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -1163,15 +1169,15 @@ checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "postcard" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ee10b999a00ca189ac2cb99f5db1ca71fb7371e3d5f493b879ca95d2a67220" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" dependencies = [ "cobs", "embedded-io 0.4.0", @@ -1217,27 +1223,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] [[package]] name = "psm" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" dependencies = [ "cc", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1318,9 +1324,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -1330,9 +1336,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -1341,9 +1347,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-demangle" @@ -1368,9 +1374,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags", "errno", @@ -1404,18 +1410,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1424,9 +1430,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1436,9 +1442,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -1521,9 +1527,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.75" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1560,18 +1566,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -1611,9 +1617,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -1661,21 +1667,21 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "utf8parse" @@ -1820,20 +1826,21 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.215.0" +version = "0.218.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847" +checksum = "22b896fa8ceb71091ace9bcb81e853f54043183a1c9667cf93422c40252ffa0a" dependencies = [ "leb128", ] [[package]] name = "wasm-encoder" -version = "0.218.0" +version = "0.219.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22b896fa8ceb71091ace9bcb81e853f54043183a1c9667cf93422c40252ffa0a" +checksum = "e2b1b95711b3ad655656a341e301cc64e33cbee94de9a99a1c5a2ab88efab79d" dependencies = [ "leb128", + "wasmparser 0.219.0", ] [[package]] @@ -1877,7 +1884,7 @@ dependencies = [ "wasmi_collections", "wasmi_core 0.38.0", "wasmi_ir", - "wasmparser-nostd", + "wasmparser 0.219.0", "wast 70.0.2", "wat", ] @@ -1997,6 +2004,19 @@ dependencies = [ "semver", ] +[[package]] +name = "wasmparser" +version = "0.219.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "324b4e56d24439495b88cd81439dad5e97f3c7b1eedc3c7e10455ed1e045e9a2" +dependencies = [ + "ahash", + "bitflags", + "hashbrown 0.14.5", + "indexmap", + "semver", +] + [[package]] name = "wasmparser-nostd" version = "0.100.2" @@ -2013,7 +2033,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c2d8a7b4dabb460208e6b4334d9db5766e84505038b2529e69c3d07ac619115" dependencies = [ "anyhow", - "wasmparser", + "wasmparser 0.207.0", ] [[package]] @@ -2055,7 +2075,7 @@ dependencies = [ "sptr", "target-lexicon", "wasm-encoder 0.207.0", - "wasmparser", + "wasmparser 0.207.0", "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", @@ -2141,7 +2161,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser", + "wasmparser 0.207.0", "wasmtime-environ", "wasmtime-versioned-export-macros", ] @@ -2165,7 +2185,7 @@ dependencies = [ "serde_derive", "target-lexicon", "wasm-encoder 0.207.0", - "wasmparser", + "wasmparser 0.207.0", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2226,7 +2246,7 @@ dependencies = [ "serde", "serde_derive", "smallvec", - "wasmparser", + "wasmparser 0.207.0", ] [[package]] @@ -2251,7 +2271,7 @@ dependencies = [ "gimli", "object", "target-lexicon", - "wasmparser", + "wasmparser 0.207.0", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -2293,24 +2313,24 @@ dependencies = [ [[package]] name = "wast" -version = "215.0.0" +version = "219.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff1d00d893593249e60720be04a7c1f42f1c4dc3806a2869f4e66ab61eb54cb" +checksum = "06880ecb25662bc21db6a83f4fcc27c41f71fbcba4f1980b650c88ada92728e1" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.215.0", + "wasm-encoder 0.219.0", ] [[package]] name = "wat" -version = "1.215.0" +version = "1.219.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670bf4d9c8cf76ae242d70ded47c546525b6dafaa6871f9bcb065344bf2b4e3d" +checksum = "11e56dbf9fc89111b0d97c91e683d7895b1a6e5633a729f2ccad2303724005b6" dependencies = [ - "wast 215.0.0", + "wast 219.0.0", ] [[package]] @@ -2397,7 +2417,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser", + "wasmparser 0.207.0", "wasmtime-cranelift", "wasmtime-environ", ] @@ -2495,9 +2515,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -2527,7 +2547,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser", + "wasmparser 0.207.0", ] [[package]] diff --git a/crates/wasmi/Cargo.toml b/crates/wasmi/Cargo.toml index 1a0a97035d..b61a0c4c9b 100644 --- a/crates/wasmi/Cargo.toml +++ b/crates/wasmi/Cargo.toml @@ -19,7 +19,7 @@ exclude = [ ] [dependencies] -wasmparser = { version = "0.100.2", package = "wasmparser-nostd", default-features = false } +wasmparser = { version = "0.219.0", default-features = false, features = ["validate", "features"] } wasmi_core = { workspace = true } wasmi_collections = { workspace = true } wasmi_ir = { workspace = true } @@ -55,7 +55,10 @@ std = [ # malious actors that control their inputs. # # An example of such an environment is `wasm32-unknown-unknown`. -no-hash-maps = ["wasmi_collections/no-hash-maps"] +no-hash-maps = [ + "wasmi_collections/no-hash-maps", + "wasmparser/no-hash-maps", +] # Enables extra checks performed during Wasmi bytecode execution. # diff --git a/crates/wasmi/src/engine/config.rs b/crates/wasmi/src/engine/config.rs index 61a63b3f5f..aba5bd7df4 100644 --- a/crates/wasmi/src/engine/config.rs +++ b/crates/wasmi/src/engine/config.rs @@ -15,26 +15,8 @@ pub struct Config { stack_limits: StackLimits, /// The amount of Wasm stacks to keep in cache at most. cached_stacks: usize, - /// Is `true` if the `mutable-global` Wasm proposal is enabled. - mutable_global: bool, - /// Is `true` if the `sign-extension` Wasm proposal is enabled. - sign_extension: bool, - /// Is `true` if the `saturating-float-to-int` Wasm proposal is enabled. - saturating_float_to_int: bool, - /// Is `true` if the [`multi-value`] Wasm proposal is enabled. - multi_value: bool, - /// Is `true` if the [`multi-memory`] Wasm proposal is enabled. - multi_memory: bool, - /// Is `true` if the [`bulk-memory`] Wasm proposal is enabled. - bulk_memory: bool, - /// Is `true` if the [`reference-types`] Wasm proposal is enabled. - reference_types: bool, - /// Is `true` if the [`tail-call`] Wasm proposal is enabled. - tail_call: bool, - /// Is `true` if the [`extended-const`] Wasm proposal is enabled. - extended_const: bool, - /// Is `true` if Wasm instructions on `f32` and `f64` types are allowed. - floats: bool, + /// The Wasm features used when validating or translating functions. + features: WasmFeatures, /// Is `true` if Wasmi executions shall consume fuel. consume_fuel: bool, /// Is `true` if Wasmi shall ignore Wasm custom sections when parsing Wasm modules. @@ -174,16 +156,7 @@ impl Default for Config { Self { stack_limits: StackLimits::default(), cached_stacks: DEFAULT_CACHED_STACKS, - mutable_global: true, - sign_extension: true, - saturating_float_to_int: true, - multi_value: true, - multi_memory: true, - bulk_memory: true, - reference_types: true, - tail_call: true, - extended_const: true, - floats: true, + features: Self::default_features(), consume_fuel: false, ignore_custom_sections: false, fuel_costs: FuelCosts::default(), @@ -194,6 +167,23 @@ impl Default for Config { } impl Config { + /// Returns the default [`WasmFeatures`]. + fn default_features() -> WasmFeatures { + let mut features = WasmFeatures::empty(); + features.set(WasmFeatures::MUTABLE_GLOBAL, true); + features.set(WasmFeatures::MULTI_VALUE, true); + features.set(WasmFeatures::MULTI_MEMORY, true); + features.set(WasmFeatures::SATURATING_FLOAT_TO_INT, true); + features.set(WasmFeatures::SIGN_EXTENSION, true); + features.set(WasmFeatures::BULK_MEMORY, true); + features.set(WasmFeatures::REFERENCE_TYPES, true); + features.set(WasmFeatures::GC_TYPES, true); // required by reference-types + features.set(WasmFeatures::TAIL_CALL, true); + features.set(WasmFeatures::EXTENDED_CONST, true); + features.set(WasmFeatures::FLOATS, true); + features + } + /// Sets the [`StackLimits`] for the [`Config`]. pub fn set_stack_limits(&mut self, stack_limits: StackLimits) -> &mut Self { self.stack_limits = stack_limits; @@ -228,7 +218,7 @@ impl Config { /// /// [`mutable-global`]: https://github.com/WebAssembly/mutable-global pub fn wasm_mutable_global(&mut self, enable: bool) -> &mut Self { - self.mutable_global = enable; + self.features.set(WasmFeatures::MUTABLE_GLOBAL, enable); self } @@ -240,7 +230,7 @@ impl Config { /// /// [`sign-extension`]: https://github.com/WebAssembly/sign-extension-ops pub fn wasm_sign_extension(&mut self, enable: bool) -> &mut Self { - self.sign_extension = enable; + self.features.set(WasmFeatures::SIGN_EXTENSION, enable); self } @@ -253,7 +243,8 @@ impl Config { /// [`saturating-float-to-int`]: /// https://github.com/WebAssembly/nontrapping-float-to-int-conversions pub fn wasm_saturating_float_to_int(&mut self, enable: bool) -> &mut Self { - self.saturating_float_to_int = enable; + self.features + .set(WasmFeatures::SATURATING_FLOAT_TO_INT, enable); self } @@ -265,7 +256,7 @@ impl Config { /// /// [`multi-value`]: https://github.com/WebAssembly/multi-value pub fn wasm_multi_value(&mut self, enable: bool) -> &mut Self { - self.multi_value = enable; + self.features.set(WasmFeatures::MULTI_VALUE, enable); self } @@ -277,7 +268,7 @@ impl Config { /// /// [`multi-memory`]: https://github.com/WebAssembly/multi-memory pub fn wasm_multi_memory(&mut self, enable: bool) -> &mut Self { - self.multi_memory = enable; + self.features.set(WasmFeatures::MULTI_MEMORY, enable); self } @@ -289,7 +280,7 @@ impl Config { /// /// [`bulk-memory`]: https://github.com/WebAssembly/bulk-memory-operations pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self { - self.bulk_memory = enable; + self.features.set(WasmFeatures::BULK_MEMORY, enable); self } @@ -301,7 +292,8 @@ impl Config { /// /// [`reference-types`]: https://github.com/WebAssembly/reference-types pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self { - self.reference_types = enable; + self.features.set(WasmFeatures::REFERENCE_TYPES, enable); + self.features.set(WasmFeatures::GC_TYPES, enable); self } @@ -313,7 +305,7 @@ impl Config { /// /// [`tail-call`]: https://github.com/WebAssembly/tail-call pub fn wasm_tail_call(&mut self, enable: bool) -> &mut Self { - self.tail_call = enable; + self.features.set(WasmFeatures::TAIL_CALL, enable); self } @@ -325,7 +317,7 @@ impl Config { /// /// [`extended-const`]: https://github.com/WebAssembly/extended-const pub fn wasm_extended_const(&mut self, enable: bool) -> &mut Self { - self.extended_const = enable; + self.features.set(WasmFeatures::EXTENDED_CONST, enable); self } @@ -333,7 +325,7 @@ impl Config { /// /// Enabled by default. pub fn floats(&mut self, enable: bool) -> &mut Self { - self.floats = enable; + self.features.set(WasmFeatures::FLOATS, enable); self } @@ -420,24 +412,6 @@ impl Config { /// Returns the [`WasmFeatures`] represented by the [`Config`]. pub(crate) fn wasm_features(&self) -> WasmFeatures { - WasmFeatures { - multi_value: self.multi_value, - mutable_global: self.mutable_global, - saturating_float_to_int: self.saturating_float_to_int, - sign_extension: self.sign_extension, - bulk_memory: self.bulk_memory, - reference_types: self.reference_types, - tail_call: self.tail_call, - extended_const: self.extended_const, - floats: self.floats, - component_model: false, - simd: false, - relaxed_simd: false, - threads: false, - multi_memory: self.multi_memory, - exceptions: false, - memory64: false, - memory_control: false, - } + self.features } } diff --git a/crates/wasmi/src/engine/mod.rs b/crates/wasmi/src/engine/mod.rs index d7c7faf68f..0460e03ffe 100644 --- a/crates/wasmi/src/engine/mod.rs +++ b/crates/wasmi/src/engine/mod.rs @@ -561,6 +561,7 @@ impl EngineInner { module: ModuleHeader, func_to_validate: Option>, ) -> Result<(), Error> { + let features = self.config().wasm_features(); match (self.config.get_compilation_mode(), func_to_validate) { (CompilationMode::Eager, Some(func_to_validate)) => { let (translation_allocs, validation_allocs) = self.get_allocs(); @@ -580,7 +581,8 @@ impl EngineInner { } (CompilationMode::LazyTranslation, Some(func_to_validate)) => { let allocs = self.get_validation_allocs(); - let translator = LazyFuncTranslator::new(func_index, engine_func, module, None); + let translator = + LazyFuncTranslator::new_unchecked(func_index, engine_func, module, features); let validator = func_to_validate.into_validator(allocs); let translator = ValidatingFuncTranslator::new(validator, translator)?; let allocs = FuncTranslationDriver::new(offset, bytes, translator)? @@ -588,8 +590,14 @@ impl EngineInner { self.recycle_validation_allocs(allocs.validation); } (CompilationMode::Lazy | CompilationMode::LazyTranslation, func_to_validate) => { - let translator = - LazyFuncTranslator::new(func_index, engine_func, module, func_to_validate); + let translator = match func_to_validate { + Some(func_to_validate) => { + LazyFuncTranslator::new(func_index, engine_func, module, func_to_validate) + } + None => { + LazyFuncTranslator::new_unchecked(func_index, engine_func, module, features) + } + }; FuncTranslationDriver::new(offset, bytes, translator)? .translate(|func_entity| self.init_func(engine_func, func_entity))?; } diff --git a/crates/wasmi/src/engine/translator/driver.rs b/crates/wasmi/src/engine/translator/driver.rs index 4dc0256bc2..75062be1f8 100644 --- a/crates/wasmi/src/engine/translator/driver.rs +++ b/crates/wasmi/src/engine/translator/driver.rs @@ -2,7 +2,7 @@ use crate::{ engine::{code_map::CompiledFuncEntity, WasmTranslator}, Error, }; -use wasmparser::FunctionBody; +use wasmparser::{BinaryReader, FunctionBody}; /// Translates Wasm bytecode into Wasmi bytecode for a single Wasm function. pub struct FuncTranslationDriver<'parser, T> { @@ -14,7 +14,10 @@ pub struct FuncTranslationDriver<'parser, T> { translator: T, } -impl<'parser, T> FuncTranslationDriver<'parser, T> { +impl<'parser, T> FuncTranslationDriver<'parser, T> +where + T: WasmTranslator<'parser>, +{ /// Creates a new Wasm to Wasmi bytecode function translator. pub fn new( offset: impl Into>, @@ -22,19 +25,16 @@ impl<'parser, T> FuncTranslationDriver<'parser, T> { translator: T, ) -> Result { let offset = offset.into().unwrap_or(0); - let func_body = FunctionBody::new(offset, bytes); + let features = translator.features(); + let reader = BinaryReader::new_features(bytes, offset, features); + let func_body = FunctionBody::new(reader); Ok(Self { func_body, bytes, translator, }) } -} -impl<'parser, T> FuncTranslationDriver<'parser, T> -where - T: WasmTranslator<'parser>, -{ /// Starts translation of the Wasm stream into Wasmi bytecode. pub fn translate( mut self, diff --git a/crates/wasmi/src/engine/translator/mod.rs b/crates/wasmi/src/engine/translator/mod.rs index d046c9f620..d103c3e45a 100644 --- a/crates/wasmi/src/engine/translator/mod.rs +++ b/crates/wasmi/src/engine/translator/mod.rs @@ -65,7 +65,7 @@ use crate::{ FuncRef, FuncType, }; -use core::fmt; +use core::{fmt, mem}; use stack::RegisterSpace; use std::vec::Vec; use utils::Wrap; @@ -76,6 +76,7 @@ use wasmparser::{ MemArg, ValidatorResources, VisitOperator, + WasmFeatures, }; macro_rules! impl_typed_for { @@ -207,6 +208,9 @@ pub trait WasmTranslator<'parser>: VisitOperator<'parser, Output = Result<(), Er /// used for translation of the Wasm function body. fn setup(&mut self, bytes: &[u8]) -> Result; + /// Returns a reference to the [`WasmFeatures`] used by the [`WasmTranslator`]. + fn features(&self) -> WasmFeatures; + /// Translates the given local variables for the translated function. fn translate_locals( &mut self, @@ -290,6 +294,10 @@ where Ok(false) } + fn features(&self) -> WasmFeatures { + self.translator.features() + } + fn translate_locals( &mut self, amount: u32, @@ -327,7 +335,7 @@ where } macro_rules! impl_visit_operator { - ( @mvp BrTable { $arg:ident: $argty:ty } => $visit:ident $($rest:tt)* ) => { + ( @mvp BrTable { $arg:ident: $argty:ty } => $visit:ident $_ann:tt $($rest:tt)* ) => { // We need to special case the `BrTable` operand since its // arguments (a.k.a. `BrTable<'a>`) are not `Copy` which all // the other impls make use of. @@ -358,7 +366,7 @@ macro_rules! impl_visit_operator { ( @tail_call $($rest:tt)* ) => { impl_visit_operator!(@@supported $($rest)*); }; - ( @@supported $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $($rest:tt)* ) => { + ( @@supported $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $_ann:tt $($rest:tt)* ) => { fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { let offset = self.current_pos(); self.validate_then_translate( @@ -368,7 +376,7 @@ macro_rules! impl_visit_operator { } impl_visit_operator!($($rest)*); }; - ( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $($rest:tt)* ) => { + ( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $ann:tt $($rest:tt)* ) => { // Wildcard match arm for all the other (yet) unsupported Wasm proposals. fn $visit(&mut self $($(, $arg: $argty)*)?) -> Self::Output { let offset = self.current_pos(); @@ -389,6 +397,7 @@ where } /// A lazy Wasm function translator that defers translation when the function is first used. +#[derive(Debug)] pub struct LazyFuncTranslator { /// The index of the lazily compiled function within its module. func_idx: FuncIdx, @@ -396,17 +405,51 @@ pub struct LazyFuncTranslator { engine_func: EngineFunc, /// The Wasm module header information used for translation. module: ModuleHeader, - /// Optional information about lazy Wasm validation. - func_to_validate: Option>, + /// Information about Wasm validation during lazy translation. + validation: Validation, +} + +/// Information about Wasm validation for lazy translation. +enum Validation { + /// Wasm validation is performed. + Checked(FuncToValidate), + /// Wasm validation is checked. + /// + /// # Dev. Note + /// + /// We still need Wasm features to properly parse the Wasm. + Unchecked(WasmFeatures), +} + +impl Validation { + /// Returns `true` if `self` performs validates Wasm upon lazy translation. + pub fn is_checked(&self) -> bool { + matches!(self, Self::Checked(_)) + } + + /// Returns the [`WasmFeatures`] used for Wasm parsing and validation. + pub fn features(&self) -> WasmFeatures { + match self { + Validation::Checked(func_to_validate) => func_to_validate.features, + Validation::Unchecked(wasm_features) => *wasm_features, + } + } + + /// Returns the [`FuncToValidate`] if `self` is checked. + pub fn take_func_to_validate(&mut self) -> Option> { + let features = self.features(); + match mem::replace(self, Self::Unchecked(features)) { + Self::Checked(func_to_validate) => Some(func_to_validate), + Self::Unchecked(_) => None, + } + } } -impl fmt::Debug for LazyFuncTranslator { +impl fmt::Debug for Validation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("LazyFuncTranslator") - .field("func_idx", &self.func_idx) - .field("engine_func", &self.engine_func) - .field("module", &self.module) - .field("validate", &self.func_to_validate.is_some()) + .field("validate", &self.is_checked()) + .field("features", &self.features()) .finish() } } @@ -417,13 +460,28 @@ impl LazyFuncTranslator { func_idx: FuncIdx, engine_func: EngineFunc, module: ModuleHeader, - func_to_validate: Option>, + func_to_validate: FuncToValidate, ) -> Self { Self { func_idx, engine_func, module, - func_to_validate, + validation: Validation::Checked(func_to_validate), + } + } + + /// Create a new [`LazyFuncTranslator`] that does not validate Wasm upon lazy translation. + pub fn new_unchecked( + func_idx: FuncIdx, + engine_func: EngineFunc, + module: ModuleHeader, + features: WasmFeatures, + ) -> Self { + Self { + func_idx, + engine_func, + module, + validation: Validation::Unchecked(features), } } } @@ -446,11 +504,16 @@ impl WasmTranslator<'_> for LazyFuncTranslator { self.engine_func, bytes, &self.module, - self.func_to_validate.take(), + self.validation.take_func_to_validate(), ); Ok(true) } + #[inline] + fn features(&self) -> WasmFeatures { + self.validation.features() + } + #[inline] fn translate_locals( &mut self, @@ -478,7 +541,7 @@ impl WasmTranslator<'_> for LazyFuncTranslator { } macro_rules! impl_visit_operator { - ( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $($rest:tt)* ) => { + ( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $ann:tt $($rest:tt)* ) => { #[inline] fn $visit(&mut self $($(, $arg: $argty)*)?) -> Self::Output { Ok(()) @@ -533,6 +596,11 @@ impl WasmTranslator<'_> for FuncTranslator { Ok(false) } + #[inline] + fn features(&self) -> WasmFeatures { + self.engine.config().wasm_features() + } + fn translate_locals( &mut self, amount: u32, diff --git a/crates/wasmi/src/engine/translator/visit.rs b/crates/wasmi/src/engine/translator/visit.rs index 9d05466770..65b8030bd1 100644 --- a/crates/wasmi/src/engine/translator/visit.rs +++ b/crates/wasmi/src/engine/translator/visit.rs @@ -57,11 +57,11 @@ macro_rules! impl_visit_operator { ( @tail_call $($rest:tt)* ) => { impl_visit_operator!(@@skipped $($rest)*); }; - ( @@skipped $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $($rest:tt)* ) => { + ( @@skipped $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $_ann:tt $($rest:tt)* ) => { // We skip Wasm operators that we already implement manually. impl_visit_operator!($($rest)*); }; - ( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $($rest:tt)* ) => { + ( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $_ann:tt $($rest:tt)* ) => { // Wildcard match arm for all the other (yet) unsupported Wasm proposals. fn $visit(&mut self $($(, $arg: $argty)*)?) -> Self::Output { self.unsupported_operator(stringify!($op)) @@ -519,12 +519,7 @@ impl<'a> VisitOperator<'a> for FuncTranslator { Ok(()) } - fn visit_call_indirect( - &mut self, - type_index: u32, - table_index: u32, - _table_byte: u8, - ) -> Self::Output { + fn visit_call_indirect(&mut self, type_index: u32, table_index: u32) -> Self::Output { bail_unreachable!(self); self.bump_fuel_consumption(FuelCosts::call)?; let type_index = FuncType::from(type_index); @@ -987,7 +982,7 @@ impl<'a> VisitOperator<'a> for FuncTranslator { ) } - fn visit_memory_size(&mut self, mem: u32, _mem_byte: u8) -> Self::Output { + fn visit_memory_size(&mut self, mem: u32) -> Self::Output { bail_unreachable!(self); let memory = index::Memory::from(mem); let result = self.alloc.stack.push_dynamic()?; @@ -995,7 +990,7 @@ impl<'a> VisitOperator<'a> for FuncTranslator { Ok(()) } - fn visit_memory_grow(&mut self, mem: u32, _mem_byte: u8) -> Self::Output { + fn visit_memory_grow(&mut self, mem: u32) -> Self::Output { bail_unreachable!(self); let delta = self.alloc.stack.pop().map_const(u32::from); let memory = index::Memory::from(mem); @@ -1044,9 +1039,9 @@ impl<'a> VisitOperator<'a> for FuncTranslator { Ok(()) } - fn visit_ref_null(&mut self, ty: wasmparser::ValType) -> Self::Output { + fn visit_ref_null(&mut self, hty: wasmparser::HeapType) -> Self::Output { bail_unreachable!(self); - let type_hint = WasmiValueType::from(ty).into_inner(); + let type_hint = WasmiValueType::from(hty).into_inner(); let null = match type_hint { ValType::FuncRef => TypedVal::from(FuncRef::null()), ValType::ExternRef => TypedVal::from(ExternRef::null()), diff --git a/crates/wasmi/src/lib.rs b/crates/wasmi/src/lib.rs index 2662fcbb67..997dcbf0e8 100644 --- a/crates/wasmi/src/lib.rs +++ b/crates/wasmi/src/lib.rs @@ -76,7 +76,7 @@ clippy::default_trait_access, clippy::items_after_statements )] -#![recursion_limit = "750"] +#![recursion_limit = "1000"] #[cfg(not(feature = "std"))] extern crate alloc as std; diff --git a/crates/wasmi/src/module/element.rs b/crates/wasmi/src/module/element.rs index 0ca715a7a3..b6d5876ac3 100644 --- a/crates/wasmi/src/module/element.rs +++ b/crates/wasmi/src/module/element.rs @@ -1,5 +1,5 @@ use super::{ConstExpr, TableIdx}; -use crate::{core::ValType, module::utils::WasmiValueType}; +use crate::core::ValType; use std::boxed::Box; /// A table element segment within a [`Module`]. @@ -54,7 +54,7 @@ impl From> for ElementSegmentKind { table_index, offset_expr, } => { - let table_index = TableIdx::from(table_index); + let table_index = TableIdx::from(table_index.unwrap_or(0)); let offset = ConstExpr::new(offset_expr); Self::Active(ActiveElementSegment { table_index, @@ -69,28 +69,33 @@ impl From> for ElementSegmentKind { impl From> for ElementSegment { fn from(element: wasmparser::Element<'_>) -> Self { - assert!( - element.ty.is_reference_type(), - "only reftypes are allowed as element types but found: {:?}", - element.ty - ); let kind = ElementSegmentKind::from(element.kind); - let ty = WasmiValueType::from(element.ty).into_inner(); - let items = match element.items { - wasmparser::ElementItems::Functions(items) => items - .into_iter() - .map(|item| { - item.unwrap_or_else(|error| panic!("failed to parse element item: {error}")) - }) - .map(ConstExpr::new_funcref) - .collect::>(), - wasmparser::ElementItems::Expressions(items) => items - .into_iter() - .map(|item| { - item.unwrap_or_else(|error| panic!("failed to parse element item: {error}")) - }) - .map(ConstExpr::new) - .collect::>(), + let (items, ty) = match element.items { + wasmparser::ElementItems::Functions(items) => { + let items = items + .into_iter() + .map(|item| { + item.unwrap_or_else(|error| panic!("failed to parse element item: {error}")) + }) + .map(ConstExpr::new_funcref) + .collect::>(); + (items, ValType::FuncRef) + } + wasmparser::ElementItems::Expressions(ref_ty, items) => { + let ty = match ref_ty { + ty if ty.is_func_ref() => ValType::FuncRef, + ty if ty.is_extern_ref() => ValType::ExternRef, + _ => panic!("unsupported Wasm reference type"), + }; + let items = items + .into_iter() + .map(|item| { + item.unwrap_or_else(|error| panic!("failed to parse element item: {error}")) + }) + .map(ConstExpr::new) + .collect::>(); + (items, ty) + } }; Self { kind, ty, items } } diff --git a/crates/wasmi/src/module/init_expr.rs b/crates/wasmi/src/module/init_expr.rs index 5e5b58de18..4e94457d4d 100644 --- a/crates/wasmi/src/module/init_expr.rs +++ b/crates/wasmi/src/module/init_expr.rs @@ -16,6 +16,7 @@ use crate::{ use core::fmt; use smallvec::SmallVec; use std::boxed::Box; +use wasmparser::AbstractHeapType; /// Types that allow evluation given an evaluation context. pub trait Eval { @@ -267,11 +268,19 @@ impl ConstExpr { wasmparser::Operator::GlobalGet { global_index } => { stack.push(Op::global(global_index)); } - wasmparser::Operator::RefNull { ty } => { - let value = match ty { - wasmparser::ValType::FuncRef => Val::from(FuncRef::null()), - wasmparser::ValType::ExternRef => Val::from(ExternRef::null()), - ty => panic!("encountered invalid value type for RefNull: {ty:?}"), + wasmparser::Operator::RefNull { hty } => { + let value = match hty { + wasmparser::HeapType::Abstract { + shared: false, + ty: AbstractHeapType::Func, + } => Val::from(FuncRef::null()), + wasmparser::HeapType::Abstract { + shared: false, + ty: AbstractHeapType::Extern, + } => Val::from(ExternRef::null()), + invalid => { + panic!("encountered invalid heap type for `ref.null`: {invalid:?}") + } }; stack.push(Op::constant(value)); } diff --git a/crates/wasmi/src/module/parser.rs b/crates/wasmi/src/module/parser.rs index 11a0c74475..3993ddad6b 100644 --- a/crates/wasmi/src/module/parser.rs +++ b/crates/wasmi/src/module/parser.rs @@ -113,20 +113,21 @@ impl ModuleParser { } let limits = self.engine.config().get_enforced_limits(); let func_types = section.into_iter().map(|result| { - let wasmparser::Type::Func(ty) = result?; + let ty = result?.into_types().next().unwrap(); + let func_ty = ty.unwrap_func(); if let Some(limit) = limits.max_params { - if ty.params().len() > limit { + if func_ty.params().len() > limit { return Err(Error::from(EnforcedLimitsError::TooManyParameters { limit, })); } } if let Some(limit) = limits.max_results { - if ty.results().len() > limit { + if func_ty.results().len() > limit { return Err(Error::from(EnforcedLimitsError::TooManyResults { limit })); } } - Ok(FuncType::from_wasmparser(ty)) + Ok(FuncType::from_wasmparser(func_ty)) }); header.push_func_types(func_types)?; Ok(()) @@ -208,9 +209,13 @@ impl ModuleParser { if let Some(validator) = &mut self.validator { validator.table_section(§ion)?; } - let tables = section - .into_iter() - .map(|table| table.map(TableType::from_wasmparser).map_err(Error::from)); + let tables = section.into_iter().map(|table| match table { + Ok(table) => { + assert!(matches!(table.init, wasmparser::TableInit::RefNull)); + Ok(TableType::from_wasmparser(table.ty)) + } + Err(err) => Err(err.into()), + }); header.push_tables(tables)?; Ok(()) } diff --git a/crates/wasmi/src/module/parser/buffered.rs b/crates/wasmi/src/module/parser/buffered.rs index bb3d145ea1..8217ec3854 100644 --- a/crates/wasmi/src/module/parser/buffered.rs +++ b/crates/wasmi/src/module/parser/buffered.rs @@ -162,10 +162,8 @@ impl ModuleParser { // to return the byte slice for the respective code section // entry payload. Please remove this work around as soon as // such an API becomes available. - let bytes = Self::consume_buffer(consumed, buffer); - let remaining = func_body.get_binary_reader().bytes_remaining(); - let start = consumed - remaining; - let bytes = &bytes[start..]; + Self::consume_buffer(consumed, buffer); + let bytes = func_body.as_bytes(); self.process_code_entry(func_body, bytes, &header)?; } _ => break, diff --git a/crates/wasmi/src/module/parser/streaming.rs b/crates/wasmi/src/module/parser/streaming.rs index 6d24a4fb2b..bd1cd7d211 100644 --- a/crates/wasmi/src/module/parser/streaming.rs +++ b/crates/wasmi/src/module/parser/streaming.rs @@ -237,9 +237,7 @@ impl ModuleParser { // to return the byte slice for the respective code section // entry payload. Please remove this work around as soon as // such an API becomes available. - let remaining = func_body.get_binary_reader().bytes_remaining(); - let start = consumed - remaining; - let bytes = &buffer[start..consumed]; + let bytes = func_body.as_bytes(); self.process_code_entry(func_body, bytes, &header)?; } _ => break, diff --git a/crates/wasmi/src/module/utils.rs b/crates/wasmi/src/module/utils.rs index be13ecdb06..68b771dccf 100644 --- a/crates/wasmi/src/module/utils.rs +++ b/crates/wasmi/src/module/utils.rs @@ -1,3 +1,5 @@ +use wasmparser::AbstractHeapType; + use crate::{core::ValType, FuncType, GlobalType, MemoryType, Mutability, TableType}; impl TableType { @@ -9,8 +11,19 @@ impl TableType { /// routine does not become part of the public API of [`TableType`]. pub(crate) fn from_wasmparser(table_type: wasmparser::TableType) -> Self { let element = WasmiValueType::from(table_type.element_type).into_inner(); - let minimum = table_type.initial; - let maximum = table_type.maximum; + let minimum: u32 = table_type + .initial + .try_into() + .unwrap_or_else(|_err| panic!("out of bounds minimum value: {}", table_type.initial)); + let maximum: Option = match table_type.maximum { + Some(maximum) => { + let maximum = maximum + .try_into() + .unwrap_or_else(|_err| panic!("out of bounds maximum value: {}", maximum)); + Some(maximum) + } + None => None, + }; Self::new(element, minimum, maximum) } } @@ -69,7 +82,7 @@ impl FuncType { /// /// We do not use the `From` trait here so that this conversion /// routine does not become part of the public API of [`FuncType`]. - pub(crate) fn from_wasmparser(func_type: wasmparser::FuncType) -> Self { + pub(crate) fn from_wasmparser(func_type: &wasmparser::FuncType) -> Self { /// Returns the [`ValType`] from the given [`wasmparser::Type`]. /// /// # Panics @@ -106,6 +119,32 @@ impl From for WasmiValueType { } } +impl From for WasmiValueType { + fn from(heap_type: wasmparser::HeapType) -> Self { + match heap_type { + wasmparser::HeapType::Abstract { + shared: false, + ty: AbstractHeapType::Func, + } => Self::from(ValType::FuncRef), + wasmparser::HeapType::Abstract { + shared: false, + ty: AbstractHeapType::Extern, + } => Self::from(ValType::ExternRef), + unsupported => panic!("encountered unsupported heap type: {unsupported:?}"), + } + } +} + +impl From for WasmiValueType { + fn from(ref_type: wasmparser::RefType) -> Self { + match ref_type { + wasmparser::RefType::FUNCREF => Self::from(ValType::FuncRef), + wasmparser::RefType::EXTERNREF => Self::from(ValType::ExternRef), + unsupported => panic!("encountered unsupported reference type: {unsupported:?}"), + } + } +} + impl From for WasmiValueType { fn from(value_type: wasmparser::ValType) -> Self { match value_type { @@ -114,8 +153,7 @@ impl From for WasmiValueType { wasmparser::ValType::F32 => Self::from(ValType::F32), wasmparser::ValType::F64 => Self::from(ValType::F64), wasmparser::ValType::V128 => panic!("wasmi does not support the `simd` Wasm proposal"), - wasmparser::ValType::FuncRef => Self::from(ValType::FuncRef), - wasmparser::ValType::ExternRef => Self::from(ValType::ExternRef), + wasmparser::ValType::Ref(ref_type) => WasmiValueType::from(ref_type), } } } diff --git a/crates/wasmi/src/table/element.rs b/crates/wasmi/src/table/element.rs index dff4a86c70..e7d2bdcc94 100644 --- a/crates/wasmi/src/table/element.rs +++ b/crates/wasmi/src/table/element.rs @@ -107,11 +107,7 @@ impl ElementSegmentEntity { panic!("unexpected failed initialization of constant expression: {const_expr:?}") }) }).collect::>(); - Self { - ty, - // items: Some(elem.items_cloned()), - items, - } + Self { ty, items } } module::ElementSegmentKind::Declared => Self::empty(ty), }