}
impl $name {
- pub fn to_u32_scalar<'tcx>(&self) -> Scalar<Tag> {
+ pub fn to_u32_scalar<'tcx>(&self) -> Scalar<Provenance> {
Scalar::from_u32(self.0.get())
}
}
this.machine.threads.sync.mutexes.push(Default::default())
}
+ #[inline]
+ /// Provides the closure with the next MutexId. Creates that mutex if the closure returns None,
+ /// otherwise returns the value from the closure
+ fn mutex_get_or_create<F>(&mut self, existing: F) -> InterpResult<'tcx, MutexId>
+ where
+ F: FnOnce(&mut MiriEvalContext<'mir, 'tcx>, MutexId) -> InterpResult<'tcx, Option<MutexId>>,
+ {
+ let this = self.eval_context_mut();
+ let next_index = this.machine.threads.sync.mutexes.next_index();
+ if let Some(old) = existing(this, next_index)? {
+ Ok(old)
+ } else {
+ let new_index = this.machine.threads.sync.mutexes.push(Default::default());
+ assert_eq!(next_index, new_index);
+ Ok(new_index)
+ }
+ }
+
#[inline]
/// Get the id of the thread that currently owns this lock.
fn mutex_get_owner(&mut self, id: MutexId) -> ThreadId {
this.machine.threads.sync.rwlocks.push(Default::default())
}
+ #[inline]
+ /// Provides the closure with the next RwLockId. Creates that RwLock if the closure returns None,
+ /// otherwise returns the value from the closure
+ fn rwlock_get_or_create<F>(&mut self, existing: F) -> InterpResult<'tcx, RwLockId>
+ where
+ F: FnOnce(
+ &mut MiriEvalContext<'mir, 'tcx>,
+ RwLockId,
+ ) -> InterpResult<'tcx, Option<RwLockId>>,
+ {
+ let this = self.eval_context_mut();
+ let next_index = this.machine.threads.sync.rwlocks.next_index();
+ if let Some(old) = existing(this, next_index)? {
+ Ok(old)
+ } else {
+ let new_index = this.machine.threads.sync.rwlocks.push(Default::default());
+ assert_eq!(next_index, new_index);
+ Ok(new_index)
+ }
+ }
+
#[inline]
/// Check if locked.
fn rwlock_is_locked(&self, id: RwLockId) -> bool {
this.machine.threads.sync.condvars.push(Default::default())
}
+ #[inline]
+ /// Provides the closure with the next CondvarId. Creates that Condvar if the closure returns None,
+ /// otherwise returns the value from the closure
+ fn condvar_get_or_create<F>(&mut self, existing: F) -> InterpResult<'tcx, CondvarId>
+ where
+ F: FnOnce(
+ &mut MiriEvalContext<'mir, 'tcx>,
+ CondvarId,
+ ) -> InterpResult<'tcx, Option<CondvarId>>,
+ {
+ let this = self.eval_context_mut();
+ let next_index = this.machine.threads.sync.condvars.next_index();
+ if let Some(old) = existing(this, next_index)? {
+ Ok(old)
+ } else {
+ let new_index = this.machine.threads.sync.condvars.push(Default::default());
+ assert_eq!(next_index, new_index);
+ Ok(new_index)
+ }
+ }
+
#[inline]
/// Is the conditional variable awaited?
fn condvar_is_awaited(&mut self, id: CondvarId) -> bool {
}
condvar.waiters.pop_front().map(|waiter| {
if let Some(data_race) = data_race {
- data_race.validate_lock_acquire(&mut condvar.data_race, waiter.thread);
+ data_race.validate_lock_acquire(&condvar.data_race, waiter.thread);
}
(waiter.thread, waiter.mutex)
})