Rollup merge of #117044 - RalfJung:miri, r=RalfJung

Miri subtree update

This should unblock https://github.com/rust-lang/rust/pull/116581
This commit is contained in:
Matthias Krüger 2023-10-23 08:12:40 +02:00 committed by GitHub
commit fe4fde24e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -1 +1 @@
249624b5043013d18c00f0401ca431c1a6baa8cd
9e3f784eb2c7c847b6c3578b373c0e0bc9233ca3

View File

@ -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<u64>,
},
}
@ -82,7 +82,7 @@ impl Clock {
// 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 @@ impl Clock {
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 @@ impl Clock {
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() } },
}
}
}

View File

@ -1,4 +1,5 @@
#![feature(rustc_private)]
#![feature(cell_update)]
#![feature(float_gamma)]
#![feature(map_try_insert)]
#![feature(never_type)]

View File

@ -37,7 +37,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
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")