Skip to content

Commit c171242

Browse files
committed
Address merging MemoryExtra into machine
1 parent da6de5f commit c171242

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/data_race.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
482482
// Only metadata on the location itself is used.
483483
let scalar = this.allow_data_races_ref(move |this| this.read_scalar(&place.into()))?;
484484

485-
if let Some(global) = &this.memory.extra.data_race {
486-
let (alloc_id, base_offset, ..) = this.memory.ptr_get_alloc(place.ptr)?;
487-
if let Some(alloc_buffers) = this.memory.get_alloc_extra(alloc_id)?.weak_memory.as_ref()
485+
if let Some(global) = &this.machine.data_race {
486+
let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?;
487+
if let Some(alloc_buffers) = this.get_alloc_extra(alloc_id)?.weak_memory.as_ref()
488488
{
489489
if atomic == AtomicReadOp::SeqCst {
490490
global.sc_read();
491491
}
492-
let mut rng = this.memory.extra.rng.borrow_mut();
492+
let mut rng = this.machine.rng.borrow_mut();
493493
let loaded = alloc_buffers.buffered_read(
494494
alloc_range(base_offset, place.layout.size),
495495
global,
@@ -517,11 +517,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
517517
this.allow_data_races_mut(move |this| this.write_scalar(val, &(*dest).into()))?;
518518

519519
this.validate_atomic_store(dest, atomic)?;
520-
let (alloc_id, base_offset, ..) = this.memory.ptr_get_alloc(dest.ptr)?;
520+
let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(dest.ptr)?;
521521
if let (
522522
crate::AllocExtra { weak_memory: Some(alloc_buffers), .. },
523-
crate::MemoryExtra { data_race: Some(global), .. },
524-
) = this.memory.get_alloc_extra_mut(alloc_id)?
523+
crate::Evaluator { data_race: Some(global), .. },
524+
) = this.get_alloc_extra_mut(alloc_id)?
525525
{
526526
if atomic == AtomicWriteOp::SeqCst {
527527
global.sc_write();
@@ -659,14 +659,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
659659
// in the modification order.
660660
// Since `old` is only a value and not the store element, we need to separately
661661
// find it in our store buffer and perform load_impl on it.
662-
if let Some(global) = &this.memory.extra.data_race {
662+
if let Some(global) = &this.machine.data_race {
663663
if fail == AtomicReadOp::SeqCst {
664664
global.sc_read();
665665
}
666666
let size = place.layout.size;
667-
let (alloc_id, base_offset, ..) = this.memory.ptr_get_alloc(place.ptr)?;
667+
let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?;
668668
if let Some(alloc_buffers) =
669-
this.memory.get_alloc_extra(alloc_id)?.weak_memory.as_ref()
669+
this.get_alloc_extra(alloc_id)?.weak_memory.as_ref()
670670
{
671671
if global.multi_threaded.get() {
672672
alloc_buffers.read_from_last_store(alloc_range(base_offset, size), global);
@@ -686,11 +686,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
686686
atomic: AtomicRwOp,
687687
) -> InterpResult<'tcx> {
688688
let this = self.eval_context_mut();
689-
let (alloc_id, base_offset, ..) = this.memory.ptr_get_alloc(place.ptr)?;
689+
let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?;
690690
if let (
691691
crate::AllocExtra { weak_memory: Some(alloc_buffers), .. },
692-
crate::MemoryExtra { data_race: Some(global), .. },
693-
) = this.memory.get_alloc_extra_mut(alloc_id)?
692+
crate::Evaluator { data_race: Some(global), .. },
693+
) = this.get_alloc_extra_mut(alloc_id)?
694694
{
695695
if atomic == AtomicRwOp::SeqCst {
696696
global.sc_read();
@@ -777,7 +777,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
777777
fn validate_atomic_fence(&mut self, atomic: AtomicFenceOp) -> InterpResult<'tcx> {
778778
let this = self.eval_context_mut();
779779
if let Some(data_race) = &mut this.machine.data_race {
780-
data_race.maybe_perform_sync_operation(move |index, mut clocks| {
780+
data_race.maybe_perform_sync_operation(|index, mut clocks| {
781781
log::trace!("Atomic fence on {:?} with ordering {:?}", index, atomic);
782782

783783
// Apply data-race detection for the current fences

src/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
571571
} else {
572572
None
573573
};
574-
let buffer_alloc = if mem.extra.weak_memory {
574+
let buffer_alloc = if ecx.machine.weak_memory {
575575
// FIXME: if this is an atomic obejct, we want to supply its initial value
576576
// while allocating the store buffer here.
577577
Some(weak_memory::AllocExtra::new_allocation(alloc.size()))

0 commit comments

Comments
 (0)