mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
reuse_pool: only do acquire_clock if we reused from a different thread
This commit is contained in:
parent
7dcfb54dc6
commit
cb1b4a6977
@ -171,7 +171,9 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
memory_kind,
|
||||
ecx.get_active_thread(),
|
||||
) {
|
||||
if let Some(data_race) = &ecx.machine.data_race {
|
||||
if let Some(clock) = clock
|
||||
&& let Some(data_race) = &ecx.machine.data_race
|
||||
{
|
||||
data_race.acquire_clock(&clock, ecx.get_active_thread());
|
||||
}
|
||||
reuse_addr
|
||||
|
@ -78,6 +78,7 @@ impl ReusePool {
|
||||
subpool.insert(pos, (addr, size, thread, clock));
|
||||
}
|
||||
|
||||
/// Returns the address to use and optionally a clock we have to synchronize with.
|
||||
pub fn take_addr(
|
||||
&mut self,
|
||||
rng: &mut impl Rng,
|
||||
@ -85,7 +86,7 @@ impl ReusePool {
|
||||
align: Align,
|
||||
kind: MemoryKind,
|
||||
thread: ThreadId,
|
||||
) -> Option<(u64, VClock)> {
|
||||
) -> Option<(u64, Option<VClock>)> {
|
||||
// Determine whether we'll even attempt a reuse. As above, we don't do reuse for stack addresses.
|
||||
if kind == MemoryKind::Stack || !rng.gen_bool(self.address_reuse_rate) {
|
||||
return None;
|
||||
@ -122,6 +123,7 @@ impl ReusePool {
|
||||
let (chosen_addr, chosen_size, chosen_thread, clock) = subpool.remove(idx);
|
||||
debug_assert!(chosen_size >= size && chosen_addr % align.bytes() == 0);
|
||||
debug_assert!(cross_thread_reuse || chosen_thread == thread);
|
||||
Some((chosen_addr, clock))
|
||||
// No synchronization needed if we reused from the current thread.
|
||||
Some((chosen_addr, if chosen_thread == thread { None } else { Some(clock) }))
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ impl VClock {
|
||||
}
|
||||
|
||||
/// Get a mutable slice to the internal vector with minimum `min_len`
|
||||
/// elements, to preserve invariants this vector must modify
|
||||
/// elements. To preserve invariants, the caller must modify
|
||||
/// the `min_len`-1 nth element to a non-zero value
|
||||
#[inline]
|
||||
fn get_mut_with_min_len(&mut self, min_len: usize) -> &mut [VTimestamp] {
|
||||
|
Loading…
Reference in New Issue
Block a user