Skip to content

Commit f238513

Browse files
committed
rename some data_race types for more clarity
1 parent 70b97a5 commit f238513

File tree

7 files changed

+159
-159
lines changed

7 files changed

+159
-159
lines changed

src/concurrency/data_race.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,35 @@ use super::weak_memory::EvalContextExt as _;
6262

6363
pub type AllocExtra = VClockAlloc;
6464

65-
/// Valid atomic read-write operations, alias of atomic::Ordering (not non-exhaustive).
65+
/// Valid atomic read-write orderings, alias of atomic::Ordering (not non-exhaustive).
6666
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
67-
pub enum AtomicRwOp {
67+
pub enum AtomicRwOrd {
6868
Relaxed,
6969
Acquire,
7070
Release,
7171
AcqRel,
7272
SeqCst,
7373
}
7474

75-
/// Valid atomic read operations, subset of atomic::Ordering.
75+
/// Valid atomic read orderings, subset of atomic::Ordering.
7676
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
77-
pub enum AtomicReadOp {
77+
pub enum AtomicReadOrd {
7878
Relaxed,
7979
Acquire,
8080
SeqCst,
8181
}
8282

83-
/// Valid atomic write operations, subset of atomic::Ordering.
83+
/// Valid atomic write orderings, subset of atomic::Ordering.
8484
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
85-
pub enum AtomicWriteOp {
85+
pub enum AtomicWriteOrd {
8686
Relaxed,
8787
Release,
8888
SeqCst,
8989
}
9090

91-
/// Valid atomic fence operations, subset of atomic::Ordering.
91+
/// Valid atomic fence orderings, subset of atomic::Ordering.
9292
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
93-
pub enum AtomicFenceOp {
93+
pub enum AtomicFenceOrd {
9494
Acquire,
9595
Release,
9696
AcqRel,
@@ -486,7 +486,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
486486
op: &OpTy<'tcx, Tag>,
487487
offset: u64,
488488
layout: TyAndLayout<'tcx>,
489-
atomic: AtomicReadOp,
489+
atomic: AtomicReadOrd,
490490
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
491491
let this = self.eval_context_ref();
492492
let value_place = this.deref_operand_and_offset(op, offset, layout)?;
@@ -500,7 +500,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
500500
offset: u64,
501501
value: impl Into<ScalarMaybeUninit<Tag>>,
502502
layout: TyAndLayout<'tcx>,
503-
atomic: AtomicWriteOp,
503+
atomic: AtomicWriteOrd,
504504
) -> InterpResult<'tcx> {
505505
let this = self.eval_context_mut();
506506
let value_place = this.deref_operand_and_offset(op, offset, layout)?;
@@ -511,7 +511,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
511511
fn read_scalar_atomic(
512512
&self,
513513
place: &MPlaceTy<'tcx, Tag>,
514-
atomic: AtomicReadOp,
514+
atomic: AtomicReadOrd,
515515
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
516516
let this = self.eval_context_ref();
517517
// This will read from the last store in the modification order of this location. In case
@@ -531,7 +531,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
531531
&mut self,
532532
val: ScalarMaybeUninit<Tag>,
533533
dest: &MPlaceTy<'tcx, Tag>,
534-
atomic: AtomicWriteOp,
534+
atomic: AtomicWriteOrd,
535535
) -> InterpResult<'tcx> {
536536
let this = self.eval_context_mut();
537537
this.validate_overlapping_atomic(dest)?;
@@ -552,7 +552,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
552552
rhs: &ImmTy<'tcx, Tag>,
553553
op: mir::BinOp,
554554
neg: bool,
555-
atomic: AtomicRwOp,
555+
atomic: AtomicRwOrd,
556556
) -> InterpResult<'tcx, ImmTy<'tcx, Tag>> {
557557
let this = self.eval_context_mut();
558558

@@ -581,7 +581,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
581581
&mut self,
582582
place: &MPlaceTy<'tcx, Tag>,
583583
new: ScalarMaybeUninit<Tag>,
584-
atomic: AtomicRwOp,
584+
atomic: AtomicRwOrd,
585585
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
586586
let this = self.eval_context_mut();
587587

@@ -602,7 +602,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
602602
place: &MPlaceTy<'tcx, Tag>,
603603
rhs: ImmTy<'tcx, Tag>,
604604
min: bool,
605-
atomic: AtomicRwOp,
605+
atomic: AtomicRwOrd,
606606
) -> InterpResult<'tcx, ImmTy<'tcx, Tag>> {
607607
let this = self.eval_context_mut();
608608

@@ -642,8 +642,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
642642
place: &MPlaceTy<'tcx, Tag>,
643643
expect_old: &ImmTy<'tcx, Tag>,
644644
new: ScalarMaybeUninit<Tag>,
645-
success: AtomicRwOp,
646-
fail: AtomicReadOp,
645+
success: AtomicRwOrd,
646+
fail: AtomicReadOrd,
647647
can_fail_spuriously: bool,
648648
) -> InterpResult<'tcx, Immediate<Tag>> {
649649
use rand::Rng as _;
@@ -696,7 +696,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
696696
fn validate_atomic_load(
697697
&self,
698698
place: &MPlaceTy<'tcx, Tag>,
699-
atomic: AtomicReadOp,
699+
atomic: AtomicReadOrd,
700700
) -> InterpResult<'tcx> {
701701
let this = self.eval_context_ref();
702702
this.validate_overlapping_atomic(place)?;
@@ -705,7 +705,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
705705
atomic,
706706
"Atomic Load",
707707
move |memory, clocks, index, atomic| {
708-
if atomic == AtomicReadOp::Relaxed {
708+
if atomic == AtomicReadOrd::Relaxed {
709709
memory.load_relaxed(&mut *clocks, index)
710710
} else {
711711
memory.load_acquire(&mut *clocks, index)
@@ -719,7 +719,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
719719
fn validate_atomic_store(
720720
&mut self,
721721
place: &MPlaceTy<'tcx, Tag>,
722-
atomic: AtomicWriteOp,
722+
atomic: AtomicWriteOrd,
723723
) -> InterpResult<'tcx> {
724724
let this = self.eval_context_mut();
725725
this.validate_overlapping_atomic(place)?;
@@ -728,7 +728,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
728728
atomic,
729729
"Atomic Store",
730730
move |memory, clocks, index, atomic| {
731-
if atomic == AtomicWriteOp::Relaxed {
731+
if atomic == AtomicWriteOrd::Relaxed {
732732
memory.store_relaxed(clocks, index)
733733
} else {
734734
memory.store_release(clocks, index)
@@ -742,9 +742,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
742742
fn validate_atomic_rmw(
743743
&mut self,
744744
place: &MPlaceTy<'tcx, Tag>,
745-
atomic: AtomicRwOp,
745+
atomic: AtomicRwOrd,
746746
) -> InterpResult<'tcx> {
747-
use AtomicRwOp::*;
747+
use AtomicRwOrd::*;
748748
let acquire = matches!(atomic, Acquire | AcqRel | SeqCst);
749749
let release = matches!(atomic, Release | AcqRel | SeqCst);
750750
let this = self.eval_context_mut();
@@ -764,7 +764,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
764764
}
765765

766766
/// Update the data-race detector for an atomic fence on the current thread.
767-
fn validate_atomic_fence(&mut self, atomic: AtomicFenceOp) -> InterpResult<'tcx> {
767+
fn validate_atomic_fence(&mut self, atomic: AtomicFenceOrd) -> InterpResult<'tcx> {
768768
let this = self.eval_context_mut();
769769
if let Some(data_race) = &mut this.machine.data_race {
770770
data_race.maybe_perform_sync_operation(|index, mut clocks| {
@@ -773,22 +773,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
773773
// Apply data-race detection for the current fences
774774
// this treats AcqRel and SeqCst as the same as an acquire
775775
// and release fence applied in the same timestamp.
776-
if atomic != AtomicFenceOp::Release {
776+
if atomic != AtomicFenceOrd::Release {
777777
// Either Acquire | AcqRel | SeqCst
778778
clocks.apply_acquire_fence();
779779
}
780-
if atomic != AtomicFenceOp::Acquire {
780+
if atomic != AtomicFenceOrd::Acquire {
781781
// Either Release | AcqRel | SeqCst
782782
clocks.apply_release_fence();
783783
}
784-
if atomic == AtomicFenceOp::SeqCst {
784+
if atomic == AtomicFenceOrd::SeqCst {
785785
data_race.last_sc_fence.borrow_mut().set_at_index(&clocks.clock, index);
786786
clocks.fence_seqcst.join(&data_race.last_sc_fence.borrow());
787787
clocks.write_seqcst.join(&data_race.last_sc_write.borrow());
788788
}
789789

790790
// Increment timestamp in case of release semantics.
791-
Ok(atomic != AtomicFenceOp::Acquire)
791+
Ok(atomic != AtomicFenceOrd::Acquire)
792792
})
793793
} else {
794794
Ok(())

src/concurrency/weak_memory.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ use rustc_const_eval::interpret::{
8282
};
8383
use rustc_data_structures::fx::FxHashMap;
8484

85-
use crate::{AtomicReadOp, AtomicRwOp, AtomicWriteOp, Tag, VClock, VTimestamp, VectorIdx};
85+
use crate::{AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, Tag, VClock, VTimestamp, VectorIdx};
8686

8787
use super::{
8888
data_race::{GlobalState, ThreadClockSet},
@@ -443,7 +443,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
443443
&mut self,
444444
new_val: ScalarMaybeUninit<Tag>,
445445
place: &MPlaceTy<'tcx, Tag>,
446-
atomic: AtomicRwOp,
446+
atomic: AtomicRwOrd,
447447
init: ScalarMaybeUninit<Tag>,
448448
) -> InterpResult<'tcx> {
449449
let this = self.eval_context_mut();
@@ -453,30 +453,30 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
453453
crate::Evaluator { data_race: Some(global), .. },
454454
) = this.get_alloc_extra_mut(alloc_id)?
455455
{
456-
if atomic == AtomicRwOp::SeqCst {
456+
if atomic == AtomicRwOrd::SeqCst {
457457
global.sc_read();
458458
global.sc_write();
459459
}
460460
let range = alloc_range(base_offset, place.layout.size);
461461
let buffer = alloc_buffers.get_or_create_store_buffer_mut(range, init)?;
462462
buffer.read_from_last_store(global);
463-
buffer.buffered_write(new_val, global, atomic == AtomicRwOp::SeqCst)?;
463+
buffer.buffered_write(new_val, global, atomic == AtomicRwOrd::SeqCst)?;
464464
}
465465
Ok(())
466466
}
467467

468468
fn buffered_atomic_read(
469469
&self,
470470
place: &MPlaceTy<'tcx, Tag>,
471-
atomic: AtomicReadOp,
471+
atomic: AtomicReadOrd,
472472
latest_in_mo: ScalarMaybeUninit<Tag>,
473473
validate: impl FnOnce() -> InterpResult<'tcx>,
474474
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
475475
let this = self.eval_context_ref();
476476
if let Some(global) = &this.machine.data_race {
477477
let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?;
478478
if let Some(alloc_buffers) = this.get_alloc_extra(alloc_id)?.weak_memory.as_ref() {
479-
if atomic == AtomicReadOp::SeqCst {
479+
if atomic == AtomicReadOrd::SeqCst {
480480
global.sc_read();
481481
}
482482
let mut rng = this.machine.rng.borrow_mut();
@@ -486,7 +486,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
486486
)?;
487487
let loaded = buffer.buffered_read(
488488
global,
489-
atomic == AtomicReadOp::SeqCst,
489+
atomic == AtomicReadOrd::SeqCst,
490490
&mut *rng,
491491
validate,
492492
)?;
@@ -504,7 +504,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
504504
&mut self,
505505
val: ScalarMaybeUninit<Tag>,
506506
dest: &MPlaceTy<'tcx, Tag>,
507-
atomic: AtomicWriteOp,
507+
atomic: AtomicWriteOrd,
508508
init: ScalarMaybeUninit<Tag>,
509509
) -> InterpResult<'tcx> {
510510
let this = self.eval_context_mut();
@@ -514,7 +514,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
514514
crate::Evaluator { data_race: Some(global), .. },
515515
) = this.get_alloc_extra_mut(alloc_id)?
516516
{
517-
if atomic == AtomicWriteOp::SeqCst {
517+
if atomic == AtomicWriteOrd::SeqCst {
518518
global.sc_write();
519519
}
520520

@@ -535,7 +535,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
535535
buffer.buffer.pop_front();
536536
}
537537

538-
buffer.buffered_write(val, global, atomic == AtomicWriteOp::SeqCst)?;
538+
buffer.buffered_write(val, global, atomic == AtomicWriteOrd::SeqCst)?;
539539
}
540540

541541
// Caller should've written to dest with the vanilla scalar write, we do nothing here
@@ -548,13 +548,13 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
548548
fn perform_read_on_buffered_latest(
549549
&self,
550550
place: &MPlaceTy<'tcx, Tag>,
551-
atomic: AtomicReadOp,
551+
atomic: AtomicReadOrd,
552552
init: ScalarMaybeUninit<Tag>,
553553
) -> InterpResult<'tcx> {
554554
let this = self.eval_context_ref();
555555

556556
if let Some(global) = &this.machine.data_race {
557-
if atomic == AtomicReadOp::SeqCst {
557+
if atomic == AtomicReadOrd::SeqCst {
558558
global.sc_read();
559559
}
560560
let size = place.layout.size;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub use crate::shims::tls::{EvalContextExt as _, TlsData};
7070
pub use crate::shims::EvalContextExt as _;
7171

7272
pub use crate::concurrency::data_race::{
73-
AtomicFenceOp, AtomicReadOp, AtomicRwOp, AtomicWriteOp,
73+
AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd,
7474
EvalContextExt as DataRaceEvalContextExt,
7575
};
7676
pub use crate::diagnostics::{

0 commit comments

Comments
 (0)