Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move vector_clock and sync into concurrency & make vector_clock private #2500

Merged
merged 2 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/concurrency/data_race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ use rustc_target::abi::{Align, Size};

use crate::*;

use super::weak_memory::EvalContextExt as _;
use super::{
vector_clock::{VClock, VTimestamp, VectorIdx},
weak_memory::EvalContextExt as _,
};

pub type AllocExtra = VClockAlloc;

Expand Down
2 changes: 2 additions & 0 deletions src/concurrency/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod data_race;
mod range_object_map;
pub mod sync;
mod vector_clock;
pub mod weak_memory;
3 changes: 2 additions & 1 deletion src/sync.rs → src/concurrency/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use log::trace;
use rustc_data_structures::fx::FxHashMap;
use rustc_index::vec::{Idx, IndexVec};

use super::vector_clock::VClock;
use crate::*;

/// We cannot use the `newtype_index!` macro because we have to use 0 as a
Expand Down Expand Up @@ -150,7 +151,7 @@ struct FutexWaiter {

/// The state of all synchronization variables.
#[derive(Default, Debug)]
pub(super) struct SynchronizationState {
pub(crate) struct SynchronizationState {
mutexes: IndexVec<MutexId, Mutex>,
rwlocks: IndexVec<RwLockId, RwLock>,
condvars: IndexVec<CondvarId, Condvar>,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/concurrency/weak_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ use crate::*;
use super::{
data_race::{GlobalState as DataRaceState, ThreadClockSet},
range_object_map::{AccessType, RangeObjectMap},
vector_clock::{VClock, VTimestamp, VectorIdx},
};

pub type AllocExtra = StoreBufferAlloc;
Expand Down
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ mod operator;
mod range_map;
mod shims;
mod stacked_borrows;
mod sync;
mod thread;
mod vector_clock;
pub mod thread;

// Establish a "crate-wide prelude": we often import `crate::*`.

Expand Down Expand Up @@ -105,12 +103,10 @@ pub use crate::range_map::RangeMap;
pub use crate::stacked_borrows::{
CallId, EvalContextExt as StackedBorEvalContextExt, Item, Permission, SbTag, Stack, Stacks,
};
pub use crate::sync::{CondvarId, EvalContextExt as SyncEvalContextExt, MutexId, RwLockId};
pub use crate::thread::{
EvalContextExt as ThreadsEvalContextExt, SchedulingAction, ThreadId, ThreadManager, ThreadState,
};
pub use crate::vector_clock::{VClock, VTimestamp, VectorIdx};

pub use concurrency::sync::{CondvarId, EvalContextExt as SyncEvalContextExt, MutexId, RwLockId};
/// Insert rustc arguments at the beginning of the argument list that Miri wants to be
/// set per default, for maximal validation power.
pub const MIRI_DEFAULT_ARGS: &[&str] = &[
Expand Down
2 changes: 1 addition & 1 deletion src/shims/time.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::{Duration, Instant, SystemTime};

use crate::thread::Time;
use crate::*;
use thread::Time;

/// Returns the time elapsed between the provided time and the unix epoch as a `Duration`.
pub fn system_time_to_duration<'tcx>(time: &SystemTime) -> InterpResult<'tcx, Duration> {
Expand Down
2 changes: 1 addition & 1 deletion src/shims/unix/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::time::SystemTime;
use rustc_hir::LangItem;
use rustc_middle::ty::{layout::TyAndLayout, query::TyCtxtAt, subst::Subst, Ty};

use crate::thread::Time;
use crate::*;
use thread::Time;

// pthread_mutexattr_t is either 4 or 8 bytes, depending on the platform.

Expand Down
2 changes: 1 addition & 1 deletion src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_middle::ty::layout::TyAndLayout;
use rustc_target::spec::abi::Abi;

use crate::concurrency::data_race;
use crate::sync::SynchronizationState;
use crate::concurrency::sync::SynchronizationState;
use crate::*;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down