From 193fec640dfaeee507cf13f677dbcda42b98374a Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Sun, 22 Oct 2023 05:29:24 +0000 Subject: [PATCH 1/3] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index bc3882bcf2b..0335ad3c1d8 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -249624b5043013d18c00f0401ca431c1a6baa8cd +9e3f784eb2c7c847b6c3578b373c0e0bc9233ca3 From 8cbac823d016c1afb3c24e3d87c2896566a7d5d7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 22 Oct 2023 08:40:37 +0200 Subject: [PATCH 2/3] clippy --- src/tools/miri/src/shims/backtrace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/src/shims/backtrace.rs b/src/tools/miri/src/shims/backtrace.rs index 08b26f5fe85..48dafc40c62 100644 --- a/src/tools/miri/src/shims/backtrace.rs +++ b/src/tools/miri/src/shims/backtrace.rs @@ -37,7 +37,7 @@ fn handle_miri_get_backtrace( let this = self.eval_context_mut(); let tcx = this.tcx; - let flags = if let Some(flags_op) = args.get(0) { + let flags = if let Some(flags_op) = args.first() { this.read_scalar(flags_op)?.to_u64()? } else { throw_ub_format!("expected at least 1 argument") From b53c34f7b823e74eed970be80dcd5622cee9cd56 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 22 Oct 2023 08:43:57 +0200 Subject: [PATCH 3/3] avoid AtomicU64 when a Cell is enough --- src/tools/miri/src/clock.rs | 13 ++++++------- src/tools/miri/src/lib.rs | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/miri/src/clock.rs b/src/tools/miri/src/clock.rs index 24bf90f104f..fd0c121626b 100644 --- a/src/tools/miri/src/clock.rs +++ b/src/tools/miri/src/clock.rs @@ -1,4 +1,4 @@ -use std::sync::atomic::{AtomicU64, Ordering}; +use std::cell::Cell; use std::time::{Duration, Instant as StdInstant}; /// When using a virtual clock, this defines how many nanoseconds we pretend are passing for each @@ -59,7 +59,7 @@ enum ClockKind { }, Virtual { /// The "current virtual time". - nanoseconds: AtomicU64, + nanoseconds: Cell, }, } @@ -82,7 +82,7 @@ pub fn tick(&self) { // Time will pass without us doing anything. } ClockKind::Virtual { nanoseconds } => { - nanoseconds.fetch_add(NANOSECONDS_PER_BASIC_BLOCK, Ordering::SeqCst); + nanoseconds.update(|x| x + NANOSECONDS_PER_BASIC_BLOCK); } } } @@ -93,7 +93,8 @@ pub fn sleep(&self, duration: Duration) { ClockKind::Host { .. } => std::thread::sleep(duration), ClockKind::Virtual { nanoseconds } => { // Just pretend that we have slept for some time. - nanoseconds.fetch_add(duration.as_nanos().try_into().unwrap(), Ordering::SeqCst); + let nanos: u64 = duration.as_nanos().try_into().unwrap(); + nanoseconds.update(|x| x + nanos); } } } @@ -110,9 +111,7 @@ pub fn now(&self) -> Instant { match &self.kind { ClockKind::Host { .. } => Instant { kind: InstantKind::Host(StdInstant::now()) }, ClockKind::Virtual { nanoseconds } => - Instant { - kind: InstantKind::Virtual { nanoseconds: nanoseconds.load(Ordering::SeqCst) }, - }, + Instant { kind: InstantKind::Virtual { nanoseconds: nanoseconds.get() } }, } } } diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 68b9164dec0..b12aae6d414 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -1,4 +1,5 @@ #![feature(rustc_private)] +#![feature(cell_update)] #![feature(float_gamma)] #![feature(map_try_insert)] #![feature(never_type)]