Skip to content

Commit ea86335

Browse files
committed
Auto merge of #1716 - tmiasko:rustup, r=RalfJung
rustup to e7c23ab933ebc1f205c3b59f4ebc85d40f67d404
2 parents 277b59c + 0eb3414 commit ea86335

29 files changed

+505
-502
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d1462d8558cf4551608457f63d9b999185ebf3bf
1+
e7c23ab933ebc1f205c3b59f4ebc85d40f67d404

src/data_race.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
446446
/// Atomic variant of read_scalar_at_offset.
447447
fn read_scalar_at_offset_atomic(
448448
&self,
449-
op: OpTy<'tcx, Tag>,
449+
op: &OpTy<'tcx, Tag>,
450450
offset: u64,
451451
layout: TyAndLayout<'tcx>,
452452
atomic: AtomicReadOp,
@@ -458,13 +458,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
458458
// Ensure that the following read at an offset is within bounds.
459459
assert!(op_place.layout.size >= offset + layout.size);
460460
let value_place = op_place.offset(offset, MemPlaceMeta::None, layout, this)?;
461-
this.read_scalar_atomic(value_place, atomic)
461+
this.read_scalar_atomic(&value_place, atomic)
462462
}
463463

464464
/// Atomic variant of write_scalar_at_offset.
465465
fn write_scalar_at_offset_atomic(
466466
&mut self,
467-
op: OpTy<'tcx, Tag>,
467+
op: &OpTy<'tcx, Tag>,
468468
offset: u64,
469469
value: impl Into<ScalarMaybeUninit<Tag>>,
470470
layout: TyAndLayout<'tcx>,
@@ -477,17 +477,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
477477
// Ensure that the following read at an offset is within bounds.
478478
assert!(op_place.layout.size >= offset + layout.size);
479479
let value_place = op_place.offset(offset, MemPlaceMeta::None, layout, this)?;
480-
this.write_scalar_atomic(value.into(), value_place, atomic)
480+
this.write_scalar_atomic(value.into(), &value_place, atomic)
481481
}
482482

483483
/// Perform an atomic read operation at the memory location.
484484
fn read_scalar_atomic(
485485
&self,
486-
place: MPlaceTy<'tcx, Tag>,
486+
place: &MPlaceTy<'tcx, Tag>,
487487
atomic: AtomicReadOp,
488488
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
489489
let this = self.eval_context_ref();
490-
let scalar = this.allow_data_races_ref(move |this| this.read_scalar(place.into()))?;
490+
let scalar = this.allow_data_races_ref(move |this| this.read_scalar(&place.into()))?;
491491
self.validate_atomic_load(place, atomic)?;
492492
Ok(scalar)
493493
}
@@ -496,31 +496,31 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
496496
fn write_scalar_atomic(
497497
&mut self,
498498
val: ScalarMaybeUninit<Tag>,
499-
dest: MPlaceTy<'tcx, Tag>,
499+
dest: &MPlaceTy<'tcx, Tag>,
500500
atomic: AtomicWriteOp,
501501
) -> InterpResult<'tcx> {
502502
let this = self.eval_context_mut();
503-
this.allow_data_races_mut(move |this| this.write_scalar(val, dest.into()))?;
503+
this.allow_data_races_mut(move |this| this.write_scalar(val, &(*dest).into()))?;
504504
self.validate_atomic_store(dest, atomic)
505505
}
506506

