diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e80781daf..3885cd9f09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,23 @@ jobs: - run: rustup component add rustfmt - run: cargo fmt --all -- --check + # Lint dependency graph for security advisories, duplicate versions, and + # incompatible licences + cargo_deny: + name: Cargo deny + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - uses: ./.github/actions/install-rust + - run: | + set -e + curl -L https://github.com/EmbarkStudios/cargo-deny/releases/download/0.8.5/cargo-deny-0.8.5-x86_64-unknown-linux-musl.tar.gz | tar xzf - + mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny + echo `pwd` >> $GITHUB_PATH + - run: cargo deny check + # Build `mdBook` documentation for `wasmtime`, and upload it as a temporary # build artifact doc_book: @@ -269,7 +286,7 @@ jobs: # Test debug (DWARF) related functionality. - run: | - sudo apt-get install -y gdb + sudo apt-get update && sudo apt-get install -y gdb cargo test test_debug_dwarf -- --ignored --test-threads 1 if: matrix.os == 'ubuntu-latest' env: diff --git a/Cargo.lock b/Cargo.lock index 2630d250e8..dda83d6e01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,9 +17,9 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "ahash" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6789e291be47ace86a60303502173d84af8327e3627ecf334356ee0f87a164c" +checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "aho-corasick" @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" +checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4" [[package]] name = "arbitrary" @@ -106,12 +106,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" @@ -163,9 +157,9 @@ dependencies = [ [[package]] name = "bit-vec" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" @@ -287,9 +281,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.61" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" dependencies = [ "jobserver", ] @@ -330,9 +324,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9da1484c6a890e374ca5086062d4847e0a2c1e5eba9afa5d48c09e8eb39b2519" +checksum = "0659001ab56b791be01d4b729c44376edc6718cf389a502e579b77b758f3296c" dependencies = [ "glob", "libc", @@ -356,9 +350,9 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb" +checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" dependencies = [ "cc", ] @@ -381,9 +375,9 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" [[package]] name = "constant_time_eq" @@ -657,7 +651,7 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.70.0", + "wasmparser", "wat", ] @@ -677,7 +671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.0", + "crossbeam-utils", ] [[package]] @@ -688,43 +682,31 @@ checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", - "crossbeam-utils 0.8.0", + "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", - "crossbeam-utils 0.8.0", + "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ "autocfg", "cfg-if 1.0.0", - "const_fn", "lazy_static", ] @@ -761,9 +743,9 @@ dependencies = [ [[package]] name = "derive_utils" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df5480412da86cdf5d6b7f3b682422c84359ff7399aa658df1d15ee83244b1d" +checksum = "64196eb9f551916167225134f1e8a90f0b5774331d3c900d6328fd94bafe3544" dependencies = [ "proc-macro2", "quote", @@ -805,6 +787,16 @@ dependencies = [ "dirs-sys", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + [[package]] name = "dirs-sys" version = "0.3.5" @@ -886,9 +878,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd" +checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" dependencies = [ "atty", "humantime 2.0.1", @@ -1108,9 +1100,9 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg", "hashbrown", @@ -1137,9 +1129,9 @@ checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" [[package]] name = "iter-enum" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cdea9771bec3d95893f6c665a4fcd477af7858446a46bc2772f560534eee43b" +checksum = "86a94bc12a53bf84b705acee29eb8697a5ea7b4587d836152499e5db0a6d52b9" dependencies = [ "derive_utils", "quote", @@ -1187,9 +1179,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "leb128" @@ -1205,9 +1197,9 @@ checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libfuzzer-sys" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8c42ab62f43795ed77a965ed07994c5584cdc94fd0ebf14b22ac1524077acc" +checksum = "fcf184a4b6b274f82a5df6b357da6055d3e82272327bba281c28bbba6f1664ef" dependencies = [ "arbitrary", "cc", @@ -1215,11 +1207,11 @@ dependencies = [ [[package]] name = "libloading" -version = "0.6.3" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9" +checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "winapi", ] @@ -1237,13 +1229,13 @@ dependencies = [ "iter-enum", "itertools", "lazy_static", - "memoffset 0.6.1", + "memoffset", "more-asserts", "quickcheck", "smallvec", "thiserror", "typemap", - "wasmparser 0.70.0", + "wasmparser", "wat", ] @@ -1303,15 +1295,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1419,14 +1402,13 @@ checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "wasmparser 0.57.0", ] [[package]] name = "once_cell" -version = "1.4.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "opaque-debug" @@ -1504,7 +1486,7 @@ version = "0.66.0" dependencies = [ "arbitrary", "bincode", - "env_logger 0.8.1", + "env_logger 0.8.2", "fst", "log", "peepmatic", @@ -1559,7 +1541,7 @@ dependencies = [ name = "peepmatic-test" version = "0.2.0" dependencies = [ - "env_logger 0.8.1", + "env_logger 0.8.2", "log", "peepmatic", "peepmatic-runtime", @@ -1582,9 +1564,9 @@ version = "0.68.0" [[package]] name = "pin-project-lite" -version = "0.1.11" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] name = "posish" @@ -1670,9 +1652,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96e0536f6528466dbbbbe6b986c34175a8d0ff25b794c4bacda22e068cd2f2c5" +checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" dependencies = [ "cc", ] @@ -1795,7 +1777,7 @@ checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque", - "crossbeam-utils 0.8.0", + "crossbeam-utils", "lazy_static", "num_cpus", ] @@ -1888,14 +1870,14 @@ dependencies = [ [[package]] name = "rust-argon2" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64 0.12.3", + "base64", "blake2b_simd", "constant_time_eq", - "crossbeam-utils 0.7.2", + "crossbeam-utils", ] [[package]] @@ -1995,18 +1977,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2", "quote", @@ -2015,9 +1997,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" +checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" dependencies = [ "itoa", "ryu", @@ -2026,9 +2008,9 @@ dependencies = [ [[package]] name = "serde_test" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a49e2f787c0fddfd5e758cbbd3cbf81c3a8d12ef091283c52d9e9b4d417d3c" +checksum = "f7f3f8714511d29f60be0ea965bc784df1b6903da5bbac801df36b1bbc7b4880" dependencies = [ "serde", ] @@ -2058,11 +2040,11 @@ dependencies = [ [[package]] name = "shellexpand" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2b22262a9aaf9464d356f656fea420634f78c881c5eebd5ef5e66d8b9bc603" +checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829" dependencies = [ - "dirs", + "dirs-next", ] [[package]] @@ -2073,9 +2055,9 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "smallvec" -version = "1.4.2" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" [[package]] name = "souper-ir" @@ -2100,9 +2082,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126d630294ec449fae0b16f964e35bf3c74f940da9dca17ee9b905f7b3112eb8" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" dependencies = [ "clap", "lazy_static", @@ -2111,9 +2093,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e51c492f9e23a220534971ff5afc14037289de430e3c83f9daf6a1b6ae91e8" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" dependencies = [ "heck", "proc-macro-error", @@ -2124,9 +2106,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.48" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ "proc-macro2", "quote", @@ -2177,18 +2159,18 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13" +checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" dependencies = [ "libc", "winapi", @@ -2271,11 +2253,11 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "log", "pin-project-lite", "tracing-attributes", @@ -2368,9 +2350,9 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" @@ -2531,24 +2513,18 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.71.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" - -[[package]] -name = "wasmparser" -version = "0.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed1b3f9e9cf01a580b9f3281214dfdb1922b5dfb8494ee312ca03ae10036c2a2" +checksum = "89a30c99437829ede826802bfcf28500cf58df00e66cb9114df98813bc145ff1" [[package]] name = "wasmprinter" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f89b2b24dce17e27fe9c09c28331cbd77067fcde5c6ea2508ac84bcbd5d3e018" +checksum = "0515db67c610037f3c53ec36976edfd1eb01bac6b1226914b17ce609480e729f" dependencies = [ "anyhow", - "wasmparser 0.70.0", + "wasmparser", ] [[package]] @@ -2569,7 +2545,7 @@ dependencies = [ "smallvec", "target-lexicon", "tempfile", - "wasmparser 0.70.0", + "wasmparser", "wasmtime-cache", "wasmtime-environ", "wasmtime-jit", @@ -2580,12 +2556,23 @@ dependencies = [ "winapi", ] +[[package]] +name = "wasmtime-bench-api" +version = "0.19.0" +dependencies = [ + "anyhow", + "wasi-common", + "wasmtime", + "wasmtime-wasi", + "wat", +] + [[package]] name = "wasmtime-c-api" version = "0.19.0" dependencies = [ "anyhow", - "env_logger 0.8.1", + "env_logger 0.8.2", "once_cell", "wasi-common", "wasmtime", @@ -2607,7 +2594,7 @@ name = "wasmtime-cache" version = "0.21.0" dependencies = [ "anyhow", - "base64 0.13.0", + "base64", "bincode", "directories-next", "errno", @@ -2631,7 +2618,7 @@ name = "wasmtime-cli" version = "0.21.0" dependencies = [ "anyhow", - "env_logger 0.8.1", + "env_logger 0.8.2", "file-per-thread-logger", "filecheck", "humantime 2.0.1", @@ -2647,7 +2634,7 @@ dependencies = [ "test-programs", "tracing-subscriber", "wasi-common", - "wasmparser 0.70.0", + "wasmparser", "wasmtime", "wasmtime-cache", "wasmtime-debug", @@ -2683,7 +2670,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.70.0", + "wasmparser", "wasmtime-environ", ] @@ -2702,7 +2689,7 @@ dependencies = [ "more-asserts", "serde", "thiserror", - "wasmparser 0.70.0", + "wasmparser", ] [[package]] @@ -2726,12 +2713,13 @@ version = "0.19.0" dependencies = [ "anyhow", "arbitrary", - "env_logger 0.8.1", + "env_logger 0.8.2", "log", "rayon", + "wasm-encoder", "wasm-smith", "wasmi", - "wasmparser 0.70.0", + "wasmparser", "wasmprinter", "wasmtime", "wasmtime-wast", @@ -2759,7 +2747,7 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.70.0", + "wasmparser", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -2776,7 +2764,7 @@ version = "0.21.0" dependencies = [ "cranelift-codegen", "lightbeam", - "wasmparser 0.70.0", + "wasmparser", "wasmtime-environ", ] @@ -2821,7 +2809,7 @@ dependencies = [ "lazy_static", "libc", "log", - "memoffset 0.6.1", + "memoffset", "more-asserts", "psm", "region", @@ -2927,12 +2915,21 @@ dependencies = [ ] [[package]] -name = "wat" -version = "1.0.30" +name = "wast" +version = "30.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d11a88d953b298172d218d18f22853f4e6e12873b62755d05617b864d312c68" +checksum = "9b79907b22f740634810e882d8d1d9d0f9563095a8ab94e786e370242bff5cd2" dependencies = [ - "wast 29.0.0", + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8279a02835bf12e61ed2b3c3cbc6ecf9918762fd97e036917c11a09ec20ca44" +dependencies = [ + "wast 30.0.0", ] [[package]] @@ -2991,7 +2988,7 @@ dependencies = [ name = "wiggle-test" version = "0.21.0" dependencies = [ - "env_logger 0.8.1", + "env_logger 0.8.2", "proptest", "thiserror", "tracing", @@ -3097,18 +3094,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.5.3+zstd.1.4.5" +version = "0.5.4+zstd.1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01b32eaf771efa709e8308605bbf9319bf485dc1503179ec0469b611937c0cd8" +checksum = "69996ebdb1ba8b1517f61387a883857818a66c8a295f487b1ffd8fd9d2c82910" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "2.0.5+zstd.1.4.5" +version = "2.0.6+zstd.1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfb642e0d27f64729a639c52db457e0ae906e7bc6f5fe8f5c453230400f1055" +checksum = "98aa931fb69ecee256d44589d19754e61851ae4769bf963b385119b1cc37a49e" dependencies = [ "libc", "zstd-sys", @@ -3116,9 +3113,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.4.17+zstd.1.4.5" +version = "1.4.18+zstd.1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89249644df056b522696b1bb9e7c18c87e8ffa3e2f0dc3b0155875d6498f01b" +checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81" dependencies = [ "cc", "glob", diff --git a/Cargo.toml b/Cargo.toml index 7741c23e67..f06fca065d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ libc = "0.2.60" log = "0.4.8" rayon = "1.2.1" humantime = "2.0.0" -wasmparser = "0.70.0" +wasmparser = "0.71.0" [dev-dependencies] env_logger = "0.8.1" @@ -64,6 +64,7 @@ opt-level = 0 [workspace] members = [ "cranelift", + "crates/bench-api", "crates/c-api", "crates/fuzzing", "crates/misc/run-examples", diff --git a/cranelift/codegen/meta/src/isa/x86/encodings.rs b/cranelift/codegen/meta/src/isa/x86/encodings.rs index de48c57c5d..bdfcef9c6f 100644 --- a/cranelift/codegen/meta/src/isa/x86/encodings.rs +++ b/cranelift/codegen/meta/src/isa/x86/encodings.rs @@ -1691,6 +1691,7 @@ fn define_simd( let usub_sat = shared.by_name("usub_sat"); let vconst = shared.by_name("vconst"); let vselect = shared.by_name("vselect"); + let widening_pairwise_dot_product_s = shared.by_name("widening_pairwise_dot_product_s"); let x86_cvtt2si = x86.by_name("x86_cvtt2si"); let x86_insertps = x86.by_name("x86_insertps"); let x86_fmax = x86.by_name("x86_fmax"); @@ -2213,6 +2214,9 @@ fn define_simd( // SIMD multiplication with lane expansion. e.enc_both_inferred(x86_pmuludq, rec_fa.opcodes(&PMULUDQ)); + // SIMD multiplication and add adjacent pairs, from SSE2. + e.enc_both_inferred(widening_pairwise_dot_product_s, rec_fa.opcodes(&PMADDWD)); + // SIMD integer multiplication for I64x2 using a AVX512. { e.enc_32_64_maybe_isap( diff --git a/cranelift/codegen/meta/src/isa/x86/opcodes.rs b/cranelift/codegen/meta/src/isa/x86/opcodes.rs index 595d13ba2b..2e72a1744d 100644 --- a/cranelift/codegen/meta/src/isa/x86/opcodes.rs +++ b/cranelift/codegen/meta/src/isa/x86/opcodes.rs @@ -508,6 +508,9 @@ pub static VPMULLQ: [u8; 4] = [0x66, 0x0f, 0x38, 0x40]; /// in xmm2/m128, and store the quadword results in xmm1 (SSE2). pub static PMULUDQ: [u8; 3] = [0x66, 0x0f, 0xf4]; +/// Multiply the packed word integers, add adjacent doubleword results. +pub static PMADDWD: [u8; 3] = [0x66, 0x0f, 0xf5]; + /// Pop top of stack into r{16,32,64}; increment stack pointer. pub static POP_REG: [u8; 1] = [0x58]; diff --git a/cranelift/codegen/src/isa/mod.rs b/cranelift/codegen/src/isa/mod.rs index 1ce10a155e..900dfd9ddd 100644 --- a/cranelift/codegen/src/isa/mod.rs +++ b/cranelift/codegen/src/isa/mod.rs @@ -75,10 +75,13 @@ use thiserror::Error; #[cfg(feature = "riscv")] mod riscv; -// Exclude the old x86 backend when the new one is enabled; it is unreachable -// anyway (requesting the x86-64 ISA will return the new backend), and a number -// of old-backend-specific tests fail. -#[cfg(all(feature = "x86", not(feature = "x64")))] +// N.B.: the old x86-64 backend (`x86`) and the new one (`x64`) can both be +// included; if the new backend is included, then it is the default backend +// returned for an x86-64 triple, but a specific option can request the old +// backend. It is important to have the ability to instantiate *both* backends +// in the same build so that we can do things like differential fuzzing between +// backends, or perhaps offer a runtime configuration flag in the future. +#[cfg(feature = "x86")] mod x86; #[cfg(feature = "x64")] @@ -117,24 +120,56 @@ macro_rules! isa_builder { }}; } +/// The "variant" for a given target. On one platform (x86-64), we have two +/// backends, the "old" and "new" one; the new one is the default if included +/// in the build configuration and not otherwise specified. +#[derive(Clone, Copy)] +pub enum BackendVariant { + /// Any backend available. + Any, + /// A "legacy" backend: one that operates using legalizations and encodings. + Legacy, + /// A backend built on `MachInst`s and the `VCode` framework. + MachInst, +} + +impl Default for BackendVariant { + fn default() -> Self { + BackendVariant::Any + } +} + +/// Look for an ISA for the given `triple`, selecting the backend variant given +/// by `variant` if available. +pub fn lookup_variant(triple: Triple, variant: BackendVariant) -> Result { + match (triple.architecture, variant) { + (Architecture::Riscv32 { .. }, _) | (Architecture::Riscv64 { .. }, _) => { + isa_builder!(riscv, (feature = "riscv"), triple) + } + (Architecture::X86_64, BackendVariant::Legacy) => { + isa_builder!(x86, (feature = "x86"), triple) + } + (Architecture::X86_64, BackendVariant::MachInst) => { + isa_builder!(x64, (feature = "x64"), triple) + } + #[cfg(feature = "x64")] + (Architecture::X86_64, BackendVariant::Any) => { + isa_builder!(x64, (feature = "x64"), triple) + } + #[cfg(not(feature = "x64"))] + (Architecture::X86_64, BackendVariant::Any) => { + isa_builder!(x86, (feature = "x86"), triple) + } + (Architecture::Arm { .. }, _) => isa_builder!(arm32, (feature = "arm32"), triple), + (Architecture::Aarch64 { .. }, _) => isa_builder!(aarch64, (feature = "arm64"), triple), + _ => Err(LookupError::Unsupported), + } +} + /// Look for an ISA for the given `triple`. /// Return a builder that can create a corresponding `TargetIsa`. pub fn lookup(triple: Triple) -> Result { - match triple.architecture { - Architecture::Riscv32 { .. } | Architecture::Riscv64 { .. } => { - isa_builder!(riscv, (feature = "riscv"), triple) - } - Architecture::X86_32 { .. } | Architecture::X86_64 => { - if cfg!(feature = "x64") { - isa_builder!(x64, (feature = "x64"), triple) - } else { - isa_builder!(x86, (all(feature = "x86", not(feature = "x64"))), triple) - } - } - Architecture::Arm { .. } => isa_builder!(arm32, (feature = "arm32"), triple), - Architecture::Aarch64 { .. } => isa_builder!(aarch64, (feature = "arm64"), triple), - _ => Err(LookupError::Unsupported), - } + lookup_variant(triple, BackendVariant::Any) } /// Look for a supported ISA with the given `name`. diff --git a/cranelift/codegen/src/isa/x64/inst/args.rs b/cranelift/codegen/src/isa/x64/inst/args.rs index 7e3b3f22a2..4c61954630 100644 --- a/cranelift/codegen/src/isa/x64/inst/args.rs +++ b/cranelift/codegen/src/isa/x64/inst/args.rs @@ -498,6 +498,7 @@ pub enum SseOpcode { Pinsrb, Pinsrw, Pinsrd, + Pmaddwd, Pmaxsb, Pmaxsw, Pmaxsd, @@ -661,6 +662,7 @@ impl SseOpcode { | SseOpcode::Pcmpgtd | SseOpcode::Pextrw | SseOpcode::Pinsrw + | SseOpcode::Pmaddwd | SseOpcode::Pmaxsw | SseOpcode::Pmaxub | SseOpcode::Pminsw @@ -842,6 +844,7 @@ impl fmt::Debug for SseOpcode { SseOpcode::Pinsrb => "pinsrb", SseOpcode::Pinsrw => "pinsrw", SseOpcode::Pinsrd => "pinsrd", + SseOpcode::Pmaddwd => "pmaddwd", SseOpcode::Pmaxsb => "pmaxsb", SseOpcode::Pmaxsw => "pmaxsw", SseOpcode::Pmaxsd => "pmaxsd", diff --git a/cranelift/codegen/src/isa/x64/inst/emit.rs b/cranelift/codegen/src/isa/x64/inst/emit.rs index 401b8aad08..fb32635a92 100644 --- a/cranelift/codegen/src/isa/x64/inst/emit.rs +++ b/cranelift/codegen/src/isa/x64/inst/emit.rs @@ -1764,6 +1764,18 @@ pub(crate) fn emit( SseOpcode::Pabsb => (LegacyPrefixes::_66, 0x0F381C, 3), SseOpcode::Pabsw => (LegacyPrefixes::_66, 0x0F381D, 3), SseOpcode::Pabsd => (LegacyPrefixes::_66, 0x0F381E, 3), + SseOpcode::Pmovsxbd => (LegacyPrefixes::_66, 0x0F3821, 3), + SseOpcode::Pmovsxbw => (LegacyPrefixes::_66, 0x0F3820, 3), + SseOpcode::Pmovsxbq => (LegacyPrefixes::_66, 0x0F3822, 3), + SseOpcode::Pmovsxwd => (LegacyPrefixes::_66, 0x0F3823, 3), + SseOpcode::Pmovsxwq => (LegacyPrefixes::_66, 0x0F3824, 3), + SseOpcode::Pmovsxdq => (LegacyPrefixes::_66, 0x0F3825, 3), + SseOpcode::Pmovzxbd => (LegacyPrefixes::_66, 0x0F3831, 3), + SseOpcode::Pmovzxbw => (LegacyPrefixes::_66, 0x0F3830, 3), + SseOpcode::Pmovzxbq => (LegacyPrefixes::_66, 0x0F3832, 3), + SseOpcode::Pmovzxwd => (LegacyPrefixes::_66, 0x0F3833, 3), + SseOpcode::Pmovzxwq => (LegacyPrefixes::_66, 0x0F3834, 3), + SseOpcode::Pmovzxdq => (LegacyPrefixes::_66, 0x0F3835, 3), SseOpcode::Sqrtps => (LegacyPrefixes::None, 0x0F51, 2), SseOpcode::Sqrtpd => (LegacyPrefixes::_66, 0x0F51, 2), SseOpcode::Sqrtss => (LegacyPrefixes::_F3, 0x0F51, 2), @@ -1861,18 +1873,7 @@ pub(crate) fn emit( SseOpcode::Pcmpgtw => (LegacyPrefixes::_66, 0x0F65, 2), SseOpcode::Pcmpgtd => (LegacyPrefixes::_66, 0x0F66, 2), SseOpcode::Pcmpgtq => (LegacyPrefixes::_66, 0x0F3837, 3), - SseOpcode::Pmovsxbd => (LegacyPrefixes::_66, 0x0F3821, 3), - SseOpcode::Pmovsxbw => (LegacyPrefixes::_66, 0x0F3820, 3), - SseOpcode::Pmovsxbq => (LegacyPrefixes::_66, 0x0F3822, 3), - SseOpcode::Pmovsxwd => (LegacyPrefixes::_66, 0x0F3823, 3), - SseOpcode::Pmovsxwq => (LegacyPrefixes::_66, 0x0F3824, 3), - SseOpcode::Pmovsxdq => (LegacyPrefixes::_66, 0x0F3825, 3), - SseOpcode::Pmovzxbd => (LegacyPrefixes::_66, 0x0F3831, 3), - SseOpcode::Pmovzxbw => (LegacyPrefixes::_66, 0x0F3830, 3), - SseOpcode::Pmovzxbq => (LegacyPrefixes::_66, 0x0F3832, 3), - SseOpcode::Pmovzxwd => (LegacyPrefixes::_66, 0x0F3833, 3), - SseOpcode::Pmovzxwq => (LegacyPrefixes::_66, 0x0F3834, 3), - SseOpcode::Pmovzxdq => (LegacyPrefixes::_66, 0x0F3835, 3), + SseOpcode::Pmaddwd => (LegacyPrefixes::_66, 0x0FF5, 2), SseOpcode::Pmaxsb => (LegacyPrefixes::_66, 0x0F383C, 3), SseOpcode::Pmaxsw => (LegacyPrefixes::_66, 0x0FEE, 2), SseOpcode::Pmaxsd => (LegacyPrefixes::_66, 0x0F383D, 3), diff --git a/cranelift/codegen/src/isa/x64/inst/emit_tests.rs b/cranelift/codegen/src/isa/x64/inst/emit_tests.rs index bda26e3f27..e2afa80e2a 100644 --- a/cranelift/codegen/src/isa/x64/inst/emit_tests.rs +++ b/cranelift/codegen/src/isa/x64/inst/emit_tests.rs @@ -10,7 +10,7 @@ //! RUST_BACKTRACE=1 cargo test --features test-programs/test_programs \ //! --features experimental_x64 --all --exclude peepmatic --exclude lightbeam \ //! --exclude wasmtime-lightbeam --exclude peepmatic-automata --exclude peepmatic-fuzzing \ -//! --exclude peepmatic-macro -- isa::x64::inst::emit_tests::test_x64_emit +//! --exclude peepmatic-macro --exclude wasmtime-wasi-nn -- isa::x64::inst::emit_tests::test_x64_emit use super::*; use crate::isa::test_utils; @@ -3067,6 +3067,12 @@ fn test_x64_emit() { "pmuludq %xmm8, %xmm9", )); + insns.push(( + Inst::xmm_rm_r(SseOpcode::Pmaddwd, RegMem::reg(xmm8), w_xmm1), + "66410FF5C8", + "pmaddwd %xmm8, %xmm1", + )); + insns.push(( Inst::xmm_rm_r(SseOpcode::Pmaxsb, RegMem::reg(xmm15), w_xmm6), "66410F383CF7", @@ -3201,81 +3207,6 @@ fn test_x64_emit() { "cvttps2dq %xmm9, %xmm8", )); - // ======================================================== - // XMM_RM_R: Packed Move - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovsxbd, RegMem::reg(xmm6), w_xmm8), - "66440F3821C6", - "pmovsxbd %xmm6, %xmm8", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovsxbw, RegMem::reg(xmm9), w_xmm10), - "66450F3820D1", - "pmovsxbw %xmm9, %xmm10", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovsxbq, RegMem::reg(xmm1), w_xmm1), - "660F3822C9", - "pmovsxbq %xmm1, %xmm1", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovsxwd, RegMem::reg(xmm13), w_xmm10), - "66450F3823D5", - "pmovsxwd %xmm13, %xmm10", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovsxwq, RegMem::reg(xmm12), w_xmm12), - "66450F3824E4", - "pmovsxwq %xmm12, %xmm12", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovsxdq, RegMem::reg(xmm10), w_xmm8), - "66450F3825C2", - "pmovsxdq %xmm10, %xmm8", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovzxbd, RegMem::reg(xmm5), w_xmm6), - "660F3831F5", - "pmovzxbd %xmm5, %xmm6", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovzxbw, RegMem::reg(xmm5), w_xmm13), - "66440F3830ED", - "pmovzxbw %xmm5, %xmm13", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovzxbq, RegMem::reg(xmm10), w_xmm11), - "66450F3832DA", - "pmovzxbq %xmm10, %xmm11", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovzxwd, RegMem::reg(xmm2), w_xmm10), - "66440F3833D2", - "pmovzxwd %xmm2, %xmm10", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovzxwq, RegMem::reg(xmm7), w_xmm4), - "660F3834E7", - "pmovzxwq %xmm7, %xmm4", - )); - - insns.push(( - Inst::xmm_rm_r(SseOpcode::Pmovzxdq, RegMem::reg(xmm3), w_xmm4), - "660F3835E3", - "pmovzxdq %xmm3, %xmm4", - )); - // XMM_Mov_R_M: float stores insns.push(( Inst::xmm_mov_r_m(SseOpcode::Movss, xmm15, Amode::imm_reg(128, r12)), @@ -3288,6 +3219,81 @@ fn test_x64_emit() { "movsd %xmm1, 0(%rsi)", )); + // ======================================================== + // XMM_MOV: Packed Move + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovsxbd, RegMem::reg(xmm6), w_xmm8), + "66440F3821C6", + "pmovsxbd %xmm6, %xmm8", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovsxbw, RegMem::reg(xmm9), w_xmm10), + "66450F3820D1", + "pmovsxbw %xmm9, %xmm10", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovsxbq, RegMem::reg(xmm1), w_xmm1), + "660F3822C9", + "pmovsxbq %xmm1, %xmm1", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovsxwd, RegMem::reg(xmm13), w_xmm10), + "66450F3823D5", + "pmovsxwd %xmm13, %xmm10", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovsxwq, RegMem::reg(xmm12), w_xmm12), + "66450F3824E4", + "pmovsxwq %xmm12, %xmm12", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovsxdq, RegMem::reg(xmm10), w_xmm8), + "66450F3825C2", + "pmovsxdq %xmm10, %xmm8", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovzxbd, RegMem::reg(xmm5), w_xmm6), + "660F3831F5", + "pmovzxbd %xmm5, %xmm6", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovzxbw, RegMem::reg(xmm5), w_xmm13), + "66440F3830ED", + "pmovzxbw %xmm5, %xmm13", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovzxbq, RegMem::reg(xmm10), w_xmm11), + "66450F3832DA", + "pmovzxbq %xmm10, %xmm11", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovzxwd, RegMem::reg(xmm2), w_xmm10), + "66440F3833D2", + "pmovzxwd %xmm2, %xmm10", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovzxwq, RegMem::reg(xmm7), w_xmm4), + "660F3834E7", + "pmovzxwq %xmm7, %xmm4", + )); + + insns.push(( + Inst::xmm_mov(SseOpcode::Pmovzxdq, RegMem::reg(xmm3), w_xmm4), + "660F3835E3", + "pmovzxdq %xmm3, %xmm4", + )); + // XmmUnary: moves and unary float ops insns.push(( Inst::xmm_unary_rm_r(SseOpcode::Movss, RegMem::reg(xmm13), w_xmm2), diff --git a/cranelift/codegen/src/isa/x64/lower.rs b/cranelift/codegen/src/isa/x64/lower.rs index a01e35bc0d..6e6198c44b 100644 --- a/cranelift/codegen/src/isa/x64/lower.rs +++ b/cranelift/codegen/src/isa/x64/lower.rs @@ -2235,6 +2235,24 @@ fn lower_insn_to_regs>( } } + Opcode::WideningPairwiseDotProductS => { + let lhs = put_input_in_reg(ctx, inputs[0]); + let rhs = input_to_reg_mem(ctx, inputs[1]); + let dst = get_output_reg(ctx, outputs[0]); + let ty = ty.unwrap(); + + ctx.emit(Inst::gen_move(dst, lhs, ty)); + + if ty == types::I32X4 { + ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmaddwd, rhs, dst)); + } else { + panic!( + "Opcode::WideningPairwiseDotProductS: unsupported laneage: {:?}", + ty + ); + } + } + Opcode::Fadd | Opcode::Fsub | Opcode::Fmul | Opcode::Fdiv => { let lhs = put_input_in_reg(ctx, inputs[0]); let rhs = input_to_reg_mem(ctx, inputs[1]); @@ -2910,12 +2928,10 @@ fn lower_insn_to_regs>( match op { Opcode::SwidenLow => match (input_ty, output_ty) { (types::I8X16, types::I16X8) => { - ctx.emit(Inst::gen_move(dst, src, output_ty)); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovsxbw, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovsxbw, RegMem::reg(src), dst)); } (types::I16X8, types::I32X4) => { - ctx.emit(Inst::gen_move(dst, src, output_ty)); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovsxwd, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovsxwd, RegMem::reg(src), dst)); } _ => unreachable!(), }, @@ -2929,7 +2945,7 @@ fn lower_insn_to_regs>( 8, false, )); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovsxbw, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovsxbw, RegMem::from(dst), dst)); } (types::I16X8, types::I32X4) => { ctx.emit(Inst::gen_move(dst, src, output_ty)); @@ -2940,18 +2956,16 @@ fn lower_insn_to_regs>( 8, false, )); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovsxwd, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovsxwd, RegMem::from(dst), dst)); } _ => unreachable!(), }, Opcode::UwidenLow => match (input_ty, output_ty) { (types::I8X16, types::I16X8) => { - ctx.emit(Inst::gen_move(dst, src, output_ty)); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovzxbw, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovzxbw, RegMem::reg(src), dst)); } (types::I16X8, types::I32X4) => { - ctx.emit(Inst::gen_move(dst, src, output_ty)); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovzxwd, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovzxwd, RegMem::reg(src), dst)); } _ => unreachable!(), }, @@ -2965,7 +2979,7 @@ fn lower_insn_to_regs>( 8, false, )); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovzxbw, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovzxbw, RegMem::from(dst), dst)); } (types::I16X8, types::I32X4) => { ctx.emit(Inst::gen_move(dst, src, output_ty)); @@ -2976,7 +2990,7 @@ fn lower_insn_to_regs>( 8, false, )); - ctx.emit(Inst::xmm_rm_r(SseOpcode::Pmovzxwd, RegMem::from(dst), dst)); + ctx.emit(Inst::xmm_mov(SseOpcode::Pmovzxwd, RegMem::from(dst), dst)); } _ => unreachable!(), }, @@ -3264,7 +3278,13 @@ fn lower_insn_to_regs>( | Opcode::Uload16Complex | Opcode::Sload16Complex | Opcode::Uload32Complex - | Opcode::Sload32Complex => { + | Opcode::Sload32Complex + | Opcode::Sload8x8 + | Opcode::Uload8x8 + | Opcode::Sload16x4 + | Opcode::Uload16x4 + | Opcode::Sload32x2 + | Opcode::Uload32x2 => { let offset = ctx.data(insn).load_store_offset().unwrap(); let elem_ty = match op { @@ -3279,6 +3299,18 @@ fn lower_insn_to_regs>( | Opcode::Uload32 | Opcode::Sload32Complex | Opcode::Uload32Complex => types::I32, + Opcode::Sload8x8 + | Opcode::Uload8x8 + | Opcode::Sload8x8Complex + | Opcode::Uload8x8Complex => types::I8X8, + Opcode::Sload16x4 + | Opcode::Uload16x4 + | Opcode::Sload16x4Complex + | Opcode::Uload16x4Complex => types::I16X4, + Opcode::Sload32x2 + | Opcode::Uload32x2 + | Opcode::Sload32x2Complex + | Opcode::Uload32x2Complex => types::I32X2, Opcode::Load | Opcode::LoadComplex => ctx.output_ty(insn, 0), _ => unimplemented!(), }; @@ -3291,7 +3323,13 @@ fn lower_insn_to_regs>( | Opcode::Sload16 | Opcode::Sload16Complex | Opcode::Sload32 - | Opcode::Sload32Complex => true, + | Opcode::Sload32Complex + | Opcode::Sload8x8 + | Opcode::Sload8x8Complex + | Opcode::Sload16x4 + | Opcode::Sload16x4Complex + | Opcode::Sload32x2 + | Opcode::Sload32x2Complex => true, _ => false, }; @@ -3302,7 +3340,13 @@ fn lower_insn_to_regs>( | Opcode::Uload16 | Opcode::Sload16 | Opcode::Uload32 - | Opcode::Sload32 => { + | Opcode::Sload32 + | Opcode::Sload8x8 + | Opcode::Uload8x8 + | Opcode::Sload16x4 + | Opcode::Uload16x4 + | Opcode::Sload32x2 + | Opcode::Uload32x2 => { assert_eq!(inputs.len(), 1, "only one input for load operands"); lower_to_amode(ctx, inputs[0], offset) } @@ -3313,7 +3357,13 @@ fn lower_insn_to_regs>( | Opcode::Uload16Complex | Opcode::Sload16Complex | Opcode::Uload32Complex - | Opcode::Sload32Complex => { + | Opcode::Sload32Complex + | Opcode::Sload8x8Complex + | Opcode::Uload8x8Complex + | Opcode::Sload16x4Complex + | Opcode::Uload16x4Complex + | Opcode::Sload32x2Complex + | Opcode::Uload32x2Complex => { assert_eq!( inputs.len(), 2, @@ -3325,12 +3375,12 @@ fn lower_insn_to_regs>( let flags = ctx.memflags(insn).expect("load should have memflags"); Amode::imm_reg_reg_shift(offset as u32, base, index, shift).with_flags(flags) } - _ => unreachable!(), }; let dst = get_output_reg(ctx, outputs[0]); let is_xmm = elem_ty.is_float() || elem_ty.is_vector(); + match (sign_extend, is_xmm) { (true, false) => { // The load is sign-extended only when the output size is lower than 64 bits, @@ -3350,15 +3400,40 @@ fn lower_insn_to_regs>( ctx.emit(match elem_ty { types::F32 => Inst::xmm_mov(SseOpcode::Movss, RegMem::mem(amode), dst), types::F64 => Inst::xmm_mov(SseOpcode::Movsd, RegMem::mem(amode), dst), + types::I8X8 => { + if sign_extend == true { + Inst::xmm_mov(SseOpcode::Pmovsxbw, RegMem::mem(amode), dst) + } else { + Inst::xmm_mov(SseOpcode::Pmovzxbw, RegMem::mem(amode), dst) + } + } + types::I16X4 => { + if sign_extend == true { + Inst::xmm_mov(SseOpcode::Pmovsxwd, RegMem::mem(amode), dst) + } else { + Inst::xmm_mov(SseOpcode::Pmovzxwd, RegMem::mem(amode), dst) + } + } + types::I32X2 => { + if sign_extend == true { + Inst::xmm_mov(SseOpcode::Pmovsxdq, RegMem::mem(amode), dst) + } else { + Inst::xmm_mov(SseOpcode::Pmovzxdq, RegMem::mem(amode), dst) + } + } _ if elem_ty.is_vector() && elem_ty.bits() == 128 => { Inst::xmm_mov(SseOpcode::Movups, RegMem::mem(amode), dst) - } // TODO Specialize for different types: MOVUPD, MOVDQU - _ => unreachable!("unexpected type for load: {:?}", elem_ty), + } + // TODO Specialize for different types: MOVUPD, MOVDQU + _ => unreachable!( + "unexpected type for load: {:?} - {:?}", + elem_ty, + elem_ty.bits() + ), }); } } } - Opcode::Store | Opcode::Istore8 | Opcode::Istore16 diff --git a/cranelift/codegen/src/isa/x86/unwind.rs b/cranelift/codegen/src/isa/x86/unwind.rs index 717964a287..2eed8b74e4 100644 --- a/cranelift/codegen/src/isa/x86/unwind.rs +++ b/cranelift/codegen/src/isa/x86/unwind.rs @@ -250,7 +250,7 @@ mod tests { use crate::ir::{ types, AbiParam, ExternalName, InstBuilder, Signature, StackSlotData, StackSlotKind, }; - use crate::isa::{lookup, CallConv}; + use crate::isa::{lookup_variant, BackendVariant, CallConv}; use crate::settings::{builder, Flags}; use crate::Context; use std::str::FromStr; @@ -258,7 +258,7 @@ mod tests { #[test] fn test_small_alloc() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -314,7 +314,7 @@ mod tests { #[test] fn test_medium_alloc() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -370,7 +370,7 @@ mod tests { #[test] fn test_large_alloc() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -442,7 +442,7 @@ mod tests { #[test] fn test_multi_return_func() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); diff --git a/cranelift/codegen/src/isa/x86/unwind/systemv.rs b/cranelift/codegen/src/isa/x86/unwind/systemv.rs index 8f112d943a..09778627bb 100644 --- a/cranelift/codegen/src/isa/x86/unwind/systemv.rs +++ b/cranelift/codegen/src/isa/x86/unwind/systemv.rs @@ -134,7 +134,7 @@ mod tests { use crate::ir::{ types, AbiParam, ExternalName, InstBuilder, Signature, StackSlotData, StackSlotKind, }; - use crate::isa::{lookup, CallConv}; + use crate::isa::{lookup_variant, BackendVariant, CallConv}; use crate::settings::{builder, Flags}; use crate::Context; use gimli::write::Address; @@ -143,7 +143,7 @@ mod tests { #[test] fn test_simple_func() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -185,7 +185,7 @@ mod tests { #[test] fn test_multi_return_func() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); diff --git a/cranelift/codegen/src/isa/x86/unwind/winx64.rs b/cranelift/codegen/src/isa/x86/unwind/winx64.rs index e49b2c1ef1..1fe93f9708 100644 --- a/cranelift/codegen/src/isa/x86/unwind/winx64.rs +++ b/cranelift/codegen/src/isa/x86/unwind/winx64.rs @@ -46,7 +46,7 @@ mod tests { use crate::ir::{ExternalName, InstBuilder, Signature, StackSlotData, StackSlotKind}; use crate::isa::unwind::winx64::UnwindCode; use crate::isa::x86::registers::RU; - use crate::isa::{lookup, CallConv}; + use crate::isa::{lookup_variant, BackendVariant, CallConv}; use crate::settings::{builder, Flags}; use crate::Context; use std::str::FromStr; @@ -54,7 +54,7 @@ mod tests { #[test] fn test_wrong_calling_convention() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -70,7 +70,7 @@ mod tests { #[test] fn test_small_alloc() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -127,7 +127,7 @@ mod tests { #[test] fn test_medium_alloc() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); @@ -188,7 +188,7 @@ mod tests { #[test] fn test_large_alloc() { - let isa = lookup(triple!("x86_64")) + let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy) .expect("expect x86 ISA") .finish(Flags::new(builder())); diff --git a/cranelift/filetests/filetests/isa/x86/simd-arithmetic-binemit.clif b/cranelift/filetests/filetests/isa/x86/simd-arithmetic-binemit.clif index 8df5c2afa8..cd942338dd 100644 --- a/cranelift/filetests/filetests/isa/x86/simd-arithmetic-binemit.clif +++ b/cranelift/filetests/filetests/isa/x86/simd-arithmetic-binemit.clif @@ -108,3 +108,9 @@ block0(v0: i64x2 [%xmm3], v1: i64x2 [%xmm5]): [-, %xmm3] v2 = x86_pmuludq v0, v1 ; bin: 66 0f f4 dd return v2 } + +function %pmaddwd(i16x8, i16x8) -> i32x4 { +block0(v0: i16x8 [%xmm8], v1: i16x8 [%xmm9]): +[-, %xmm8] v2 = widening_pairwise_dot_product_s v0, v1 ; bin: 66 45 0f f5 c1 + return v2 +} diff --git a/cranelift/native/src/lib.rs b/cranelift/native/src/lib.rs index 668a1934bf..3bd5716dac 100644 --- a/cranelift/native/src/lib.rs +++ b/cranelift/native/src/lib.rs @@ -34,10 +34,26 @@ use raw_cpuid::CpuId; /// machine, or `Err(())` if the host machine is not supported /// in the current configuration. pub fn builder() -> Result { - let mut isa_builder = isa::lookup(Triple::host()).map_err(|err| match err { - isa::LookupError::SupportDisabled => "support for architecture disabled at compile time", - isa::LookupError::Unsupported => "unsupported architecture", - })?; + builder_with_backend_variant(isa::BackendVariant::Any) +} + +/// Return an `isa` builder configured for the current host +/// machine, or `Err(())` if the host machine is not supported +/// in the current configuration. +/// +/// Selects the given backend variant specifically; this is +/// useful when more than oen backend exists for a given target +/// (e.g., on x86-64). +pub fn builder_with_backend_variant( + variant: isa::BackendVariant, +) -> Result { + let mut isa_builder = + isa::lookup_variant(Triple::host(), variant).map_err(|err| match err { + isa::LookupError::SupportDisabled => { + "support for architecture disabled at compile time" + } + isa::LookupError::Unsupported => "unsupported architecture", + })?; if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { parse_x86_cpuid(&mut isa_builder)?; diff --git a/cranelift/object/src/backend.rs b/cranelift/object/src/backend.rs index 81dd75c4cd..98ab139a2f 100644 --- a/cranelift/object/src/backend.rs +++ b/cranelift/object/src/backend.rs @@ -145,6 +145,18 @@ impl ObjectModule { } } +fn validate_symbol(name: &str) -> ModuleResult<()> { + // null bytes are not allowed in symbol names and will cause the `object` + // crate to panic. Let's return a clean error instead. + if name.contains("\0") { + return Err(ModuleError::Backend(anyhow::anyhow!( + "Symbol {:?} has a null byte, which is disallowed", + name + ))); + } + Ok(()) +} + impl Module for ObjectModule { fn isa(&self) -> &dyn TargetIsa { &*self.isa @@ -160,6 +172,8 @@ impl Module for ObjectModule { linkage: Linkage, signature: &ir::Signature, ) -> ModuleResult { + validate_symbol(name)?; + let (id, decl) = self .declarations .declare_function(name, linkage, signature)?; @@ -194,6 +208,8 @@ impl Module for ObjectModule { writable: bool, tls: bool, ) -> ModuleResult { + validate_symbol(name)?; + let (id, decl) = self .declarations .declare_data(name, linkage, writable, tls)?; diff --git a/cranelift/object/tests/basic.rs b/cranelift/object/tests/basic.rs index 18acae5733..dad2bbca9d 100644 --- a/cranelift/object/tests/basic.rs +++ b/cranelift/object/tests/basic.rs @@ -197,3 +197,46 @@ fn libcall_function() { module.finish(); } + +#[test] +#[should_panic( + expected = "Result::unwrap()` on an `Err` value: Backend(Symbol \"function\\u{0}with\\u{0}nul\\u{0}bytes\" has a null byte, which is disallowed" +)] +fn reject_nul_byte_symbol_for_func() { + let flag_builder = settings::builder(); + let isa_builder = cranelift_codegen::isa::lookup_by_name("x86_64-unknown-linux-gnu").unwrap(); + let isa = isa_builder.finish(settings::Flags::new(flag_builder)); + let mut module = + ObjectModule::new(ObjectBuilder::new(isa, "foo", default_libcall_names()).unwrap()); + + let sig = Signature { + params: vec![], + returns: vec![], + call_conv: CallConv::SystemV, + }; + + let _ = module + .declare_function("function\u{0}with\u{0}nul\u{0}bytes", Linkage::Local, &sig) + .unwrap(); +} + +#[test] +#[should_panic( + expected = "Result::unwrap()` on an `Err` value: Backend(Symbol \"data\\u{0}with\\u{0}nul\\u{0}bytes\" has a null byte, which is disallowed" +)] +fn reject_nul_byte_symbol_for_data() { + let flag_builder = settings::builder(); + let isa_builder = cranelift_codegen::isa::lookup_by_name("x86_64-unknown-linux-gnu").unwrap(); + let isa = isa_builder.finish(settings::Flags::new(flag_builder)); + let mut module = + ObjectModule::new(ObjectBuilder::new(isa, "foo", default_libcall_names()).unwrap()); + + let _ = module + .declare_data( + "data\u{0}with\u{0}nul\u{0}bytes", + Linkage::Local, + /* writable = */ true, + /* tls = */ false, + ) + .unwrap(); +} diff --git a/cranelift/wasm/Cargo.toml b/cranelift/wasm/Cargo.toml index 48e19a9d57..4a37c004d1 100644 --- a/cranelift/wasm/Cargo.toml +++ b/cranelift/wasm/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["webassembly", "wasm"] edition = "2018" [dependencies] -wasmparser = { version = "0.70", default-features = false } +wasmparser = { version = "0.71", default-features = false } cranelift-codegen = { path = "../codegen", version = "0.68.0", default-features = false } cranelift-entity = { path = "../entity", version = "0.68.0" } cranelift-frontend = { path = "../frontend", version = "0.68.0", default-features = false } diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index 2fe171842b..998a0c7417 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -1810,7 +1810,20 @@ pub fn translate_operator( let (a, b) = pop2_with_bitcast(state, I16X8, builder); state.push1(builder.ins().widening_pairwise_dot_product_s(a, b)); } - + Operator::I16x8ExtMulLowI8x16S + | Operator::I16x8ExtMulHighI8x16S + | Operator::I16x8ExtMulLowI8x16U + | Operator::I16x8ExtMulHighI8x16U + | Operator::I32x4ExtMulLowI16x8S + | Operator::I32x4ExtMulHighI16x8S + | Operator::I32x4ExtMulLowI16x8U + | Operator::I32x4ExtMulHighI16x8U + | Operator::I64x2ExtMulLowI32x4S + | Operator::I64x2ExtMulHighI32x4S + | Operator::I64x2ExtMulLowI32x4U + | Operator::I64x2ExtMulHighI32x4U => { + return Err(wasm_unsupported!("proposed simd operator {:?}", op)); + } Operator::ReturnCall { .. } | Operator::ReturnCallIndirect { .. } => { return Err(wasm_unsupported!("proposed tail-call operator {:?}", op)); } diff --git a/crates/bench-api/Cargo.toml b/crates/bench-api/Cargo.toml new file mode 100644 index 0000000000..02dfd986be --- /dev/null +++ b/crates/bench-api/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "wasmtime-bench-api" +version = "0.19.0" +authors = ["The Wasmtime Project Developers"] +description = "Exposes a benchmarking API for the Wasmtime runtime" +license = "Apache-2.0 WITH LLVM-exception" +repository = "https://github.com/bytecodealliance/wasmtime" +readme = "README.md" +edition = "2018" +publish = false + +[lib] +name = "wasmtime_bench_api" +crate-type = ["rlib", "cdylib"] +# The rlib is only included here so that `cargo test` will run. + +[dependencies] +anyhow = "1.0" +wasmtime = { path = "../wasmtime", default-features = false } +wasmtime-wasi = { path = "../wasi" } +wasi-common = { path = "../wasi-common" } + + +[dev-dependencies] +wat = "1.0" diff --git a/crates/bench-api/src/lib.rs b/crates/bench-api/src/lib.rs new file mode 100644 index 0000000000..a2958f09a8 --- /dev/null +++ b/crates/bench-api/src/lib.rs @@ -0,0 +1,248 @@ +//! A C API for benchmarking Wasmtime's WebAssembly compilation, instantiation, +//! and execution. +//! +//! The API expects sequential calls to: +//! +//! - `wasm_bench_create` +//! - `wasm_bench_compile` +//! - `wasm_bench_instantiate` +//! - `wasm_bench_execute` +//! - `wasm_bench_free` +//! +//! You may repeat this sequence of calls multiple times to take multiple +//! measurements of compilation, instantiation, and execution time within a +//! single process. +//! +//! All API calls must happen on the same thread. +//! +//! Functions which return pointers use null as an error value. Function which +//! return `int` use `0` as OK and non-zero as an error value. +//! +//! # Example +//! +//! ``` +//! use wasmtime_bench_api::*; +//! +//! let engine = unsafe { wasm_bench_create() }; +//! assert!(!engine.is_null()); +//! +//! let wasm = wat::parse_bytes(br#" +//! (module +//! (func $bench_start (import "bench" "start")) +//! (func $bench_end (import "bench" "end")) +//! (func $start (export "_start") +//! call $bench_start +//! i32.const 1 +//! i32.const 2 +//! i32.add +//! drop +//! call $bench_end +//! ) +//! ) +//! "#).unwrap(); +//! +//! // Start your compilation timer here. +//! let code = unsafe { wasm_bench_compile(engine, wasm.as_ptr(), wasm.len()) }; +//! // End your compilation timer here. +//! assert_eq!(code, OK); +//! +//! // The Wasm benchmark will expect us to provide functions to start ("bench" +//! // "start") and stop ("bench" "stop") the measurement counters/timers during +//! // execution. +//! extern "C" fn bench_start() { +//! // Start your execution timer here. +//! } +//! extern "C" fn bench_stop() { +//! // End your execution timer here. +//! } +//! +//! // Start your instantiation timer here. +//! let code = unsafe { wasm_bench_instantiate(engine, bench_start, bench_stop) }; +//! // End your instantiation timer here. +//! assert_eq!(code, OK); +//! +//! // No need to start timers for the execution since, by convention, the timer +//! // functions we passed during instantiation will be called by the benchmark +//! // at the appropriate time (before and after the benchmarked section). +//! let code = unsafe { wasm_bench_execute(engine) }; +//! assert_eq!(code, OK); +//! +//! unsafe { +//! wasm_bench_free(engine); +//! } +//! ``` + +use anyhow::{anyhow, Context, Result}; +use std::os::raw::{c_int, c_void}; +use std::slice; +use wasi_common::WasiCtxBuilder; +use wasmtime::{Config, Engine, Instance, Linker, Module, Store}; +use wasmtime_wasi::Wasi; + +pub type ExitCode = c_int; +pub const OK: ExitCode = 0; +pub const ERR: ExitCode = -1; + +/// Exposes a C-compatible way of creating the engine from the bytes of a single +/// Wasm module. +/// +/// This function returns a pointer to a structure that contains the engine's +/// initialized state. +#[no_mangle] +pub extern "C" fn wasm_bench_create() -> *mut c_void { + let state = Box::new(BenchState::new()); + Box::into_raw(state) as _ +} + +/// Free the engine state allocated by this library. +#[no_mangle] +pub extern "C" fn wasm_bench_free(state: *mut c_void) { + assert!(!state.is_null()); + unsafe { + Box::from_raw(state as *mut BenchState); + } +} + +/// Compile the Wasm benchmark module. +#[no_mangle] +pub extern "C" fn wasm_bench_compile( + state: *mut c_void, + wasm_bytes: *const u8, + wasm_bytes_length: usize, +) -> ExitCode { + let state = unsafe { (state as *mut BenchState).as_mut().unwrap() }; + let wasm_bytes = unsafe { slice::from_raw_parts(wasm_bytes, wasm_bytes_length) }; + let result = state.compile(wasm_bytes).context("failed to compile"); + to_exit_code(result) +} + +/// Instantiate the Wasm benchmark module. +#[no_mangle] +pub extern "C" fn wasm_bench_instantiate( + state: *mut c_void, + bench_start: extern "C" fn(), + bench_end: extern "C" fn(), +) -> ExitCode { + let state = unsafe { (state as *mut BenchState).as_mut().unwrap() }; + let result = state + .instantiate(bench_start, bench_end) + .context("failed to instantiate"); + to_exit_code(result) +} + +/// Execute the Wasm benchmark module. +#[no_mangle] +pub extern "C" fn wasm_bench_execute(state: *mut c_void) -> ExitCode { + let state = unsafe { (state as *mut BenchState).as_mut().unwrap() }; + let result = state.execute().context("failed to execute"); + to_exit_code(result) +} + +/// Helper function for converting a Rust result to a C error code. +/// +/// This will print an error indicating some information regarding the failure. +fn to_exit_code(result: impl Into>) -> ExitCode { + match result.into() { + Ok(_) => OK, + Err(error) => { + eprintln!("{:?}", error); + ERR + } + } +} + +/// This structure contains the actual Rust implementation of the state required +/// to manage the Wasmtime engine between calls. +struct BenchState { + engine: Engine, + store: Store, + module: Option, + instance: Option, + did_execute: bool, +} + +impl BenchState { + fn new() -> Self { + let mut config = Config::new(); + config.wasm_simd(true); + // NB: do not configure a code cache. + + let engine = Engine::new(&config); + let store = Store::new(&engine); + Self { + engine, + store, + module: None, + instance: None, + did_execute: false, + } + } + + fn compile(&mut self, bytes: &[u8]) -> Result<()> { + assert!( + self.module.is_none(), + "create a new engine to repeat compilation" + ); + self.module = Some(Module::from_binary(&self.engine, bytes)?); + Ok(()) + } + + fn instantiate( + &mut self, + bench_start: extern "C" fn(), + bench_end: extern "C" fn(), + ) -> Result<()> { + assert!( + self.instance.is_none(), + "create a new engine to repeat instantiation" + ); + let module = self + .module + .as_mut() + .expect("compile the module before instantiating it"); + + let mut linker = Linker::new(&self.store); + + // Import a very restricted WASI environment. + let mut cx = WasiCtxBuilder::new(); + cx.inherit_stdio(); + let cx = cx.build()?; + let wasi = Wasi::new(linker.store(), cx); + wasi.add_to_linker(&mut linker)?; + + // Import the specialized benchmarking functions. + linker.func("bench", "start", move || bench_start())?; + linker.func("bench", "end", move || bench_end())?; + + self.instance = Some(linker.instantiate(&module)?); + Ok(()) + } + + fn execute(&mut self) -> Result<()> { + assert!(!self.did_execute, "create a new engine to repeat execution"); + self.did_execute = true; + + let instance = self + .instance + .as_ref() + .expect("instantiate the module before executing it"); + + let start_func = instance.get_func("_start").expect("a _start function"); + let runnable_func = start_func.get0::<()>()?; + match runnable_func() { + Ok(_) => Ok(()), + Err(trap) => { + // Since _start will likely return by using the system `exit` call, we must + // check the trap code to see if it actually represents a successful exit. + match trap.i32_exit_status() { + Some(0) => Ok(()), + Some(n) => Err(anyhow!("_start exited with a non-zero code: {}", n)), + None => Err(anyhow!( + "executing the benchmark resulted in a trap: {}", + trap + )), + } + } + } + } +} diff --git a/crates/debug/Cargo.toml b/crates/debug/Cargo.toml index f3b5bdede7..c893c9ab13 100644 --- a/crates/debug/Cargo.toml +++ b/crates/debug/Cargo.toml @@ -13,8 +13,8 @@ edition = "2018" [dependencies] gimli = "0.23.0" -wasmparser = "0.70" -object = { version = "0.22.0", default-features = false, features = ["read", "write"] } +wasmparser = "0.71" +object = { version = "0.22.0", default-features = false, features = ["read_core", "elf", "write"] } wasmtime-environ = { path = "../environ", version = "0.21.0" } target-lexicon = { version = "0.11.0", default-features = false } anyhow = "1.0" diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml index 26b0ec0eaf..aa132a340f 100644 --- a/crates/environ/Cargo.toml +++ b/crates/environ/Cargo.toml @@ -16,7 +16,7 @@ anyhow = "1.0" cranelift-codegen = { path = "../../cranelift/codegen", version = "0.68.0", features = ["enable-serde"] } cranelift-entity = { path = "../../cranelift/entity", version = "0.68.0", features = ["enable-serde"] } cranelift-wasm = { path = "../../cranelift/wasm", version = "0.68.0", features = ["enable-serde"] } -wasmparser = "0.70" +wasmparser = "0.71" indexmap = { version = "1.0.2", features = ["serde-1"] } thiserror = "1.0.4" serde = { version = "1.0.94", features = ["derive"] } diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.toml index 7120601b2e..2cc157704a 100644 --- a/crates/fuzzing/Cargo.toml +++ b/crates/fuzzing/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" name = "wasmtime-fuzzing" publish = false version = "0.19.0" +license = "Apache-2.0 WITH LLVM-exception" [dependencies] anyhow = "1.0.22" @@ -12,10 +13,11 @@ arbitrary = { version = "0.4.1", features = ["derive"] } env_logger = "0.8.1" log = "0.4.8" rayon = "1.2.1" -wasmparser = "0.70" +wasmparser = "0.71" wasmprinter = "0.2.17" wasmtime = { path = "../wasmtime" } wasmtime-wast = { path = "../wast" } +wasm-encoder = "0.2" wasm-smith = "0.3.0" wasmi = "0.7.0" diff --git a/crates/fuzzing/src/generators/table_ops.rs b/crates/fuzzing/src/generators/table_ops.rs index 45aaa5b802..adb2373fea 100644 --- a/crates/fuzzing/src/generators/table_ops.rs +++ b/crates/fuzzing/src/generators/table_ops.rs @@ -1,8 +1,11 @@ //! Generating series of `table.get` and `table.set` operations. use arbitrary::Arbitrary; -use std::fmt::Write; use std::ops::Range; +use wasm_encoder::{ + CodeSection, EntityType, Export, ExportSection, Function, FunctionSection, ImportSection, + Instruction, Limits, Module, TableSection, TableType, TypeSection, ValType, +}; /// A description of a Wasm module that makes a series of `externref` table /// operations. @@ -32,7 +35,7 @@ impl TableOps { table_size } - /// Convert this into a WAT string. + /// Serialize this module into a Wasm binary. /// /// The module requires a single import: `(import "" "gc" (func))`. This /// should be a function to trigger GC. @@ -43,32 +46,62 @@ impl TableOps { /// The "run" function is guaranteed to terminate (no loops or recursive /// calls), but is not guaranteed to avoid traps (might access out-of-bounds /// of the table). - pub fn to_wat_string(&self) -> String { - let mut wat = "(module\n".to_string(); + pub fn to_wasm_binary(&self) -> Vec { + let mut module = Module::new(); // Import the GC function. - wat.push_str(" (import \"\" \"gc\" (func))\n"); + let mut imports = ImportSection::new(); + imports.import("", Some("gc"), EntityType::Function(0)); // Define our table. - wat.push_str(" (table $table "); - write!(&mut wat, "{}", self.table_size()).unwrap(); - wat.push_str(" externref)\n"); + let mut tables = TableSection::new(); + tables.table(TableType { + element_type: ValType::ExternRef, + limits: Limits { + min: self.table_size(), + max: None, + }, + }); + + // Encode the types for all functions that we are using. + let mut types = TypeSection::new(); + types.function(vec![], vec![]); // 0: "gc" + let mut params: Vec = Vec::with_capacity(self.num_params() as usize); + for _i in 0..self.num_params() { + params.push(ValType::ExternRef); + } + let results = vec![]; + types.function(params, results); // 1: "run" // Define the "run" function export. - wat.push_str(r#" (func (export "run") (param"#); - for _ in 0..self.num_params() { - wat.push_str(" externref"); - } - wat.push_str(")\n"); - for op in self.ops.iter().take(MAX_OPS) { - wat.push_str(" "); - op.to_wat_string(&mut wat); - wat.push('\n'); - } - wat.push_str(" )\n"); + let mut functions = FunctionSection::new(); + functions.function(1); - wat.push_str(")\n"); - wat + let mut exports = ExportSection::new(); + exports.export("run", Export::Function(1)); + + let mut params: Vec<(u32, ValType)> = Vec::with_capacity(self.num_params() as usize); + for _i in 0..self.num_params() { + params.push((0, ValType::ExternRef)); + } + let mut func = Function::new(params); + + for op in self.ops.iter().take(MAX_OPS) { + op.insert(&mut func); + } + + let mut code = CodeSection::new(); + code.function(&func); + + module + .section(&types) + .section(&imports) + .section(&functions) + .section(&tables) + .section(&exports) + .section(&code); + + module.finish() } } @@ -77,37 +110,34 @@ pub(crate) enum TableOp { // `(call 0)` Gc, // `(drop (table.get x))` - Get(u32), + Get(i32), // `(table.set x (local.get y))` - SetFromParam(u32, u8), + SetFromParam(i32, u32), // `(table.set x (table.get y))` - SetFromGet(u32, u32), + SetFromGet(i32, i32), } impl TableOp { - fn to_wat_string(&self, wat: &mut String) { + fn insert(&self, func: &mut Function) { match self { Self::Gc => { - wat.push_str("(call 0)"); + func.instruction(Instruction::Call(0)); } Self::Get(x) => { - wat.push_str("(drop (table.get $table (i32.const "); - write!(wat, "{}", x).unwrap(); - wat.push_str(")))"); + func.instruction(Instruction::I32Const(*x)); + func.instruction(Instruction::TableGet { table: 0 }); + func.instruction(Instruction::Drop); } Self::SetFromParam(x, y) => { - wat.push_str("(table.set $table (i32.const "); - write!(wat, "{}", x).unwrap(); - wat.push_str(") (local.get "); - write!(wat, "{}", y).unwrap(); - wat.push_str("))"); + func.instruction(Instruction::I32Const(*x)); + func.instruction(Instruction::LocalGet(*y)); + func.instruction(Instruction::TableSet { table: 0 }); } Self::SetFromGet(x, y) => { - wat.push_str("(table.set $table (i32.const "); - write!(wat, "{}", x).unwrap(); - wat.push_str(") (table.get $table (i32.const "); - write!(wat, "{}", y).unwrap(); - wat.push_str(")))"); + func.instruction(Instruction::I32Const(*x)); + func.instruction(Instruction::I32Const(*y)); + func.instruction(Instruction::TableGet { table: 0 }); + func.instruction(Instruction::TableSet { table: 0 }); } } } @@ -132,17 +162,26 @@ mod tests { let expected = r#" (module - (import "" "gc" (func)) - (table $table 10 externref) - (func (export "run") (param externref externref) - (call 0) - (drop (table.get $table (i32.const 0))) - (table.set $table (i32.const 1) (local.get 2)) - (table.set $table (i32.const 3) (table.get $table (i32.const 4))) - ) -) + (type (;0;) (func)) + (type (;1;) (func (param externref externref))) + (import "" "gc" (func (;0;) (type 0))) + (func (;1;) (type 1) (param externref externref) + call 0 + i32.const 0 + table.get 0 + drop + i32.const 1 + local.get 2 + table.set 0 + i32.const 3 + i32.const 4 + table.get 0 + table.set 0) + (table (;0;) 10 externref) + (export "run" (func 1))) "#; - let actual = ops.to_wat_string(); + let actual = ops.to_wasm_binary(); + let actual = wasmprinter::print_bytes(&actual).unwrap(); assert_eq!(actual.trim(), expected.trim()); } } diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs index 9f04dc44df..6581f9e0dc 100644 --- a/crates/fuzzing/src/oracles.rs +++ b/crates/fuzzing/src/oracles.rs @@ -40,17 +40,6 @@ fn log_wasm(wasm: &[u8]) { } } -fn log_wat(wat: &str) { - if !log::log_enabled!(log::Level::Debug) { - return; - } - - let i = CNT.fetch_add(1, SeqCst); - let name = format!("testcase{}.wat", i); - log::debug!("wrote wat file to `{}`", name); - std::fs::write(&name, wat).expect("failed to write wat file"); -} - /// Instantiate the Wasm buffer, and implicitly fail if we have an unexpected /// panic or segfault or anything else that can be detected "passively". /// @@ -418,9 +407,9 @@ pub fn table_ops(config: crate::generators::Config, ops: crate::generators::tabl let engine = Engine::new(&config); let store = Store::new(&engine); - let wat = ops.to_wat_string(); - log_wat(&wat); - let module = match Module::new(&engine, &wat) { + let wasm = ops.to_wasm_binary(); + log_wasm(&wasm); + let module = match Module::new(&engine, &wasm) { Ok(m) => m, Err(_) => return, }; diff --git a/crates/jit/Cargo.toml b/crates/jit/Cargo.toml index c754126d92..7b578543b7 100644 --- a/crates/jit/Cargo.toml +++ b/crates/jit/Cargo.toml @@ -28,7 +28,7 @@ rayon = { version = "1.0", optional = true } region = "2.1.0" thiserror = "1.0.4" target-lexicon = { version = "0.11.0", default-features = false } -wasmparser = "0.70" +wasmparser = "0.71" more-asserts = "0.2.1" anyhow = "1.0" cfg-if = "1.0" diff --git a/crates/lightbeam/Cargo.toml b/crates/lightbeam/Cargo.toml index d178090cfa..65ad3ba751 100644 --- a/crates/lightbeam/Cargo.toml +++ b/crates/lightbeam/Cargo.toml @@ -24,7 +24,7 @@ more-asserts = "0.2.1" smallvec = "1.0.0" thiserror = "1.0.9" typemap = "0.3" -wasmparser = "0.70" +wasmparser = "0.71" [dev-dependencies] lazy_static = "1.2" diff --git a/crates/lightbeam/wasmtime/Cargo.toml b/crates/lightbeam/wasmtime/Cargo.toml index 41b47115ee..51b0900b50 100644 --- a/crates/lightbeam/wasmtime/Cargo.toml +++ b/crates/lightbeam/wasmtime/Cargo.toml @@ -13,6 +13,6 @@ edition = "2018" [dependencies] lightbeam = { path = "..", version = "0.21.0" } -wasmparser = "0.70" +wasmparser = "0.71" cranelift-codegen = { path = "../../../cranelift/codegen", version = "0.68.0" } wasmtime-environ = { path = "../../environ", version = "0.21.0" } diff --git a/crates/profiling/src/jitdump_linux.rs b/crates/profiling/src/jitdump_linux.rs index e16978843f..ef6684c95f 100644 --- a/crates/profiling/src/jitdump_linux.rs +++ b/crates/profiling/src/jitdump_linux.rs @@ -249,11 +249,7 @@ impl State { let header = FileHeader { timestamp: self.get_time_stamp(), e_machine: self.get_e_machine(), - magic: if cfg!(target_endian = "little") { - 0x4A695444 - } else { - 0x4454694a - }, + magic: 0x4A695444, version: 1, size: mem::size_of::() as u32, pad1: 0, diff --git a/crates/test-programs/Cargo.toml b/crates/test-programs/Cargo.toml index b1f8e6ac40..b3eb67c6d2 100644 --- a/crates/test-programs/Cargo.toml +++ b/crates/test-programs/Cargo.toml @@ -5,6 +5,7 @@ authors = ["The Wasmtime Project Developers"] readme = "README.md" edition = "2018" publish = false +license = "Apache-2.0 WITH LLVM-exception" [build-dependencies] cfg-if = "1.0" diff --git a/crates/wasi-common/src/sys/stdio.rs b/crates/wasi-common/src/sys/stdio.rs index 97005767d4..9ac6d6c9ca 100644 --- a/crates/wasi-common/src/sys/stdio.rs +++ b/crates/wasi-common/src/sys/stdio.rs @@ -17,7 +17,7 @@ // TODO it might worth re-investigating the suitability of this type on Windows. use super::{fd, AsFile}; -use crate::handle::{Fdflags, Filetype, Handle, HandleRights, Rights, RightsExt, Size}; +use crate::handle::{Fdflags, Filestat, Filetype, Handle, HandleRights, Rights, RightsExt, Size}; use crate::sandboxed_tty_writer::SandboxedTTYWriter; use crate::{Error, Result}; use std::any::Any; @@ -65,6 +65,9 @@ impl Handle for Stdin { } Ok(()) } + fn filestat_get(&self) -> Result { + fd::filestat_get(&*self.as_file()?) + } fn read_vectored(&self, iovs: &mut [io::IoSliceMut]) -> Result { let nread = io::stdin().read_vectored(iovs)?; Ok(nread) @@ -111,6 +114,9 @@ impl Handle for Stdout { } Ok(()) } + fn filestat_get(&self) -> Result { + fd::filestat_get(&*self.as_file()?) + } fn write_vectored(&self, iovs: &[io::IoSlice]) -> Result { // lock for the duration of the scope let stdout = io::stdout(); @@ -165,6 +171,9 @@ impl Handle for Stderr { } Ok(()) } + fn filestat_get(&self) -> Result { + fd::filestat_get(&*self.as_file()?) + } fn write_vectored(&self, iovs: &[io::IoSlice]) -> Result { // Always sanitize stderr, even if it's not directly connected to a tty, // because stderr is meant for diagnostics rather than binary output, diff --git a/crates/wasi-common/src/sys/unix/mod.rs b/crates/wasi-common/src/sys/unix/mod.rs index 7135486ec2..84d8ec581e 100644 --- a/crates/wasi-common/src/sys/unix/mod.rs +++ b/crates/wasi-common/src/sys/unix/mod.rs @@ -9,7 +9,8 @@ pub(crate) mod poll; pub(crate) mod stdio; cfg_if::cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(any(target_os = "linux", + target_os = "android"))] { mod linux; use linux as sys_impl; } else if #[cfg(target_os = "emscripten")] { diff --git a/crates/wasi-common/yanix/src/dir.rs b/crates/wasi-common/yanix/src/dir.rs index 50166a35b1..8e6c70a40f 100644 --- a/crates/wasi-common/yanix/src/dir.rs +++ b/crates/wasi-common/yanix/src/dir.rs @@ -36,9 +36,15 @@ impl Dir { } /// Set the position of the directory stream, see `seekdir(3)`. - #[cfg(not(target_os = "android"))] pub fn seek(&mut self, loc: SeekLoc) { - unsafe { libc::seekdir(self.0.as_ptr(), loc.0) } + // https://github.com/rust-lang/libc/pull/1996 + #[cfg(not(target_os = "android"))] + use libc::seekdir; + #[cfg(target_os = "android")] + extern "C" { + fn seekdir(dirp: *mut libc::DIR, loc: libc::c_long); + } + unsafe { seekdir(self.0.as_ptr(), loc.0) } } /// Reset directory stream, see `rewinddir(3)`. @@ -50,10 +56,16 @@ impl Dir { /// /// If this location is given to `Dir::seek`, the entries up to the previously returned /// will be omitted and the iteration will start from the currently pending directory entry. - #[cfg(not(target_os = "android"))] #[allow(dead_code)] pub fn tell(&self) -> SeekLoc { - let loc = unsafe { libc::telldir(self.0.as_ptr()) }; + #[cfg(not(target_os = "android"))] + use libc::telldir; + #[cfg(target_os = "android")] + extern "C" { + fn telldir(dirp: *mut libc::DIR) -> libc::c_long; + } + // https://github.com/rust-lang/libc/pull/1996 + let loc = unsafe { telldir(self.0.as_ptr()) }; SeekLoc(loc) } @@ -93,11 +105,9 @@ impl Entry { } } -#[cfg(not(target_os = "android"))] #[derive(Clone, Copy, Debug)] pub struct SeekLoc(pub(crate) libc::c_long); -#[cfg(not(target_os = "android"))] impl SeekLoc { pub fn to_raw(&self) -> i64 { self.0.into() diff --git a/crates/wasi-common/yanix/src/file.rs b/crates/wasi-common/yanix/src/file.rs index 1764d29120..62af1c9d77 100644 --- a/crates/wasi-common/yanix/src/file.rs +++ b/crates/wasi-common/yanix/src/file.rs @@ -90,11 +90,26 @@ bitflags! { const WRONLY = libc::O_WRONLY; const RDWR = libc::O_RDWR; #[cfg(any(target_os = "linux", + target_os = "android", target_os = "netbsd", target_os = "openbsd", target_os = "wasi", target_os = "emscripten"))] - const RSYNC = libc::O_RSYNC; + const RSYNC = { + // Have to use cfg_if: https://github.com/bitflags/bitflags/issues/137 + cfg_if! { + if #[cfg(any(target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "wasi", + target_os = "emscripten"))] { + libc::O_RSYNC + } else if #[cfg(target_os = "android")] { + // Android defines O_RSYNC as O_SYNC + libc::O_SYNC + } + } + }; const SYNC = libc::O_SYNC; const TRUNC = libc::O_TRUNC; #[cfg(any(target_os = "linux", diff --git a/crates/wasi-common/yanix/src/sys/linux/filetime.rs b/crates/wasi-common/yanix/src/sys/linux/filetime.rs index 3c4cdfa9f6..34faefc6d6 100644 --- a/crates/wasi-common/yanix/src/sys/linux/filetime.rs +++ b/crates/wasi-common/yanix/src/sys/linux/filetime.rs @@ -53,5 +53,8 @@ pub fn utimensat( return Err(err); } - super::utimesat::utimesat(dirfd, path, atime, mtime, symlink_nofollow) + #[cfg(not(target_os = "android"))] + return super::utimesat::utimesat(dirfd, path, atime, mtime, symlink_nofollow); + #[cfg(target_os = "android")] + unreachable!(); } diff --git a/crates/wasi-common/yanix/src/sys/linux/mod.rs b/crates/wasi-common/yanix/src/sys/linux/mod.rs index 26432d36dd..37d8a0a8af 100644 --- a/crates/wasi-common/yanix/src/sys/linux/mod.rs +++ b/crates/wasi-common/yanix/src/sys/linux/mod.rs @@ -2,4 +2,5 @@ pub(crate) mod dir; pub(crate) mod fadvise; pub(crate) mod file; pub(crate) mod filetime; +#[cfg(not(target_os = "android"))] pub(crate) mod utimesat; diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 1fa4f012f4..9f22c01c40 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -16,7 +16,7 @@ wasmtime-jit = { path = "../jit", version = "0.21.0" } wasmtime-cache = { path = "../cache", version = "0.21.0", optional = true } wasmtime-profiling = { path = "../profiling", version = "0.21.0" } target-lexicon = { version = "0.11.0", default-features = false } -wasmparser = "0.70" +wasmparser = "0.71" anyhow = "1.0.19" region = "2.2.0" libc = "0.2" diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000000..37e5a3a0f8 --- /dev/null +++ b/deny.toml @@ -0,0 +1,45 @@ +# Documentation for this configuration file can be found here +# https://embarkstudios.github.io/cargo-deny/checks/cfg.html + +targets = [ + { triple = "x86_64-unknown-linux-gnu" }, + { triple = "x86_64-apple-darwin" }, + { triple = "x86_64-pc-windows-msvc" }, + { triple = "aarch64-linux-android" }, +] + +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html +[advisories] +vulnerability = "deny" +unmaintained = "deny" +yanked = "deny" +ignore = [ +] + +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html +[licenses] +allow = [ + "Apache-2.0 WITH LLVM-exception", + "Apache-2.0", + "BSD-2-Clause", + "CC0-1.0", + "MIT", + "MPL-2.0", + "Zlib", +] + +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +multiple-versions = "deny" +wildcards = "allow" +deny = [] + +# Skip some multiple-versions checks, until they can be fixed. +skip = [ + { name = "ansi_term" }, # transitive dependencies only + { name = "cfg-if" }, # transitive dependencies use 0.1 + { name = "env_logger" }, # pretty_env_logger and file-per-thread-logger depend on 0.7 + { name = "humantime" }, # caused by env_logger + { name = "getrandom" }, # rand not updates to 0.2 yet + { name = "wast" }, # old one pulled in by witx +] diff --git a/docs/WASI-tutorial.md b/docs/WASI-tutorial.md index 2c5cc84bba..8a01ce5f19 100644 --- a/docs/WASI-tutorial.md +++ b/docs/WASI-tutorial.md @@ -121,14 +121,14 @@ use std::io::{Read, Write}; fn process(input_fname: &str, output_fname: &str) -> Result<(), String> { let mut input_file = - fs::File::open(input_fname).map_err(|err| format!("error opening input: {}", err))?; + fs::File::open(input_fname).map_err(|err| format!("error opening input {}: {}", input_fname, err))?; let mut contents = Vec::new(); input_file .read_to_end(&mut contents) .map_err(|err| format!("read error: {}", err))?; let mut output_file = fs::File::create(output_fname) - .map_err(|err| format!("error opening output '{}': {}", output_fname, err))?; + .map_err(|err| format!("error opening output {}: {}", output_fname, err))?; output_file .write_all(&contents) .map_err(|err| format!("write error: {}", err)) @@ -139,7 +139,7 @@ fn main() { let program = args[0].clone(); if args.len() < 3 { - eprintln!("{} ", program); + eprintln!("usage: {} ", program); return; } diff --git a/src/lib.rs b/src/lib.rs index b7eaaa8a09..39bda21f66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,6 +127,10 @@ struct CommonOptions { #[structopt(long)] enable_multi_memory: bool, + /// Enable support for the module-linking proposal + #[structopt(long)] + enable_module_linking: bool, + /// Enable all experimental Wasm features #[structopt(long)] enable_all: bool, @@ -198,6 +202,7 @@ impl CommonOptions { .wasm_multi_value(self.enable_multi_value.unwrap_or(true) || self.enable_all) .wasm_threads(self.enable_threads || self.enable_all) .wasm_multi_memory(self.enable_multi_memory || self.enable_all) + .wasm_module_linking(self.enable_module_linking || self.enable_all) .cranelift_opt_level(self.opt_level()) .strategy(pick_compilation_strategy(self.cranelift, self.lightbeam)?)? .profiler(pick_profiling_strategy(self.jitdump, self.vtune)?)?