From 1befdcf99c4b4ab500cc180d238d2180c1a2a754 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Wed, 26 Apr 2023 02:10:26 +0200 Subject: [PATCH 01/16] WIP: bump `rustc` nightly and a few deps too needs patched toolset from mozilla (PRs submitted: https://github.com/mozilla/nixpkgs-mozilla/pull/309) --- default.nix | 6 +++--- nix/default.nix | 2 +- nix/sources.json | 14 ++++++------- rts/cargo-vendor-tools/Cargo.lock | 28 ++++++++++++------------- rts/motoko-rts-tests/Cargo.lock | 35 ++++++++++++++++++------------- rts/motoko-rts/Cargo.lock | 20 +++++++++--------- 6 files changed, 56 insertions(+), 49 deletions(-) diff --git a/default.nix b/default.nix index f0d3787f8d8..1707dadffad 100644 --- a/default.nix +++ b/default.nix @@ -162,14 +162,14 @@ rec { cargoVendorTools = nixpkgs.rustPlatform.buildRustPackage rec { name = "cargo-vendor-tools"; src = subpath "./rts/${name}/"; - cargoSha256 = "sha256-gzLk4kNBSbd8ujJ/7mNs/vwCu76ASqtyoVU84PdaJCw="; + cargoSha256 = "sha256-E6GTFvmZMjGsVlec7aH3QaizqIET6Dz8Csh0N1jeX+M="; }; # Path to vendor-rust-std-deps, provided by cargo-vendor-tools vendorRustStdDeps = "${cargoVendorTools}/bin/vendor-rust-std-deps"; # SHA256 of Rust std deps - rustStdDepsHash = "sha256-dGQzospDaIlGKWu08b8oaXJgIsniBVxI//zc6/LywIE="; + rustStdDepsHash = "sha256-A3WPIx+weu4wIYV7cweGkRxYGAPt7srxBAtMEyPOkhI="; # Vendor directory for Rust std deps rustStdDeps = nixpkgs.stdenvNoCC.mkDerivation { @@ -195,7 +195,7 @@ rec { name = "motoko-rts-deps"; src = subpath ./rts; sourceRoot = "rts/motoko-rts-tests"; - sha256 = "sha256-jCk92mPwXd8H8zEH4OMdcEwFM8IiYdlhYdYr+WzDW5E="; + sha256 = "sha256-RvzNAfxKK9b7JzaZAvE6Etgbh+ARehFrkWqukI1yL8A="; copyLockfile = true; }; diff --git a/nix/default.nix b/nix/default.nix index 2f927cb5eae..d7cb0e9f3aa 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -103,7 +103,7 @@ let # Rust nightly (self: super: let - rust-channel = self.moz_overlay.rustChannelOf { date = "2022-10-30"; channel = "nightly"; }; + rust-channel = self.moz_overlay.rustChannelOf { date = "2023-04-21"; channel = "nightly"; }; in rec { rustc-nightly = rust-channel.rust.override { targets = [ diff --git a/nix/sources.json b/nix/sources.json index 436a00b2bc1..08c337b1a35 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -90,10 +90,10 @@ "homepage": "https://wasi.dev", "owner": "WebAssembly", "repo": "wasi-libc", - "rev": "099caae3eb9111a67d2f0e1b4f9f5f98e682482a", - "sha256": "1rf2ck7x5hzycz8yhcbmn7whmmypw0fl8lm0rcnjapcnr0cgbckx", + "rev": "38f48942fabf1b59e73bca126340b219fa9a78aa", + "sha256": "0j2d6p32825a1nf5brm870pwkclwqfy7fxkgyk32y4k3axcsz6z2", "type": "tarball", - "url": "https://github.com/WebAssembly/wasi-libc/archive/099caae3eb9111a67d2f0e1b4f9f5f98e682482a.tar.gz", + "url": "https://github.com/WebAssembly/wasi-libc/archive/38f48942fabf1b59e73bca126340b219fa9a78aa.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { @@ -114,12 +114,12 @@ "builtin": false, "description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)", "homepage": null, - "owner": "mozilla", + "owner": "ggreif", "repo": "nixpkgs-mozilla", - "rev": "d38863db88e100866b3e494a651ee4962b762fcc", - "sha256": "0wb4qw0jyf6s9ynf2w11qizx6shgj0yz6fgcax91p4p8y7lfbryk", + "rev": "bb30801a4444bfb81e1e4c177f921a6526ccf234", + "sha256": "0yjls0866pd02dxkak558k24b19ljjcizy4r7dpjnsmafn25kx0a", "type": "tarball", - "url": "https://github.com/mozilla/nixpkgs-mozilla/archive/d38863db88e100866b3e494a651ee4962b762fcc.tar.gz", + "url": "https://github.com/ggreif/nixpkgs-mozilla/archive/bb30801a4444bfb81e1e4c177f921a6526ccf234.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "ocaml-vlq": { diff --git a/rts/cargo-vendor-tools/Cargo.lock b/rts/cargo-vendor-tools/Cargo.lock index 5b1b3026052..3f40dfa5cf6 100644 --- a/rts/cargo-vendor-tools/Cargo.lock +++ b/rts/cargo-vendor-tools/Cargo.lock @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -107,15 +107,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "opaque-debug" @@ -125,21 +125,21 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", diff --git a/rts/motoko-rts-tests/Cargo.lock b/rts/motoko-rts-tests/Cargo.lock index a0117435696..f68c1e31f33 100644 --- a/rts/motoko-rts-tests/Cargo.lock +++ b/rts/motoko-rts-tests/Cargo.lock @@ -37,9 +37,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -54,9 +54,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" + +[[package]] +name = "libm" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "motoko-rts" @@ -94,6 +100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -110,9 +117,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -142,9 +149,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -190,15 +197,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -207,9 +214,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "wasi" diff --git a/rts/motoko-rts/Cargo.lock b/rts/motoko-rts/Cargo.lock index fb453f0060e..38910e441b2 100644 --- a/rts/motoko-rts/Cargo.lock +++ b/rts/motoko-rts/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "libc" -version = "0.2.139" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "motoko-rts" @@ -27,27 +27,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -56,6 +56,6 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" From 314a3640126d25a0ec14b8e2db5edc62ba1ad12c Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Wed, 26 Apr 2023 16:59:38 +0200 Subject: [PATCH 02/16] Update sources.json --- nix/sources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/sources.json b/nix/sources.json index 201269e776e..c369dfb096e 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -114,7 +114,7 @@ "builtin": false, "description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)", "homepage": null, - "owner": "ggreif", + "owner": "mozilla", "repo": "nixpkgs-mozilla", "rev": "c72bae8641d4486b3bd7b556d577df519f640f9a", "sha256": "0yjls0866pd02dxkak558k24b19ljjcizy4r7dpjnsmafn25kx0a", From c5ee47e72677e0fe77c39a06abde82f51ac3eaa6 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Mon, 15 May 2023 16:58:43 +0200 Subject: [PATCH 03/16] Avoid unaligned 64-bit pointer dereferencing --- rts/motoko-rts-tests/Cargo.lock | 7 --- rts/motoko-rts-tests/src/main.rs | 14 ++++- rts/motoko-rts-tests/src/stream.rs | 4 +- .../src/gc/incremental/mark_bitmap.rs | 6 ++- .../src/gc/incremental/partitioned_heap.rs | 5 ++ rts/motoko-rts/src/gc/mark_compact/bitmap.rs | 7 ++- rts/motoko-rts/src/stream.rs | 54 +++++++++++++------ rts/motoko-rts/src/types.rs | 33 +++++++++--- src/codegen/compile.ml | 7 +-- 9 files changed, 101 insertions(+), 36 deletions(-) diff --git a/rts/motoko-rts-tests/Cargo.lock b/rts/motoko-rts-tests/Cargo.lock index 20e616c3dcd..dea7c950617 100644 --- a/rts/motoko-rts-tests/Cargo.lock +++ b/rts/motoko-rts-tests/Cargo.lock @@ -58,12 +58,6 @@ version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" -[[package]] -name = "libm" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" - [[package]] name = "motoko-rts" version = "0.1.0" @@ -101,7 +95,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm", ] [[package]] diff --git a/rts/motoko-rts-tests/src/main.rs b/rts/motoko-rts-tests/src/main.rs index 0e84f191cd0..3b2e92fadbc 100644 --- a/rts/motoko-rts-tests/src/main.rs +++ b/rts/motoko-rts-tests/src/main.rs @@ -12,7 +12,7 @@ mod stream; mod text; mod utf8; -use motoko_rts::types::Bytes; +use motoko_rts::types::{read64, write64, Bytes}; fn main() { if std::mem::size_of::() != 4 { @@ -21,6 +21,7 @@ fn main() { } unsafe { + test_read_write_64_bit(); bigint::test(); bitrel::test(); continuation_table::test(); @@ -34,6 +35,17 @@ fn main() { } } +fn test_read_write_64_bit() { + println!("Testing 64-bit read-write"); + const TEST_VALUE: u64 = 0x1234_5678_9abc_def0; + let mut lower = 0u32; + let mut upper = 0u32; + write64(&mut lower, &mut upper, TEST_VALUE); + assert_eq!(lower, 0x9abc_def0); + assert_eq!(upper, 0x1234_5678); + assert_eq!(read64(lower, upper), TEST_VALUE); +} + // Called by the RTS to panic #[no_mangle] extern "C" fn rts_trap(ptr: *const u8, len: Bytes) -> ! { diff --git a/rts/motoko-rts-tests/src/stream.rs b/rts/motoko-rts-tests/src/stream.rs index 32c689afa1d..3321ea7142f 100644 --- a/rts/motoko-rts-tests/src/stream.rs +++ b/rts/motoko-rts-tests/src/stream.rs @@ -4,6 +4,7 @@ use crate::memory::TestMemory; use motoko_rts::stream::alloc_stream; use motoko_rts::types::{size_of, Blob, Bytes, Stream, Value, Words}; +use motoko_rts_macros::is_incremental_gc; pub unsafe fn test() { println!("Testing streaming ..."); @@ -33,7 +34,8 @@ pub unsafe fn test() { println!(" Testing stream decay"); let blob = stream.as_stream().split(); assert_eq!(blob.as_blob().len(), Bytes(STREAM_SMALL_SIZE)); - assert_eq!(stream.as_blob().len(), Bytes(24)); + const REMAINDER: u32 = if is_incremental_gc!() { 20 } else { 24 }; + assert_eq!(stream.as_blob().len(), Bytes(REMAINDER)); println!(" Testing stream filling (blocks)"); const STREAM_LARGE_SIZE: u32 = 6000; diff --git a/rts/motoko-rts/src/gc/incremental/mark_bitmap.rs b/rts/motoko-rts/src/gc/incremental/mark_bitmap.rs index 9542f54f361..e614d5b2b4a 100644 --- a/rts/motoko-rts/src/gc/incremental/mark_bitmap.rs +++ b/rts/motoko-rts/src/gc/incremental/mark_bitmap.rs @@ -46,7 +46,9 @@ impl MarkBitmap { } /// Assign and initialize the bitmap memory at the defined address. + /// The `bitmap_address` must be 64-bit-aligned for fast iteration. pub unsafe fn assign(&mut self, bitmap_address: *mut u8) { + debug_assert_eq!(bitmap_address as usize % size_of::(), 0); memzero( bitmap_address as usize, Bytes(BITMAP_SIZE as u32).to_words(), @@ -96,7 +98,7 @@ impl MarkBitmap { /// The iterator separates advancing `next()` from inspection `current_marked_offset()` /// to better support the incremental evacuation and update GC increments. pub struct BitmapIterator { - /// Start address of the mark bitmap. + /// Start address of the mark bitmap. Must be 64-bit-aligned. bitmap_pointer: *mut u8, /// Index of next bit to continue iteration in the bitmap. /// Invariant during (initialized and unfinished): @@ -123,6 +125,7 @@ const BIT_INDEX_END: usize = BITMAP_SIZE * u8::BITS as usize; const _: () = assert!(BIT_INDEX_END < BITMAP_ITERATION_END); impl BitmapIterator { + /// The `bitmap_pointer` must be 64-bit-aligned. fn new(bitmap_pointer: *mut u8) -> BitmapIterator { debug_assert_ne!(bitmap_pointer, null_mut()); debug_assert_eq!(PARTITION_SIZE % size_of::(), 0); @@ -171,6 +174,7 @@ impl BitmapIterator { if self.next_bit_index < BIT_INDEX_END { debug_assert_eq!(self.next_bit_index % u8::BITS as usize, 0); let word64_index = self.next_bit_index / u8::BITS as usize; + // The bitmap pointer is guaranteed to be always 64-bit aligned, see `BitmapIterator::new()`. self.current_word = unsafe { *(self.bitmap_pointer.add(word64_index) as *const u64) }; self.leading_zeros = self.current_word.leading_zeros() as usize; diff --git a/rts/motoko-rts/src/gc/incremental/partitioned_heap.rs b/rts/motoko-rts/src/gc/incremental/partitioned_heap.rs index 6ce339393ad..19bda8b558e 100644 --- a/rts/motoko-rts/src/gc/incremental/partitioned_heap.rs +++ b/rts/motoko-rts/src/gc/incremental/partitioned_heap.rs @@ -429,6 +429,7 @@ impl PartitionedHeap { rts_trap_with("Cannot grow memory"); } + /// The returned bitmap address is guaranteed to be 64-bit-aligned. unsafe fn allocate_bitmap(&mut self, mem: &mut M) -> *mut u8 { if self.bitmap_allocation_pointer % PARTITION_SIZE == 0 { let partition = self.allocate_temporary_partition(); @@ -437,6 +438,10 @@ impl PartitionedHeap { } let bitmap_address = self.bitmap_allocation_pointer as *mut u8; self.bitmap_allocation_pointer += BITMAP_SIZE; + debug_assert_eq!( + bitmap_address as usize % size_of::().to_bytes().as_usize(), + 0 + ); bitmap_address } diff --git a/rts/motoko-rts/src/gc/mark_compact/bitmap.rs b/rts/motoko-rts/src/gc/mark_compact/bitmap.rs index c1da3b257e1..dc86885489a 100644 --- a/rts/motoko-rts/src/gc/mark_compact/bitmap.rs +++ b/rts/motoko-rts/src/gc/mark_compact/bitmap.rs @@ -133,7 +133,8 @@ pub unsafe fn iter_bits() -> BitmapIter { let current_word = if blob_len_64bit_words == 0 { 0 } else { - *(BITMAP_PTR as *const u64) + let bitmap_ptr64 = BITMAP_PTR as *const u64; + bitmap_ptr64.read_unaligned() }; debug_assert!(BITMAP_PTR as usize >= BITMAP_FORBIDDEN_PTR as usize); @@ -190,7 +191,9 @@ impl BitmapIter { return BITMAP_ITER_END; } self.current_word = unsafe { - *(BITMAP_FORBIDDEN_PTR.add(self.current_bit_idx as usize / 8) as *const u64) + let ptr64 = + BITMAP_FORBIDDEN_PTR.add(self.current_bit_idx as usize / 8) as *const u64; + ptr64.read_unaligned() }; self.leading_zeros = self.current_word.leading_zeros(); } diff --git a/rts/motoko-rts/src/stream.rs b/rts/motoko-rts/src/stream.rs index b206971cb17..f3de8a92f84 100644 --- a/rts/motoko-rts/src/stream.rs +++ b/rts/motoko-rts/src/stream.rs @@ -22,8 +22,8 @@ // into the leading bytes: // - `obj header` contains tag (BLOB) and forwarding pointer // - `len` is in blob metadata -// - 'padding' because the compiler automatically align `ptr64` to 64-bit according to -// C-memory representation +// - `ptr64`, `start64`, and `limit64` are each represented as two 32-bit components +// in little Endian encoding. // - `ptr64` and `limit64` are the next and past-end pointers into stable memory // - `filled` and `cache` are the number of bytes consumed from the blob, and the // staging area of the stream, respectively @@ -38,12 +38,12 @@ use crate::mem_utils::memcpy_bytes; use crate::memory::{alloc_blob, Memory}; use crate::rts_trap_with; use crate::tommath_bindings::{mp_div_2d, mp_int}; -use crate::types::{size_of, Blob, Bytes, Stream, Value, TAG_BLOB}; +use crate::types::{read64, size_of, write64, Blob, Bytes, Stream, Value, TAG_BLOB}; -use motoko_rts_macros::{ic_mem_fn, is_incremental_gc}; +use motoko_rts_macros::ic_mem_fn; const MAX_STREAM_SIZE: Bytes = Bytes((1 << 30) - 1); -const INITIAL_STREAM_FILLED: Bytes = Bytes(if is_incremental_gc!() { 36 } else { 32 }); +const INITIAL_STREAM_FILLED: Bytes = Bytes(32); const STREAM_CHUNK_SIZE: Bytes = Bytes(128); #[ic_mem_fn] @@ -57,9 +57,9 @@ pub unsafe fn alloc_stream(mem: &mut M, size: Bytes) -> *mut Str } let ptr = alloc_blob(mem, size + INITIAL_STREAM_FILLED); let stream = ptr.as_stream(); - (*stream).ptr64 = 0; - (*stream).start64 = 0; - (*stream).limit64 = 0; + stream.write_ptr64(0); + stream.write_start64(0); + stream.write_limit64(0); (*stream).outputter = Stream::no_backing_store; (*stream).filled = INITIAL_STREAM_FILLED; allocation_barrier(ptr); @@ -73,6 +73,30 @@ extern "C" { } impl Stream { + pub unsafe fn write_ptr64(self: *mut Self, value: u64) { + write64(&mut (*self).ptr_lower, &mut (*self).ptr_upper, value); + } + + pub unsafe fn read_ptr64(self: *const Self) -> u64 { + read64((*self).ptr_lower, (*self).ptr_upper) + } + + pub unsafe fn write_start64(self: *mut Self, value: u64) { + write64(&mut (*self).start_lower, &mut (*self).start_upper, value); + } + + pub unsafe fn read_start64(self: *const Self) -> u64 { + read64((*self).start_lower, (*self).start_upper) + } + + pub unsafe fn write_limit64(self: *mut Self, value: u64) { + write64(&mut (*self).limit_lower, &mut (*self).limit_upper, value); + } + + pub unsafe fn read_limit64(self: *const Self) -> u64 { + read64((*self).limit_lower, (*self).limit_upper) + } + #[inline] pub unsafe fn cache_addr(self: *const Self) -> *const u8 { self.add(1) as *const u8 // skip closure header @@ -99,9 +123,9 @@ impl Stream { #[cfg(feature = "ic")] fn send_to_stable(self: *mut Self, ptr: *const u8, n: Bytes) { unsafe { - let next_ptr64 = (*self).ptr64 + n.as_u32() as u64; - stable64_write_moc((*self).ptr64, ptr as u64, n.as_u32() as u64); - (*self).ptr64 = next_ptr64 + let next_ptr64 = self.read_ptr64() + n.as_u32() as u64; + stable64_write_moc(self.read_ptr64(), ptr as u64, n.as_u32() as u64); + self.write_ptr64(next_ptr64); } } @@ -111,9 +135,9 @@ impl Stream { #[export_name = "stream_stable_dest"] pub fn setup_stable_dest(self: *mut Self, start: u64, limit: u64) { unsafe { - (*self).ptr64 = start; - (*self).start64 = start; - (*self).limit64 = limit; + self.write_ptr64(start); + self.write_start64(start); + self.write_limit64(limit); (*self).outputter = Self::send_to_stable; } } @@ -122,7 +146,7 @@ impl Stream { #[export_name = "stream_write"] pub fn cache_bytes(self: *mut Self, ptr: *const u8, n: Bytes) { unsafe { - if (*self).limit64 != 0 && n > STREAM_CHUNK_SIZE + if self.read_limit64() != 0 && n > STREAM_CHUNK_SIZE || (*self).filled + n > (*self).header.len { self.flush(); diff --git a/rts/motoko-rts/src/types.rs b/rts/motoko-rts/src/types.rs index 868d81a7b5d..5d929087050 100644 --- a/rts/motoko-rts/src/types.rs +++ b/rts/motoko-rts/src/types.rs @@ -658,21 +658,42 @@ impl Blob { } } +/// Note: Do not declare 64-bit fields, as otherwise, the objects are expected to be 64-bit aligned. +/// This is not the case in the current heap design. +/// Moreover, fields would also get 64-bit aligned causing implicit paddding. + #[repr(C)] // See the note at the beginning of this module pub struct Stream { pub header: Blob, - // Cannot use `#[incremental_gc]` as Rust only allows non-macro attributes for fields. - #[cfg(feature = "incremental_gc")] - pub padding: u32, // The insertion of the forwarding pointer in the header implies 1 word padding to 64-bit. + /// Components of the 64-bit `ptr` value. Little-Endian encoding. + /// Use `read_ptr64()` and `write_ptr64()` to access. + pub ptr_lower: u32, + pub ptr_upper: u32, + + /// Components of the 64-bit `start` value. Little-Endian encoding. + /// Use `read_start64()` and `write_start64()` to access. + pub start_lower: u32, + pub start_upper: u32, + + /// Components of the 64-bit `limit` value. Little-Endian encoding. + /// Use `read_limit64()` and `write_limit64()` to access. + pub limit_lower: u32, + pub limit_upper: u32, - pub ptr64: u64, - pub start64: u64, - pub limit64: u64, pub outputter: fn(*mut Self, *const u8, Bytes) -> (), pub filled: Bytes, // cache data follows .. } +pub fn read64(lower: u32, upper: u32) -> u64 { + ((upper as u64) << 32) + lower as u64 +} + +pub fn write64(lower: &mut u32, upper: &mut u32, value: u64) { + *upper = (value >> 32) as u32; + *lower = (value & u32::MAX as u64) as u32; +} + impl Stream { pub unsafe fn is_forwarded(self: *const Self) -> bool { (self as *const Obj).is_forwarded() diff --git a/src/codegen/compile.ml b/src/codegen/compile.ml index 2ff1e216e71..48f9ce191d9 100644 --- a/src/codegen/compile.ml +++ b/src/codegen/compile.ml @@ -1137,7 +1137,8 @@ module Heap = struct (* Although we occasionally want to treat two consecutive 32 bit fields as one 64 bit number *) - + + (* Requires little Endian encoding, see also `Stream` in `types.rs` *) let load_field64_unskewed (i : int32) : G.t = let offset = Int32.mul word_size i in G.i (Load {ty = I64Type; align = 2; offset; sz = None}) @@ -7016,7 +7017,7 @@ module BlobStream : Stream = struct let name_for fn_name ts = "@Bl_" ^ fn_name ^ "<" ^ Typ_hash.typ_seq_hash ts ^ ">" let absolute_offset env get_token = - let offset = if !Flags.gc_strategy = Flags.Incremental then 9l else 8l in (* see invariant in `stream.rs` *) + let offset = 8l in (* see invariant in `stream.rs` *) let filled_field = Int32.add (Blob.len_field env) offset in get_token ^^ Tagged.load_field_unskewed env filled_field @@ -7114,7 +7115,7 @@ module Stabilization = struct E.call_import env "rts" "stream_stable_dest" let ptr64_field env = - let offset = if !Flags.gc_strategy = Flags.Incremental then 2l else 1l in (* see invariant in `stream.rs` *) + let offset = 1l in (* see invariant in `stream.rs` *) Int32.add (Blob.len_field env) offset (* see invariant in `stream.rs`, padding for 64-bit after Stream header *) let terminate env get_token get_data_size header_size = From 85e98f2beac03c66dbafd5a52e50a93f95d6b84a Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Mon, 15 May 2023 17:00:08 +0200 Subject: [PATCH 04/16] Update benchmark results --- test/bench/ok/heap-32.drun-run.ok | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bench/ok/heap-32.drun-run.ok b/test/bench/ok/heap-32.drun-run.ok index f50c78e9a4f..85faa48e3c7 100644 --- a/test/bench/ok/heap-32.drun-run.ok +++ b/test/bench/ok/heap-32.drun-run.ok @@ -1,5 +1,5 @@ ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 ingress Completed: Reply: 0x4449444c0000 -debug.print: (50_227, +91_377_860, 1_433_858_160) -debug.print: (50_070, +102_586_000, 1_505_791_140) +debug.print: (50_227, +91_377_860, 1_435_538_669) +debug.print: (50_070, +102_586_000, 1_507_623_284) ingress Completed: Reply: 0x4449444c0000 From 4708e9623d895973a8315dbfabe30bd15ad6f5f2 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Mon, 15 May 2023 17:40:58 +0200 Subject: [PATCH 05/16] Update hash in nix dependency --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index facf1ac64ec..a19895d65c0 100644 --- a/default.nix +++ b/default.nix @@ -195,7 +195,7 @@ rec { name = "motoko-rts-deps"; src = subpath ./rts; sourceRoot = "rts/motoko-rts-tests"; - sha256 = "sha256-RvzNAfxKK9b7JzaZAvE6Etgbh+ARehFrkWqukI1yL8A="; + sha256 = "sha256-jN5nx5UNBHlYKnC0kk90h6mWPUNrqPS7Wln2TixbGgA="; copyLockfile = true; }; From c1fcd76fcebbfdcc3effa895a2f55c90e0909e79 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Mon, 15 May 2023 19:06:24 +0200 Subject: [PATCH 06/16] Experiment: Temporarily disable wasm profiler tests --- default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index a19895d65c0..d6e1817978c 100644 --- a/default.nix +++ b/default.nix @@ -515,7 +515,8 @@ rec { perf = perf_subdir "perf" [ moc nixpkgs.drun ]; bench = perf_subdir "bench" [ moc nixpkgs.drun ]; viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3 ]; - inherit qc lsp unit candid profiling-graphs coverage; + # inherit qc lsp unit candid profiling-graphs coverage; + inherit qc lsp unit candid coverage; }) // { recurseForDerivations = true; }; samples = stdenv.mkDerivation { @@ -689,7 +690,7 @@ rec { mkdir -p $out ln -s ${base-doc} $out/base-doc ln -s ${docs} $out/docs - ln -s ${tests.profiling-graphs} $out/flamegraphs + # ln -s ${tests.profiling-graphs} $out/flamegraphs ln -s ${tests.coverage} $out/coverage cd $out; # generate a simple index.html, listing the entry points From 2fdba2f083de9403053f0428ccd6260be81f7c94 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Mon, 15 May 2023 19:12:02 +0200 Subject: [PATCH 07/16] Temporarily disable profiling test --- default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/default.nix b/default.nix index d6e1817978c..29567f8bed0 100644 --- a/default.nix +++ b/default.nix @@ -690,7 +690,6 @@ rec { mkdir -p $out ln -s ${base-doc} $out/base-doc ln -s ${docs} $out/docs - # ln -s ${tests.profiling-graphs} $out/flamegraphs ln -s ${tests.coverage} $out/coverage cd $out; # generate a simple index.html, listing the entry points From 5d1dffef9dfe52926c6b1ba19bda0c95800824c7 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Tue, 16 May 2023 09:33:27 +0200 Subject: [PATCH 08/16] Adjust wasm-profiler for upgraded Rust compiler version --- wasm-profiler/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm-profiler/Cargo.toml b/wasm-profiler/Cargo.toml index aa5598e448f..b3869acbc1d 100644 --- a/wasm-profiler/Cargo.toml +++ b/wasm-profiler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2018" [dependencies] -parity-wasm = "0.42.2" +parity-wasm = { version = "0.42.2", features = ["std", "sign_ext"] } structopt = "0.3" clap = "2.33" From d63c9ad75ca72b511e2723a3d42da6a8b935adc6 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Tue, 16 May 2023 09:35:06 +0200 Subject: [PATCH 09/16] Revert temporary deactivation of WASM profiler --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 29567f8bed0..a19895d65c0 100644 --- a/default.nix +++ b/default.nix @@ -515,8 +515,7 @@ rec { perf = perf_subdir "perf" [ moc nixpkgs.drun ]; bench = perf_subdir "bench" [ moc nixpkgs.drun ]; viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3 ]; - # inherit qc lsp unit candid profiling-graphs coverage; - inherit qc lsp unit candid coverage; + inherit qc lsp unit candid profiling-graphs coverage; }) // { recurseForDerivations = true; }; samples = stdenv.mkDerivation { @@ -690,6 +689,7 @@ rec { mkdir -p $out ln -s ${base-doc} $out/base-doc ln -s ${docs} $out/docs + ln -s ${tests.profiling-graphs} $out/flamegraphs ln -s ${tests.coverage} $out/coverage cd $out; # generate a simple index.html, listing the entry points From 70ea1029f442137cbd15a79ece05988ac00aa35f Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Tue, 16 May 2023 09:46:41 +0200 Subject: [PATCH 10/16] Code refactoring --- rts/motoko-rts/src/stream.rs | 26 +--------------------- rts/motoko-rts/src/types.rs | 42 ++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/rts/motoko-rts/src/stream.rs b/rts/motoko-rts/src/stream.rs index f3de8a92f84..6daa4d70f69 100644 --- a/rts/motoko-rts/src/stream.rs +++ b/rts/motoko-rts/src/stream.rs @@ -38,7 +38,7 @@ use crate::mem_utils::memcpy_bytes; use crate::memory::{alloc_blob, Memory}; use crate::rts_trap_with; use crate::tommath_bindings::{mp_div_2d, mp_int}; -use crate::types::{read64, size_of, write64, Blob, Bytes, Stream, Value, TAG_BLOB}; +use crate::types::{size_of, Blob, Bytes, Stream, Value, TAG_BLOB}; use motoko_rts_macros::ic_mem_fn; @@ -73,30 +73,6 @@ extern "C" { } impl Stream { - pub unsafe fn write_ptr64(self: *mut Self, value: u64) { - write64(&mut (*self).ptr_lower, &mut (*self).ptr_upper, value); - } - - pub unsafe fn read_ptr64(self: *const Self) -> u64 { - read64((*self).ptr_lower, (*self).ptr_upper) - } - - pub unsafe fn write_start64(self: *mut Self, value: u64) { - write64(&mut (*self).start_lower, &mut (*self).start_upper, value); - } - - pub unsafe fn read_start64(self: *const Self) -> u64 { - read64((*self).start_lower, (*self).start_upper) - } - - pub unsafe fn write_limit64(self: *mut Self, value: u64) { - write64(&mut (*self).limit_lower, &mut (*self).limit_upper, value); - } - - pub unsafe fn read_limit64(self: *const Self) -> u64 { - read64((*self).limit_lower, (*self).limit_upper) - } - #[inline] pub unsafe fn cache_addr(self: *const Self) -> *const u8 { self.add(1) as *const u8 // skip closure header diff --git a/rts/motoko-rts/src/types.rs b/rts/motoko-rts/src/types.rs index 5d929087050..e0eb0c83236 100644 --- a/rts/motoko-rts/src/types.rs +++ b/rts/motoko-rts/src/types.rs @@ -685,15 +685,6 @@ pub struct Stream { pub filled: Bytes, // cache data follows .. } -pub fn read64(lower: u32, upper: u32) -> u64 { - ((upper as u64) << 32) + lower as u64 -} - -pub fn write64(lower: &mut u32, upper: &mut u32, value: u64) { - *upper = (value >> 32) as u32; - *lower = (value & u32::MAX as u64) as u32; -} - impl Stream { pub unsafe fn is_forwarded(self: *const Self) -> bool { (self as *const Obj).is_forwarded() @@ -703,6 +694,39 @@ impl Stream { debug_assert!(!self.is_forwarded()); self as *mut Blob } + + pub unsafe fn write_ptr64(self: *mut Self, value: u64) { + write64(&mut (*self).ptr_lower, &mut (*self).ptr_upper, value); + } + + pub unsafe fn read_ptr64(self: *const Self) -> u64 { + read64((*self).ptr_lower, (*self).ptr_upper) + } + + pub unsafe fn write_start64(self: *mut Self, value: u64) { + write64(&mut (*self).start_lower, &mut (*self).start_upper, value); + } + + pub unsafe fn read_start64(self: *const Self) -> u64 { + read64((*self).start_lower, (*self).start_upper) + } + + pub unsafe fn write_limit64(self: *mut Self, value: u64) { + write64(&mut (*self).limit_lower, &mut (*self).limit_upper, value); + } + + pub unsafe fn read_limit64(self: *const Self) -> u64 { + read64((*self).limit_lower, (*self).limit_upper) + } +} + +pub fn read64(lower: u32, upper: u32) -> u64 { + ((upper as u64) << u32::BITS) + lower as u64 +} + +pub fn write64(lower: &mut u32, upper: &mut u32, value: u64) { + *upper = (value >> u32::BITS) as u32; + *lower = (value & u32::MAX as u64) as u32; } /// Only used by the copying GC - not to be confused with the forwarding pointer in the general object header From 683135df3ce5ce4290d7a9e2ff979c8ba12f05f0 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Mon, 22 May 2023 09:26:05 +0200 Subject: [PATCH 11/16] Refactor code comments --- rts/motoko-rts/src/stream.rs | 2 +- rts/motoko-rts/src/types.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rts/motoko-rts/src/stream.rs b/rts/motoko-rts/src/stream.rs index 6daa4d70f69..f8717238927 100644 --- a/rts/motoko-rts/src/stream.rs +++ b/rts/motoko-rts/src/stream.rs @@ -23,7 +23,7 @@ // - `obj header` contains tag (BLOB) and forwarding pointer // - `len` is in blob metadata // - `ptr64`, `start64`, and `limit64` are each represented as two 32-bit components -// in little Endian encoding. +// in little endian encoding. // - `ptr64` and `limit64` are the next and past-end pointers into stable memory // - `filled` and `cache` are the number of bytes consumed from the blob, and the // staging area of the stream, respectively diff --git a/rts/motoko-rts/src/types.rs b/rts/motoko-rts/src/types.rs index e0eb0c83236..c7a0b9e0eae 100644 --- a/rts/motoko-rts/src/types.rs +++ b/rts/motoko-rts/src/types.rs @@ -666,17 +666,17 @@ impl Blob { pub struct Stream { pub header: Blob, - /// Components of the 64-bit `ptr` value. Little-Endian encoding. + /// Components of the 64-bit `ptr` value. Little-endian encoding. /// Use `read_ptr64()` and `write_ptr64()` to access. pub ptr_lower: u32, pub ptr_upper: u32, - /// Components of the 64-bit `start` value. Little-Endian encoding. + /// Components of the 64-bit `start` value. Little-endian encoding. /// Use `read_start64()` and `write_start64()` to access. pub start_lower: u32, pub start_upper: u32, - /// Components of the 64-bit `limit` value. Little-Endian encoding. + /// Components of the 64-bit `limit` value. Little-endian encoding. /// Use `read_limit64()` and `write_limit64()` to access. pub limit_lower: u32, pub limit_upper: u32, From 7b145e3b18fbd595daa881bb666c2ad9b8094e67 Mon Sep 17 00:00:00 2001 From: Luc Blaeser <112870813+luc-blaeser@users.noreply.github.com> Date: Mon, 22 May 2023 09:29:35 +0200 Subject: [PATCH 12/16] Adjust code comment Co-authored-by: Claudio Russo --- src/codegen/compile.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/compile.ml b/src/codegen/compile.ml index 6a1d1aef963..8e3eccb04fd 100644 --- a/src/codegen/compile.ml +++ b/src/codegen/compile.ml @@ -1138,7 +1138,7 @@ module Heap = struct (* Although we occasionally want to treat two consecutive 32 bit fields as one 64 bit number *) - (* Requires little Endian encoding, see also `Stream` in `types.rs` *) + (* Requires little-endian encoding, see also `Stream` in `types.rs` *) let load_field64_unskewed (i : int32) : G.t = let offset = Int32.mul word_size i in G.i (Load {ty = I64Type; align = 2; offset; sz = None}) From 2394c950a804cc6c5e57d33fd6fb56897e6f55ee Mon Sep 17 00:00:00 2001 From: Luc Blaeser <112870813+luc-blaeser@users.noreply.github.com> Date: Mon, 22 May 2023 09:38:26 +0200 Subject: [PATCH 13/16] Code refactoring Co-authored-by: Claudio Russo --- rts/motoko-rts/src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rts/motoko-rts/src/types.rs b/rts/motoko-rts/src/types.rs index c7a0b9e0eae..76e4cef973c 100644 --- a/rts/motoko-rts/src/types.rs +++ b/rts/motoko-rts/src/types.rs @@ -721,7 +721,7 @@ impl Stream { } pub fn read64(lower: u32, upper: u32) -> u64 { - ((upper as u64) << u32::BITS) + lower as u64 + ((upper as u64) << u32::BITS) | lower as u64 } pub fn write64(lower: &mut u32, upper: &mut u32, value: u64) { From 11665e88df488ecc86ab22a400d7aac68afda312 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Wed, 24 May 2023 09:29:43 +0200 Subject: [PATCH 14/16] Revert rustc upgrade Keep the current version and prepare upgrade for later --- default.nix | 6 +++--- nix/default.nix | 2 +- nix/sources.json | 6 +++--- rts/cargo-vendor-tools/Cargo.lock | 28 ++++++++++++++-------------- rts/motoko-rts-tests/Cargo.lock | 28 ++++++++++++++-------------- rts/motoko-rts/Cargo.lock | 20 ++++++++++---------- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/default.nix b/default.nix index 58a93960ee6..a0f22b651f0 100644 --- a/default.nix +++ b/default.nix @@ -162,14 +162,14 @@ rec { cargoVendorTools = nixpkgs.rustPlatform.buildRustPackage rec { name = "cargo-vendor-tools"; src = subpath "./rts/${name}/"; - cargoSha256 = "sha256-E6GTFvmZMjGsVlec7aH3QaizqIET6Dz8Csh0N1jeX+M="; + cargoSha256 = "sha256-gzLk4kNBSbd8ujJ/7mNs/vwCu76ASqtyoVU84PdaJCw="; }; # Path to vendor-rust-std-deps, provided by cargo-vendor-tools vendorRustStdDeps = "${cargoVendorTools}/bin/vendor-rust-std-deps"; # SHA256 of Rust std deps - rustStdDepsHash = "sha256-A3WPIx+weu4wIYV7cweGkRxYGAPt7srxBAtMEyPOkhI="; + rustStdDepsHash = "sha256-dGQzospDaIlGKWu08b8oaXJgIsniBVxI//zc6/LywIE="; # Vendor directory for Rust std deps rustStdDeps = nixpkgs.stdenvNoCC.mkDerivation { @@ -195,7 +195,7 @@ rec { name = "motoko-rts-deps"; src = subpath ./rts; sourceRoot = "rts/motoko-rts-tests"; - sha256 = "sha256-jN5nx5UNBHlYKnC0kk90h6mWPUNrqPS7Wln2TixbGgA="; + sha256 = "sha256-jCk92mPwXd8H8zEH4OMdcEwFM8IiYdlhYdYr+WzDW5E="; copyLockfile = true; }; diff --git a/nix/default.nix b/nix/default.nix index 104d27e6001..d158d2344ec 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -103,7 +103,7 @@ let # Rust nightly (self: super: let - rust-channel = self.moz_overlay.rustChannelOf { date = "2023-04-21"; channel = "nightly"; }; + rust-channel = self.moz_overlay.rustChannelOf { date = "2022-10-30"; channel = "nightly"; }; in rec { rustc-nightly = rust-channel.rust.override { targets = [ diff --git a/nix/sources.json b/nix/sources.json index a8eaa2c0db7..e6331cfef3f 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -90,10 +90,10 @@ "homepage": "https://wasi.dev", "owner": "WebAssembly", "repo": "wasi-libc", - "rev": "38f48942fabf1b59e73bca126340b219fa9a78aa", - "sha256": "0j2d6p32825a1nf5brm870pwkclwqfy7fxkgyk32y4k3axcsz6z2", + "rev": "099caae3eb9111a67d2f0e1b4f9f5f98e682482a", + "sha256": "1rf2ck7x5hzycz8yhcbmn7whmmypw0fl8lm0rcnjapcnr0cgbckx", "type": "tarball", - "url": "https://github.com/WebAssembly/wasi-libc/archive/38f48942fabf1b59e73bca126340b219fa9a78aa.tar.gz", + "url": "https://github.com/WebAssembly/wasi-libc/archive/099caae3eb9111a67d2f0e1b4f9f5f98e682482a.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { diff --git a/rts/cargo-vendor-tools/Cargo.lock b/rts/cargo-vendor-tools/Cargo.lock index 3f40dfa5cf6..5b1b3026052 100644 --- a/rts/cargo-vendor-tools/Cargo.lock +++ b/rts/cargo-vendor-tools/Cargo.lock @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -107,15 +107,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "opaque-debug" @@ -125,21 +125,21 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ "itoa", "ryu", diff --git a/rts/motoko-rts-tests/Cargo.lock b/rts/motoko-rts-tests/Cargo.lock index dea7c950617..5be0c969848 100644 --- a/rts/motoko-rts-tests/Cargo.lock +++ b/rts/motoko-rts-tests/Cargo.lock @@ -37,9 +37,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -54,9 +54,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "motoko-rts" @@ -111,9 +111,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" dependencies = [ "unicode-ident", ] @@ -143,9 +143,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.26" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -191,15 +191,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "syn" -version = "1.0.109" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "wasi" diff --git a/rts/motoko-rts/Cargo.lock b/rts/motoko-rts/Cargo.lock index 38910e441b2..fb453f0060e 100644 --- a/rts/motoko-rts/Cargo.lock +++ b/rts/motoko-rts/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "libc" -version = "0.2.142" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "motoko-rts" @@ -27,27 +27,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] [[package]] name = "syn" -version = "1.0.109" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", @@ -56,6 +56,6 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" From 386adcf023e1ef2b02bb657db6c76eacff2be123 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Wed, 24 May 2023 09:32:29 +0200 Subject: [PATCH 15/16] Update performance benchmark --- test/bench/ok/heap-32.drun-run.ok | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bench/ok/heap-32.drun-run.ok b/test/bench/ok/heap-32.drun-run.ok index 85faa48e3c7..f50c78e9a4f 100644 --- a/test/bench/ok/heap-32.drun-run.ok +++ b/test/bench/ok/heap-32.drun-run.ok @@ -1,5 +1,5 @@ ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 ingress Completed: Reply: 0x4449444c0000 -debug.print: (50_227, +91_377_860, 1_435_538_669) -debug.print: (50_070, +102_586_000, 1_507_623_284) +debug.print: (50_227, +91_377_860, 1_433_858_160) +debug.print: (50_070, +102_586_000, 1_505_791_140) ingress Completed: Reply: 0x4449444c0000 From 759db5f7f9ec030e34fc004a1a777c3d7ae2e431 Mon Sep 17 00:00:00 2001 From: luc-blaeser Date: Wed, 24 May 2023 09:50:18 +0200 Subject: [PATCH 16/16] Adjust hash in nix build --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index a0f22b651f0..40ee04620a5 100644 --- a/default.nix +++ b/default.nix @@ -195,7 +195,7 @@ rec { name = "motoko-rts-deps"; src = subpath ./rts; sourceRoot = "rts/motoko-rts-tests"; - sha256 = "sha256-jCk92mPwXd8H8zEH4OMdcEwFM8IiYdlhYdYr+WzDW5E="; + sha256 = "sha256-bmJF19LIvTMZnj78XF30lxqRlvQaZ0YlqCO2wnwmiNg="; copyLockfile = true; };