507507
/// Perform a atomic operation on a memory location.
508508
fn atomic_op_immediate(
509509
&mut self,
510-
place: MPlaceTy<'tcx, Tag>,
511-
rhs: ImmTy<'tcx, Tag>,
510+
place: &MPlaceTy<'tcx, Tag>,
511+
rhs: &ImmTy<'tcx, Tag>,
512512
op: mir::BinOp,
513513
neg: bool,
514514
atomic: AtomicRwOp,
515515
) -> InterpResult<'tcx, ImmTy<'tcx, Tag>> {
516516
let this = self.eval_context_mut();
517517

518-
let old = this.allow_data_races_mut(|this| this.read_immediate(place.into()))?;
518+
let old = this.allow_data_races_mut(|this| this.read_immediate(&place.into()))?;
519519

520520
// Atomics wrap around on overflow.
521-
let val = this.binary_op(op, old, rhs)?;
522-
let val = if neg { this.unary_op(mir::UnOp::Not, val)? } else { val };
523-
this.allow_data_races_mut(|this| this.write_immediate(*val, place.into()))?;
521+
let val = this.binary_op(op, &old, rhs)?;
522+
let val = if neg { this.unary_op(mir::UnOp::Not, &val)? } else { val };
523+
this.allow_data_races_mut(|this| this.write_immediate(*val, &(*place).into()))?;
524524

525525
this.validate_atomic_rmw(place, atomic)?;
526526
Ok(old)
@@ -530,14 +530,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
530530
/// scalar value, the old value is returned.
531531
fn atomic_exchange_scalar(
532532
&mut self,
533-
place: MPlaceTy<'tcx, Tag>,
533+
place: &MPlaceTy<'tcx, Tag>,
534534
new: ScalarMaybeUninit<Tag>,
535535
atomic: AtomicRwOp,
536536
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
537537
let this = self.eval_context_mut();
538538

539-
let old = this.allow_data_races_mut(|this| this.read_scalar(place.into()))?;
540-
this.allow_data_races_mut(|this| this.write_scalar(new, place.into()))?;
539+
let old = this.allow_data_races_mut(|this| this.read_scalar(&place.into()))?;
540+
this.allow_data_races_mut(|this| this.write_scalar(new, &(*place).into()))?;
541541
this.validate_atomic_rmw(place, atomic)?;
542542
Ok(old)
543543
}
@@ -550,8 +550,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
550550
/// identical.
551551
fn atomic_compare_exchange_scalar(
552552
&mut self,
553-
place: MPlaceTy<'tcx, Tag>,
554-
expect_old: ImmTy<'tcx, Tag>,
553+
place: &MPlaceTy<'tcx, Tag>,
554+
expect_old: &ImmTy<'tcx, Tag>,
555555
new: ScalarMaybeUninit<Tag>,
556556
success: AtomicRwOp,
557557
fail: AtomicReadOp,
@@ -564,9 +564,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
564564
// to read with the failure ordering and if successful then try again with the success
565565
// read ordering and write in the success case.
566566
// Read as immediate for the sake of `binary_op()`
567-
let old = this.allow_data_races_mut(|this| this.read_immediate(place.into()))?;
567+
let old = this.allow_data_races_mut(|this| this.read_immediate(&(place.into())))?;
568568
// `binary_op` will bail if either of them is not a scalar.
569-
let eq = this.overflowing_binary_op(mir::BinOp::Eq, old, expect_old)?.0;
569+
let eq = this.overflowing_binary_op(mir::BinOp::Eq, &old, expect_old)?.0;
570570
// If the operation would succeed, but is "weak", fail some portion
571571
// of the time, based on `rate`.
572572
let rate = this.memory.extra.cmpxchg_weak_failure_rate;
@@ -581,7 +581,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
581581
// if successful, perform a full rw-atomic validation
582582
// otherwise treat this as an atomic load with the fail ordering.
583583
if cmpxchg_success {
584-
this.allow_data_races_mut(|this| this.write_scalar(new, place.into()))?;
584+
this.allow_data_races_mut(|this| this.write_scalar(new, &(*place).into()))?;
585585
this.validate_atomic_rmw(place, success)?;
586586
} else {
587587
this.validate_atomic_load(place, fail)?;
@@ -595,7 +595,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
595595
/// associated memory-place and on the current thread.
596596
fn validate_atomic_load(
597597
&self,
598-
place: MPlaceTy<'tcx, Tag>,
598+
place: &MPlaceTy<'tcx, Tag>,
599599
atomic: AtomicReadOp,
600600
) -> InterpResult<'tcx> {
601601
let this = self.eval_context_ref();
@@ -617,7 +617,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
617617
/// associated memory-place and on the current thread.
618618
fn validate_atomic_store(
619619
&mut self,
620-
place: MPlaceTy<'tcx, Tag>,
620+
place: &MPlaceTy<'tcx, Tag>,
621621
atomic: AtomicWriteOp,
622622
) -> InterpResult<'tcx> {
623623
let this = self.eval_context_ref();
@@ -639,7 +639,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
639639
/// at the associated memory place and on the current thread.
640640
fn validate_atomic_rmw(
641641
&mut self,
642-
place: MPlaceTy<'tcx, Tag>,
642+
place: &MPlaceTy<'tcx, Tag>,
643643
atomic: AtomicRwOp,
644644
) -> InterpResult<'tcx> {
645645
use AtomicRwOp::*;
@@ -973,7 +973,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
973973
/// atomic-stores/atomic-rmw?
974974
fn validate_atomic_op<A: Debug + Copy>(
975975
&self,
976-
place: MPlaceTy<'tcx, Tag>,
976+
place: &MPlaceTy<'tcx, Tag>,
977977
atomic: A,
978978
description: &str,
979979
mut op: impl FnMut(

src/eval.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
138138
ecx.layout_of(tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), u64::try_from(argvs.len()).unwrap()))?;
139139
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into());
140140
for (idx, arg) in argvs.into_iter().enumerate() {
141-
let place = ecx.mplace_field(argvs_place, idx)?;
142-
ecx.write_scalar(arg, place.into())?;
141+
let place = ecx.mplace_field(&argvs_place, idx)?;
142+
ecx.write_scalar(arg, &place.into())?;
143143
}
144144
ecx.memory.mark_immutable(argvs_place.ptr.assert_ptr().alloc_id)?;
145145
// A pointer to that place is the 3rd argument for main.
@@ -148,14 +148,14 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
148148
{
149149
let argc_place =
150150
ecx.allocate(ecx.machine.layouts.isize, MiriMemoryKind::Machine.into());
151-
ecx.write_scalar(argc, argc_place.into())?;
151+
ecx.write_scalar(argc, &argc_place.into())?;
152152
ecx.machine.argc = Some(argc_place.ptr);
153153

154154
let argv_place = ecx.allocate(
155155
ecx.layout_of(tcx.mk_imm_ptr(tcx.types.unit))?,
156156
MiriMemoryKind::Machine.into(),
157157
);
158-
ecx.write_scalar(argv, argv_place.into())?;
158+
ecx.write_scalar(argv, &argv_place.into())?;
159159
ecx.machine.argv = Some(argv_place.ptr);
160160
}
161161
// Store command line as UTF-16 for Windows `GetCommandLineW`.
@@ -177,8 +177,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
177177
ecx.machine.cmd_line = Some(cmd_place.ptr);
178178
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
179179
for (idx, &c) in cmd_utf16.iter().enumerate() {
180-
let place = ecx.mplace_field(cmd_place, idx)?;
181-
ecx.write_scalar(Scalar::from_u16(c), place.into())?;
180+
let place = ecx.mplace_field(&cmd_place, idx)?;
181+
ecx.write_scalar(Scalar::from_u16(c), &place.into())?;
182182
}
183183
}
184184
argv
@@ -190,7 +190,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
190190
ecx.call_function(
191191
start_instance,
192192
&[main_ptr.into(), argc.into(), argv.into()],
193-
Some(ret_place.into()),
193+
Some(&ret_place.into()),
194194
StackPopCleanup::None { cleanup: true },
195195
)?;
196196

@@ -239,7 +239,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
239239
}
240240
ecx.process_diagnostics(info);
241241
}
242-
let return_code = ecx.read_scalar(ret_place.into())?.check_init()?.to_machine_isize(&ecx)?;
242+
let return_code = ecx.read_scalar(&ret_place.into())?.check_init()?.to_machine_isize(&ecx)?;
243243
Ok(return_code)
244244
})();
245245

0 commit comments

Comments
 (0)