diff --git a/.github/cross-linux-riscv64/Dockerfile b/.github/cross-linux-riscv64/Dockerfile index 0ff67fa7bd4..47af4ee98fb 100644 --- a/.github/cross-linux-riscv64/Dockerfile +++ b/.github/cross-linux-riscv64/Dockerfile @@ -28,7 +28,7 @@ RUN apt-get update && \ # install rust tools RUN curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" -RUN rustup -v toolchain install 1.79 +RUN rustup -v toolchain install 1.81 # add docker the manual way COPY install_docker.sh / RUN /install_docker.sh @@ -61,7 +61,7 @@ ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc RUST_TEST_THREADS=1 \ PKG_CONFIG_PATH="/usr/lib/riscv64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" -RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.79-x86_64-unknown-linux-gnu +RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.81-x86_64-unknown-linux-gnu #compile libssl-dev for riscv64! COPY build_openssl.sh / diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 13886359670..903deeb0a5e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -249,7 +249,7 @@ jobs: }, { key: v8, - build-cmd: 'make test-wasmi-v8', + build-cmd: 'make test-v8-api', name: 'Test API for v8 feature' } @@ -271,12 +271,36 @@ jobs: container: ${{ matrix.metadata.container }} steps: - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ env.MSRV }} + - name: Install Nextest uses: taiki-e/install-action@nextest + - name: Install `ninja` on Ubuntu + if: startsWith(matrix.metadata.build, 'linux-') + shell: bash + run: | + sudo apt-get install ninja-build -y + + - name: Install `ninja` on macOS + if: startsWith(matrix.metadata.build, 'macos-') + shell: bash + run: | + brew install ninja + + - name: Install `ninja` on Windows + if: startsWith(matrix.metadata.build, 'windows-') + shell: bash + run: | + choco install ninja + + - name: Setup MSVC (Windows) + uses: ilammy/msvc-dev-cmd@v1 + if: matrix.metadata.build == 'windows-x64' + - name: Test WAMR API if: ${{ matrix.build-what.key == 'wamr' }} run: ${{ matrix.build-what.build-cmd }} @@ -286,7 +310,7 @@ jobs: run: ${{ matrix.build-what.build-cmd }} - name: Test v8 API - if: ${{ matrix.build-what.key == 'wasmi' }} + if: ${{ matrix.build-what.key == 'v8' }} run: ${{ matrix.build-what.build-cmd }} test_build_docs_rs: @@ -299,6 +323,12 @@ jobs: toolchain: "nightly-2024-08-21" target: x86_64-unknown-linux-gnu - run: cargo install toml-cli # toml-cli is required to run `make test-build-docs-rs` + + - name: Install `ninja` on Ubuntu + shell: bash + run: | + sudo apt-get install ninja-build -y + - name: Install LLVM 18 run: | curl --proto '=https' --tlsv1.2 -sSf https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz -L -o llvm.tar.xz diff --git a/.gitmodules b/.gitmodules index 573fd1a6a10..a30cb090f4c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/api/third_party/wamr"] path = lib/api/third_party/wamr url = https://github.com/bytecodealliance/wasm-micro-runtime +[submodule "lib/api/third_party/v8-cmake"] + path = lib/api/third_party/v8-cmake + url = https://github.com/laper32/v8-cmake diff --git a/Cargo.lock b/Cargo.lock index 16b5b02dedc..f4a33d79c1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.7.8" @@ -363,16 +374,14 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.69.4" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", "itertools 0.12.1", - "lazy_static", - "lazycell", "log 0.4.22", "prettyplease", "proc-macro2", @@ -381,7 +390,6 @@ dependencies = [ "rustc-hash 1.1.0", "shlex", "syn 2.0.74", - "which", ] [[package]] @@ -396,18 +404,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "blake3" version = "1.5.3" @@ -479,8 +475,20 @@ version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "bytecheck_derive 0.6.12", + "ptr_meta 0.1.4", + "simdutf8", +] + +[[package]] +name = "bytecheck" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c8f430744b23b54ad15161fcbc22d82a29b73eacbe425fea23ec822600bc6f" +dependencies = [ + "bytecheck_derive 0.8.0", + "ptr_meta 0.3.0", + "rancor", "simdutf8", ] @@ -495,6 +503,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "bytecheck_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523363cbe1df49b68215efdf500b103ac3b0fb4836aed6d15689a076eadb8fff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + [[package]] name = "byteorder" version = "1.5.0" @@ -529,6 +548,27 @@ dependencies = [ "serde", ] +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "camino" version = "1.1.7" @@ -1034,6 +1074,21 @@ dependencies = [ "build_const", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -1381,6 +1436,12 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +[[package]] +name = "deflate64" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" + [[package]] name = "deranged" version = "0.3.11" @@ -1921,12 +1982,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "fuse" version = "0.3.1" @@ -1963,9 +2018,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1973,9 +2028,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" @@ -1990,15 +2045,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -2007,21 +2062,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -2366,15 +2421,6 @@ dependencies = [ "digest", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "0.2.12" @@ -2869,12 +2915,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "leb128" version = "0.2.5" @@ -3088,7 +3128,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aba8ecb0450dfabce4ad72085eed0a75dffe8f21f7ada05638564ea9db2d7fb1" dependencies = [ "byteorder", - "crc", + "crc 1.8.1", +] + +[[package]] +name = "lzma-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" +dependencies = [ + "byteorder", + "crc 3.2.1", ] [[package]] @@ -3352,6 +3402,26 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "685a9ac4b61f4e728e1d2c6a7844609c16527aeb5e6c865915c08e619c16410f" +[[package]] +name = "munge" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64142d38c84badf60abf06ff9bd80ad2174306a5b11bd4706535090a30a419df" +dependencies = [ + "munge_macro", +] + +[[package]] +name = "munge_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb5c1d8184f13f7d0ccbeeca0def2f9a181bce2624302793005f5ca8aa62e5e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + [[package]] name = "native-tls" version = "0.2.12" @@ -4001,7 +4071,16 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" dependencies = [ - "ptr_meta_derive", + "ptr_meta_derive 0.1.4", +] + +[[package]] +name = "ptr_meta" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9e76f66d3f9606f44e45598d155cb13ecf09f4a28199e48daf8c8fc937ea90" +dependencies = [ + "ptr_meta_derive 0.3.0", ] [[package]] @@ -4015,6 +4094,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ptr_meta_derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + [[package]] name = "pulldown-cmark" version = "0.8.0" @@ -4090,10 +4180,13 @@ dependencies = [ ] [[package]] -name = "radium" -version = "0.7.0" +name = "rancor" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +dependencies = [ + "ptr_meta 0.3.0", +] [[package]] name = "rand" @@ -4277,11 +4370,11 @@ dependencies = [ [[package]] name = "rend" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +checksum = "a31c1f1959e4db12c985c0283656be0925f1539549db1e47c4bd0b8b599e1ef7" dependencies = [ - "bytecheck", + "bytecheck 0.8.0", ] [[package]] @@ -4358,32 +4451,32 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.44" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +checksum = "395027076c569819ea6035ee62e664f5e03d74e281744f55261dd1afd939212b" dependencies = [ - "bitvec", - "bytecheck", + "bytecheck 0.8.0", "bytes 1.7.1", - "hashbrown 0.12.3", - "indexmap 1.9.3", - "ptr_meta", + "hashbrown 0.14.5", + "indexmap 2.4.0", + "munge", + "ptr_meta 0.3.0", + "rancor", "rend", "rkyv_derive", - "seahash", "tinyvec", "uuid", ] [[package]] name = "rkyv_derive" -version = "0.7.44" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +checksum = "09cb82b74b4810f07e460852c32f522e979787691b0b7b7439fe473e49d49b2f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.74", ] [[package]] @@ -4756,12 +4849,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "security-framework" version = "2.11.1" @@ -5251,12 +5338,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tar" version = "0.4.41" @@ -6480,7 +6561,7 @@ dependencies = [ "async-trait", "base64 0.21.7", "bincode", - "bytecheck", + "bytecheck 0.6.12", "bytes 1.7.1", "derivative", "futures-util", @@ -6875,6 +6956,7 @@ dependencies = [ "tempfile", "thiserror", "tracing", + "ureq", "wasm-bindgen", "wasm-bindgen-test", "wasmer-compiler", @@ -6888,6 +6970,7 @@ dependencies = [ "wasmparser 0.216.0", "wat", "windows-sys 0.59.0", + "zip", ] [[package]] @@ -7376,7 +7459,7 @@ dependencies = [ "async-trait", "base64 0.21.7", "bincode", - "bytecheck", + "bytecheck 0.6.12", "bytes 1.7.1", "derivative", "lz4_flex", @@ -7434,7 +7517,7 @@ dependencies = [ "indicatif", "lazy_static", "log 0.4.22", - "lzma-rs", + "lzma-rs 0.2.0", "minisign", "pretty_assertions", "rand", @@ -7493,12 +7576,12 @@ dependencies = [ name = "wasmer-types" version = "4.3.7" dependencies = [ - "bytecheck", + "bytecheck 0.6.12", "enum-iterator", "enumset", "getrandom", "hex", - "indexmap 1.9.3", + "indexmap 2.4.0", "memoffset 0.9.1", "more-asserts", "rkyv", @@ -7523,7 +7606,7 @@ dependencies = [ "derivative", "enum-iterator", "fnv", - "indexmap 1.9.3", + "indexmap 2.4.0", "lazy_static", "libc", "mach2", @@ -7548,7 +7631,7 @@ dependencies = [ "base64 0.21.7", "bincode", "blake3", - "bytecheck", + "bytecheck 0.6.12", "bytes 1.7.1", "cfg-if 1.0.0", "chrono", @@ -7692,6 +7775,7 @@ dependencies = [ "crossbeam-queue 0.3.11", "glob", "lazy_static", + "reqwest", "rustc_version 0.4.0", "serial_test", "tempfile", @@ -7717,9 +7801,9 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.37.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b86f2293bfa33e392bb06392846d7cbda4b2dd6175c3e3de6005439a0c481a0" +checksum = "b07e84e3bcdab2f4301827623260ada2557596ca462f7470b60f5182a25270b1" dependencies = [ "arrayvec 0.7.4", "multi-stash", @@ -7733,9 +7817,9 @@ dependencies = [ [[package]] name = "wasmi_c_api_impl" -version = "0.37.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de5f36cf2ed39fe9a063fd2bd7302758999d8f49c3574ca17a3749d92132ffa" +checksum = "3cf549ed7d6488b41acb6950afb07bd84be1cf655ae50b4bc2f24f1b30aba554" dependencies = [ "wasmi", "wasmi_c_api_macros", @@ -7743,9 +7827,9 @@ dependencies = [ [[package]] name = "wasmi_c_api_macros" -version = "0.37.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4b876c940d1989c0e98b5e1c871afece98e9e43a2fc2d1b03f1f5ecf424fda7" +checksum = "f96d000c5be4f27470f7d89550aef550ffd971273469a35fa01216f165528c57" dependencies = [ "proc-macro2", "quote", @@ -7753,9 +7837,9 @@ dependencies = [ [[package]] name = "wasmi_collections" -version = "0.37.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e092d1164284a49206258cca7294c806517676ec4d7c80bffeafc11000df7e5" +checksum = "0d0fd5f4f2c4fe0c98554bb7293108ed2b1d0c124dce0974f999de7d517d37bc" dependencies = [ "ahash 0.8.11", "hashbrown 0.14.5", @@ -7764,9 +7848,9 @@ dependencies = [ [[package]] name = "wasmi_core" -version = "0.37.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f6fe14a130901f6f1414d6da4e3791db55445a0329bf4363994a936d677078" +checksum = "76a5f7bbd933a0fb3bac6c541f8bd90c0c8adcd91bb3ac088a2088995325b3d9" dependencies = [ "downcast-rs", "libm", @@ -7776,9 +7860,9 @@ dependencies = [ [[package]] name = "wasmi_ir" -version = "0.37.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06cd31d091e8fb80919f7b6526b4778ba49b5c7ee2fd021de5e7617d0a7d7ead" +checksum = "5a3345445247388df2b5b35250a30c9209c27c8d2c6db1bf4c89b65636264bf9" dependencies = [ "wasmi_core", ] @@ -7979,18 +8063,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "whoami" version = "1.5.1" @@ -8283,15 +8355,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "xattr" version = "1.3.1" @@ -8356,22 +8419,48 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] [[package]] name = "zip" -version = "2.1.6" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" +checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" dependencies = [ + "aes", "arbitrary", + "bzip2", + "constant_time_eq", "crc32fast", "crossbeam-utils 0.8.20", + "deflate64", "displaydoc", "flate2", + "hmac", "indexmap 2.4.0", + "lzma-rs 0.3.0", "memchr", + "pbkdf2", + "rand", + "sha1", "thiserror", + "time 0.3.36", + "zeroize", "zopfli", + "zstd", ] [[package]] @@ -8387,3 +8476,31 @@ dependencies = [ "once_cell", "simd-adler32", ] + +[[package]] +name = "zstd" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.13+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index 0334e6128f2..b7a9b315356 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -108,13 +108,14 @@ memoffset = "0.9.0" wasmparser = { version = "0.216.0", default-features = false, features = [ "validate", ] } -rkyv = { version = "0.7.40", features = ["indexmap", "validation", "strict"] } +rkyv = { version = "0.8.8", features = ["indexmap-2", "bytes-1"] } memmap2 = { version = "0.6.2" } toml = { version = "0.5.9", features = ["preserve_order"] } indexmap = "2" serde_yaml = "0.9.34" libc = { version = "^0.2", default-features = false } gimli = { version = "0.28.1" } +futures-util = { version = "0.3.31" } [build-dependencies] test-generator = { path = "tests/lib/test-generator" } @@ -147,6 +148,7 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [ "env-filter", "fmt", ] } +reqwest.workspace = true [features] # Don't add the compiler features in default, please add them on the Makefile @@ -220,6 +222,10 @@ opt-level = 3 [profile.dev.package.digest] opt-level = 3 +[[bench]] +name = "deserialize_modules" +harness = false + [[bench]] name = "static_and_dynamic_functions" harness = false diff --git a/benches/deserialize_modules.rs b/benches/deserialize_modules.rs new file mode 100644 index 00000000000..1c45e87527d --- /dev/null +++ b/benches/deserialize_modules.rs @@ -0,0 +1,97 @@ +use criterion::{criterion_group, criterion_main, Criterion}; + +use wasmer::*; + +static BENCHMARKS_ARTIFACTS_BASE_URL: &str = "https://pub-53a226d993e144159d6f8b993fe0cbf3.r2.dev"; + +pub fn serialize_deserialize(c: &mut Criterion, small: &[u8], medium: &[u8], large: &[u8]) { + let engine = Engine::default(); + + c.bench_function(&format!("rkyv_from-binary_small"), |b| { + b.iter(|| { + let module = Module::from_binary(&engine, small); + assert!(module.is_ok()); + drop(module); + }) + }); + + c.bench_function(&format!("rkyv_from-binary_medium"), |b| { + b.iter(|| { + let module = Module::from_binary(&engine, medium); + assert!(module.is_ok()); + drop(module); + }) + }); + + c.bench_function(&format!("rkyv_from-binary_large"), |b| { + b.iter(|| { + let module = Module::from_binary(&engine, large); + assert!(module.is_ok()); + drop(module); + }) + }); +} + +pub fn serialize_deserialize_unchecked( + c: &mut Criterion, + small: &[u8], + medium: &[u8], + large: &[u8], +) { + let engine = Engine::default(); + + c.bench_function(&format!("rkyv_from-binary-unchecked_small"), |b| { + b.iter(|| unsafe { + let module = Module::from_binary_unchecked(&engine, small); + assert!(module.is_ok()); + drop(module); + }) + }); + + c.bench_function(&format!("rkyv_from-binary-unchecked_medium"), |b| { + b.iter(|| unsafe { + let module = Module::from_binary_unchecked(&engine, medium); + assert!(module.is_ok()); + drop(module); + }) + }); + + c.bench_function(&format!("rkyv_from-binary-unchecked_large"), |b| { + b.iter(|| unsafe { + let module = Module::from_binary_unchecked(&engine, large); + assert!(module.is_ok()); + drop(module); + }) + }); +} + +pub fn download_and_run(c: &mut Criterion) { + let small = reqwest::blocking::get(BENCHMARKS_ARTIFACTS_BASE_URL.to_owned() + "/small.wasm") + .unwrap() + .bytes() + .unwrap(); + + let medium = reqwest::blocking::get(BENCHMARKS_ARTIFACTS_BASE_URL.to_owned() + "/medium.wasm") + .unwrap() + .bytes() + .unwrap(); + + let large = reqwest::blocking::get(BENCHMARKS_ARTIFACTS_BASE_URL.to_owned() + "/large.wasm") + .unwrap() + .bytes() + .unwrap(); + + let small = small.as_ref(); + let medium = medium.as_ref(); + let large = large.as_ref(); + serialize_deserialize(c, small, medium, large); + serialize_deserialize_unchecked(c, small, medium, large); +} + +criterion_group!( + name = benches; + config = Criterion::default().sample_size(60); + targets = download_and_run +); + +criterion_main!(benches); diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index 2e1f5b41dca..bc837ab74bd 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -37,7 +37,7 @@ tracing = { version = "0.1" } wat = { version = "=1.216.0", optional = true } rustc-demangle = "0.1" shared-buffer = { workspace = true } -wasmi_c_api = { version = "0.37.1", package = "wasmi_c_api_impl", optional = true } +wasmi_c_api = { version = "0.38.0", package = "wasmi_c_api_impl", optional = true } seq-macro = {version = "0.3.5", optional = true} # Dependencies and Development Dependencies for `sys`. @@ -148,8 +148,10 @@ static-artifact-load = ["wasmer-compiler/static-artifact-load"] static-artifact-create = ["wasmer-compiler/static-artifact-create"] [build-dependencies] -bindgen = "0.69.4" +bindgen = "0.70.1" cmake = "0.1.50" +ureq = "2.10.1" +zip = "2.2.0" [package.metadata.docs.rs] features = [ diff --git a/lib/api/build.rs b/lib/api/build.rs index 5351238438f..2307becc746 100644 --- a/lib/api/build.rs +++ b/lib/api/build.rs @@ -1,28 +1,64 @@ fn main() { #[cfg(feature = "wamr")] { + const WAMR_ZIP: &str = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-2.1.0.zip"; + const WAMR_DIR: &str = "wasm-micro-runtime-WAMR-2.1.0"; + use cmake::Config; use std::{env, path::PathBuf}; let crate_root = env::var("CARGO_MANIFEST_DIR").unwrap(); - let wamr_dir = PathBuf::from(&crate_root).join("third_party").join("wamr"); - - let mut fetch_submodules = std::process::Command::new("git"); - fetch_submodules - .current_dir(crate_root) - .arg("submodule") - .arg("update") - .arg("--init"); - let res = fetch_submodules.output(); - - if let Err(e) = res { - panic!("fetching submodules failed: {e}"); - } - - let dst = Config::new(wamr_dir.clone()) - .always_configure(true) - .generator("Unix Makefiles") + // Read target os from cargo env + // Transform from cargo value to valid wasm-micro-runtime os + let target_os = match env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() { + "linux" => "linux", + "windows" => "windows", + "macos" => "darwin", + "freebsd" => "freebsd", + "android" => "android", + "ios" => "ios", + other => panic!("Unsupported CARGO_CFG_TARGET_OS: {}", other), + }; + + // Read target arch from cargo env + // Transform from cargo value to valid wasm-micro-runtime WAMR_BUILD_TARGET + let target_arch = match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() { + "x86" => "X86_32", + "x86_64" => "X86_64", + "arm" => "ARM", + "aarch64" => "AARCH64", + "mips" => "MIPS", + "powerpc" => "POWERPC", + "powerpc64" => "POWERPC64", + other => panic!("Unsupported CARGO_CFG_TARGET_ARCH: {}", other), + }; + + // Cleanup tmp data from prior builds + let wamr_dir = PathBuf::from(&crate_root).join("third_party/wamr"); + let zip_dir = PathBuf::from(&crate_root).join(WAMR_DIR); + let _ = std::fs::remove_dir_all(&wamr_dir); + let _ = std::fs::remove_dir_all(&zip_dir); + + // Fetch & extract wasm-micro-runtime source + let zip = ureq::get(WAMR_ZIP).call().expect("failed to download wamr"); + let mut zip_data = Vec::new(); + zip.into_reader() + .read_to_end(&mut zip_data) + .expect("failed to download wamr"); + zip::read::ZipArchive::new(std::io::Cursor::new(zip_data)) + .expect("failed to open wamr zip file") + .extract(&crate_root) + .expect("failed to extract wamr zip file"); + let _ = std::fs::remove_dir_all(&wamr_dir); + std::fs::rename(zip_dir, &wamr_dir).expect("failed to rename wamr dir"); + + let wamr_platform_dir = wamr_dir.join("product-mini/platforms").join(target_os); + let mut dst = Config::new(wamr_platform_dir.as_path()); + + dst.always_configure(true) + .generator("Ninja") + .no_build_target(true) .define( "CMAKE_BUILD_TYPE", if cfg!(debug_assertions) { @@ -39,7 +75,7 @@ fn main() { .define("WAMR_BUILD_BULK_MEMORY", "1") .define("WAMR_BUILD_REF_TYPES", "1") .define("WAMR_BUILD_SIMD", "1") - .define("WAMR_ENABLE_FAST_INTERP", "1") + .define("WAMR_BUILD_FAST_INTERP", "1") .define("WAMR_BUILD_LIB_PTHREAD", "1") .define("WAMR_BUILD_LIB_WASI_THREADS", "0") .define("WAMR_BUILD_LIBC_WASI", "0") @@ -47,7 +83,16 @@ fn main() { .define("WAMR_BUILD_SHARED_MEMORY", "1") .define("WAMR_BUILD_MULTI_MODULE", "0") .define("WAMR_DISABLE_HW_BOUND_CHECK", "1") - .build(); + .define("WAMR_BUILD_TARGET", target_arch); + + if cfg!(target_os = "windows") { + dst.define("CMAKE_CXX_COMPILER", "cl.exe"); + dst.define("CMAKE_C_COMPILER", "cl.exe"); + dst.define("CMAKE_LINKER_TYPE", "MSVC"); + dst.define("WAMR_BUILD_PLATFORM", "windows"); + } + + let dst = dst.build(); // Check output of `cargo build --verbose`, should see something like: // -L native=/path/runng/target/debug/build/runng-sys-abc1234/out @@ -65,12 +110,6 @@ fn main() { .to_str() .unwrap(), ) - .header( - wamr_dir - .join("core/iwasm/include/wasm_c_api.h") - .to_str() - .unwrap(), - ) .header( wamr_dir .join("core/iwasm/include/wasm_export.h") @@ -80,7 +119,7 @@ fn main() { .derive_default(true) .derive_debug(true) .generate() - .expect("Unable to generate bindings for `wamr`!"); + .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) @@ -122,7 +161,8 @@ fn main() { .current_dir(crate_root) .arg("submodule") .arg("update") - .arg("--init"); + .arg("--init") + .arg("--recursive"); let res = fetch_submodules.output(); @@ -130,8 +170,9 @@ fn main() { panic!("fetching submodules failed: {e}"); } - let dst = Config::new(v8_cmake_dir.clone()) - .always_configure(true) + let mut dst = Config::new(v8_cmake_dir.clone()); + + dst.always_configure(true) .generator("Ninja") .define( "CMAKE_BUILD_TYPE", @@ -141,8 +182,16 @@ fn main() { "Release" }, ) - .build_target("wee8") - .build(); + .build_target("wee8"); + + if cfg!(target_os = "windows") { + dst.define("CMAKE_CXX_COMPILER", "cl.exe"); + dst.define("CMAKE_C_COMPILER", "cl.exe"); + dst.define("CMAKE_LINKER_TYPE", "MSVC"); + dst.define("WAMR_BUILD_PLATFORM", "windows"); + } + + let dst = dst.build(); // Check output of `cargo build --verbose`, should see something like: // -L native=/path/runng/target/debug/build/runng-sys-abc1234/out @@ -156,12 +205,19 @@ fn main() { println!("cargo:rustc-link-lib=v8_libbase"); println!("cargo:rustc-link-lib=v8_base_without_compiler"); println!("cargo:rustc-link-lib=v8_compiler"); - println!("cargo:rustc-link-lib=c++"); println!("cargo:rustc-link-lib=v8_libplatform"); println!("cargo:rustc-link-lib=v8_libsampler"); println!("cargo:rustc-link-lib=v8_snapshot"); println!("cargo:rustc-link-lib=v8_torque_generated"); + if cfg!(any(target_os = "linux",)) { + println!("cargo:rustc-link-lib=stdc++"); + } else if cfg!(target_os = "windows") { + /* do nothing */ + } else { + println!("cargo:rustc-link-lib=c++"); + } + let bindings = bindgen::Builder::default() .header( v8_cmake_dir diff --git a/lib/api/src/c_api/as_c.rs b/lib/api/src/c_api/as_c.rs index 4ac660ba50b..59f74fa68b2 100644 --- a/lib/api/src/c_api/as_c.rs +++ b/lib/api/src/c_api/as_c.rs @@ -42,7 +42,7 @@ pub trait AsC: Sized { #[cfg(feature = "v8")] #[inline] pub fn param_from_c(value: &wasm_val_t) -> Value { - match value.kind as u32 { + match value.kind as _ { crate::bindings::wasm_valkind_enum_WASM_I32 => Value::I32(unsafe { value.of.i32_ }), crate::bindings::wasm_valkind_enum_WASM_I64 => Value::I64(unsafe { value.of.i64_ }), crate::bindings::wasm_valkind_enum_WASM_F32 => Value::F32(unsafe { value.of.f32_ }), @@ -62,7 +62,7 @@ pub fn param_from_c(value: &wasm_val_t) -> Value { #[cfg(any(feature = "wamr", feature = "wasmi"))] #[inline] pub fn param_from_c(value: &wasm_val_t) -> Value { - match value.kind as u32 { + match value.kind as _ { crate::bindings::wasm_valkind_enum_WASM_I32 => Value::I32(unsafe { value.of.i32_ }), crate::bindings::wasm_valkind_enum_WASM_I64 => Value::I64(unsafe { value.of.i64_ }), crate::bindings::wasm_valkind_enum_WASM_F32 => Value::F32(unsafe { value.of.f32_ }), @@ -178,7 +178,7 @@ pub fn type_to_c(type_: &Type) -> wasm_valkind_t { Type::F64 => wasm_valkind_enum_WASM_F64 as _, Type::FuncRef => wasm_valkind_enum_WASM_FUNCREF as _, Type::ExternRef => { - #[cfg(any(feature = "wasmi" , feature = "wamr"))] + #[cfg(any(feature = "wasmi", feature = "wamr"))] { crate::bindings::wasm_valkind_enum_WASM_EXTERNREF as _ } @@ -209,7 +209,7 @@ pub fn valtype_to_type(type_: *const wasm_valtype_t) -> Type { let type_ = unsafe { wasm_valtype_kind(type_) }; #[cfg(feature = "wamr")] - match type_ as u32 { + match type_ as _ { crate::bindings::wasm_valkind_enum_WASM_I32 => Type::I32, crate::bindings::wasm_valkind_enum_WASM_I64 => Type::I64, crate::bindings::wasm_valkind_enum_WASM_F32 => Type::F32, @@ -223,7 +223,7 @@ pub fn valtype_to_type(type_: *const wasm_valtype_t) -> Type { ), } #[cfg(feature = "wasmi")] - match type_ as u32 { + match type_ as _ { crate::bindings::wasm_valkind_enum_WASM_I32 => Type::I32, crate::bindings::wasm_valkind_enum_WASM_I64 => Type::I64, crate::bindings::wasm_valkind_enum_WASM_F32 => Type::F32, @@ -236,7 +236,7 @@ pub fn valtype_to_type(type_: *const wasm_valtype_t) -> Type { ), } #[cfg(feature = "v8")] - match type_ as u32 { + match type_ as _ { crate::bindings::wasm_valkind_enum_WASM_I32 => Type::I32, crate::bindings::wasm_valkind_enum_WASM_I64 => Type::I64, crate::bindings::wasm_valkind_enum_WASM_F32 => Type::F32, diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 9a1c3907f62..4231d9c2a87 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -221,7 +221,7 @@ comfy-table = "7.0.1" # Used by tuntap and connect -futures-util = "0.3" +futures-util = { workspace = true } mio = { version = "0.8", optional = true } tokio-tungstenite = { version = "0.21.0", features = [ "rustls-tls-webpki-roots", diff --git a/lib/cli/src/commands/app/delete.rs b/lib/cli/src/commands/app/delete.rs index fb5b23e6e45..d11d77f4ba0 100644 --- a/lib/cli/src/commands/app/delete.rs +++ b/lib/cli/src/commands/app/delete.rs @@ -33,7 +33,7 @@ impl AsyncCliCommand for CmdAppDelete { if interactive { let theme = dialoguer::theme::ColorfulTheme::default(); let should_use = Confirm::with_theme(&theme) - .with_prompt(&format!( + .with_prompt(format!( "Really delete the app '{}/{}'? (id: {})", app.owner.global_name, app.name, diff --git a/lib/cli/src/commands/create_exe.rs b/lib/cli/src/commands/create_exe.rs index c76b078a612..4058eda65a6 100644 --- a/lib/cli/src/commands/create_exe.rs +++ b/lib/cli/src/commands/create_exe.rs @@ -1284,14 +1284,15 @@ fn link_exe_from_dir( let out_path = directory.join("wasmer_main.exe"); #[cfg(not(target_os = "windows"))] let out_path = directory.join("wasmer_main"); - cmd.arg(&format!("-femit-bin={}", out_path.display())); + cmd.arg(format!("-femit-bin={}", out_path.display())); + cmd.args( - &object_paths + object_paths .iter() .map(|o| normalize_path(&format!("{}", o.display()))) .collect::>(), ); - cmd.arg(&normalize_path(&format!("{}", library_path.display()))); + cmd.arg(normalize_path(&format!("{}", library_path.display()))); cmd.arg(normalize_path(&format!( "{}", directory diff --git a/lib/cli/src/commands/run/mod.rs b/lib/cli/src/commands/run/mod.rs index 3966aaa6cc1..a95ffdd8691 100644 --- a/lib/cli/src/commands/run/mod.rs +++ b/lib/cli/src/commands/run/mod.rs @@ -507,7 +507,7 @@ impl Run { } fn from_binfmt_args_fallible() -> Result { - if !cfg!(linux) { + if cfg!(not(target_os = "linux")) { bail!("binfmt_misc is only available on linux."); } diff --git a/lib/cli/src/error.rs b/lib/cli/src/error.rs index 1d7a36ad9b0..d410bf1605e 100644 --- a/lib/cli/src/error.rs +++ b/lib/cli/src/error.rs @@ -3,7 +3,7 @@ use anyhow::{Chain, Error}; use colored::*; use std::fmt::{self, Debug, Write}; -#[cfg(not(any(feature = "jsc", feature = "wasm-c-api")))] +#[cfg(not(any(feature = "jsc", feature = "wamr", feature = "wasmi", feature = "v8")))] use wasmer::RuntimeError; /// A `PrettyError` for printing `anyhow::Error` nicely. @@ -27,7 +27,7 @@ macro_rules! warning { }) } -#[cfg(not(any(feature = "jsc", feature = "wasm-c-api")))] +#[cfg(not(any(feature = "jsc", feature = "wamr", feature = "wasmi", feature = "v8")))] impl PrettyError { /// Process a `Result` printing any errors and exiting /// the process after @@ -53,7 +53,7 @@ impl PrettyError { } } -#[cfg(any(feature = "jsc", feature = "wasm-c-api"))] +#[cfg(any(feature = "jsc", feature = "wamr", feature = "wasmi", feature = "v8"))] impl PrettyError { /// Process a `Result` printing any errors and exiting /// the process after diff --git a/lib/compiler-llvm/src/translator/code.rs b/lib/compiler-llvm/src/translator/code.rs index ef894aecfdb..00f51cddfc0 100644 --- a/lib/compiler-llvm/src/translator/code.rs +++ b/lib/compiler-llvm/src/translator/code.rs @@ -985,7 +985,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { let canonical_qnan = f_ty .get_element_type() .into_float_type() - .const_float(std::f64::NAN); + .const_float(f64::NAN); let canonical_qnan = self.splat_vector(canonical_qnan.as_basic_value_enum(), f_ty)?; err_nt!(self .builder @@ -999,7 +999,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { err!(self .builder .build_float_compare(FloatPredicate::UNO, value, zero, "nan")); - let canonical_qnan = f_ty.const_float(std::f64::NAN); + let canonical_qnan = f_ty.const_float(f64::NAN); err_nt!(self .builder .build_select(nan_cmp, canonical_qnan, value, "") diff --git a/lib/compiler/src/artifact_builders/artifact_builder.rs b/lib/compiler/src/artifact_builders/artifact_builder.rs index ef7ae0c0c86..92b30688397 100644 --- a/lib/compiler/src/artifact_builders/artifact_builder.rs +++ b/lib/compiler/src/artifact_builders/artifact_builder.rs @@ -11,8 +11,7 @@ use crate::Features; use crate::{ModuleEnvironment, ModuleMiddlewareChain}; use core::mem::MaybeUninit; use enumset::EnumSet; -use rkyv::de::deserializers::SharedDeserializeMap; -use rkyv::option::ArchivedOption; +use rkyv::{option::ArchivedOption, rancor::Error as RkyvError}; use self_cell::self_cell; use shared_buffer::OwnedBuffer; use std::sync::Arc; @@ -275,7 +274,7 @@ impl<'a> ModuleFromArchive<'a> { Ok(Self { compilation: &module.compilation, data_initializers: &module.data_initializers, - cpu_features: module.cpu_features, + cpu_features: module.cpu_features.to_native(), original_module: module, }) } @@ -313,9 +312,8 @@ impl ArtifactBuildFromArchive { let cell = ArtifactBuildFromArchiveCell::try_new(buffer, |buffer| { let module = module_builder(buffer)?; - let mut deserializer = SharedDeserializeMap::new(); compile_info = MaybeUninit::new( - rkyv::Deserialize::deserialize(&module.compile_info, &mut deserializer) + rkyv::deserialize::<_, RkyvError>(&module.compile_info) .map_err(|e| DeserializeError::CorruptedBinary(format!("{:?}", e)))?, ); ModuleFromArchive::from_serializable_module(module) @@ -390,7 +388,10 @@ impl ArtifactBuildFromArchive { /// Get LibCall Trampoline Section Index pub fn get_libcall_trampolines(&self) -> SectionIndex { - self.cell.borrow_dependent().compilation.libcall_trampolines + rkyv::deserialize::<_, RkyvError>( + &self.cell.borrow_dependent().compilation.libcall_trampolines, + ) + .unwrap() } /// Get LibCall Trampoline Length @@ -398,13 +399,16 @@ impl ArtifactBuildFromArchive { self.cell .borrow_dependent() .compilation - .libcall_trampoline_len as usize + .libcall_trampoline_len + .to_native() as usize } /// Get Debug optional Dwarf ref - pub fn get_debug_ref(&self) -> Option<&Dwarf> { + pub fn get_debug_ref(&self) -> Option { match self.cell.borrow_dependent().compilation.debug { - ArchivedOption::Some(ref x) => Some(x), + ArchivedOption::Some(ref x) => { + Some(rkyv::deserialize::<_, rkyv::rancor::Error>(x).unwrap()) + } ArchivedOption::None => None, } } @@ -420,10 +424,8 @@ impl ArtifactBuildFromArchive { pub fn deserialize_frame_info_ref( &self, ) -> Result, DeserializeError> { - let mut deserializer = SharedDeserializeMap::new(); - rkyv::Deserialize::deserialize( + rkyv::deserialize::<_, RkyvError>( &self.cell.borrow_dependent().compilation.function_frame_info, - &mut deserializer, ) .map_err(|e| DeserializeError::CorruptedBinary(format!("{:?}", e))) } @@ -476,12 +478,9 @@ impl<'a> ArtifactCreate<'a> for ArtifactBuildFromArchive { // deserialized from a file makes little sense, so hopefully, this is not a // common use-case. - let mut deserializer = SharedDeserializeMap::new(); - let mut module: SerializableModule = rkyv::Deserialize::deserialize( - self.cell.borrow_dependent().original_module, - &mut deserializer, - ) - .map_err(|e| SerializeError::Generic(e.to_string()))?; + let mut module: SerializableModule = + rkyv::deserialize::<_, RkyvError>(self.cell.borrow_dependent().original_module) + .map_err(|e| SerializeError::Generic(e.to_string()))?; module.compile_info = self.compile_info.clone(); serialize_module(&module) } diff --git a/lib/compiler/src/engine/artifact.rs b/lib/compiler/src/engine/artifact.rs index 0864abf46c9..d9a06b94cdd 100644 --- a/lib/compiler/src/engine/artifact.rs +++ b/lib/compiler/src/engine/artifact.rs @@ -359,7 +359,8 @@ impl Artifact { }; let debug_ref = match &artifact { - ArtifactBuildVariant::Plain(p) => p.get_debug_ref(), + // Why clone? See comment at the top of ./lib/types/src/indexes.rs. + ArtifactBuildVariant::Plain(p) => p.get_debug_ref().cloned(), ArtifactBuildVariant::Archived(a) => a.get_debug_ref(), }; let eh_frame = match debug_ref { diff --git a/lib/compiler/src/engine/inner.rs b/lib/compiler/src/engine/inner.rs index 3957c8fe1d0..d7528f41f73 100644 --- a/lib/compiler/src/engine/inner.rs +++ b/lib/compiler/src/engine/inner.rs @@ -378,7 +378,7 @@ impl EngineInner { .collect::>(); let (executable_sections, data_sections): (Vec<_>, _) = custom_sections .clone() - .partition(|section| *section.protection() == CustomSectionProtection::ReadExecute); + .partition(|section| section.protection() == CustomSectionProtection::ReadExecute); self.code_memory.push(CodeMemory::new()); let (mut allocated_functions, allocated_executable_sections, allocated_data_sections) = @@ -426,7 +426,7 @@ impl EngineInner { let allocated_custom_sections = custom_sections .map(|section| { SectionBodyPtr( - if *section.protection() == CustomSectionProtection::ReadExecute { + if section.protection() == CustomSectionProtection::ReadExecute { exec_iter.next() } else { data_iter.next() diff --git a/lib/compiler/src/engine/trap/frame_info.rs b/lib/compiler/src/engine/trap/frame_info.rs index 795e631ef48..b6c4859425f 100644 --- a/lib/compiler/src/engine/trap/frame_info.rs +++ b/lib/compiler/src/engine/trap/frame_info.rs @@ -244,7 +244,8 @@ impl CompiledFunctionFrameInfoVariant<'_> { VecTrapInformationVariant::Ref(&info.traps) } CompiledFunctionFrameInfoVariant::Archived(info) => { - VecTrapInformationVariant::Archived(&info.traps) + let traps = rkyv::deserialize::<_, rkyv::rancor::Error>(&info.traps).unwrap(); + VecTrapInformationVariant::Owned(traps) } } } @@ -254,7 +255,7 @@ impl CompiledFunctionFrameInfoVariant<'_> { #[derive(Debug)] pub enum VecTrapInformationVariant<'a> { Ref(&'a Vec), - Archived(&'a ArchivedVec), + Owned(Vec), } impl Deref for VecTrapInformationVariant<'_> { @@ -263,7 +264,7 @@ impl Deref for VecTrapInformationVariant<'_> { fn deref(&self) -> &Self::Target { match self { VecTrapInformationVariant::Ref(traps) => traps, - VecTrapInformationVariant::Archived(traps) => traps, + VecTrapInformationVariant::Owned(traps) => traps, } } } @@ -289,28 +290,32 @@ impl FunctionAddressMapVariant<'_> { pub fn start_srcloc(&self) -> SourceLoc { match self { FunctionAddressMapVariant::Ref(map) => map.start_srcloc, - FunctionAddressMapVariant::Archived(map) => map.start_srcloc, + FunctionAddressMapVariant::Archived(map) => { + rkyv::deserialize::<_, rkyv::rancor::Error>(&map.start_srcloc).unwrap() + } } } pub fn end_srcloc(&self) -> SourceLoc { match self { FunctionAddressMapVariant::Ref(map) => map.end_srcloc, - FunctionAddressMapVariant::Archived(map) => map.end_srcloc, + FunctionAddressMapVariant::Archived(map) => { + rkyv::deserialize::<_, rkyv::rancor::Error>(&map.end_srcloc).unwrap() + } } } pub fn body_offset(&self) -> usize { match self { FunctionAddressMapVariant::Ref(map) => map.body_offset, - FunctionAddressMapVariant::Archived(map) => map.body_offset as usize, + FunctionAddressMapVariant::Archived(map) => map.body_offset.to_native() as usize, } } pub fn body_len(&self) -> usize { match self { FunctionAddressMapVariant::Ref(map) => map.body_len, - FunctionAddressMapVariant::Archived(map) => map.body_len as usize, + FunctionAddressMapVariant::Archived(map) => map.body_len.to_native() as usize, } } } @@ -328,7 +333,7 @@ impl FunctionAddressMapInstructionVariant<'_> { instructions.binary_search_by_key(&key, |map| map.code_offset) } FunctionAddressMapInstructionVariant::Archived(instructions) => { - instructions.binary_search_by_key(&key, |map| map.code_offset as usize) + instructions.binary_search_by_key(&key, |map| map.code_offset.to_native() as usize) } } } @@ -339,9 +344,9 @@ impl FunctionAddressMapInstructionVariant<'_> { FunctionAddressMapInstructionVariant::Archived(instructions) => instructions .get(index) .map(|map| InstructionAddressMap { - srcloc: map.srcloc, - code_offset: map.code_offset as usize, - code_len: map.code_len as usize, + srcloc: rkyv::deserialize::<_, rkyv::rancor::Error>(&map.srcloc).unwrap(), + code_offset: map.code_offset.to_native() as usize, + code_len: map.code_len.to_native() as usize, }) .unwrap(), } diff --git a/lib/emscripten/Cargo.toml b/lib/emscripten/Cargo.toml index 8500c5ab604..482bb8ce9ad 100644 --- a/lib/emscripten/Cargo.toml +++ b/lib/emscripten/Cargo.toml @@ -27,3 +27,6 @@ getrandom = "0.2" [package.metadata.docs.rs] features = ["wasmer/sys"] rustc-args = ["--cfg", "docsrs"] + +[features] +debug = [] diff --git a/lib/journal/Cargo.toml b/lib/journal/Cargo.toml index 891040d40f0..ea350cd67de 100644 --- a/lib/journal/Cargo.toml +++ b/lib/journal/Cargo.toml @@ -10,13 +10,17 @@ repository.workspace = true rust-version.workspace = true [features] -default = [ "log-file", "wasmer/sys" ] -log-file = [ "shared-buffer" ] +default = ["log-file", "wasmer/sys"] +log-file = ["shared-buffer"] [dependencies] wasmer = { default-features = false, path = "../api", version = "=4.3.7" } -wasmer-wasix-types = { path = "../wasi-types", version = "0.27.0", features = [ "enable-serde" ] } -virtual-net = { path = "../virtual-net", version = "0.8.0", default-features = false, features = ["rkyv"] } +wasmer-wasix-types = { path = "../wasi-types", version = "0.27.0", features = [ + "enable-serde", +] } +virtual-net = { path = "../virtual-net", version = "0.8.0", default-features = false, features = [ + "rkyv", +] } virtual-fs = { path = "../virtual-fs", version = "0.16.0", default-features = false } shared-buffer = { workspace = true, optional = true } @@ -37,4 +41,4 @@ serde_json = { version = "^1" } [dev-dependencies] tracing-test = "0.2.4" -tempfile = "3.6.0" \ No newline at end of file +tempfile = "3.6.0" diff --git a/lib/journal/src/concrete/aligned_cow_str.rs b/lib/journal/src/concrete/aligned_cow_str.rs index c9676cbaf49..00f2e0eb015 100644 --- a/lib/journal/src/concrete/aligned_cow_str.rs +++ b/lib/journal/src/concrete/aligned_cow_str.rs @@ -1,9 +1,10 @@ -use std::{borrow::Cow, fmt, ops::Deref}; +use std::{borrow::Cow, ops::Deref}; use rkyv::{ - ser::{ScratchSpace, Serializer}, + rancor::Fallible, + ser::{Allocator, WriterExt}, vec::{ArchivedVec, VecResolver}, - Archive, Archived, Serialize, + Archive, Archived, }; #[derive(Clone)] @@ -40,9 +41,9 @@ impl<'a> Default for AlignedCowStr<'a> { } } -impl<'a> fmt::Debug for AlignedCowStr<'a> { +impl<'a> std::fmt::Debug for AlignedCowStr<'a> { #[inline] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.inner.fmt(f) } } @@ -95,20 +96,19 @@ impl<'a> Archive for AlignedCowStr<'a> { type Resolver = VecResolver; #[inline] - unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { - ArchivedVec::resolve_from_len(self.inner.as_bytes().len(), pos, resolver, out); + fn resolve(&self, resolver: Self::Resolver, out: rkyv::Place) { + ArchivedVec::resolve_from_len(self.inner.as_bytes().len(), resolver, out); } } -impl<'a, S: ScratchSpace + Serializer + ?Sized> Serialize for AlignedCowStr<'a> { +impl<'a, S> rkyv::Serialize for AlignedCowStr<'a> +where + S: Fallible + WriterExt + Allocator + ?Sized, + S::Error: rkyv::rancor::Source, +{ #[inline] fn serialize(&self, serializer: &mut S) -> Result { serializer.align(Self::ALIGNMENT)?; - unsafe { - ArchivedVec::>::serialize_copy_from_slice( - self.inner.as_bytes(), - serializer, - ) - } + ArchivedVec::>::serialize_from_slice(self.inner.as_bytes(), serializer) } } diff --git a/lib/journal/src/concrete/aligned_cow_vec.rs b/lib/journal/src/concrete/aligned_cow_vec.rs index 49ff1bb93c7..f4da8359d95 100644 --- a/lib/journal/src/concrete/aligned_cow_vec.rs +++ b/lib/journal/src/concrete/aligned_cow_vec.rs @@ -5,9 +5,10 @@ use std::{ }; use rkyv::{ - ser::{ScratchSpace, Serializer}, + rancor::Fallible, + ser::{Allocator, WriterExt}, vec::{ArchivedVec, VecResolver}, - Archive, Archived, Serialize, + Archive, Archived, }; /// An aligned COW vector of bytes which avoids copying data @@ -197,17 +198,19 @@ where type Resolver = VecResolver; #[inline] - unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { - ArchivedVec::resolve_from_len(self.len(), pos, resolver, out); + fn resolve(&self, resolver: Self::Resolver, out: rkyv::Place) { + ArchivedVec::resolve_from_len(self.len(), resolver, out); } } -impl<'a, S: ScratchSpace + Serializer + ?Sized> Serialize for AlignedCowVec<'a, u8> { +impl<'a, S> rkyv::Serialize for AlignedCowVec<'a, u8> +where + S: Fallible + WriterExt + Allocator + ?Sized, + S::Error: rkyv::rancor::Source, +{ #[inline] fn serialize(&self, serializer: &mut S) -> Result { serializer.align(Self::ALIGNMENT)?; - unsafe { - ArchivedVec::>::serialize_copy_from_slice(self.as_slice(), serializer) - } + ArchivedVec::>::serialize_from_slice(self.as_slice(), serializer) } } diff --git a/lib/journal/src/concrete/archived.rs b/lib/journal/src/concrete/archived.rs index 64d0ad2ce6b..9d58d5952be 100644 --- a/lib/journal/src/concrete/archived.rs +++ b/lib/journal/src/concrete/archived.rs @@ -1,6 +1,9 @@ use num_enum::{IntoPrimitive, TryFromPrimitive}; -use rkyv::ser::{ScratchSpace, Serializer}; -use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use rkyv::rancor::Fallible; +use rkyv::ser::{Allocator, Writer}; +use rkyv::{ + api::serialize_using, Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize, +}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use std::time::{Duration, SystemTime}; @@ -22,7 +25,7 @@ pub const JOURNAL_MAGIC_NUMBER_BYTES: [u8; 8] = JOURNAL_MAGIC_NUMBER.to_be_bytes RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalEntryRecordType { InitModuleV1 = 1, ProcessExitV1 = 2, @@ -93,251 +96,177 @@ impl JournalEntryRecordType { /// can not be manipulated or corrupted. pub unsafe fn deserialize_archive(self, data: &[u8]) -> anyhow::Result> { match self { - JournalEntryRecordType::InitModuleV1 => ArchivedJournalEntry::InitModuleV1( - rkyv::archived_root::(data), - ), + JournalEntryRecordType::InitModuleV1 => { + ArchivedJournalEntry::InitModuleV1(rkyv::access_unchecked(data)) + } JournalEntryRecordType::ClearEtherealV1 => { - ArchivedJournalEntry::ClearEtherealV1(rkyv::archived_root::< - JournalEntryClearEtherealV1, - >(data)) + ArchivedJournalEntry::ClearEtherealV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::ProcessExitV1 => { + ArchivedJournalEntry::ProcessExitV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::SetThreadV1 => { + ArchivedJournalEntry::SetThreadV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::CloseThreadV1 => { + ArchivedJournalEntry::CloseThreadV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::ProcessExitV1 => ArchivedJournalEntry::ProcessExitV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::SetThreadV1 => ArchivedJournalEntry::SetThreadV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::CloseThreadV1 => ArchivedJournalEntry::CloseThreadV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::FileDescriptorSeekV1 => { - ArchivedJournalEntry::FileDescriptorSeekV1(rkyv::archived_root::< - JournalEntryFileDescriptorSeekV1, - >(data)) + ArchivedJournalEntry::FileDescriptorSeekV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorWriteV1 => { - ArchivedJournalEntry::FileDescriptorWriteV1(rkyv::archived_root::< - JournalEntryFileDescriptorWriteV1, - >(data)) + ArchivedJournalEntry::FileDescriptorWriteV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::UpdateMemoryRegionV1 => { - ArchivedJournalEntry::UpdateMemoryRegionV1(rkyv::archived_root::< - JournalEntryUpdateMemoryRegionV1, - >(data)) + ArchivedJournalEntry::UpdateMemoryRegionV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SetClockTimeV1 => { - ArchivedJournalEntry::SetClockTimeV1(rkyv::archived_root::< - JournalEntrySetClockTimeV1, - >(data)) + ArchivedJournalEntry::SetClockTimeV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::OpenFileDescriptorV1 => { - ArchivedJournalEntry::OpenFileDescriptorV1(rkyv::archived_root::< - JournalEntryOpenFileDescriptorV1, - >(data)) + ArchivedJournalEntry::OpenFileDescriptorV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::CloseFileDescriptorV1 => { - ArchivedJournalEntry::CloseFileDescriptorV1(rkyv::archived_root::< - JournalEntryCloseFileDescriptorV1, - >(data)) + ArchivedJournalEntry::CloseFileDescriptorV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::RenumberFileDescriptorV1 => { - ArchivedJournalEntry::RenumberFileDescriptorV1(rkyv::archived_root::< - JournalEntryRenumberFileDescriptorV1, - >(data)) + ArchivedJournalEntry::RenumberFileDescriptorV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::DuplicateFileDescriptorV1 => { - ArchivedJournalEntry::DuplicateFileDescriptorV1(rkyv::archived_root::< - JournalEntryDuplicateFileDescriptorV1, - >(data)) + ArchivedJournalEntry::DuplicateFileDescriptorV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::CreateDirectoryV1 => { - ArchivedJournalEntry::CreateDirectoryV1(rkyv::archived_root::< - JournalEntryCreateDirectoryV1, - >(data)) + ArchivedJournalEntry::CreateDirectoryV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::RemoveDirectoryV1 => { - ArchivedJournalEntry::RemoveDirectoryV1(rkyv::archived_root::< - JournalEntryRemoveDirectoryV1, - >(data)) + ArchivedJournalEntry::RemoveDirectoryV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::PathSetTimesV1 => { - ArchivedJournalEntry::PathSetTimesV1(rkyv::archived_root::< - JournalEntryPathSetTimesV1, - >(data)) + ArchivedJournalEntry::PathSetTimesV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorSetTimesV1 => { - ArchivedJournalEntry::FileDescriptorSetTimesV1(rkyv::archived_root::< - JournalEntryFileDescriptorSetTimesV1, - >(data)) + ArchivedJournalEntry::FileDescriptorSetTimesV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorSetSizeV1 => { - ArchivedJournalEntry::FileDescriptorSetSizeV1(rkyv::archived_root::< - JournalEntryFileDescriptorSetSizeV1, - >(data)) + ArchivedJournalEntry::FileDescriptorSetSizeV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorSetFlagsV1 => { - ArchivedJournalEntry::FileDescriptorSetFlagsV1(rkyv::archived_root::< - JournalEntryFileDescriptorSetFlagsV1, - >(data)) + ArchivedJournalEntry::FileDescriptorSetFlagsV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorSetRightsV1 => { - ArchivedJournalEntry::FileDescriptorSetRightsV1(rkyv::archived_root::< - JournalEntryFileDescriptorSetRightsV1, - >(data)) + ArchivedJournalEntry::FileDescriptorSetRightsV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorAdviseV1 => { - ArchivedJournalEntry::FileDescriptorAdviseV1(rkyv::archived_root::< - JournalEntryFileDescriptorAdviseV1, - >(data)) + ArchivedJournalEntry::FileDescriptorAdviseV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::FileDescriptorAllocateV1 => { - ArchivedJournalEntry::FileDescriptorAllocateV1(rkyv::archived_root::< - JournalEntryFileDescriptorAllocateV1, - >(data)) + ArchivedJournalEntry::FileDescriptorAllocateV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::CreateHardLinkV1 => { - ArchivedJournalEntry::CreateHardLinkV1(rkyv::archived_root::< - JournalEntryCreateHardLinkV1, - >(data)) + ArchivedJournalEntry::CreateHardLinkV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::CreateSymbolicLinkV1 => { - ArchivedJournalEntry::CreateSymbolicLinkV1(rkyv::archived_root::< - JournalEntryCreateSymbolicLinkV1, - >(data)) + ArchivedJournalEntry::CreateSymbolicLinkV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::UnlinkFileV1 => { + ArchivedJournalEntry::UnlinkFileV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::PathRenameV1 => { + ArchivedJournalEntry::PathRenameV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::UnlinkFileV1 => ArchivedJournalEntry::UnlinkFileV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::PathRenameV1 => ArchivedJournalEntry::PathRenameV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::ChangeDirectoryV1 => { - ArchivedJournalEntry::ChangeDirectoryV1(rkyv::archived_root::< - JournalEntryChangeDirectoryV1, - >(data)) + ArchivedJournalEntry::ChangeDirectoryV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::EpollCreateV1 => { + ArchivedJournalEntry::EpollCreateV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::EpollCtlV1 => { + ArchivedJournalEntry::EpollCtlV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::EpollCreateV1 => ArchivedJournalEntry::EpollCreateV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::EpollCtlV1 => ArchivedJournalEntry::EpollCtlV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::TtySetV1 => { - ArchivedJournalEntry::TtySetV1(rkyv::archived_root::(data)) + ArchivedJournalEntry::TtySetV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::CreatePipeV1 => { + ArchivedJournalEntry::CreatePipeV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::CreateEventV1 => { + ArchivedJournalEntry::CreateEventV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::PortAddAddrV1 => { + ArchivedJournalEntry::PortAddAddrV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::PortDelAddrV1 => { + ArchivedJournalEntry::PortDelAddrV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::CreatePipeV1 => ArchivedJournalEntry::CreatePipeV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::CreateEventV1 => ArchivedJournalEntry::CreateEventV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::PortAddAddrV1 => ArchivedJournalEntry::PortAddAddrV1( - rkyv::archived_root::(data), - ), - JournalEntryRecordType::PortDelAddrV1 => ArchivedJournalEntry::PortDelAddrV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::PortAddrClearV1 => return Ok(JournalEntry::PortAddrClearV1), - JournalEntryRecordType::PortBridgeV1 => ArchivedJournalEntry::PortBridgeV1( - rkyv::archived_root::(data), - ), + JournalEntryRecordType::PortBridgeV1 => { + ArchivedJournalEntry::PortBridgeV1(rkyv::access_unchecked(data)) + } JournalEntryRecordType::PortUnbridgeV1 => return Ok(JournalEntry::PortUnbridgeV1), JournalEntryRecordType::PortDhcpAcquireV1 => { return Ok(JournalEntry::PortDhcpAcquireV1) } JournalEntryRecordType::PortGatewaySetV1 => { - ArchivedJournalEntry::PortGatewaySetV1(rkyv::archived_root::< - JournalEntryPortGatewaySetV1, - >(data)) + ArchivedJournalEntry::PortGatewaySetV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::PortRouteAddV1 => { - ArchivedJournalEntry::PortRouteAddV1(rkyv::archived_root::< - JournalEntryPortRouteAddV1, - >(data)) + ArchivedJournalEntry::PortRouteAddV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::PortRouteClearV1 => return Ok(JournalEntry::PortRouteClearV1), JournalEntryRecordType::PortRouteDelV1 => { - ArchivedJournalEntry::PortRouteDelV1(rkyv::archived_root::< - JournalEntryPortRouteDelV1, - >(data)) + ArchivedJournalEntry::PortRouteDelV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::SocketOpenV1 => { + ArchivedJournalEntry::SocketOpenV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::SocketOpenV1 => ArchivedJournalEntry::SocketOpenV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::SocketListenV1 => { - ArchivedJournalEntry::SocketListenV1(rkyv::archived_root::< - JournalEntrySocketListenV1, - >(data)) + ArchivedJournalEntry::SocketListenV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::SocketBindV1 => { + ArchivedJournalEntry::SocketBindV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::SocketBindV1 => ArchivedJournalEntry::SocketBindV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::SocketConnectedV1 => { - ArchivedJournalEntry::SocketConnectedV1(rkyv::archived_root::< - JournalEntrySocketConnectedV1, - >(data)) + ArchivedJournalEntry::SocketConnectedV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketAcceptedV1 => { - ArchivedJournalEntry::SocketAcceptedV1(rkyv::archived_root::< - JournalEntrySocketAcceptedV1, - >(data)) + ArchivedJournalEntry::SocketAcceptedV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketJoinIpv4MulticastV1 => { - ArchivedJournalEntry::SocketJoinIpv4MulticastV1(rkyv::archived_root::< - JournalEntrySocketJoinIpv4MulticastV1, - >(data)) + ArchivedJournalEntry::SocketJoinIpv4MulticastV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketJoinIpv6MulticastV1 => { - ArchivedJournalEntry::SocketJoinIpv6MulticastV1(rkyv::archived_root::< - JournalEntrySocketJoinIpv6MulticastV1, - >(data)) + ArchivedJournalEntry::SocketJoinIpv6MulticastV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketLeaveIpv4MulticastV1 => { - ArchivedJournalEntry::SocketLeaveIpv4MulticastV1(rkyv::archived_root::< - JournalEntrySocketLeaveIpv4MulticastV1, - >(data)) + ArchivedJournalEntry::SocketLeaveIpv4MulticastV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketLeaveIpv6MulticastV1 => { - ArchivedJournalEntry::SocketLeaveIpv6MulticastV1(rkyv::archived_root::< - JournalEntrySocketLeaveIpv6MulticastV1, - >(data)) + ArchivedJournalEntry::SocketLeaveIpv6MulticastV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketSendFileV1 => { - ArchivedJournalEntry::SocketSendFileV1(rkyv::archived_root::< - JournalEntrySocketSendFileV1, - >(data)) + ArchivedJournalEntry::SocketSendFileV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketSendToV1 => { - ArchivedJournalEntry::SocketSendToV1(rkyv::archived_root::< - JournalEntrySocketSendToV1, - >(data)) + ArchivedJournalEntry::SocketSendToV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::SocketSendV1 => { + ArchivedJournalEntry::SocketSendV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::SocketSendV1 => ArchivedJournalEntry::SocketSendV1( - rkyv::archived_root::(data), - ), JournalEntryRecordType::SocketSetOptFlagV1 => { - ArchivedJournalEntry::SocketSetOptFlagV1(rkyv::archived_root::< - JournalEntrySocketSetOptFlagV1, - >(data)) + ArchivedJournalEntry::SocketSetOptFlagV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketSetOptSizeV1 => { - ArchivedJournalEntry::SocketSetOptSizeV1(rkyv::archived_root::< - JournalEntrySocketSetOptSizeV1, - >(data)) + ArchivedJournalEntry::SocketSetOptSizeV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketSetOptTimeV1 => { - ArchivedJournalEntry::SocketSetOptTimeV1(rkyv::archived_root::< - JournalEntrySocketSetOptTimeV1, - >(data)) + ArchivedJournalEntry::SocketSetOptTimeV1(rkyv::access_unchecked(data)) } JournalEntryRecordType::SocketShutdownV1 => { - ArchivedJournalEntry::SocketShutdownV1(rkyv::archived_root::< - JournalEntrySocketShutdownV1, - >(data)) + ArchivedJournalEntry::SocketShutdownV1(rkyv::access_unchecked(data)) + } + JournalEntryRecordType::SnapshotV1 => { + ArchivedJournalEntry::SnapshotV1(rkyv::access_unchecked(data)) } - JournalEntryRecordType::SnapshotV1 => ArchivedJournalEntry::SnapshotV1( - rkyv::archived_root::(data), - ), } .try_into() } @@ -428,33 +357,37 @@ impl<'a> JournalEntry<'a> { } } - pub fn serialize_archive( + pub fn serialize_archive( self, serializer: &mut T, ) -> anyhow::Result where - T::Error: std::fmt::Display, + T::Error: rkyv::rancor::Source, { let amt = match self { JournalEntry::InitModuleV1 { wasm_hash } => { - serializer.serialize_value(&JournalEntryInitModuleV1 { wasm_hash }) + serialize_using(&JournalEntryInitModuleV1 { wasm_hash }, serializer) } JournalEntry::ClearEtherealV1 => { - serializer.serialize_value(&JournalEntryClearEtherealV1 {}) + serialize_using(&JournalEntryClearEtherealV1 {}, serializer) } JournalEntry::UpdateMemoryRegionV1 { region, compressed_data, - } => serializer.serialize_value(&JournalEntryUpdateMemoryRegionV1 { - start: region.start, - end: region.end, - compressed_data: compressed_data.into(), - }), - JournalEntry::ProcessExitV1 { exit_code } => { - serializer.serialize_value(&JournalEntryProcessExitV1 { + } => serialize_using( + &JournalEntryUpdateMemoryRegionV1 { + start: region.start, + end: region.end, + compressed_data: compressed_data.into(), + }, + serializer, + ), + JournalEntry::ProcessExitV1 { exit_code } => serialize_using( + &JournalEntryProcessExitV1 { exit_code: exit_code.map(|e| e.into()), - }) - } + }, + serializer, + ), JournalEntry::SetThreadV1 { id, call_stack, @@ -463,46 +396,56 @@ impl<'a> JournalEntry<'a> { is_64bit, start, layout, - } => serializer.serialize_value(&JournalEntrySetThreadV1 { - id, - call_stack: call_stack.into(), - memory_stack: memory_stack.into(), - store_data: store_data.into(), - start: start.into(), - layout: layout.into(), - is_64bit, - }), - JournalEntry::CloseThreadV1 { id, exit_code } => { - serializer.serialize_value(&JournalEntryCloseThreadV1 { + } => serialize_using( + &JournalEntrySetThreadV1 { + id, + call_stack: call_stack.into(), + memory_stack: memory_stack.into(), + store_data: store_data.into(), + start: start.into(), + layout: layout.into(), + is_64bit, + }, + serializer, + ), + JournalEntry::CloseThreadV1 { id, exit_code } => serialize_using( + &JournalEntryCloseThreadV1 { id, exit_code: exit_code.map(|e| e.into()), - }) - } - JournalEntry::FileDescriptorSeekV1 { fd, offset, whence } => serializer - .serialize_value(&JournalEntryFileDescriptorSeekV1 { + }, + serializer, + ), + JournalEntry::FileDescriptorSeekV1 { fd, offset, whence } => serialize_using( + &JournalEntryFileDescriptorSeekV1 { fd, offset, whence: whence.into(), - }), + }, + serializer, + ), JournalEntry::FileDescriptorWriteV1 { fd, offset, data, is_64bit, - } => serializer.serialize_value(&JournalEntryFileDescriptorWriteV1 { - fd, - offset, - data: data.into(), - is_64bit, - }), - JournalEntry::SetClockTimeV1 { clock_id, time } => { - serializer.serialize_value(&JournalEntrySetClockTimeV1 { + } => serialize_using( + &JournalEntryFileDescriptorWriteV1 { + fd, + offset, + data: data.into(), + is_64bit, + }, + serializer, + ), + JournalEntry::SetClockTimeV1 { clock_id, time } => serialize_using( + &JournalEntrySetClockTimeV1 { clock_id: clock_id.into(), time, - }) - } + }, + serializer, + ), JournalEntry::CloseFileDescriptorV1 { fd } => { - serializer.serialize_value(&JournalEntryCloseFileDescriptorV1 { fd }) + serialize_using(&JournalEntryCloseFileDescriptorV1 { fd }, serializer) } JournalEntry::OpenFileDescriptorV1 { fd, @@ -513,38 +456,47 @@ impl<'a> JournalEntry<'a> { fs_rights_base, fs_rights_inheriting, fs_flags, - } => serializer.serialize_value(&JournalEntryOpenFileDescriptorV1 { - fd, - dirfd, - dirflags, - path: path.into(), - o_flags: o_flags.bits(), - fs_rights_base: fs_rights_base.bits(), - fs_rights_inheriting: fs_rights_inheriting.bits(), - fs_flags: fs_flags.bits(), - }), - JournalEntry::RenumberFileDescriptorV1 { old_fd, new_fd } => { - serializer.serialize_value(&JournalEntryRenumberFileDescriptorV1 { old_fd, new_fd }) - } + } => serialize_using( + &JournalEntryOpenFileDescriptorV1 { + fd, + dirfd, + dirflags, + path: path.into(), + o_flags: o_flags.bits(), + fs_rights_base: fs_rights_base.bits(), + fs_rights_inheriting: fs_rights_inheriting.bits(), + fs_flags: fs_flags.bits(), + }, + serializer, + ), + JournalEntry::RenumberFileDescriptorV1 { old_fd, new_fd } => serialize_using( + &JournalEntryRenumberFileDescriptorV1 { old_fd, new_fd }, + serializer, + ), JournalEntry::DuplicateFileDescriptorV1 { original_fd, copied_fd, - } => serializer.serialize_value(&JournalEntryDuplicateFileDescriptorV1 { - original_fd, - copied_fd, - }), - JournalEntry::CreateDirectoryV1 { fd, path } => { - serializer.serialize_value(&JournalEntryCreateDirectoryV1 { + } => serialize_using( + &JournalEntryDuplicateFileDescriptorV1 { + original_fd, + copied_fd, + }, + serializer, + ), + JournalEntry::CreateDirectoryV1 { fd, path } => serialize_using( + &JournalEntryCreateDirectoryV1 { fd, path: path.into(), - }) - } - JournalEntry::RemoveDirectoryV1 { fd, path } => { - serializer.serialize_value(&JournalEntryRemoveDirectoryV1 { + }, + serializer, + ), + JournalEntry::RemoveDirectoryV1 { fd, path } => serialize_using( + &JournalEntryRemoveDirectoryV1 { fd, path: path.into(), - }) - } + }, + serializer, + ), JournalEntry::PathSetTimesV1 { fd, flags, @@ -552,114 +504,144 @@ impl<'a> JournalEntry<'a> { st_atim, st_mtim, fst_flags, - } => serializer.serialize_value(&JournalEntryPathSetTimesV1 { - fd, - flags, - path: path.into(), - st_atim, - st_mtim, - fst_flags: fst_flags.bits(), - }), + } => serialize_using( + &JournalEntryPathSetTimesV1 { + fd, + flags, + path: path.into(), + st_atim, + st_mtim, + fst_flags: fst_flags.bits(), + }, + serializer, + ), JournalEntry::FileDescriptorSetTimesV1 { fd, st_atim, st_mtim, fst_flags, - } => serializer.serialize_value(&JournalEntryFileDescriptorSetTimesV1 { - fd, - st_atim, - st_mtim, - fst_flags: fst_flags.bits(), - }), - JournalEntry::FileDescriptorSetFlagsV1 { fd, flags } => { - serializer.serialize_value(&JournalEntryFileDescriptorSetFlagsV1 { + } => serialize_using( + &JournalEntryFileDescriptorSetTimesV1 { + fd, + st_atim, + st_mtim, + fst_flags: fst_flags.bits(), + }, + serializer, + ), + JournalEntry::FileDescriptorSetFlagsV1 { fd, flags } => serialize_using( + &JournalEntryFileDescriptorSetFlagsV1 { fd, flags: flags.bits(), - }) - } + }, + serializer, + ), JournalEntry::FileDescriptorSetRightsV1 { fd, fs_rights_base, fs_rights_inheriting, - } => serializer.serialize_value(&JournalEntryFileDescriptorSetRightsV1 { - fd, - fs_rights_base: fs_rights_base.bits(), - fs_rights_inheriting: fs_rights_inheriting.bits(), - }), - JournalEntry::FileDescriptorSetSizeV1 { fd, st_size } => { - serializer.serialize_value(&JournalEntryFileDescriptorSetSizeV1 { fd, st_size }) - } + } => serialize_using( + &JournalEntryFileDescriptorSetRightsV1 { + fd, + fs_rights_base: fs_rights_base.bits(), + fs_rights_inheriting: fs_rights_inheriting.bits(), + }, + serializer, + ), + JournalEntry::FileDescriptorSetSizeV1 { fd, st_size } => serialize_using( + &JournalEntryFileDescriptorSetSizeV1 { fd, st_size }, + serializer, + ), JournalEntry::FileDescriptorAdviseV1 { fd, offset, len, advice, - } => serializer.serialize_value(&JournalEntryFileDescriptorAdviseV1 { - fd, - offset, - len, - advice: advice.into(), - }), - JournalEntry::FileDescriptorAllocateV1 { fd, offset, len } => serializer - .serialize_value(&JournalEntryFileDescriptorAllocateV1 { fd, offset, len }), + } => serialize_using( + &JournalEntryFileDescriptorAdviseV1 { + fd, + offset, + len, + advice: advice.into(), + }, + serializer, + ), + JournalEntry::FileDescriptorAllocateV1 { fd, offset, len } => serialize_using( + &JournalEntryFileDescriptorAllocateV1 { fd, offset, len }, + serializer, + ), JournalEntry::CreateHardLinkV1 { old_fd, old_path, old_flags, new_fd, new_path, - } => serializer.serialize_value(&JournalEntryCreateHardLinkV1 { - old_fd, - old_path: old_path.into(), - old_flags, - new_fd, - new_path: new_path.into(), - }), + } => serialize_using( + &JournalEntryCreateHardLinkV1 { + old_fd, + old_path: old_path.into(), + old_flags, + new_fd, + new_path: new_path.into(), + }, + serializer, + ), JournalEntry::CreateSymbolicLinkV1 { old_path, fd, new_path, - } => serializer.serialize_value(&JournalEntryCreateSymbolicLinkV1 { - old_path: old_path.into(), - fd, - new_path: new_path.into(), - }), - JournalEntry::UnlinkFileV1 { fd, path } => { - serializer.serialize_value(&JournalEntryUnlinkFileV1 { + } => serialize_using( + &JournalEntryCreateSymbolicLinkV1 { + old_path: old_path.into(), + fd, + new_path: new_path.into(), + }, + serializer, + ), + JournalEntry::UnlinkFileV1 { fd, path } => serialize_using( + &JournalEntryUnlinkFileV1 { fd, path: path.into(), - }) - } + }, + serializer, + ), JournalEntry::PathRenameV1 { old_fd, old_path, new_fd, new_path, - } => serializer.serialize_value(&JournalEntryPathRenameV1 { - old_fd, - old_path: old_path.into(), - new_fd, - new_path: new_path.into(), - }), - JournalEntry::ChangeDirectoryV1 { path } => { - serializer.serialize_value(&JournalEntryChangeDirectoryV1 { path: path.into() }) - } + } => serialize_using( + &JournalEntryPathRenameV1 { + old_fd, + old_path: old_path.into(), + new_fd, + new_path: new_path.into(), + }, + serializer, + ), + JournalEntry::ChangeDirectoryV1 { path } => serialize_using( + &JournalEntryChangeDirectoryV1 { path: path.into() }, + serializer, + ), JournalEntry::EpollCreateV1 { fd } => { - serializer.serialize_value(&JournalEntryEpollCreateV1 { fd }) + serialize_using(&JournalEntryEpollCreateV1 { fd }, serializer) } JournalEntry::EpollCtlV1 { epfd, op, fd, event, - } => serializer.serialize_value(&JournalEntryEpollCtlV1 { - epfd, - op: op.into(), - fd, - event: event.map(|e| e.into()), - }), - JournalEntry::TtySetV1 { tty, line_feeds } => { - serializer.serialize_value(&JournalEntryTtySetV1 { + } => serialize_using( + &JournalEntryEpollCtlV1 { + epfd, + op: op.into(), + fd, + event: event.map(|e| e.into()), + }, + serializer, + ), + JournalEntry::TtySetV1 { tty, line_feeds } => serialize_using( + &JournalEntryTtySetV1 { cols: tty.cols, rows: tty.rows, width: tty.width, @@ -670,79 +652,93 @@ impl<'a> JournalEntry<'a> { echo: tty.echo, line_buffered: tty.line_buffered, line_feeds, - }) - } + }, + serializer, + ), JournalEntry::CreatePipeV1 { fd1, fd2 } => { - serializer.serialize_value(&JournalEntryCreatePipeV1 { fd1, fd2 }) + serialize_using(&JournalEntryCreatePipeV1 { fd1, fd2 }, serializer) } JournalEntry::CreateEventV1 { initial_val, flags, fd, - } => serializer.serialize_value(&JournalEntryCreateEventV1 { - initial_val, - flags, - fd, - }), + } => serialize_using( + &JournalEntryCreateEventV1 { + initial_val, + flags, + fd, + }, + serializer, + ), JournalEntry::PortAddAddrV1 { cidr } => { - serializer.serialize_value(&JournalEntryPortAddAddrV1 { cidr: cidr.into() }) + serialize_using(&JournalEntryPortAddAddrV1 { cidr: cidr.into() }, serializer) } JournalEntry::PortDelAddrV1 { addr } => { - serializer.serialize_value(&JournalEntryPortDelAddrV1 { addr }) + serialize_using(&JournalEntryPortDelAddrV1 { addr }, serializer) } - JournalEntry::PortAddrClearV1 => serializer.serialize_value(&()), + JournalEntry::PortAddrClearV1 => serialize_using(&(), serializer), JournalEntry::PortBridgeV1 { network, token, security, - } => serializer.serialize_value(&JournalEntryPortBridgeV1 { - network: network.into(), - token: token.into(), - security: security.into(), - }), - JournalEntry::PortUnbridgeV1 => serializer.serialize_value(&()), - JournalEntry::PortDhcpAcquireV1 => serializer.serialize_value(&()), + } => serialize_using( + &JournalEntryPortBridgeV1 { + network: network.into(), + token: token.into(), + security: security.into(), + }, + serializer, + ), + JournalEntry::PortUnbridgeV1 => serialize_using(&(), serializer), + JournalEntry::PortDhcpAcquireV1 => serialize_using(&(), serializer), JournalEntry::PortGatewaySetV1 { ip } => { - serializer.serialize_value(&JournalEntryPortGatewaySetV1 { ip }) + serialize_using(&JournalEntryPortGatewaySetV1 { ip }, serializer) } JournalEntry::PortRouteAddV1 { cidr, via_router, preferred_until, expires_at, - } => serializer.serialize_value(&JournalEntryPortRouteAddV1 { - cidr: cidr.into(), - via_router, - preferred_until, - expires_at, - }), - JournalEntry::PortRouteClearV1 => serializer.serialize_value(&()), + } => serialize_using( + &JournalEntryPortRouteAddV1 { + cidr: cidr.into(), + via_router, + preferred_until, + expires_at, + }, + serializer, + ), + JournalEntry::PortRouteClearV1 => serialize_using(&(), serializer), JournalEntry::PortRouteDelV1 { ip } => { - serializer.serialize_value(&JournalEntryPortRouteDelV1 { ip }) + serialize_using(&JournalEntryPortRouteDelV1 { ip }, serializer) } - JournalEntry::SocketOpenV1 { af, ty, pt, fd } => { - serializer.serialize_value(&JournalEntrySocketOpenV1 { + JournalEntry::SocketOpenV1 { af, ty, pt, fd } => serialize_using( + &JournalEntrySocketOpenV1 { af: af.into(), ty: ty.into(), pt: pt.into(), fd, - }) - } + }, + serializer, + ), JournalEntry::SocketListenV1 { fd, backlog } => { - serializer.serialize_value(&JournalEntrySocketListenV1 { fd, backlog }) + serialize_using(&JournalEntrySocketListenV1 { fd, backlog }, serializer) } JournalEntry::SocketBindV1 { fd, addr } => { - serializer.serialize_value(&JournalEntrySocketBindV1 { fd, addr }) + serialize_using(&JournalEntrySocketBindV1 { fd, addr }, serializer) } JournalEntry::SocketConnectedV1 { fd, local_addr, peer_addr, - } => serializer.serialize_value(&JournalEntrySocketConnectedV1 { - fd, - local_addr, - peer_addr, - }), + } => serialize_using( + &JournalEntrySocketConnectedV1 { + fd, + local_addr, + peer_addr, + }, + serializer, + ), JournalEntry::SocketAcceptedV1 { listen_fd, fd, @@ -750,120 +746,149 @@ impl<'a> JournalEntry<'a> { peer_addr, fd_flags, non_blocking: nonblocking, - } => serializer.serialize_value(&JournalEntrySocketAcceptedV1 { - listen_fd, - fd, - local_addr: addr, - peer_addr, - fd_flags: fd_flags.bits(), - nonblocking, - }), + } => serialize_using( + &JournalEntrySocketAcceptedV1 { + listen_fd, + fd, + local_addr: addr, + peer_addr, + fd_flags: fd_flags.bits(), + nonblocking, + }, + serializer, + ), JournalEntry::SocketJoinIpv4MulticastV1 { fd, multiaddr, iface, - } => serializer.serialize_value(&JournalEntrySocketJoinIpv4MulticastV1 { - fd, - multiaddr, - iface, - }), + } => serialize_using( + &JournalEntrySocketJoinIpv4MulticastV1 { + fd, + multiaddr, + iface, + }, + serializer, + ), JournalEntry::SocketJoinIpv6MulticastV1 { fd, multi_addr: multiaddr, iface, - } => serializer.serialize_value(&JournalEntrySocketJoinIpv6MulticastV1 { - fd, - multiaddr, - iface, - }), + } => serialize_using( + &JournalEntrySocketJoinIpv6MulticastV1 { + fd, + multiaddr, + iface, + }, + serializer, + ), JournalEntry::SocketLeaveIpv4MulticastV1 { fd, multi_addr: multiaddr, iface, - } => serializer.serialize_value(&JournalEntrySocketLeaveIpv4MulticastV1 { - fd, - multiaddr, - iface, - }), + } => serialize_using( + &JournalEntrySocketLeaveIpv4MulticastV1 { + fd, + multiaddr, + iface, + }, + serializer, + ), JournalEntry::SocketLeaveIpv6MulticastV1 { fd, multi_addr: multiaddr, iface, - } => serializer.serialize_value(&JournalEntrySocketLeaveIpv6MulticastV1 { - fd, - multiaddr, - iface, - }), + } => serialize_using( + &JournalEntrySocketLeaveIpv6MulticastV1 { + fd, + multiaddr, + iface, + }, + serializer, + ), JournalEntry::SocketSendFileV1 { socket_fd, file_fd, offset, count, - } => serializer.serialize_value(&JournalEntrySocketSendFileV1 { - socket_fd, - file_fd, - offset, - count, - }), + } => serialize_using( + &JournalEntrySocketSendFileV1 { + socket_fd, + file_fd, + offset, + count, + }, + serializer, + ), JournalEntry::SocketSendToV1 { fd, data, flags, addr, is_64bit, - } => serializer.serialize_value(&JournalEntrySocketSendToV1 { - fd, - data: data.into(), - flags, - addr, - is_64bit, - }), + } => serialize_using( + &JournalEntrySocketSendToV1 { + fd, + data: data.into(), + flags, + addr, + is_64bit, + }, + serializer, + ), JournalEntry::SocketSendV1 { fd, data, flags, is_64bit, - } => serializer.serialize_value(&JournalEntrySocketSendV1 { - fd, - data: data.into(), - flags, - is_64bit, - }), - JournalEntry::SocketSetOptFlagV1 { fd, opt, flag } => { - serializer.serialize_value(&JournalEntrySocketSetOptFlagV1 { + } => serialize_using( + &JournalEntrySocketSendV1 { + fd, + data: data.into(), + flags, + is_64bit, + }, + serializer, + ), + JournalEntry::SocketSetOptFlagV1 { fd, opt, flag } => serialize_using( + &JournalEntrySocketSetOptFlagV1 { fd, opt: opt.into(), flag, - }) - } - JournalEntry::SocketSetOptSizeV1 { fd, opt, size } => { - serializer.serialize_value(&JournalEntrySocketSetOptSizeV1 { + }, + serializer, + ), + JournalEntry::SocketSetOptSizeV1 { fd, opt, size } => serialize_using( + &JournalEntrySocketSetOptSizeV1 { fd, opt: opt.into(), size, - }) - } - JournalEntry::SocketSetOptTimeV1 { fd, ty, time } => { - serializer.serialize_value(&JournalEntrySocketSetOptTimeV1 { + }, + serializer, + ), + JournalEntry::SocketSetOptTimeV1 { fd, ty, time } => serialize_using( + &JournalEntrySocketSetOptTimeV1 { fd, ty: ty.into(), time, - }) - } - JournalEntry::SocketShutdownV1 { fd, how } => { - serializer.serialize_value(&JournalEntrySocketShutdownV1 { + }, + serializer, + ), + JournalEntry::SocketShutdownV1 { fd, how } => serialize_using( + &JournalEntrySocketShutdownV1 { fd, how: how.into(), - }) - } - JournalEntry::SnapshotV1 { when, trigger } => { - serializer.serialize_value(&JournalEntrySnapshotV1 { + }, + serializer, + ), + JournalEntry::SnapshotV1 { when, trigger } => serialize_using( + &JournalEntrySnapshotV1 { since_epoch: when .duration_since(SystemTime::UNIX_EPOCH) .unwrap_or(Duration::ZERO), trigger: trigger.into(), - }) - } + }, + serializer, + ), } .map_err(|err| anyhow::format_err!("failed to serialize journal record - {}", err))?; Ok(amt) @@ -877,7 +902,7 @@ impl<'a> JournalEntry<'a> { /// changes to the journal entry types without having to /// worry about backward and forward compatibility #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub(crate) struct JournalEntryHeader { pub record_type: u16, pub record_size: u64, @@ -948,7 +973,7 @@ pub enum ArchivedJournalEntry<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryInitModuleV1 { pub wasm_hash: Box<[u8]>, } @@ -956,13 +981,13 @@ pub struct JournalEntryInitModuleV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryClearEtherealV1 {} #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryProcessExitV1 { pub exit_code: Option, } @@ -970,7 +995,7 @@ pub struct JournalEntryProcessExitV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntrySetThreadV1<'a> { pub id: u32, pub call_stack: AlignedCowVec<'a, u8>, @@ -984,7 +1009,7 @@ pub struct JournalEntrySetThreadV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryCloseThreadV1 { pub id: u32, pub exit_code: Option, @@ -993,7 +1018,7 @@ pub struct JournalEntryCloseThreadV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorSeekV1 { pub fd: u32, pub whence: JournalWhenceV1, @@ -1008,7 +1033,7 @@ pub struct JournalEntryFileDescriptorSeekV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryFileDescriptorWriteV1<'a> { /// DO NOT MOVE! pub data: AlignedCowVec<'a, u8>, @@ -1020,7 +1045,7 @@ pub struct JournalEntryFileDescriptorWriteV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryUpdateMemoryRegionV1<'a> { pub compressed_data: AlignedCowVec<'a, u8>, pub start: u64, @@ -1030,7 +1055,7 @@ pub struct JournalEntryUpdateMemoryRegionV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySetClockTimeV1 { pub clock_id: JournalSnapshot0ClockidV1, pub time: u64, @@ -1039,7 +1064,7 @@ pub struct JournalEntrySetClockTimeV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryOpenFileDescriptorV1<'a> { pub fd: u32, pub dirfd: u32, @@ -1054,7 +1079,7 @@ pub struct JournalEntryOpenFileDescriptorV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryCloseFileDescriptorV1 { pub fd: u32, } @@ -1062,7 +1087,7 @@ pub struct JournalEntryCloseFileDescriptorV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryRenumberFileDescriptorV1 { pub old_fd: u32, pub new_fd: u32, @@ -1071,7 +1096,7 @@ pub struct JournalEntryRenumberFileDescriptorV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryDuplicateFileDescriptorV1 { pub original_fd: u32, pub copied_fd: u32, @@ -1080,7 +1105,7 @@ pub struct JournalEntryDuplicateFileDescriptorV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryCreateDirectoryV1<'a> { pub fd: u32, pub path: AlignedCowStr<'a>, @@ -1089,7 +1114,7 @@ pub struct JournalEntryCreateDirectoryV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryRemoveDirectoryV1<'a> { pub fd: u32, pub path: AlignedCowStr<'a>, @@ -1098,7 +1123,7 @@ pub struct JournalEntryRemoveDirectoryV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryPathSetTimesV1<'a> { pub fd: u32, pub flags: u32, @@ -1111,7 +1136,7 @@ pub struct JournalEntryPathSetTimesV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorSetTimesV1 { pub fd: u32, pub fst_flags: u16, @@ -1122,7 +1147,7 @@ pub struct JournalEntryFileDescriptorSetTimesV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorSetSizeV1 { pub fd: u32, pub st_size: u64, @@ -1131,7 +1156,7 @@ pub struct JournalEntryFileDescriptorSetSizeV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorSetFlagsV1 { pub fd: u32, pub flags: u16, @@ -1140,7 +1165,7 @@ pub struct JournalEntryFileDescriptorSetFlagsV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorSetRightsV1 { pub fd: u32, pub fs_rights_base: u64, @@ -1150,7 +1175,7 @@ pub struct JournalEntryFileDescriptorSetRightsV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorAdviseV1 { pub fd: u32, pub offset: u64, @@ -1161,7 +1186,7 @@ pub struct JournalEntryFileDescriptorAdviseV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryFileDescriptorAllocateV1 { pub fd: u32, pub offset: u64, @@ -1171,7 +1196,7 @@ pub struct JournalEntryFileDescriptorAllocateV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryCreateHardLinkV1<'a> { pub old_fd: u32, pub old_path: AlignedCowStr<'a>, @@ -1183,7 +1208,7 @@ pub struct JournalEntryCreateHardLinkV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryCreateSymbolicLinkV1<'a> { pub fd: u32, pub old_path: AlignedCowStr<'a>, @@ -1193,7 +1218,7 @@ pub struct JournalEntryCreateSymbolicLinkV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryUnlinkFileV1<'a> { pub fd: u32, pub path: AlignedCowStr<'a>, @@ -1202,7 +1227,7 @@ pub struct JournalEntryUnlinkFileV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryPathRenameV1<'a> { pub old_fd: u32, pub old_path: AlignedCowStr<'a>, @@ -1213,7 +1238,7 @@ pub struct JournalEntryPathRenameV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryChangeDirectoryV1<'a> { pub path: AlignedCowStr<'a>, } @@ -1221,7 +1246,7 @@ pub struct JournalEntryChangeDirectoryV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryEpollCreateV1 { pub fd: u32, } @@ -1229,7 +1254,7 @@ pub struct JournalEntryEpollCreateV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryEpollCtlV1 { pub epfd: u32, pub op: JournalEpollCtlV1, @@ -1240,7 +1265,7 @@ pub struct JournalEntryEpollCtlV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryTtySetV1 { pub cols: u32, pub rows: u32, @@ -1257,7 +1282,7 @@ pub struct JournalEntryTtySetV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryCreatePipeV1 { pub fd1: u32, pub fd2: u32, @@ -1266,7 +1291,7 @@ pub struct JournalEntryCreatePipeV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryCreateEventV1 { pub initial_val: u64, pub flags: u16, @@ -1276,7 +1301,7 @@ pub struct JournalEntryCreateEventV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryPortAddAddrV1 { pub cidr: JournalIpCidrV1, } @@ -1284,7 +1309,7 @@ pub struct JournalEntryPortAddAddrV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryPortDelAddrV1 { pub addr: IpAddr, } @@ -1292,7 +1317,7 @@ pub struct JournalEntryPortDelAddrV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntryPortBridgeV1<'a> { pub network: AlignedCowStr<'a>, pub token: AlignedCowStr<'a>, @@ -1302,7 +1327,7 @@ pub struct JournalEntryPortBridgeV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryPortGatewaySetV1 { pub ip: IpAddr, } @@ -1310,7 +1335,7 @@ pub struct JournalEntryPortGatewaySetV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryPortRouteAddV1 { pub cidr: JournalIpCidrV1, pub via_router: IpAddr, @@ -1321,7 +1346,7 @@ pub struct JournalEntryPortRouteAddV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntryPortRouteDelV1 { pub ip: IpAddr, } @@ -1329,7 +1354,7 @@ pub struct JournalEntryPortRouteDelV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketOpenV1 { pub af: JournalAddressfamilyV1, pub ty: JournalSocktypeV1, @@ -1340,7 +1365,7 @@ pub struct JournalEntrySocketOpenV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketListenV1 { pub fd: u32, pub backlog: u32, @@ -1349,7 +1374,7 @@ pub struct JournalEntrySocketListenV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketBindV1 { pub fd: u32, pub addr: SocketAddr, @@ -1358,7 +1383,7 @@ pub struct JournalEntrySocketBindV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketConnectedV1 { pub fd: u32, pub local_addr: SocketAddr, @@ -1368,7 +1393,7 @@ pub struct JournalEntrySocketConnectedV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketAcceptedV1 { pub listen_fd: u32, pub fd: u32, @@ -1381,7 +1406,7 @@ pub struct JournalEntrySocketAcceptedV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketJoinIpv4MulticastV1 { pub fd: u32, pub multiaddr: Ipv4Addr, @@ -1391,7 +1416,7 @@ pub struct JournalEntrySocketJoinIpv4MulticastV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketJoinIpv6MulticastV1 { pub fd: u32, pub multiaddr: Ipv6Addr, @@ -1401,7 +1426,7 @@ pub struct JournalEntrySocketJoinIpv6MulticastV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketLeaveIpv4MulticastV1 { pub fd: u32, pub multiaddr: Ipv4Addr, @@ -1411,7 +1436,7 @@ pub struct JournalEntrySocketLeaveIpv4MulticastV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketLeaveIpv6MulticastV1 { pub fd: u32, pub multiaddr: Ipv6Addr, @@ -1421,7 +1446,7 @@ pub struct JournalEntrySocketLeaveIpv6MulticastV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketSendFileV1 { pub socket_fd: u32, pub file_fd: u32, @@ -1432,7 +1457,7 @@ pub struct JournalEntrySocketSendFileV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntrySocketSendToV1<'a> { pub fd: u32, pub data: AlignedCowVec<'a, u8>, @@ -1444,7 +1469,7 @@ pub struct JournalEntrySocketSendToV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(attr(repr(align(8))))] pub struct JournalEntrySocketSendV1<'a> { pub fd: u32, pub data: AlignedCowVec<'a, u8>, @@ -1455,7 +1480,7 @@ pub struct JournalEntrySocketSendV1<'a> { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketSetOptFlagV1 { pub fd: u32, pub opt: JournalSockoptionV1, @@ -1465,7 +1490,7 @@ pub struct JournalEntrySocketSetOptFlagV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketSetOptSizeV1 { pub fd: u32, pub opt: JournalSockoptionV1, @@ -1475,7 +1500,7 @@ pub struct JournalEntrySocketSetOptSizeV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketSetOptTimeV1 { pub fd: u32, pub ty: JournalTimeTypeV1, @@ -1485,7 +1510,7 @@ pub struct JournalEntrySocketSetOptTimeV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySocketShutdownV1 { pub fd: u32, pub how: JournalSocketShutdownV1, @@ -1494,7 +1519,7 @@ pub struct JournalEntrySocketShutdownV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalEntrySnapshotV1 { pub since_epoch: Duration, pub trigger: JournalSnapshotTriggerV1, @@ -1502,7 +1527,7 @@ pub struct JournalEntrySnapshotV1 { #[repr(C)] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalSnapshot0ClockidV1 { Realtime, Monotonic, @@ -1513,7 +1538,7 @@ pub enum JournalSnapshot0ClockidV1 { #[repr(C)] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalWhenceV1 { Set, Cur, @@ -1523,7 +1548,7 @@ pub enum JournalWhenceV1 { #[repr(C)] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalAdviceV1 { Normal, Sequential, @@ -1537,7 +1562,7 @@ pub enum JournalAdviceV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct JournalIpCidrV1 { pub ip: IpAddr, pub prefix: u8, @@ -1545,7 +1570,7 @@ pub struct JournalIpCidrV1 { #[repr(C)] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalExitCodeV1 { Errno(u16), Other(i32), @@ -1565,7 +1590,7 @@ pub enum JournalExitCodeV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalSnapshotTriggerV1 { Idle, Listen, @@ -1595,7 +1620,7 @@ pub enum JournalSnapshotTriggerV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalEpollCtlV1 { Add, Mod, @@ -1606,7 +1631,7 @@ pub enum JournalEpollCtlV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct JournalEpollEventCtlV1 { pub events: u32, pub ptr: u64, @@ -1629,7 +1654,7 @@ pub struct JournalEpollEventCtlV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalStreamSecurityV1 { Unencrypted, AnyEncryption, @@ -1652,7 +1677,7 @@ pub enum JournalStreamSecurityV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalAddressfamilyV1 { Unspec, Inet4, @@ -1674,7 +1699,7 @@ pub enum JournalAddressfamilyV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalSocktypeV1 { Unknown, Stream, @@ -1697,7 +1722,7 @@ pub enum JournalSocktypeV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalSockoptionV1 { Noop, ReusePort, @@ -1742,7 +1767,7 @@ pub enum JournalSockoptionV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalTimeTypeV1 { ReadTimeout, WriteTimeout, @@ -1766,7 +1791,7 @@ pub enum JournalTimeTypeV1 { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum JournalSocketShutdownV1 { Read, Write, @@ -1788,7 +1813,7 @@ pub enum JournalSocketShutdownV1 { Eq, Hash, )] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub enum JournalThreadStartTypeV1 { MainThread, ThreadSpawn { start_ptr: u64 }, @@ -1797,7 +1822,7 @@ pub enum JournalThreadStartTypeV1 { #[repr(C)] #[repr(align(8))] #[derive(Debug, Clone, Copy, RkyvSerialize, RkyvDeserialize, Archive, PartialEq, Eq, Hash)] -#[archive_attr(derive(CheckBytes), repr(align(8)))] +#[rkyv(derive(Debug), attr(repr(align(8))))] pub struct JournalWasiMemoryLayout { pub stack_upper: u64, pub stack_lower: u64, diff --git a/lib/journal/src/concrete/archived_from.rs b/lib/journal/src/concrete/archived_from.rs index 3d7c7deeee0..724526986f1 100644 --- a/lib/journal/src/concrete/archived_from.rs +++ b/lib/journal/src/concrete/archived_from.rs @@ -161,10 +161,12 @@ impl From for wasi::ExitCode { impl From<&'_ ArchivedJournalExitCodeV1> for wasi::ExitCode { fn from(val: &'_ ArchivedJournalExitCodeV1) -> Self { match val { - ArchivedJournalExitCodeV1::Errno(errno) => { - wasi::ExitCode::Errno((*errno).try_into().unwrap_or(wasi::Errno::Unknown)) - } - ArchivedJournalExitCodeV1::Other(id) => wasi::ExitCode::Other(*id), + ArchivedJournalExitCodeV1::Errno(errno) => wasi::ExitCode::Errno( + (errno.to_native()) + .try_into() + .unwrap_or(wasi::Errno::Unknown), + ), + ArchivedJournalExitCodeV1::Other(id) => wasi::ExitCode::Other(id.to_native()), } } } @@ -289,11 +291,11 @@ impl From for wasi::EpollEventCtl { impl From<&'_ ArchivedJournalEpollEventCtlV1> for wasi::EpollEventCtl { fn from(val: &'_ ArchivedJournalEpollEventCtlV1) -> Self { Self { - events: wasi::EpollType::from_bits_truncate(val.events), - ptr: val.ptr, - fd: val.fd, - data1: val.data1, - data2: val.data2, + events: wasi::EpollType::from_bits_truncate(val.events.to_native()), + ptr: val.ptr.to_native(), + fd: val.fd.to_native(), + data1: val.data1.to_native(), + data2: val.data2.to_native(), } } } @@ -593,7 +595,7 @@ impl From<&'_ ArchivedJournalThreadStartTypeV1> for ThreadStartType { ArchivedJournalThreadStartTypeV1::MainThread => ThreadStartType::MainThread, ArchivedJournalThreadStartTypeV1::ThreadSpawn { start_ptr } => { ThreadStartType::ThreadSpawn { - start_ptr: *start_ptr, + start_ptr: start_ptr.to_native(), } } } @@ -625,10 +627,10 @@ impl From for WasiMemoryLayout { impl From<&'_ ArchivedJournalWasiMemoryLayout> for WasiMemoryLayout { fn from(value: &'_ ArchivedJournalWasiMemoryLayout) -> Self { Self { - stack_upper: value.stack_upper, - stack_lower: value.stack_lower, - guard_size: value.guard_size, - stack_size: value.stack_size, + stack_upper: value.stack_upper.to_native(), + stack_lower: value.stack_lower.to_native(), + guard_size: value.guard_size.to_native(), + stack_size: value.stack_size.to_native(), } } } @@ -664,7 +666,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { compressed_data, }, ) => Self::UpdateMemoryRegionV1 { - region: (*start)..(*end), + region: (start.to_native())..(end.to_native()), compressed_data: Cow::Borrowed(compressed_data.as_ref()), }, ArchivedJournalEntry::ProcessExitV1(ArchivedJournalEntryProcessExitV1 { @@ -681,7 +683,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { start, layout, }) => Self::SetThreadV1 { - id: *id, + id: id.to_native(), call_stack: call_stack.as_ref().into(), memory_stack: memory_stack.as_ref().into(), store_data: store_data.as_ref().into(), @@ -693,7 +695,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { id, exit_code, }) => Self::CloseThreadV1 { - id: *id, + id: id.to_native(), exit_code: exit_code.as_ref().map(|code| code.into()), }, ArchivedJournalEntry::FileDescriptorWriteV1( @@ -705,8 +707,8 @@ impl<'a> TryFrom> for JournalEntry<'a> { }, ) => Self::FileDescriptorWriteV1 { data: data.as_ref().into(), - fd: *fd, - offset: *offset, + fd: fd.to_native(), + offset: offset.to_native(), is_64bit: *is_64bit, }, ArchivedJournalEntry::FileDescriptorSeekV1( @@ -716,8 +718,8 @@ impl<'a> TryFrom> for JournalEntry<'a> { ref whence, }, ) => Self::FileDescriptorSeekV1 { - fd: *fd, - offset: *offset, + fd: fd.to_native(), + offset: offset.to_native(), whence: whence.into(), }, ArchivedJournalEntry::OpenFileDescriptorV1( @@ -732,28 +734,30 @@ impl<'a> TryFrom> for JournalEntry<'a> { fs_flags, }, ) => Self::OpenFileDescriptorV1 { - fd: *fd, - dirfd: *dirfd, - dirflags: *dirflags, + fd: fd.to_native(), + dirfd: dirfd.to_native(), + dirflags: dirflags.to_native(), path: String::from_utf8_lossy(path.as_ref()), - o_flags: wasi::Oflags::from_bits_truncate(*o_flags), - fs_rights_base: wasi::Rights::from_bits_truncate(*fs_rights_base), - fs_rights_inheriting: wasi::Rights::from_bits_truncate(*fs_rights_inheriting), - fs_flags: wasi::Fdflags::from_bits_truncate(*fs_flags), + o_flags: wasi::Oflags::from_bits_truncate(o_flags.to_native()), + fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()), + fs_rights_inheriting: wasi::Rights::from_bits_truncate( + fs_rights_inheriting.to_native(), + ), + fs_flags: wasi::Fdflags::from_bits_truncate(fs_flags.to_native()), }, ArchivedJournalEntry::CloseFileDescriptorV1( ArchivedJournalEntryCloseFileDescriptorV1 { fd }, - ) => Self::CloseFileDescriptorV1 { fd: *fd }, + ) => Self::CloseFileDescriptorV1 { fd: fd.to_native() }, ArchivedJournalEntry::RemoveDirectoryV1(ArchivedJournalEntryRemoveDirectoryV1 { fd, path, }) => Self::RemoveDirectoryV1 { - fd: *fd, + fd: fd.to_native(), path: String::from_utf8_lossy(path.as_ref()), }, ArchivedJournalEntry::UnlinkFileV1(ArchivedJournalEntryUnlinkFileV1 { fd, path }) => { Self::UnlinkFileV1 { - fd: *fd, + fd: fd.to_native(), path: String::from_utf8_lossy(path.as_ref()), } } @@ -763,9 +767,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { new_fd, new_path, }) => Self::PathRenameV1 { - old_fd: *old_fd, + old_fd: old_fd.to_native(), old_path: String::from_utf8_lossy(old_path.as_ref()), - new_fd: *new_fd, + new_fd: new_fd.to_native(), new_path: String::from_utf8_lossy(new_path.as_ref()), }, ArchivedJournalEntry::SnapshotV1(ArchivedJournalEntrySnapshotV1 { @@ -782,13 +786,13 @@ impl<'a> TryFrom> for JournalEntry<'a> { time, }) => Self::SetClockTimeV1 { clock_id: clock_id.into(), - time: *time, + time: time.to_native(), }, ArchivedJournalEntry::RenumberFileDescriptorV1( ArchivedJournalEntryRenumberFileDescriptorV1 { old_fd, new_fd }, ) => Self::RenumberFileDescriptorV1 { - old_fd: *old_fd, - new_fd: *new_fd, + old_fd: old_fd.to_native(), + new_fd: new_fd.to_native(), }, ArchivedJournalEntry::DuplicateFileDescriptorV1( ArchivedJournalEntryDuplicateFileDescriptorV1 { @@ -796,14 +800,14 @@ impl<'a> TryFrom> for JournalEntry<'a> { copied_fd: new_fd, }, ) => Self::DuplicateFileDescriptorV1 { - original_fd: *old_fd, - copied_fd: *new_fd, + original_fd: old_fd.to_native(), + copied_fd: new_fd.to_native(), }, ArchivedJournalEntry::CreateDirectoryV1(ArchivedJournalEntryCreateDirectoryV1 { fd, path, }) => Self::CreateDirectoryV1 { - fd: *fd, + fd: fd.to_native(), path: String::from_utf8_lossy(path.as_ref()), }, ArchivedJournalEntry::PathSetTimesV1(ArchivedJournalEntryPathSetTimesV1 { @@ -814,12 +818,12 @@ impl<'a> TryFrom> for JournalEntry<'a> { st_mtim, fst_flags, }) => Self::PathSetTimesV1 { - fd: *fd, + fd: fd.to_native(), path: String::from_utf8_lossy(path.as_ref()), - flags: *flags, - st_atim: *st_atim, - st_mtim: *st_mtim, - fst_flags: wasi::Fstflags::from_bits_truncate(*fst_flags), + flags: flags.to_native(), + st_atim: st_atim.to_native(), + st_mtim: st_mtim.to_native(), + fst_flags: wasi::Fstflags::from_bits_truncate(fst_flags.to_native()), }, ArchivedJournalEntry::FileDescriptorSetTimesV1( ArchivedJournalEntryFileDescriptorSetTimesV1 { @@ -829,22 +833,22 @@ impl<'a> TryFrom> for JournalEntry<'a> { fst_flags, }, ) => Self::FileDescriptorSetTimesV1 { - fd: *fd, - st_atim: *st_atim, - st_mtim: *st_mtim, - fst_flags: wasi::Fstflags::from_bits_truncate(*fst_flags), + fd: fd.to_native(), + st_atim: st_atim.to_native(), + st_mtim: st_mtim.to_native(), + fst_flags: wasi::Fstflags::from_bits_truncate(fst_flags.to_native()), }, ArchivedJournalEntry::FileDescriptorSetSizeV1( ArchivedJournalEntryFileDescriptorSetSizeV1 { fd, st_size }, ) => Self::FileDescriptorSetSizeV1 { - fd: *fd, - st_size: *st_size, + fd: fd.to_native(), + st_size: st_size.to_native(), }, ArchivedJournalEntry::FileDescriptorSetFlagsV1( ArchivedJournalEntryFileDescriptorSetFlagsV1 { fd, flags }, ) => Self::FileDescriptorSetFlagsV1 { - fd: *fd, - flags: wasi::Fdflags::from_bits_truncate(*flags), + fd: fd.to_native(), + flags: wasi::Fdflags::from_bits_truncate(flags.to_native()), }, ArchivedJournalEntry::FileDescriptorSetRightsV1( ArchivedJournalEntryFileDescriptorSetRightsV1 { @@ -853,9 +857,11 @@ impl<'a> TryFrom> for JournalEntry<'a> { fs_rights_inheriting, }, ) => Self::FileDescriptorSetRightsV1 { - fd: *fd, - fs_rights_base: wasi::Rights::from_bits_truncate(*fs_rights_base), - fs_rights_inheriting: wasi::Rights::from_bits_truncate(*fs_rights_inheriting), + fd: fd.to_native(), + fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()), + fs_rights_inheriting: wasi::Rights::from_bits_truncate( + fs_rights_inheriting.to_native(), + ), }, ArchivedJournalEntry::FileDescriptorAdviseV1( ArchivedJournalEntryFileDescriptorAdviseV1 { @@ -865,17 +871,17 @@ impl<'a> TryFrom> for JournalEntry<'a> { ref advice, }, ) => Self::FileDescriptorAdviseV1 { - fd: *fd, - offset: *offset, - len: *len, + fd: fd.to_native(), + offset: offset.to_native(), + len: len.to_native(), advice: advice.into(), }, ArchivedJournalEntry::FileDescriptorAllocateV1( ArchivedJournalEntryFileDescriptorAllocateV1 { fd, offset, len }, ) => Self::FileDescriptorAllocateV1 { - fd: *fd, - offset: *offset, - len: *len, + fd: fd.to_native(), + offset: offset.to_native(), + len: len.to_native(), }, ArchivedJournalEntry::CreateHardLinkV1(ArchivedJournalEntryCreateHardLinkV1 { old_fd, @@ -884,10 +890,10 @@ impl<'a> TryFrom> for JournalEntry<'a> { new_fd, new_path, }) => Self::CreateHardLinkV1 { - old_fd: *old_fd, + old_fd: old_fd.to_native(), old_path: String::from_utf8_lossy(old_path.as_ref()), - old_flags: *old_flags, - new_fd: *new_fd, + old_flags: old_flags.to_native(), + new_fd: new_fd.to_native(), new_path: String::from_utf8_lossy(new_path.as_ref()), }, ArchivedJournalEntry::CreateSymbolicLinkV1( @@ -898,7 +904,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { }, ) => Self::CreateSymbolicLinkV1 { old_path: String::from_utf8_lossy(old_path.as_ref()), - fd: *fd, + fd: fd.to_native(), new_path: String::from_utf8_lossy(new_path.as_ref()), }, ArchivedJournalEntry::ChangeDirectoryV1(ArchivedJournalEntryChangeDirectoryV1 { @@ -907,7 +913,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { path: String::from_utf8_lossy(path.as_ref()), }, ArchivedJournalEntry::EpollCreateV1(ArchivedJournalEntryEpollCreateV1 { fd }) => { - Self::EpollCreateV1 { fd: *fd } + Self::EpollCreateV1 { fd: fd.to_native() } } ArchivedJournalEntry::EpollCtlV1(ArchivedJournalEntryEpollCtlV1 { epfd, @@ -915,9 +921,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { fd, ref event, }) => Self::EpollCtlV1 { - epfd: *epfd, + epfd: epfd.to_native(), op: op.into(), - fd: *fd, + fd: fd.to_native(), event: event.as_ref().map(|e| e.into()), }, ArchivedJournalEntry::TtySetV1(ArchivedJournalEntryTtySetV1 { @@ -933,10 +939,10 @@ impl<'a> TryFrom> for JournalEntry<'a> { line_feeds, }) => Self::TtySetV1 { tty: wasi::Tty { - cols: *cols, - rows: *rows, - width: *width, - height: *height, + cols: cols.to_native(), + rows: rows.to_native(), + width: width.to_native(), + height: height.to_native(), stdin_tty: *stdin_tty, stdout_tty: *stdout_tty, stderr_tty: *stderr_tty, @@ -947,8 +953,8 @@ impl<'a> TryFrom> for JournalEntry<'a> { }, ArchivedJournalEntry::CreatePipeV1(ArchivedJournalEntryCreatePipeV1 { fd1, fd2 }) => { Self::CreatePipeV1 { - fd1: *fd1, - fd2: *fd2, + fd1: fd1.to_native(), + fd2: fd2.to_native(), } } ArchivedJournalEntry::PortAddAddrV1(ArchivedJournalEntryPortAddAddrV1 { cidr }) => { @@ -1007,19 +1013,19 @@ impl<'a> TryFrom> for JournalEntry<'a> { }) => Self::SocketOpenV1 { af: af.into(), ty: ty.into(), - pt: (*pt).try_into().unwrap_or(wasi::SockProto::Max), - fd: *fd, + pt: (pt.to_native()).try_into().unwrap_or(wasi::SockProto::Max), + fd: fd.to_native(), }, ArchivedJournalEntry::SocketListenV1(ArchivedJournalEntrySocketListenV1 { fd, backlog, }) => Self::SocketListenV1 { - fd: *fd, - backlog: *backlog, + fd: fd.to_native(), + backlog: backlog.to_native(), }, ArchivedJournalEntry::SocketBindV1(ArchivedJournalEntrySocketBindV1 { fd, addr }) => { Self::SocketBindV1 { - fd: *fd, + fd: fd.to_native(), addr: addr.as_socket_addr(), } } @@ -1028,7 +1034,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { local_addr, peer_addr, }) => Self::SocketConnectedV1 { - fd: *fd, + fd: fd.to_native(), local_addr: local_addr.as_socket_addr(), peer_addr: peer_addr.as_socket_addr(), }, @@ -1040,11 +1046,11 @@ impl<'a> TryFrom> for JournalEntry<'a> { fd_flags, nonblocking, }) => Self::SocketAcceptedV1 { - listen_fd: *listen_fd, - fd: *fd, + listen_fd: listen_fd.to_native(), + fd: fd.to_native(), local_addr: local_addr.as_socket_addr(), peer_addr: peer_addr.as_socket_addr(), - fd_flags: wasi::Fdflags::from_bits_truncate(*fd_flags), + fd_flags: wasi::Fdflags::from_bits_truncate(fd_flags.to_native()), non_blocking: *nonblocking, }, ArchivedJournalEntry::SocketJoinIpv4MulticastV1( @@ -1054,7 +1060,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { iface, }, ) => Self::SocketJoinIpv4MulticastV1 { - fd: *fd, + fd: fd.to_native(), multiaddr: multiaddr.as_ipv4(), iface: iface.as_ipv4(), }, @@ -1065,9 +1071,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { iface, }, ) => Self::SocketJoinIpv6MulticastV1 { - fd: *fd, + fd: fd.to_native(), multi_addr: multiaddr.as_ipv6(), - iface: *iface, + iface: iface.to_native(), }, ArchivedJournalEntry::SocketLeaveIpv4MulticastV1( ArchivedJournalEntrySocketLeaveIpv4MulticastV1 { @@ -1076,7 +1082,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { iface, }, ) => Self::SocketLeaveIpv4MulticastV1 { - fd: *fd, + fd: fd.to_native(), multi_addr: multiaddr.as_ipv4(), iface: iface.as_ipv4(), }, @@ -1087,9 +1093,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { iface, }, ) => Self::SocketLeaveIpv6MulticastV1 { - fd: *fd, + fd: fd.to_native(), multi_addr: multiaddr.as_ipv6(), - iface: *iface, + iface: iface.to_native(), }, ArchivedJournalEntry::SocketSendFileV1(ArchivedJournalEntrySocketSendFileV1 { socket_fd, @@ -1097,10 +1103,10 @@ impl<'a> TryFrom> for JournalEntry<'a> { offset, count, }) => Self::SocketSendFileV1 { - socket_fd: *socket_fd, - file_fd: *file_fd, - offset: *offset, - count: *count, + socket_fd: socket_fd.to_native(), + file_fd: file_fd.to_native(), + offset: offset.to_native(), + count: count.to_native(), }, ArchivedJournalEntry::SocketSendToV1(ArchivedJournalEntrySocketSendToV1 { fd, @@ -1109,9 +1115,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { addr, is_64bit, }) => Self::SocketSendToV1 { - fd: *fd, + fd: fd.to_native(), data: data.as_ref().into(), - flags: *flags, + flags: flags.to_native(), addr: addr.as_socket_addr(), is_64bit: *is_64bit, }, @@ -1121,9 +1127,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { flags, is_64bit, }) => Self::SocketSendV1 { - fd: *fd, + fd: fd.to_native(), data: data.as_ref().into(), - flags: *flags, + flags: flags.to_native(), is_64bit: *is_64bit, }, ArchivedJournalEntry::SocketSetOptFlagV1(ArchivedJournalEntrySocketSetOptFlagV1 { @@ -1131,7 +1137,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { ref opt, flag, }) => Self::SocketSetOptFlagV1 { - fd: *fd, + fd: fd.to_native(), opt: opt.into(), flag: *flag, }, @@ -1140,16 +1146,16 @@ impl<'a> TryFrom> for JournalEntry<'a> { ref opt, size, }) => Self::SocketSetOptSizeV1 { - fd: *fd, + fd: fd.to_native(), opt: opt.into(), - size: *size, + size: size.to_native(), }, ArchivedJournalEntry::SocketSetOptTimeV1(ArchivedJournalEntrySocketSetOptTimeV1 { fd, ref ty, time, }) => Self::SocketSetOptTimeV1 { - fd: *fd, + fd: fd.to_native(), ty: ty.into(), time: time.as_ref().map(|time| (*time).into()), }, @@ -1157,7 +1163,7 @@ impl<'a> TryFrom> for JournalEntry<'a> { fd, ref how, }) => Self::SocketShutdownV1 { - fd: *fd, + fd: fd.to_native(), how: how.into(), }, ArchivedJournalEntry::CreateEventV1(ArchivedJournalEntryCreateEventV1 { @@ -1165,9 +1171,9 @@ impl<'a> TryFrom> for JournalEntry<'a> { flags, fd, }) => Self::CreateEventV1 { - initial_val: *initial_val, - flags: *flags, - fd: *fd, + initial_val: initial_val.to_native(), + flags: flags.to_native(), + fd: fd.to_native(), }, }) } diff --git a/lib/journal/src/concrete/log_file.rs b/lib/journal/src/concrete/log_file.rs index 3ae99aa0c92..ab8a0337602 100644 --- a/lib/journal/src/concrete/log_file.rs +++ b/lib/journal/src/concrete/log_file.rs @@ -1,7 +1,13 @@ use bytes::Buf; -use rkyv::ser::{ - serializers::{AllocScratch, CompositeSerializer, SharedSerializeMap, WriteSerializer}, - Serializer, +use rkyv::{ + api::high::HighSerializer, + rancor::Strategy, + ser::{ + allocator::{Arena, ArenaHandle}, + sharing::Share, + writer::IoWriter, + Positional, Serializer, Writer, + }, }; use shared_buffer::OwnedBuffer; use std::{ @@ -31,10 +37,49 @@ pub struct LogFileJournal { rx: LogFileJournalRx, } -#[derive(Debug)] struct TxState { + /// The original handle to the file + underlying_file: File, + + /// A modified handle to the original underlying file file: File, - serializer: CompositeSerializer, AllocScratch, SharedSerializeMap>, + + /// The arena necessary for serialization + arena: Arena, + + /// The latest position in the file the serializator got to + pos: usize, +} + +impl TxState { + fn get_serializer(&mut self) -> Serializer, ArenaHandle<'_>, Share> { + self.get_serializer_with_pos(self.pos) + } + + fn get_serializer_with_pos( + &mut self, + pos: usize, + ) -> Serializer, ArenaHandle<'_>, Share> { + Serializer::new( + IoWriter::with_pos(&self.file, pos), + self.arena.acquire(), + Share::new(), + ) + } + + fn to_high<'a>( + serializer: &'a mut Serializer, ArenaHandle<'a>, Share>, + ) -> &'a mut HighSerializer, ArenaHandle<'a>, rkyv::rancor::Error> { + Strategy::wrap(serializer) + } +} + +impl std::fmt::Debug for TxState { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("TxState") + .field("file", &self.underlying_file) + .finish() + } } #[derive(Debug, Clone)] @@ -63,7 +108,7 @@ impl LogFileJournalRx { impl LogFileJournalTx { pub fn as_rx(&self) -> anyhow::Result { let state = self.state.lock().unwrap(); - let file = state.file.try_clone()?; + let file = state.underlying_file.try_clone()?; let store = OffloadBackingStore::from_file(&file); let buffer = store.owned_buffer(); @@ -124,24 +169,35 @@ impl LogFileJournal { // Move to the end of the file and write the // magic if one is needed let underlying_file = file.try_clone()?; + let arena = Arena::new(); + let end_pos = file.seek(SeekFrom::End(0))?; - let mut serializer = WriteSerializer::with_pos(file, end_pos as usize); + + let mut tx = TxState { + underlying_file, + arena, + file, + pos: end_pos as usize, + }; + + let mut serializer = tx.get_serializer(); + let serializer = TxState::to_high(&mut serializer); + if serializer.pos() == 0 { let magic = JOURNAL_MAGIC_NUMBER; let magic = magic.to_be_bytes(); serializer.write(&magic)?; } + let last_pos = serializer.pos(); + let _ = serializer; + + tx.arena.shrink(); + tx.pos = last_pos; + // Create the tx let tx = LogFileJournalTx { - state: Arc::new(Mutex::new(TxState { - file: underlying_file, - serializer: CompositeSerializer::new( - serializer, - AllocScratch::default(), - SharedSerializeMap::default(), - ), - })), + state: Arc::new(Mutex::new(tx)), }; // First we create the readable journal @@ -178,27 +234,36 @@ impl WritableJournal for LogFileJournalTx { // Write the header (with a record size of zero) let record_type: JournalEntryRecordType = entry.archive_record_type(); - let offset_header = state.serializer.pos() as u64; - state.serializer.write(&[0u8; 8])?; + let mut serializer = state.get_serializer(); + let serializer = TxState::to_high(&mut serializer); + let offset_header = serializer.pos() as u64; + tracing::trace!("serpos is {offset_header}"); + serializer.write(&[0u8; 8])?; // Now serialize the actual data to the log - let offset_start = state.serializer.pos() as u64; - entry.serialize_archive(&mut state.serializer)?; - let offset_end = state.serializer.pos() as u64; + let offset_start = serializer.pos() as u64; + entry.serialize_archive(serializer)?; + let offset_end = serializer.pos() as u64; let record_size = offset_end - offset_start; tracing::trace!( "delimiter header={offset_header},start={offset_start},record_size={record_size}" ); + let last_pos = serializer.pos(); + let _ = serializer; + // Write the record and then move back to the end again - state.file.seek(SeekFrom::Start(offset_header))?; + state.underlying_file.seek(SeekFrom::Start(offset_header))?; let header_bytes = { let a = (record_type as u16).to_be_bytes(); let b = &record_size.to_be_bytes()[2..8]; [a[0], a[1], b[0], b[1], b[2], b[3], b[4], b[5]] }; - state.file.write_all(&header_bytes)?; - state.file.seek(SeekFrom::Start(offset_end))?; + state.underlying_file.write_all(&header_bytes)?; + state.underlying_file.seek(SeekFrom::Start(offset_end))?; + + state.arena.shrink(); + state.pos = last_pos; // Now write the actual data and update the offsets Ok(LogWriteResult { @@ -209,7 +274,7 @@ impl WritableJournal for LogFileJournalTx { fn flush(&self) -> anyhow::Result<()> { let mut state = self.state.lock().unwrap(); - state.file.flush()?; + state.underlying_file.flush()?; Ok(()) } } diff --git a/lib/journal/src/concrete/tests.rs b/lib/journal/src/concrete/tests.rs index f9d22117c34..0a5d9395d3b 100644 --- a/lib/journal/src/concrete/tests.rs +++ b/lib/journal/src/concrete/tests.rs @@ -5,8 +5,14 @@ use std::{ use super::*; use lz4_flex::compress_prepend_size; -use rkyv::ser::serializers::{ - AllocScratch, CompositeSerializer, SharedSerializeMap, WriteSerializer, +use rkyv::{ + api::high::HighSerializer, + rancor::Strategy, + ser::{ + allocator::{Arena, ArenaHandle}, + sharing::Share, + Serializer, + }, }; use wasmer_wasix_types::wasi; @@ -18,14 +24,13 @@ pub fn run_test(record: JournalEntry<'_>) { tracing::info!("record_type: {:?}", record_type); // Serialize it + let mut arena = Arena::new(); let mut buffer = Vec::new(); - let mut serializer = CompositeSerializer::new( - WriteSerializer::new(&mut buffer), - AllocScratch::default(), - SharedSerializeMap::default(), - ); + let mut serializer = Serializer::new(&mut buffer, arena.acquire(), Share::new()); + let serializer: &mut HighSerializer<&mut Vec, ArenaHandle, rkyv::rancor::Error> = + Strategy::wrap(&mut serializer); - record.clone().serialize_archive(&mut serializer).unwrap(); + record.clone().serialize_archive(serializer).unwrap(); let buffer = &buffer[..]; if buffer.len() < 20 { tracing::info!("buffer: {:x?}", buffer); diff --git a/lib/registry/Cargo.toml b/lib/registry/Cargo.toml index bdf0b036a25..2de8063f32d 100644 --- a/lib/registry/Cargo.toml +++ b/lib/registry/Cargo.toml @@ -10,19 +10,34 @@ repository.workspace = true rust-version.workspace = true [features] -build-package = ["rusqlite", "indexmap", "wasmer-wasm-interface", "wasmparser", "rpassword", "minisign", "time"] +build-package = [ + "rusqlite", + "indexmap", + "wasmer-wasm-interface", + "wasmparser", + "rpassword", + "minisign", + "time", +] +full = [] [dependencies] anyhow = "1.0.65" -clap = { version = "4.3.7", default-features = false, features = ["derive", "env"], optional = true } +clap = { version = "4.3.7", default-features = false, features = [ + "derive", + "env", +], optional = true } console = "0.15.2" dialoguer = "0.11.0" dirs = "4.0.0" filetime = "0.2.19" flate2 = "1.0.24" futures = "0.3" -futures-util = "0.3.25" -graphql-ws-client = {version = "0.8.0", features = ["async-tungstenite", "client-graphql-client"]} +futures-util = { workspace = true } +graphql-ws-client = { version = "0.8.0", features = [ + "async-tungstenite", + "client-graphql-client", +] } graphql_client = "0.13.0" hex = "0.4.3" indexmap = { version = "1.9.3", optional = true } @@ -33,7 +48,12 @@ lzma-rs = "0.2.0" minisign = { version = "0.7.2", optional = true } rand = "0.8.5" regex = "1.7.0" -reqwest = { workspace = true, default-features = false, features = ["blocking", "multipart", "json", "stream"] } +reqwest = { workspace = true, default-features = false, features = [ + "blocking", + "multipart", + "json", + "stream", +] } rpassword = { version = "7.2.0", optional = true } rusqlite = { version = "0.28.0", optional = true, features = ["bundled"] } semver = "1.0.14" @@ -42,10 +62,14 @@ serde_json = "1.0.85" tar = "0.4.38" tempfile = "3.6.0" thiserror = "1.0.37" -time = { version = "0.3.17", default-features = false, features = ["parsing", "std", "formatting"], optional = true } +time = { version = "0.3.17", default-features = false, features = [ + "parsing", + "std", + "formatting", +], optional = true } tldextract = "0.6.0" -tokio = {version = "1", features = ["rt-multi-thread"]} -tokio-tungstenite = {version = "0.21", features = ["rustls-tls-native-roots"]} +tokio = { version = "1", features = ["rt-multi-thread"] } +tokio-tungstenite = { version = "0.21", features = ["rustls-tls-native-roots"] } toml.workspace = true tracing = "0.1.40" url = "2.5.0" @@ -54,7 +78,10 @@ wasmer-wasm-interface = { version = "4.3.7", path = "../wasm-interface", optiona wasmparser = { workspace = true, optional = true } whoami = "1.2.3" webc.workspace = true -async-tungstenite = { version = "0.25.1", features = ["tokio-runtime", "tokio-rustls-native-certs"] } +async-tungstenite = { version = "0.25.1", features = [ + "tokio-runtime", + "tokio-rustls-native-certs", +] } [dev-dependencies] pretty_assertions = "1.3.0" diff --git a/lib/registry/src/lib.rs b/lib/registry/src/lib.rs index 6804d864e1d..3303ef97c0e 100644 --- a/lib/registry/src/lib.rs +++ b/lib/registry/src/lib.rs @@ -349,7 +349,7 @@ where if entry.header().entry_type().is_file() { entry.unpack_in(&dst_normalized)?; } else if entry.header().entry_type() == EntryType::Directory { - std::fs::create_dir_all(&Path::new(&dst_normalized).join(&path))?; + std::fs::create_dir_all(Path::new(&dst_normalized).join(&path))?; } } Ok(()) diff --git a/lib/types/Cargo.toml b/lib/types/Cargo.toml index d36bb7fafd0..510f6a11a3b 100644 --- a/lib/types/Cargo.toml +++ b/lib/types/Cargo.toml @@ -13,11 +13,14 @@ rust-version.workspace = true version.workspace = true [dependencies] -serde = { version = "1.0", features = ["derive", "rc"], optional = true, default-features = false } +serde = { version = "1.0", features = [ + "derive", + "rc", +], optional = true, default-features = false } serde_bytes = { version = "0.11", optional = true } thiserror = "1.0" more-asserts = "0.2" -indexmap = { version = "1.6" } +indexmap = { workspace = true } rkyv = { workspace = true } enum-iterator = "0.7.0" target-lexicon = { version = "0.12.2", default-features = false } @@ -40,7 +43,7 @@ memoffset.workspace = true default = ["std"] std = [] core = [] -enable-serde = ["serde", "serde/std", "serde_bytes", "indexmap/serde-1"] +enable-serde = ["serde", "serde/std", "serde_bytes", "indexmap/serde"] [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] diff --git a/lib/types/src/compilation/address_map.rs b/lib/types/src/compilation/address_map.rs index 0fee3ccd217..bb3adf5ed7d 100644 --- a/lib/types/src/compilation/address_map.rs +++ b/lib/types/src/compilation/address_map.rs @@ -1,3 +1,9 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + //! Data structures to provide transformation of the source // addresses of a WebAssembly module into the native code. @@ -10,7 +16,7 @@ use serde::{Deserialize, Serialize}; /// Single source location to generated address mapping. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, Copy, PartialEq, Eq)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct InstructionAddressMap { /// Original source location. pub srcloc: SourceLoc, @@ -25,7 +31,7 @@ pub struct InstructionAddressMap { /// Function and its instructions addresses mappings. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq, Default)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct FunctionAddressMap { /// Instructions maps. /// The array is sorted by the InstructionAddressMap::code_offset field. diff --git a/lib/types/src/compilation/function.rs b/lib/types/src/compilation/function.rs index aabf1195674..ad6e9f58b86 100644 --- a/lib/types/src/compilation/function.rs +++ b/lib/types/src/compilation/function.rs @@ -1,3 +1,8 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] // This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md @@ -24,7 +29,7 @@ use super::unwind::CompiledFunctionUnwindInfoLike; /// the frame information after a `Trap`. #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq, Default)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct CompiledFunctionFrameInfo { /// The traps (in the function body). /// @@ -38,7 +43,7 @@ pub struct CompiledFunctionFrameInfo { /// The function body. #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct FunctionBody { /// The function body bytes. #[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))] @@ -91,7 +96,7 @@ impl<'a> FunctionBodyLike<'a> for ArchivedFunctionBody { /// and unwind information). #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct CompiledFunction { /// The function body. pub body: FunctionBody, @@ -116,10 +121,8 @@ pub type CustomSections = PrimaryMap; /// In the future this structure may also hold other information useful /// for debugging. #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] -#[derive( - RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes, Debug, PartialEq, Eq, Clone, -)] -#[archive(as = "Self")] +#[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, PartialEq, Eq, Clone)] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct Dwarf { /// The section index in the [`Compilation`] that corresponds to the exception frames. /// [Learn diff --git a/lib/types/src/compilation/module.rs b/lib/types/src/compilation/module.rs index 43be092d271..1d2f9ffbdd7 100644 --- a/lib/types/src/compilation/module.rs +++ b/lib/types/src/compilation/module.rs @@ -1,3 +1,9 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + //! Types for modules. use crate::entity::PrimaryMap; use crate::{Features, MemoryIndex, MemoryStyle, ModuleInfo, TableIndex, TableStyle}; @@ -13,7 +19,7 @@ use std::sync::Arc; /// or the `MemoryStyle` and `TableStyle`). #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] #[derive(Debug, Clone, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct CompileModuleInfo { /// The features used for compiling the module pub features: Features, diff --git a/lib/types/src/compilation/relocation.rs b/lib/types/src/compilation/relocation.rs index 0b1b1331a10..3d2c3824717 100644 --- a/lib/types/src/compilation/relocation.rs +++ b/lib/types/src/compilation/relocation.rs @@ -1,3 +1,9 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + //! Relocation is the process of assigning load addresses for position-dependent //! code and data of a program and adjusting the code and data to reflect the //! assigned addresses. @@ -21,10 +27,8 @@ use serde::{Deserialize, Serialize}; /// Relocation kinds for every ISA. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive( - RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes, Copy, Clone, Debug, PartialEq, Eq, -)] -#[archive(as = "Self")] +#[derive(RkyvSerialize, RkyvDeserialize, Archive, Copy, Clone, Debug, PartialEq, Eq)] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u8)] pub enum RelocationKind { /// absolute 4-byte @@ -93,7 +97,7 @@ impl fmt::Display for RelocationKind { /// A record of a relocation to perform. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct Relocation { /// The relocation kind. pub kind: RelocationKind, @@ -193,28 +197,26 @@ impl RelocationLike for Relocation { impl RelocationLike for ArchivedRelocation { fn kind(&self) -> RelocationKind { - self.kind + rkyv::deserialize::<_, String>(&self.kind).unwrap() } fn reloc_target(&self) -> RelocationTarget { - self.reloc_target + rkyv::deserialize::<_, String>(&self.reloc_target).unwrap() } fn offset(&self) -> CodeOffset { - self.offset + self.offset.into() } fn addend(&self) -> Addend { - self.addend + self.addend.into() } } /// Destination function. Can be either user function or some special one, like `memory.grow`. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive( - RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes, Debug, Copy, Clone, PartialEq, Eq, -)] -#[archive(as = "Self")] +#[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Copy, Clone, PartialEq, Eq)] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u8)] pub enum RelocationTarget { /// A relocation to a function defined locally in the wasm (not an imported one). diff --git a/lib/types/src/compilation/section.rs b/lib/types/src/compilation/section.rs index 14d97f34600..b29c1559c41 100644 --- a/lib/types/src/compilation/section.rs +++ b/lib/types/src/compilation/section.rs @@ -1,3 +1,9 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + //! This module define the required structures to emit custom //! Sections in a `Compilation`. //! @@ -17,7 +23,6 @@ use serde::{Deserialize, Serialize}; RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, Copy, Clone, PartialEq, @@ -29,7 +34,7 @@ use serde::{Deserialize, Serialize}; Default, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq, PartialOrd))] pub struct SectionIndex(u32); entity_impl!(SectionIndex); @@ -38,10 +43,8 @@ entity_impl!(SectionIndex); /// /// Determines how a custom section may be used. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive( - RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes, Debug, Clone, PartialEq, Eq, -)] -#[archive(as = "Self")] +#[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq)] +#[rkyv(derive(Debug), compare(PartialEq, PartialOrd))] #[repr(u8)] pub enum CustomSectionProtection { /// A custom section with read permission. @@ -57,7 +60,7 @@ pub enum CustomSectionProtection { /// in the emitted module. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct CustomSection { /// Memory protection that applies to this section. pub protection: CustomSectionProtection, @@ -79,7 +82,7 @@ pub struct CustomSection { pub trait CustomSectionLike<'a> { type Relocations: RelocationLike; - fn protection(&self) -> &CustomSectionProtection; + fn protection(&self) -> CustomSectionProtection; fn bytes(&self) -> &[u8]; fn relocations(&'a self) -> &[Self::Relocations]; } @@ -87,8 +90,8 @@ pub trait CustomSectionLike<'a> { impl<'a> CustomSectionLike<'a> for CustomSection { type Relocations = Relocation; - fn protection(&self) -> &CustomSectionProtection { - &self.protection + fn protection(&self) -> CustomSectionProtection { + self.protection.clone() } fn bytes(&self) -> &[u8] { @@ -103,8 +106,9 @@ impl<'a> CustomSectionLike<'a> for CustomSection { impl<'a> CustomSectionLike<'a> for ArchivedCustomSection { type Relocations = ArchivedRelocation; - fn protection(&self) -> &CustomSectionProtection { - &self.protection + fn protection(&self) -> CustomSectionProtection { + let protection = rkyv::deserialize::(&self.protection); + protection.unwrap() } fn bytes(&self) -> &[u8] { @@ -119,7 +123,7 @@ impl<'a> CustomSectionLike<'a> for ArchivedCustomSection { /// The bytes in the section. #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq, Default)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug), compare(PartialEq, PartialOrd))] pub struct SectionBody(#[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))] Vec); impl SectionBody { diff --git a/lib/types/src/compilation/symbols.rs b/lib/types/src/compilation/symbols.rs index 239034159c6..dc0eb7a48cd 100644 --- a/lib/types/src/compilation/symbols.rs +++ b/lib/types/src/compilation/symbols.rs @@ -1,14 +1,16 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + //! This module define the required structures for compilation symbols. use crate::{ entity::{EntityRef, PrimaryMap}, CompileModuleInfo, DeserializeError, FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SectionIndex, SerializeError, SignatureIndex, }; -use rkyv::{ - archived_value, check_archived_value, de::deserializers::SharedDeserializeMap, - ser::serializers::AllocSerializer, ser::Serializer as RkyvSerializer, Archive, - Deserialize as RkyvDeserialize, Serialize as RkyvSerialize, -}; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; @@ -17,7 +19,7 @@ use serde::{Deserialize, Serialize}; RkyvSerialize, RkyvDeserialize, Archive, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq, PartialOrd))] pub enum Symbol { /// A metadata section, indexed by a unique prefix /// (usually the wasm file SHA256 hash) @@ -50,7 +52,7 @@ pub trait SymbolRegistry: Send + Sync { /// Serializable struct that represents the compiled metadata. #[derive(Debug, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct ModuleMetadata { /// Compile info pub compile_info: CompileModuleInfo, @@ -90,13 +92,9 @@ impl ModuleMetadata { /// The bytes will have the following format: /// RKYV serialization (any length) + POS (8 bytes) pub fn serialize(&self) -> Result, SerializeError> { - let mut serializer = AllocSerializer::<4096>::default(); - let pos = serializer - .serialize_value(self) - .map_err(|err| SerializeError::Generic(format!("{}", err)))? as u64; - let mut serialized_data = serializer.into_serializer().into_inner(); - serialized_data.extend_from_slice(&pos.to_le_bytes()); - Ok(serialized_data.to_vec()) + rkyv::to_bytes::(self) + .map(|v| v.into_vec()) + .map_err(|e| SerializeError::Generic(e.to_string())) } /// Deserialize a Module from a slice. @@ -130,18 +128,7 @@ impl ModuleMetadata { unsafe fn archive_from_slice( metadata_slice: &[u8], ) -> Result<&ArchivedModuleMetadata, DeserializeError> { - if metadata_slice.len() < 8 { - return Err(DeserializeError::Incompatible( - "invalid serialized ModuleMetadata".into(), - )); - } - let mut pos: [u8; 8] = Default::default(); - pos.copy_from_slice(&metadata_slice[metadata_slice.len() - 8..metadata_slice.len()]); - let pos: u64 = u64::from_le_bytes(pos); - Ok(archived_value::( - &metadata_slice[..metadata_slice.len() - 8], - pos as usize, - )) + Ok(rkyv::access_unchecked(metadata_slice)) } /// # Safety @@ -151,15 +138,7 @@ impl ModuleMetadata { fn archive_from_slice_checked( metadata_slice: &[u8], ) -> Result<&ArchivedModuleMetadata, DeserializeError> { - if metadata_slice.len() < 8 { - return Err(DeserializeError::Incompatible( - "invalid serialized ModuleMetadata".into(), - )); - } - let mut pos: [u8; 8] = Default::default(); - pos.copy_from_slice(&metadata_slice[metadata_slice.len() - 8..metadata_slice.len()]); - let pos: u64 = u64::from_le_bytes(pos); - check_archived_value::(&metadata_slice[..metadata_slice.len() - 8], pos as usize) + rkyv::access::<_, rkyv::rancor::Error>(metadata_slice) .map_err(|e| DeserializeError::CorruptedBinary(e.to_string())) } @@ -167,8 +146,7 @@ impl ModuleMetadata { pub fn deserialize_from_archive( archived: &ArchivedModuleMetadata, ) -> Result { - let mut deserializer = SharedDeserializeMap::new(); - RkyvDeserialize::deserialize(archived, &mut deserializer) + rkyv::deserialize::<_, rkyv::rancor::Error>(archived) .map_err(|e| DeserializeError::CorruptedBinary(format!("{:?}", e))) } } diff --git a/lib/types/src/compilation/unwind.rs b/lib/types/src/compilation/unwind.rs index 0dae88d9cb6..64cf53211c2 100644 --- a/lib/types/src/compilation/unwind.rs +++ b/lib/types/src/compilation/unwind.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// [unwind info]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019 #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive, Debug, Clone, PartialEq, Eq)] -#[archive_attr(derive(rkyv::CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub enum CompiledFunctionUnwindInfo { /// Windows UNWIND_INFO. WindowsX64(Vec), diff --git a/lib/types/src/entity/primary_map.rs b/lib/types/src/entity/primary_map.rs index a810791331e..4f7ddc6a3ec 100644 --- a/lib/types/src/entity/primary_map.rs +++ b/lib/types/src/entity/primary_map.rs @@ -34,7 +34,6 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Hash, PartialEq, Eq)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(rkyv::CheckBytes))] pub struct PrimaryMap where K: EntityRef, diff --git a/lib/types/src/entity/secondary_map.rs b/lib/types/src/entity/secondary_map.rs index 554bc4278ae..1d334a0f63e 100644 --- a/lib/types/src/entity/secondary_map.rs +++ b/lib/types/src/entity/secondary_map.rs @@ -28,7 +28,6 @@ use serde::{ /// The map does not track if an entry for a key has been inserted or not. Instead it behaves as if /// all keys have a default entry from the beginning. #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(rkyv::CheckBytes))] pub struct SecondaryMap where K: EntityRef, diff --git a/lib/types/src/features.rs b/lib/types/src/features.rs index 54197762db5..db8bf765a5b 100644 --- a/lib/types/src/features.rs +++ b/lib/types/src/features.rs @@ -6,10 +6,10 @@ use serde::{Deserialize, Serialize}; /// Features usually have a corresponding [WebAssembly proposal]. /// /// [WebAssembly proposal]: https://github.com/WebAssembly/proposals -#[derive(Clone, Debug, Eq, PartialEq, rkyv::CheckBytes)] +#[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct Features { /// Threads proposal should be enabled pub threads: bool, diff --git a/lib/types/src/indexes.rs b/lib/types/src/indexes.rs index 5d161d61eee..fac7944d98e 100644 --- a/lib/types/src/indexes.rs +++ b/lib/types/src/indexes.rs @@ -4,6 +4,21 @@ use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; +/* + * [todo] xdoardo (on 2024/10/09) + * + * While updating rkyv from 0.7.x to 0.8.x it became unfeasible to represent archived + * version of some types as themselves (i.e. `rkyv(as = Self)`). This means that in cases + * like this one we can't simply return a reference to the underlying value. + * + * Hopefully as 0.8.x matures a bit more we can return to `rkyv(as = Self)`, making all + * of this faster and leaner. The missing bits for it are: + * + * 1. rkyv::rend::{u32_le, i32_le, u64_le, ..} should implement `serde::Serialize` and + * `serde::Deserialize`. + * + */ + /// Index type of a function defined locally inside the WebAssembly module. #[derive( Copy, @@ -17,10 +32,9 @@ use serde::{Deserialize, Serialize}; RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] pub struct LocalFunctionIndex(u32); entity_impl!(LocalFunctionIndex); @@ -49,10 +63,9 @@ entity_impl!(LocalMemoryIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] pub struct LocalGlobalIndex(u32); entity_impl!(LocalGlobalIndex); @@ -69,10 +82,12 @@ entity_impl!(LocalGlobalIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv( + derive(Debug, PartialOrd, Ord, PartialEq, Eq), + compare(PartialOrd, PartialEq) +)] pub struct FunctionIndex(u32); entity_impl!(FunctionIndex); @@ -89,10 +104,12 @@ entity_impl!(FunctionIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv( + derive(Debug, PartialOrd, Ord, PartialEq, Eq), + compare(PartialOrd, PartialEq) +)] pub struct TableIndex(u32); entity_impl!(TableIndex); @@ -109,10 +126,9 @@ entity_impl!(TableIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] pub struct GlobalIndex(u32); entity_impl!(GlobalIndex); @@ -129,11 +145,10 @@ entity_impl!(GlobalIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] -pub struct MemoryIndex(u32); +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] +pub struct MemoryIndex(pub(crate) u32); entity_impl!(MemoryIndex); /// Index type of a signature (imported or local) inside the WebAssembly module. @@ -149,10 +164,9 @@ entity_impl!(MemoryIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] pub struct SignatureIndex(u32); entity_impl!(SignatureIndex); @@ -169,10 +183,12 @@ entity_impl!(SignatureIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv( + derive(Debug, PartialOrd, Ord, PartialEq, Eq), + compare(PartialOrd, PartialEq) +)] pub struct DataIndex(u32); entity_impl!(DataIndex); @@ -189,10 +205,13 @@ entity_impl!(DataIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv( + derive(Debug, PartialOrd, Ord, PartialEq, Eq), + compare(PartialOrd, PartialEq) +)] + pub struct ElemIndex(u32); entity_impl!(ElemIndex); @@ -209,10 +228,9 @@ entity_impl!(ElemIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] pub struct CustomSectionIndex(u32); entity_impl!(CustomSectionIndex); @@ -229,10 +247,9 @@ entity_impl!(CustomSectionIndex); RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] #[repr(u8)] pub enum ExportIndex { /// Function export. @@ -247,20 +264,10 @@ pub enum ExportIndex { /// An entity to import. #[derive( - Clone, - Debug, - Hash, - PartialEq, - Eq, - PartialOrd, - Ord, - RkyvSerialize, - RkyvDeserialize, - Archive, - rkyv::CheckBytes, + Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, RkyvSerialize, RkyvDeserialize, Archive, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] #[repr(u8)] pub enum ImportIndex { /// Function import. diff --git a/lib/types/src/initializers.rs b/lib/types/src/initializers.rs index 4c8f177d94b..5d346939e43 100644 --- a/lib/types/src/initializers.rs +++ b/lib/types/src/initializers.rs @@ -1,15 +1,20 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + use crate::indexes::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex}; use crate::lib::std::boxed::Box; -use enumset::__internal::EnumSetTypeRepr; -use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; /// A WebAssembly table initializer. #[derive(Clone, Debug, Hash, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct TableInitializer { /// The index of a table to initialize. pub table_index: TableIndex, @@ -25,7 +30,7 @@ pub struct TableInitializer { /// should be performed. #[derive(Clone, Debug, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct DataInitializerLocation { /// The index of the memory to initialize. pub memory_index: MemoryIndex, @@ -61,18 +66,18 @@ impl DataInitializerLocationLike for &DataInitializerLocation { impl DataInitializerLocationLike for &ArchivedDataInitializerLocation { fn memory_index(&self) -> MemoryIndex { - MemoryIndex::from_u32(self.memory_index.as_u32()) + MemoryIndex::from_u32(rkyv::deserialize::<_, ()>(&self.memory_index).unwrap().0) } fn base(&self) -> Option { - match self.base { + match &self.base { rkyv::option::ArchivedOption::None => None, - rkyv::option::ArchivedOption::Some(base) => Some(GlobalIndex::from_u32(base.as_u32())), + rkyv::option::ArchivedOption::Some(base) => rkyv::deserialize::<_, String>(base).ok(), } } fn offset(&self) -> usize { - self.offset.to_usize() + rkyv::deserialize::<_, ()>(&self.offset).unwrap() } } @@ -91,7 +96,7 @@ pub struct DataInitializer<'data> { /// holding a reference to it #[derive(Debug, Clone, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct OwnedDataInitializer { /// The location where the initialization is to be performed. pub location: DataInitializerLocation, diff --git a/lib/types/src/libcalls.rs b/lib/types/src/libcalls.rs index 21222c588d6..dfd6139c987 100644 --- a/lib/types/src/libcalls.rs +++ b/lib/types/src/libcalls.rs @@ -18,10 +18,9 @@ use std::fmt; RkyvSerialize, RkyvDeserialize, Archive, - rkyv::CheckBytes, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u16)] pub enum LibCall { /// ceil.f32 diff --git a/lib/types/src/memory.rs b/lib/types/src/memory.rs index 5999f0c11c3..76ae1a7927f 100644 --- a/lib/types/src/memory.rs +++ b/lib/types/src/memory.rs @@ -8,20 +8,9 @@ use std::iter::Sum; use std::ops::{Add, AddAssign}; /// Implementation styles for WebAssembly linear memory. -#[derive( - Debug, - Clone, - Copy, - PartialEq, - Eq, - Hash, - RkyvSerialize, - RkyvDeserialize, - Archive, - rkyv::CheckBytes, -)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u8)] pub enum MemoryStyle { /// The actual memory can be resized and moved. diff --git a/lib/types/src/module.rs b/lib/types/src/module.rs index 5ddea198a5a..b433363e112 100644 --- a/lib/types/src/module.rs +++ b/lib/types/src/module.rs @@ -13,11 +13,8 @@ use crate::{ }; use indexmap::IndexMap; -use rkyv::{ - de::SharedDeserializeRegistry, ser::ScratchSpace, ser::Serializer, - ser::SharedSerializeRegistry, Archive, Archived, CheckBytes, Deserialize as RkyvDeserialize, - Fallible, Serialize as RkyvSerialize, -}; +use rkyv::rancor::{Fallible, Source, Trace}; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -27,7 +24,7 @@ use std::iter::ExactSizeIterator; use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; #[derive(Debug, Clone, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct ModuleId { id: usize, } @@ -50,7 +47,7 @@ impl Default for ModuleId { /// Hash key of an import #[derive(Debug, Hash, Eq, PartialEq, Clone, Default, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive_attr(derive(CheckBytes, PartialEq, Eq, Hash, Debug))] +#[rkyv(derive(PartialOrd, Ord, PartialEq, Eq, Hash, Debug))] pub struct ImportKey { /// Module name pub module: String, @@ -187,7 +184,7 @@ pub struct ModuleInfo { /// Mirror version of ModuleInfo that can derive rkyv traits #[derive(Debug, RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct ArchivableModuleInfo { name: Option, hash: Option, @@ -279,26 +276,28 @@ impl Archive for ModuleInfo { type Archived = ::Archived; type Resolver = ::Resolver; - unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { - ArchivableModuleInfo::from(self).resolve(pos, resolver, out) + fn resolve(&self, resolver: Self::Resolver, out: rkyv::Place) { + ArchivableModuleInfo::from(self).resolve(resolver, out) } } -impl RkyvSerialize +impl RkyvSerialize for ModuleInfo +where + ::Error: rkyv::rancor::Source + rkyv::rancor::Trace, { fn serialize(&self, serializer: &mut S) -> Result { ArchivableModuleInfo::from(self).serialize(serializer) } } -impl RkyvDeserialize - for Archived +impl RkyvDeserialize for ArchivedArchivableModuleInfo +where + D::Error: Source + Trace, { fn deserialize(&self, deserializer: &mut D) -> Result { - let r: ArchivableModuleInfo = - RkyvDeserialize::::deserialize(self, deserializer)?; - Ok(ModuleInfo::from(r)) + let archived = RkyvDeserialize::::deserialize(self, deserializer)?; + Ok(ModuleInfo::from(archived)) } } diff --git a/lib/types/src/module_hash.rs b/lib/types/src/module_hash.rs index 7c4e967f599..33b8fc916f6 100644 --- a/lib/types/src/module_hash.rs +++ b/lib/types/src/module_hash.rs @@ -1,6 +1,6 @@ use std::fmt::{self, Display, Formatter}; -use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; use sha2::Digest; @@ -28,7 +28,7 @@ pub enum HashAlgorithm { RkyvDeserialize, Archive, )] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub enum ModuleHash { /// xxhash diff --git a/lib/types/src/serialize.rs b/lib/types/src/serialize.rs index d98af1dac76..a0625c30c14 100644 --- a/lib/types/src/serialize.rs +++ b/lib/types/src/serialize.rs @@ -1,3 +1,9 @@ +/* + * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] + * on their own. + */ +#![allow(missing_docs)] + use crate::entity::PrimaryMap; use crate::{ compilation::target::CpuFeature, CompileModuleInfo, CompiledFunctionFrameInfo, CustomSection, @@ -6,19 +12,14 @@ use crate::{ SerializeError, SignatureIndex, TableIndex, TableStyle, }; use enumset::EnumSet; -use rkyv::check_archived_value; -use rkyv::{ - archived_value, de::deserializers::SharedDeserializeMap, ser::serializers::AllocSerializer, - ser::Serializer as RkyvSerializer, Archive, CheckBytes, Deserialize as RkyvDeserialize, - Serialize as RkyvSerialize, -}; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; use std::convert::TryInto; use std::mem; /// The compilation related data for a serialized modules #[derive(Archive, Default, RkyvDeserialize, RkyvSerialize)] #[allow(missing_docs)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct SerializableCompilation { pub function_bodies: PrimaryMap, pub function_relocations: PrimaryMap>, @@ -40,20 +41,16 @@ impl SerializableCompilation { /// The bytes will have the following format: /// RKYV serialization (any length) + POS (8 bytes) pub fn serialize(&self) -> Result, SerializeError> { - let mut serializer = AllocSerializer::<4096>::default(); - let pos = serializer - .serialize_value(self) - .map_err(to_serialize_error)? as u64; - let mut serialized_data = serializer.into_serializer().into_inner(); - serialized_data.extend_from_slice(&pos.to_le_bytes()); - Ok(serialized_data.to_vec()) + rkyv::to_bytes::(self) + .map(|v| v.into_vec()) + .map_err(|e| SerializeError::Generic(e.to_string())) } } /// Serializable struct that is able to serialize from and to a `ArtifactInfo`. #[derive(Archive, RkyvDeserialize, RkyvSerialize)] #[allow(missing_docs)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct SerializableModule { /// The main serializable compilation object pub compilation: SerializableCompilation, @@ -65,22 +62,14 @@ pub struct SerializableModule { pub cpu_features: u64, } -fn to_serialize_error(err: impl std::error::Error) -> SerializeError { - SerializeError::Generic(format!("{}", err)) -} - impl SerializableModule { /// Serialize a Module into bytes /// The bytes will have the following format: /// RKYV serialization (any length) + POS (8 bytes) pub fn serialize(&self) -> Result, SerializeError> { - let mut serializer = AllocSerializer::<4096>::default(); - let pos = serializer - .serialize_value(self) - .map_err(to_serialize_error)? as u64; - let mut serialized_data = serializer.into_serializer().into_inner(); - serialized_data.extend_from_slice(&pos.to_le_bytes()); - Ok(serialized_data.to_vec()) + rkyv::to_bytes::(self) + .map(|v| v.into_vec()) + .map_err(|e| SerializeError::Generic(e.to_string())) } /// Deserialize a Module from a slice. @@ -120,18 +109,7 @@ impl SerializableModule { pub unsafe fn archive_from_slice( metadata_slice: &[u8], ) -> Result<&ArchivedSerializableModule, DeserializeError> { - if metadata_slice.len() < 8 { - return Err(DeserializeError::Incompatible( - "invalid serialized data".into(), - )); - } - let mut pos: [u8; 8] = Default::default(); - pos.copy_from_slice(&metadata_slice[metadata_slice.len() - 8..metadata_slice.len()]); - let pos: u64 = u64::from_le_bytes(pos); - Ok(archived_value::( - &metadata_slice[..metadata_slice.len() - 8], - pos as usize, - )) + Ok(rkyv::access_unchecked(metadata_slice)) } /// Deserialize an archived module. @@ -141,25 +119,16 @@ impl SerializableModule { pub fn archive_from_slice_checked( metadata_slice: &[u8], ) -> Result<&ArchivedSerializableModule, DeserializeError> { - if metadata_slice.len() < 8 { - return Err(DeserializeError::Incompatible( - "invalid serialized data".into(), - )); - } - let mut pos: [u8; 8] = Default::default(); - pos.copy_from_slice(&metadata_slice[metadata_slice.len() - 8..metadata_slice.len()]); - let pos: u64 = u64::from_le_bytes(pos); - check_archived_value::(&metadata_slice[..metadata_slice.len() - 8], pos as usize) - .map_err(|err| DeserializeError::CorruptedBinary(err.to_string())) + rkyv::access::<_, rkyv::rancor::Error>(metadata_slice) + .map_err(|e| DeserializeError::CorruptedBinary(e.to_string())) } /// Deserialize a compilation module from an archive pub fn deserialize_from_archive( archived: &ArchivedSerializableModule, ) -> Result { - let mut deserializer = SharedDeserializeMap::new(); - RkyvDeserialize::deserialize(archived, &mut deserializer) - .map_err(|e| DeserializeError::CorruptedBinary(format!("{:?}", e))) + rkyv::deserialize::<_, rkyv::rancor::Error>(archived) + .map_err(|e| DeserializeError::CorruptedBinary(e.to_string())) } /// Create a `ModuleInfo` for instantiation @@ -211,7 +180,7 @@ pub struct MetadataHeader { impl MetadataHeader { /// Current ABI version. Increment this any time breaking changes are made /// to the format of the serialized data. - pub const CURRENT_VERSION: u32 = 7; + pub const CURRENT_VERSION: u32 = 8; /// Magic number to identify wasmer metadata. const MAGIC: [u8; 8] = *b"WASMER\0\0"; diff --git a/lib/types/src/stack/sourceloc.rs b/lib/types/src/stack/sourceloc.rs index e91586f4073..0302cbbea56 100644 --- a/lib/types/src/stack/sourceloc.rs +++ b/lib/types/src/stack/sourceloc.rs @@ -23,8 +23,8 @@ use serde::{Deserialize, Serialize}; )] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] #[repr(transparent)] -#[derive(Debug, Clone, Copy, PartialEq, Eq, rkyv::CheckBytes)] -#[archive(as = "Self")] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[rkyv(derive(Debug))] pub struct SourceLoc(u32); impl SourceLoc { diff --git a/lib/types/src/stack/trap.rs b/lib/types/src/stack/trap.rs index b13c14b7df6..dd02adc80b3 100644 --- a/lib/types/src/stack/trap.rs +++ b/lib/types/src/stack/trap.rs @@ -7,10 +7,8 @@ use serde::{Deserialize, Serialize}; /// Information about trap. #[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))] -#[derive( - RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes, Clone, Copy, Debug, PartialEq, Eq, -)] -#[archive(as = "Self")] +#[derive(RkyvSerialize, RkyvDeserialize, Archive, Clone, Copy, Debug, PartialEq, Eq)] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct TrapInformation { /// The offset of the trapping instruction in native code. It is relative to the beginning of the function. pub code_offset: CodeOffset, diff --git a/lib/types/src/table.rs b/lib/types/src/table.rs index 0b155d1f881..a09a8febb60 100644 --- a/lib/types/src/table.rs +++ b/lib/types/src/table.rs @@ -1,15 +1,12 @@ -use bytecheck::CheckBytes; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; /// Implementation styles for WebAssembly tables. -#[derive( - Debug, Clone, Hash, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive, CheckBytes, -)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] #[repr(u8)] +#[rkyv(derive(Debug))] pub enum TableStyle { /// Signatures are stored in the table and checked in the caller. CallerChecksSignature, diff --git a/lib/types/src/trapcode.rs b/lib/types/src/trapcode.rs index ae8066d89c4..0a63af47aa9 100644 --- a/lib/types/src/trapcode.rs +++ b/lib/types/src/trapcode.rs @@ -14,21 +14,11 @@ use thiserror::Error; /// /// All trap instructions have an explicit trap code. #[derive( - Clone, - Copy, - PartialEq, - Eq, - Debug, - Hash, - Error, - RkyvSerialize, - RkyvDeserialize, - Archive, - rkyv::CheckBytes, + Clone, Copy, PartialEq, Eq, Debug, Hash, Error, RkyvSerialize, RkyvDeserialize, Archive, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u32)] -#[archive(as = "Self")] pub enum TrapCode { /// The current stack space was exhausted. /// diff --git a/lib/types/src/types.rs b/lib/types/src/types.rs index 3b9e4af215f..bcd823ac3c3 100644 --- a/lib/types/src/types.rs +++ b/lib/types/src/types.rs @@ -6,7 +6,6 @@ use crate::lib::std::string::{String, ToString}; use crate::lib::std::vec::Vec; use crate::units::Pages; -use bytecheck::CheckBytes; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; @@ -18,8 +17,8 @@ use serde::{Deserialize, Serialize}; /// A list of all possible value types in WebAssembly. #[derive(Copy, Debug, Clone, Eq, PartialEq, Hash)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive(RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes)] -#[archive(as = "Self")] +#[derive(RkyvSerialize, RkyvDeserialize, Archive)] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u8)] pub enum Type { /// Signed 32 bit integer. @@ -61,10 +60,10 @@ impl fmt::Display for Type { } /// The WebAssembly V128 type -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, CheckBytes)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct V128(pub(crate) [u8; 16]); impl V128 { @@ -242,7 +241,7 @@ impl ExternType { #[derive(Debug, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct FunctionType { /// The parameters of the function params: Box<[Type]>, @@ -326,10 +325,9 @@ impl From<&Self> for FunctionType { } /// Indicator of whether a global is mutable or not -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, CheckBytes)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialOrd, PartialEq))] #[repr(u8)] pub enum Mutability { /// The global is constant and its value does not change @@ -365,10 +363,9 @@ impl From for bool { } /// WebAssembly global. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, CheckBytes)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq))] pub struct GlobalType { /// The type of the value stored in the global. pub ty: Type, @@ -410,10 +407,9 @@ impl fmt::Display for GlobalType { } /// Globals are initialized via the `const` operators or by referring to another import. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, RkyvSerialize, RkyvDeserialize, Archive)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[derive(RkyvSerialize, RkyvDeserialize, Archive, rkyv::CheckBytes)] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq))] #[repr(u8)] pub enum GlobalInit { /// An `i32.const`. @@ -447,7 +443,7 @@ pub enum GlobalInit { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct TableType { /// The type of data stored in elements of the table. pub ty: Type, @@ -488,7 +484,7 @@ impl fmt::Display for TableType { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] #[derive(RkyvSerialize, RkyvDeserialize, Archive)] -#[archive_attr(derive(CheckBytes, Debug))] +#[rkyv(derive(Debug))] pub struct MemoryType { /// The minimum number of pages in the memory. pub minimum: Pages, diff --git a/lib/types/src/units.rs b/lib/types/src/units.rs index 60e488b4a31..a08ebeb8a35 100644 --- a/lib/types/src/units.rs +++ b/lib/types/src/units.rs @@ -21,20 +21,10 @@ pub const WASM_MIN_PAGES: u32 = 0x100; /// Units of WebAssembly pages (as specified to be 65,536 bytes). #[derive( - Copy, - Clone, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - RkyvSerialize, - RkyvDeserialize, - Archive, - rkyv::CheckBytes, + Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RkyvSerialize, RkyvDeserialize, Archive, )] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -#[archive(as = "Self")] +#[rkyv(derive(Debug), compare(PartialEq, PartialOrd))] pub struct Pages(pub u32); impl Pages { diff --git a/lib/virtual-fs/Cargo.toml b/lib/virtual-fs/Cargo.toml index 8b7b41a3cbe..9c8f632cbe1 100644 --- a/lib/virtual-fs/Cargo.toml +++ b/lib/virtual-fs/Cargo.toml @@ -27,33 +27,50 @@ replace_with = "0.1.7" shared-buffer = { workspace = true } slab = { version = "0.4" } thiserror = "1" -tokio = { version = "1", features = ["io-util", "sync", "macros"], default-features = false } +tokio = { version = "1", features = [ + "io-util", + "sync", + "macros", +], default-features = false } tracing = { version = "0.1" } typetag = { version = "0.1", optional = true } webc = { workspace = true, optional = true, features = ["v1"] } -serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } +serde = { version = "1.0", default-features = false, features = [ + "derive", +], optional = true } [target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies] getrandom = { version = "0.2" } [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] -getrandom = { version = "0.2", features = [ "js" ] } +getrandom = { version = "0.2", features = ["js"] } [dev-dependencies] pretty_assertions = "1.3.0" tempfile = "3.6.0" tracing-test = "0.2.4" -tokio = { version = "1", features = ["io-util", "rt"], default-features = false } +tokio = { version = "1", features = [ + "io-util", + "rt", +], default-features = false } [features] default = ["host-fs", "webc-fs", "static-fs"] -host-fs = ["libc", "fs_extra", "filetime", "tokio/fs", "tokio/io-std", "tokio/rt"] +host-fs = [ + "libc", + "fs_extra", + "filetime", + "tokio/fs", + "tokio/io-std", + "tokio/rt", +] webc-fs = ["webc", "anyhow"] static-fs = ["webc", "anyhow"] enable-serde = ["typetag", "serde"] no-time = [] # Enables memory tracking/limiting functionality for the in-memory filesystem. tracking = [] +futures = [] [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] diff --git a/lib/virtual-io/Cargo.toml b/lib/virtual-io/Cargo.toml index 4d25ba07536..3c8aec67945 100644 --- a/lib/virtual-io/Cargo.toml +++ b/lib/virtual-io/Cargo.toml @@ -14,11 +14,13 @@ thiserror = "1" bytes = "1.1" async-trait = { version = "^0.1" } tracing = "0.1" -mio = { version = "0.8", features = [ "os-poll" ], optional = true } +mio = { version = "0.8", features = ["os-poll"], optional = true } socket2 = { version = "0.4", optional = true } derivative = { version = "^2" } futures = { version = "0.3" } serde = { version = "1.0", default-features = false, features = ["derive"] } [features] -sys = [ "mio", "socket2" ] \ No newline at end of file +sys = ["mio", "socket2"] +js = [] + diff --git a/lib/virtual-net/Cargo.toml b/lib/virtual-net/Cargo.toml index b7b01572cae..c965ef4e284 100644 --- a/lib/virtual-net/Cargo.toml +++ b/lib/virtual-net/Cargo.toml @@ -19,14 +19,14 @@ libc = { workspace = true, optional = true } mio = { version = "0.8", optional = true, features = ["net"] } socket2 = { version = "0.4", optional = true } derivative = { version = "^2" } -virtual-mio = { path = "../virtual-io", version = "0.3.0", default-features = false } +virtual-mio = { path = "../virtual-io", version = "0.3.0", default-features = false } base64 = "0.21" bincode = { version = "1.3" } serde = { version = "1.0", default-features = false, features = ["derive"] } pin-project-lite = "0.2.9" -futures-util = { version = "0.3" } +futures-util = { workspace = true } anyhow = "1.0" -tokio-serde = { version = "0.8", features = [ "bincode" ], optional = true } +tokio-serde = { version = "0.8", features = ["bincode"], optional = true } tokio-util = { version = "0.7.8", features = ["codec"], optional = true } hyper-tungstenite = { version = "0.13", optional = true } hyper = { workspace = true, optional = true } @@ -41,20 +41,40 @@ default-features = false features = ["proto-ipv4", "std", "alloc"] [dev-dependencies] -tokio = { version = "1", default-features = false, features = [ "macros", "rt-multi-thread" ] } +tokio = { version = "1", default-features = false, features = [ + "macros", + "rt-multi-thread", +] } tracing-test = { version = "0.2" } serial_test = "2.0.0" [features] -default = [ "host-net", "remote", "json", "messagepack", "cbor", "hyper", "tokio-tungstenite" ] -host-net = [ "libc", "tokio/io-util", "virtual-mio/sys", "tokio/net", "tokio/rt", "socket2", "mio" ] -remote = [ "libc", "tokio/io-util", "tokio/sync", "tokio-serde", "tokio-util" ] -json = [ "tokio-serde/json" ] -messagepack = [ "tokio-serde/messagepack" ] -cbor = [ "tokio-serde/cbor" ] -hyper = [ "hyper-tungstenite", "hyper-util", "dep:hyper" ] -tokio-tungstenite = [ "dep:tokio-tungstenite" ] -rkyv = [ "dep:rkyv", "dep:bytecheck" ] +default = [ + "host-net", + "remote", + "json", + "messagepack", + "cbor", + "hyper", + "tokio-tungstenite", +] +host-net = [ + "libc", + "tokio/io-util", + "virtual-mio/sys", + "tokio/net", + "tokio/rt", + "socket2", + "mio", +] +remote = ["libc", "tokio/io-util", "tokio/sync", "tokio-serde", "tokio-util"] +json = ["tokio-serde/json"] +messagepack = ["tokio-serde/messagepack"] +cbor = ["tokio-serde/cbor"] +hyper = ["hyper-tungstenite", "hyper-util", "dep:hyper"] +tokio-tungstenite = ["dep:tokio-tungstenite"] +tokio = [] +rkyv = ["dep:rkyv", "dep:bytecheck"] [package.metadata.docs.rs] features = ["host-net", "remote"] diff --git a/lib/virtual-net/src/lib.rs b/lib/virtual-net/src/lib.rs index b468fd45106..1bb45337c7d 100644 --- a/lib/virtual-net/src/lib.rs +++ b/lib/virtual-net/src/lib.rs @@ -22,7 +22,7 @@ pub use composite::CompositeTcpListener; pub use loopback::LoopbackNetworking; use pin_project_lite::pin_project; #[cfg(feature = "rkyv")] -use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "remote")] pub use server::{RemoteNetworkingServer, RemoteNetworkingServerDriver}; use std::fmt; @@ -55,7 +55,6 @@ pub type Result = std::result::Result; /// Represents an IP address and its netmask #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, Deserialize)] #[cfg_attr(feature = "rkyv", derive(RkyvSerialize, RkyvDeserialize, Archive))] -#[cfg_attr(feature = "rkyv", archive_attr(derive(CheckBytes)))] pub struct IpCidr { pub ip: IpAddr, pub prefix: u8, @@ -64,7 +63,6 @@ pub struct IpCidr { /// Represents a routing entry in the routing table of the interface #[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "rkyv", derive(RkyvSerialize, RkyvDeserialize, Archive))] -#[cfg_attr(feature = "rkyv", archive_attr(derive(CheckBytes)))] pub struct IpRoute { pub cidr: IpCidr, pub via_router: IpAddr, diff --git a/lib/vm/Cargo.toml b/lib/vm/Cargo.toml index 0fcf37541f3..1b58506c3cc 100644 --- a/lib/vm/Cargo.toml +++ b/lib/vm/Cargo.toml @@ -17,7 +17,7 @@ memoffset.workspace = true dashmap.workspace = true wasmer-types = { path = "../types", version = "=4.3.7" } libc.workspace = true -indexmap = { version = "1.6" } +indexmap = { workspace = true } thiserror = "1.0" more-asserts = "0.2" cfg-if = "1.0" @@ -48,7 +48,7 @@ maintenance = { status = "actively-developed" } [features] default = [] -enable-serde = ["serde", "indexmap/serde-1", "wasmer-types/enable-serde" ] +enable-serde = ["serde", "indexmap/serde", "wasmer-types/enable-serde" ] [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] diff --git a/lib/vm/src/sig_registry.rs b/lib/vm/src/sig_registry.rs index 78dcbce8ecd..71d5f4b23c2 100644 --- a/lib/vm/src/sig_registry.rs +++ b/lib/vm/src/sig_registry.rs @@ -45,12 +45,12 @@ impl SignatureRegistry { match entry { hash_map::Entry::Occupied(entry) => *entry.get(), hash_map::Entry::Vacant(entry) => { - // Keep `signature_hash` len under 2**32 -- VMSharedSignatureIndex::new(std::u32::MAX) + // Keep `signature_hash` len under 2**32 -- VMSharedSignatureIndex::new(u32::MAX) // is reserved for VMSharedSignatureIndex::default(). debug_assert_lt!( len, u32::MAX as usize, - "Invariant check: signature_hash.len() < std::u32::MAX" + "Invariant check: signature_hash.len() < u32::MAX" ); let sig_id = VMSharedSignatureIndex::new(u32::try_from(len).unwrap()); entry.insert(sig_id); diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index 8c1149a902f..a48b183d354 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -7,7 +7,7 @@ //! signalhandling mechanisms. use crate::vmcontext::{VMFunctionContext, VMTrampoline}; -use crate::{Trap, VMFunctionBody}; +use crate::{Trap, VMContext, VMFunctionBody}; use backtrace::Backtrace; use core::ptr::{read, read_unaligned}; use corosensei::stack::DefaultStack; @@ -677,11 +677,11 @@ pub unsafe fn wasmer_call_trampoline( catch_traps(trap_handler, config, || { mem::transmute::< unsafe extern "C" fn( - *mut crate::vmcontext::VMContext, + *mut VMContext, *const VMFunctionBody, *mut wasmer_types::RawValue, ), - extern "C" fn(crate::vmcontext::VMFunctionContext, *const VMFunctionBody, *mut u8), + extern "C" fn(VMFunctionContext, *const VMFunctionBody, *mut u8), >(trampoline)(vmctx, callee, values_vec); }) } diff --git a/lib/wasix/src/runners/mod.rs b/lib/wasix/src/runners/mod.rs index 25ccfc939f4..e9a012ec017 100644 --- a/lib/wasix/src/runners/mod.rs +++ b/lib/wasix/src/runners/mod.rs @@ -59,7 +59,7 @@ mod response_tracing { _latency: std::time::Duration, span: &tracing::Span, ) { - span.record("status_code", &tracing::field::display(response.status())); + span.record("status_code", tracing::field::display(response.status())); tracing::info!("response generated") } } diff --git a/lib/wasix/src/state/mod.rs b/lib/wasix/src/state/mod.rs index 6d1dce47069..0faf6ee0e8a 100644 --- a/lib/wasix/src/state/mod.rs +++ b/lib/wasix/src/state/mod.rs @@ -122,8 +122,8 @@ pub(crate) struct WasiFutexState { /// interact. /// /// * The contents of files are not stored and may be modified by -/// other, concurrently running programs. Data such as the contents -/// of directories are lazily loaded. +/// other, concurrently running programs. Data such as the contents +/// of directories are lazily loaded. #[derive(Debug)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub(crate) struct WasiState { diff --git a/lib/wasix/src/syscalls/wasi/clock_time_get.rs b/lib/wasix/src/syscalls/wasi/clock_time_get.rs index f1caab9635e..2554318f279 100644 --- a/lib/wasix/src/syscalls/wasi/clock_time_get.rs +++ b/lib/wasix/src/syscalls/wasi/clock_time_get.rs @@ -6,12 +6,16 @@ use crate::syscalls::*; /// ### `clock_time_get()` /// Get the time of the specified clock +/// /// Inputs: +/// /// - `Clockid clock_id` /// The ID of the clock to query /// - `Timestamp precision` /// The maximum amount of error the reading may have +/// /// Output: +/// /// - `Timestamp *time` /// The value of the clock in nanoseconds #[cfg_attr( diff --git a/lib/wasix/src/syscalls/wasi/fd_filestat_get.rs b/lib/wasix/src/syscalls/wasi/fd_filestat_get.rs index e893a35185e..28bff629d0c 100644 --- a/lib/wasix/src/syscalls/wasi/fd_filestat_get.rs +++ b/lib/wasix/src/syscalls/wasi/fd_filestat_get.rs @@ -4,9 +4,11 @@ use crate::types::wasi::Snapshot0Filestat; /// ### `fd_filestat_get()` /// Get the metadata of an open file +/// /// Input: /// - `Fd fd` /// The open file descriptor whose metadata will be read +/// /// Output: /// - `Filestat *buf` /// Where the metadata from `fd` will be written @@ -28,9 +30,11 @@ pub fn fd_filestat_get( /// ### `fd_filestat_get()` /// Get the metadata of an open file +/// /// Input: /// - `__wasi_fd_t fd` /// The open file descriptor whose metadata will be read +/// /// Output: /// - `__wasi_filestat_t *buf` /// Where the metadata from `fd` will be written @@ -50,9 +54,11 @@ pub(crate) fn fd_filestat_get_internal( /// ### `fd_filestat_get_old()` /// Get the metadata of an open file +/// /// Input: /// - `Fd fd` /// The open file descriptor whose metadata will be read +/// /// Output: /// - `Snapshot0Filestat *buf` /// Where the metadata from `fd` will be written diff --git a/lib/wasix/src/syscalls/wasi/poll_oneoff.rs b/lib/wasix/src/syscalls/wasi/poll_oneoff.rs index a5af39321a8..41e80b34e5b 100644 --- a/lib/wasix/src/syscalls/wasi/poll_oneoff.rs +++ b/lib/wasix/src/syscalls/wasi/poll_oneoff.rs @@ -44,6 +44,7 @@ impl EventResult { /// ### `poll_oneoff()` /// Concurrently poll for a set of events +/// /// Inputs: /// - `const __wasi_subscription_t *in` /// The events to subscribe to @@ -51,6 +52,7 @@ impl EventResult { /// The events that have occured /// - `u32 nsubscriptions` /// The number of subscriptions and the number of events +/// /// Output: /// - `u32 nevents` /// The number of events seen @@ -198,6 +200,7 @@ pub(crate) fn poll_fd_guard( /// ### `poll_oneoff()` /// Concurrently poll for a set of events +/// /// Inputs: /// - `const __wasi_subscription_t *in` /// The events to subscribe to @@ -205,6 +208,7 @@ pub(crate) fn poll_fd_guard( /// The events that have occured /// - `u32 nsubscriptions` /// The number of subscriptions and the number of events +/// /// Output: /// - `u32 nevents` /// The number of events seen @@ -399,7 +403,7 @@ where }; Span::current().record( "seen", - &format!( + format!( "clock(id={},userdata={})", clock_info.clock_id as u32, evt.userdata ), @@ -451,9 +455,9 @@ where Ok(evts) => { // If its a timeout then return an event for it if evts.len() == 1 { - Span::current().record("seen", &format!("{:?}", evts.first().unwrap())); + Span::current().record("seen", format!("{:?}", evts.first().unwrap())); } else { - Span::current().record("seen", &format!("trigger_cnt=({})", evts.len())); + Span::current().record("seen", format!("trigger_cnt=({})", evts.len())); } // Process the events diff --git a/lib/wasix/src/syscalls/wasix/futex_wait.rs b/lib/wasix/src/syscalls/wasix/futex_wait.rs index 1d371351096..44fe2966bb7 100644 --- a/lib/wasix/src/syscalls/wasix/futex_wait.rs +++ b/lib/wasix/src/syscalls/wasix/futex_wait.rs @@ -113,7 +113,7 @@ pub(super) fn futex_wait_internal( OptionTag::Some => Some(Duration::from_nanos(timeout.u)), _ => None, }; - Span::current().record("timeout", &format!("{:?}", timeout)); + Span::current().record("timeout", format!("{:?}", timeout)); let state = env.state.clone(); let futex_idx: u64 = futex_ptr.offset().into(); diff --git a/lib/wasix/src/syscalls/wasix/port_addr_add.rs b/lib/wasix/src/syscalls/wasix/port_addr_add.rs index 5a9d5909a66..66c07021c24 100644 --- a/lib/wasix/src/syscalls/wasix/port_addr_add.rs +++ b/lib/wasix/src/syscalls/wasix/port_addr_add.rs @@ -18,7 +18,7 @@ pub fn port_addr_add( let memory = unsafe { env.memory_view(&ctx) }; let cidr = wasi_try_ok!(crate::net::read_cidr(&memory, ip)); - Span::current().record("ip", &format!("{:?}", cidr)); + Span::current().record("ip", format!("{:?}", cidr)); wasi_try_ok!(port_addr_add_internal(&mut ctx, cidr)?); diff --git a/lib/wasix/src/syscalls/wasix/port_addr_remove.rs b/lib/wasix/src/syscalls/wasix/port_addr_remove.rs index eb689243576..159214e8e48 100644 --- a/lib/wasix/src/syscalls/wasix/port_addr_remove.rs +++ b/lib/wasix/src/syscalls/wasix/port_addr_remove.rs @@ -16,7 +16,7 @@ pub fn port_addr_remove( let memory = unsafe { env.memory_view(&ctx) }; let ip = wasi_try_ok!(crate::net::read_ip(&memory, ip)); - Span::current().record("ip", &format!("{:?}", ip)); + Span::current().record("ip", format!("{:?}", ip)); wasi_try_ok!(port_addr_remove_internal(&mut ctx, ip)?); diff --git a/lib/wasix/src/syscalls/wasix/port_gateway_set.rs b/lib/wasix/src/syscalls/wasix/port_gateway_set.rs index fc0549ea2c1..200569726b3 100644 --- a/lib/wasix/src/syscalls/wasix/port_gateway_set.rs +++ b/lib/wasix/src/syscalls/wasix/port_gateway_set.rs @@ -16,7 +16,7 @@ pub fn port_gateway_set( let memory = unsafe { env.memory_view(&ctx) }; let ip = wasi_try_ok!(crate::net::read_ip(&memory, ip)); - Span::current().record("ip", &format!("{:?}", ip)); + Span::current().record("ip", format!("{:?}", ip)); wasi_try_ok!(port_gateway_set_internal(&mut ctx, ip)?); diff --git a/lib/wasix/src/syscalls/wasix/port_route_add.rs b/lib/wasix/src/syscalls/wasix/port_route_add.rs index 00e9f781c34..837604fe0d3 100644 --- a/lib/wasix/src/syscalls/wasix/port_route_add.rs +++ b/lib/wasix/src/syscalls/wasix/port_route_add.rs @@ -17,10 +17,10 @@ pub fn port_route_add( let memory = unsafe { env.memory_view(&ctx) }; let cidr = wasi_try_ok!(crate::net::read_cidr(&memory, cidr)); - Span::current().record("cidr", &format!("{:?}", cidr)); + Span::current().record("cidr", format!("{:?}", cidr)); let via_router = wasi_try_ok!(crate::net::read_ip(&memory, via_router)); - Span::current().record("via_router", &format!("{:?}", via_router)); + Span::current().record("via_router", format!("{:?}", via_router)); let preferred_until = wasi_try_mem_ok!(preferred_until.read(&memory)); let preferred_until = match preferred_until.tag { diff --git a/lib/wasix/src/syscalls/wasix/port_route_remove.rs b/lib/wasix/src/syscalls/wasix/port_route_remove.rs index 0b1b5da2923..5c8a5b1b526 100644 --- a/lib/wasix/src/syscalls/wasix/port_route_remove.rs +++ b/lib/wasix/src/syscalls/wasix/port_route_remove.rs @@ -12,7 +12,7 @@ pub fn port_route_remove( let memory = unsafe { env.memory_view(&ctx) }; let ip = wasi_try_ok!(crate::net::read_ip(&memory, ip)); - Span::current().record("ip", &format!("{:?}", ip)); + Span::current().record("ip", format!("{:?}", ip)); wasi_try_ok!(port_route_remove_internal(&mut ctx, ip)?); diff --git a/lib/wasix/src/syscalls/wasix/sock_addr_local.rs b/lib/wasix/src/syscalls/wasix/sock_addr_local.rs index ac329bfd50c..7641b0c1f58 100644 --- a/lib/wasix/src/syscalls/wasix/sock_addr_local.rs +++ b/lib/wasix/src/syscalls/wasix/sock_addr_local.rs @@ -25,7 +25,7 @@ pub fn sock_addr_local( |socket, _| socket.addr_local() )); - Span::current().record("addr", &format!("{:?}", addr)); + Span::current().record("addr", format!("{:?}", addr)); let memory = unsafe { ctx.data().memory_view(&ctx) }; wasi_try!(crate::net::write_ip_port( diff --git a/lib/wasix/src/syscalls/wasix/sock_addr_peer.rs b/lib/wasix/src/syscalls/wasix/sock_addr_peer.rs index c49aea0d072..bb068aa5d37 100644 --- a/lib/wasix/src/syscalls/wasix/sock_addr_peer.rs +++ b/lib/wasix/src/syscalls/wasix/sock_addr_peer.rs @@ -24,7 +24,7 @@ pub fn sock_addr_peer( Rights::empty(), |socket, _| socket.addr_peer() )); - Span::current().record("addr", &format!("{:?}", addr)); + Span::current().record("addr", format!("{:?}", addr)); let env = ctx.data(); let memory = unsafe { env.memory_view(&ctx) }; diff --git a/lib/wasix/src/syscalls/wasix/sock_bind.rs b/lib/wasix/src/syscalls/wasix/sock_bind.rs index bdea8822e3f..ad3e2899eee 100644 --- a/lib/wasix/src/syscalls/wasix/sock_bind.rs +++ b/lib/wasix/src/syscalls/wasix/sock_bind.rs @@ -20,7 +20,7 @@ pub fn sock_bind( let addr = wasi_try_ok!(crate::net::read_ip_port(&memory, addr)); let addr = SocketAddr::new(addr.0, addr.1); - Span::current().record("addr", &format!("{:?}", addr)); + Span::current().record("addr", format!("{:?}", addr)); wasi_try_ok!(sock_bind_internal(&mut ctx, sock, addr)?); diff --git a/lib/wasix/src/syscalls/wasix/sock_connect.rs b/lib/wasix/src/syscalls/wasix/sock_connect.rs index 3942d3dbcb4..7ac33c84f87 100644 --- a/lib/wasix/src/syscalls/wasix/sock_connect.rs +++ b/lib/wasix/src/syscalls/wasix/sock_connect.rs @@ -23,7 +23,7 @@ pub fn sock_connect( let memory = unsafe { env.memory_view(&ctx) }; let addr = wasi_try_ok!(crate::net::read_ip_port(&memory, addr)); let peer_addr = SocketAddr::new(addr.0, addr.1); - Span::current().record("addr", &format!("{:?}", peer_addr)); + Span::current().record("addr", format!("{:?}", peer_addr)); wasi_try_ok!(sock_connect_internal(&mut ctx, sock, peer_addr)?); diff --git a/lib/wasix/src/syscalls/wasix/sock_recv_from.rs b/lib/wasix/src/syscalls/wasix/sock_recv_from.rs index 17df5bab3cc..dd4c083eea3 100644 --- a/lib/wasix/src/syscalls/wasix/sock_recv_from.rs +++ b/lib/wasix/src/syscalls/wasix/sock_recv_from.rs @@ -134,7 +134,7 @@ pub(super) fn sock_recv_from_internal( }; Span::current() .record("nread", bytes_read) - .record("peer", &format!("{:?}", peer)); + .record("peer", format!("{:?}", peer)); wasi_try_ok!(write_ip_port(&memory, ro_addr, peer.ip(), peer.port())); diff --git a/lib/wasix/src/syscalls/wasix/sock_send_to.rs b/lib/wasix/src/syscalls/wasix/sock_send_to.rs index 48ec74675c9..ad70e22c6a3 100644 --- a/lib/wasix/src/syscalls/wasix/sock_send_to.rs +++ b/lib/wasix/src/syscalls/wasix/sock_send_to.rs @@ -36,7 +36,7 @@ pub fn sock_send_to( wasi_try_ok!(read_ip_port(&memory, addr)) }; let addr = SocketAddr::new(addr_ip, addr_port); - Span::current().record("addr", &format!("{:?}", addr)); + Span::current().record("addr", format!("{:?}", addr)); let bytes_written = wasi_try_ok!(sock_send_to_internal( &ctx, diff --git a/lib/wasix/src/syscalls/wasix/sock_set_opt_time.rs b/lib/wasix/src/syscalls/wasix/sock_set_opt_time.rs index 6196cc5e4a4..90c72bda01b 100644 --- a/lib/wasix/src/syscalls/wasix/sock_set_opt_time.rs +++ b/lib/wasix/src/syscalls/wasix/sock_set_opt_time.rs @@ -24,7 +24,7 @@ pub fn sock_set_opt_time( OptionTag::Some => Some(Duration::from_nanos(time.u)), _ => return Ok(Errno::Inval), }; - Span::current().record("time", &format!("{:?}", time)); + Span::current().record("time", format!("{:?}", time)); let ty = match opt { Sockoption::RecvTimeout => TimeType::ReadTimeout, diff --git a/lib/wasix/src/syscalls/wasix/sock_status.rs b/lib/wasix/src/syscalls/wasix/sock_status.rs index 81a7b960927..5126ce0662d 100644 --- a/lib/wasix/src/syscalls/wasix/sock_status.rs +++ b/lib/wasix/src/syscalls/wasix/sock_status.rs @@ -23,7 +23,7 @@ pub fn sock_status( WasiSocketStatus::Closed => Sockstatus::Closed, WasiSocketStatus::Failed => Sockstatus::Failed, }; - Span::current().record("status", &format!("{:?}", status)); + Span::current().record("status", format!("{:?}", status)); let env = ctx.data(); let memory = unsafe { env.memory_view(&ctx) }; diff --git a/lib/wasm-interface/src/parser.rs b/lib/wasm-interface/src/parser.rs index 03475a9b303..320a433504c 100644 --- a/lib/wasm-interface/src/parser.rs +++ b/lib/wasm-interface/src/parser.rs @@ -23,11 +23,11 @@ //! identifier = any character that's not a whitespace character or an open or close parenthesis //! type = "i32" | "i64" | "f32" | "f64" //! -//! + means 1 or more -//! * means 0 or more -//! ? means 0 or 1 -//! | means "or" -//! "\"" means one `"` character +//! `+` means 1 or more +//! `*` means 0 or more +//! `?` means 0 or 1 +//! `|` means "or" +//! `\"` means one `"` character //! //! comments start with a `;` character and go until a newline `\n` character is reached //! comments and whitespace are valid between any tokens diff --git a/rust-toolchain b/rust-toolchain index 17420a571fe..ace1327fbd9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.79 +1.81 \ No newline at end of file diff --git a/tests/compilers/wasmu/linux/bash.wasmu b/tests/compilers/wasmu/linux/bash.wasmu index 250829379cd..4019feb71b0 100644 Binary files a/tests/compilers/wasmu/linux/bash.wasmu and b/tests/compilers/wasmu/linux/bash.wasmu differ diff --git a/tests/compilers/wasmu/linux/cowsay.wasmu b/tests/compilers/wasmu/linux/cowsay.wasmu index edad4ec6020..76cc6bd8ccb 100644 Binary files a/tests/compilers/wasmu/linux/cowsay.wasmu and b/tests/compilers/wasmu/linux/cowsay.wasmu differ diff --git a/tests/compilers/wasmu/linux/python-3.11.3.wasmu b/tests/compilers/wasmu/linux/python-3.11.3.wasmu index 3a00242a73d..cdd9683ee12 100644 Binary files a/tests/compilers/wasmu/linux/python-3.11.3.wasmu and b/tests/compilers/wasmu/linux/python-3.11.3.wasmu differ diff --git a/tests/compilers/wasmu/windows/bash.wasmu b/tests/compilers/wasmu/windows/bash.wasmu index 129d6fdcda6..c44f8d7eac3 100644 Binary files a/tests/compilers/wasmu/windows/bash.wasmu and b/tests/compilers/wasmu/windows/bash.wasmu differ diff --git a/tests/compilers/wasmu/windows/cowsay.wasmu b/tests/compilers/wasmu/windows/cowsay.wasmu index a3b5c42aad2..407dbd8859d 100644 Binary files a/tests/compilers/wasmu/windows/cowsay.wasmu and b/tests/compilers/wasmu/windows/cowsay.wasmu differ diff --git a/tests/compilers/wasmu/windows/python-3.11.3.wasmu b/tests/compilers/wasmu/windows/python-3.11.3.wasmu index c48ae7bb06e..887829a09ca 100644 Binary files a/tests/compilers/wasmu/windows/python-3.11.3.wasmu and b/tests/compilers/wasmu/windows/python-3.11.3.wasmu differ