mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
reuse_pool: only do acquire_clock if we reused from a different thread
This commit is contained in:
@@ -171,7 +171,9 @@ fn addr_from_alloc_id(
|
||||
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 @@ pub fn add_addr(
|
||||
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 @@ pub fn take_addr(
|
||||
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 @@ pub fn take_addr(
|
||||
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 @@ pub fn as_slice(&self) -> &[VTimestamp] {
|
||||
}
|
||||
|
||||
/// 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] {
|
||||
|
||||
Reference in New Issue
Block a user