Skip to content

Commit 19add0b

Browse files
committed
places and pointers are not the same thing; this is a place
1 parent f47e589 commit 19add0b

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/shims/intrinsics.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -49,83 +49,83 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
4949
}
5050

5151
"volatile_load" => {
52-
let ptr = this.deref_operand(args[0])?;
53-
this.copy_op(ptr.into(), dest)?;
52+
let place = this.deref_operand(args[0])?;
53+
this.copy_op(place.into(), dest)?;
5454
}
5555

5656
"volatile_store" => {
57-
let ptr = this.deref_operand(args[0])?;
58-
this.copy_op(args[1], ptr.into())?;
57+
let place = this.deref_operand(args[0])?;
58+
this.copy_op(args[1], place.into())?;
5959
}
6060

6161
"atomic_load" |
6262
"atomic_load_relaxed" |
6363
"atomic_load_acq" => {
64-
let ptr = this.deref_operand(args[0])?;
65-
let val = this.read_scalar(ptr.into())?; // make sure it fits into a scalar; otherwise it cannot be atomic
64+
let place = this.deref_operand(args[0])?;
65+
let val = this.read_scalar(place.into())?; // make sure it fits into a scalar; otherwise it cannot be atomic
6666

6767
// Check alignment requirements. Atomics must always be aligned to their size,
6868
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
6969
// be 8-aligned).
70-
let align = Align::from_bytes(ptr.layout.size.bytes()).unwrap();
71-
this.memory().check_ptr_access(ptr.ptr, ptr.layout.size, align)?;
70+
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
71+
this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
7272

7373
this.write_scalar(val, dest)?;
7474
}
7575

7676
"atomic_store" |
7777
"atomic_store_relaxed" |
7878
"atomic_store_rel" => {
79-
let ptr = this.deref_operand(args[0])?;
79+
let place = this.deref_operand(args[0])?;
8080
let val = this.read_scalar(args[1])?; // make sure it fits into a scalar; otherwise it cannot be atomic
8181

8282
// Check alignment requirements. Atomics must always be aligned to their size,
8383
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
8484
// be 8-aligned).
85-
let align = Align::from_bytes(ptr.layout.size.bytes()).unwrap();
86-
this.memory().check_ptr_access(ptr.ptr, ptr.layout.size, align)?;
85+
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
86+
this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
8787

88-
this.write_scalar(val, ptr.into())?;
88+
this.write_scalar(val, place.into())?;
8989
}
9090

9191
"atomic_fence_acq" => {
9292
// we are inherently singlethreaded and singlecored, this is a nop
9393
}
9494

9595
_ if intrinsic_name.starts_with("atomic_xchg") => {
96-
let ptr = this.deref_operand(args[0])?;
96+
let place = this.deref_operand(args[0])?;
9797
let new = this.read_scalar(args[1])?;
98-
let old = this.read_scalar(ptr.into())?;
98+
let old = this.read_scalar(place.into())?;
9999

100100
// Check alignment requirements. Atomics must always be aligned to their size,
101101
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
102102
// be 8-aligned).
103-
let align = Align::from_bytes(ptr.layout.size.bytes()).unwrap();
104-
this.memory().check_ptr_access(ptr.ptr, ptr.layout.size, align)?;
103+
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
104+
this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
105105

106106
this.write_scalar(old, dest)?; // old value is returned
107-
this.write_scalar(new, ptr.into())?;
107+
this.write_scalar(new, place.into())?;
108108
}
109109

110110
_ if intrinsic_name.starts_with("atomic_cxchg") => {
111-
let ptr = this.deref_operand(args[0])?;
111+
let place = this.deref_operand(args[0])?;
112112
let expect_old = this.read_immediate(args[1])?; // read as immediate for the sake of `binary_op()`
113113
let new = this.read_scalar(args[2])?;
114-
let old = this.read_immediate(ptr.into())?; // read as immediate for the sake of `binary_op()`
114+
let old = this.read_immediate(place.into())?; // read as immediate for the sake of `binary_op()`
115115

116116
// Check alignment requirements. Atomics must always be aligned to their size,
117117
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
118118
// be 8-aligned).
119-
let align = Align::from_bytes(ptr.layout.size.bytes()).unwrap();
120-
this.memory().check_ptr_access(ptr.ptr, ptr.layout.size, align)?;
119+
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
120+
this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
121121

122122
// binary_op will bail if either of them is not a scalar
123123
let (eq, _) = this.binary_op(mir::BinOp::Eq, old, expect_old)?;
124124
let res = Immediate::ScalarPair(old.to_scalar_or_undef(), eq.into());
125125
this.write_immediate(res, dest)?; // old value is returned
126126
// update ptr depending on comparison
127127
if eq.to_bool()? {
128-
this.write_scalar(new, ptr.into())?;
128+
this.write_scalar(new, place.into())?;
129129
}
130130
}
131131

@@ -159,18 +159,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
159159
"atomic_xsub_rel" |
160160
"atomic_xsub_acqrel" |
161161
"atomic_xsub_relaxed" => {
162-
let ptr = this.deref_operand(args[0])?;
163-
if !ptr.layout.ty.is_integral() {
162+
let place = this.deref_operand(args[0])?;
163+
if !place.layout.ty.is_integral() {
164164
bug!("Atomic arithmetic operations only work on integer types");
165165
}
166166
let rhs = this.read_immediate(args[1])?;
167-
let old = this.read_immediate(ptr.into())?;
167+
let old = this.read_immediate(place.into())?;
168168

169169
// Check alignment requirements. Atomics must always be aligned to their size,
170170
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
171171
// be 8-aligned).
172-
let align = Align::from_bytes(ptr.layout.size.bytes()).unwrap();
173-
this.memory().check_ptr_access(ptr.ptr, ptr.layout.size, align)?;
172+
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
173+
this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
174174

175175
this.write_immediate(*old, dest)?; // old value is returned
176176
let (op, neg) = match intrinsic_name.split('_').nth(1).unwrap() {
@@ -189,7 +189,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
189189
} else {
190190
val
191191
};
192-
this.write_scalar(val, ptr.into())?;
192+
this.write_scalar(val, place.into())?;
193193
}
194194

195195
"breakpoint" => unimplemented!(), // halt miri

0 commit comments

Comments
 (0)