@@ -49,83 +49,83 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
49
49
}
50
50
51
51
"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) ?;
54
54
}
55
55
56
56
"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 ( ) ) ?;
59
59
}
60
60
61
61
"atomic_load" |
62
62
"atomic_load_relaxed" |
63
63
"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
66
66
67
67
// Check alignment requirements. Atomics must always be aligned to their size,
68
68
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
69
69
// 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) ?;
72
72
73
73
this. write_scalar ( val, dest) ?;
74
74
}
75
75
76
76
"atomic_store" |
77
77
"atomic_store_relaxed" |
78
78
"atomic_store_rel" => {
79
- let ptr = this. deref_operand ( args[ 0 ] ) ?;
79
+ let place = this. deref_operand ( args[ 0 ] ) ?;
80
80
let val = this. read_scalar ( args[ 1 ] ) ?; // make sure it fits into a scalar; otherwise it cannot be atomic
81
81
82
82
// Check alignment requirements. Atomics must always be aligned to their size,
83
83
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
84
84
// 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) ?;
87
87
88
- this. write_scalar ( val, ptr . into ( ) ) ?;
88
+ this. write_scalar ( val, place . into ( ) ) ?;
89
89
}
90
90
91
91
"atomic_fence_acq" => {
92
92
// we are inherently singlethreaded and singlecored, this is a nop
93
93
}
94
94
95
95
_ if intrinsic_name. starts_with ( "atomic_xchg" ) => {
96
- let ptr = this. deref_operand ( args[ 0 ] ) ?;
96
+ let place = this. deref_operand ( args[ 0 ] ) ?;
97
97
let new = this. read_scalar ( args[ 1 ] ) ?;
98
- let old = this. read_scalar ( ptr . into ( ) ) ?;
98
+ let old = this. read_scalar ( place . into ( ) ) ?;
99
99
100
100
// Check alignment requirements. Atomics must always be aligned to their size,
101
101
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
102
102
// 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) ?;
105
105
106
106
this. write_scalar ( old, dest) ?; // old value is returned
107
- this. write_scalar ( new, ptr . into ( ) ) ?;
107
+ this. write_scalar ( new, place . into ( ) ) ?;
108
108
}
109
109
110
110
_ if intrinsic_name. starts_with ( "atomic_cxchg" ) => {
111
- let ptr = this. deref_operand ( args[ 0 ] ) ?;
111
+ let place = this. deref_operand ( args[ 0 ] ) ?;
112
112
let expect_old = this. read_immediate ( args[ 1 ] ) ?; // read as immediate for the sake of `binary_op()`
113
113
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()`
115
115
116
116
// Check alignment requirements. Atomics must always be aligned to their size,
117
117
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
118
118
// 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) ?;
121
121
122
122
// binary_op will bail if either of them is not a scalar
123
123
let ( eq, _) = this. binary_op ( mir:: BinOp :: Eq , old, expect_old) ?;
124
124
let res = Immediate :: ScalarPair ( old. to_scalar_or_undef ( ) , eq. into ( ) ) ;
125
125
this. write_immediate ( res, dest) ?; // old value is returned
126
126
// update ptr depending on comparison
127
127
if eq. to_bool ( ) ? {
128
- this. write_scalar ( new, ptr . into ( ) ) ?;
128
+ this. write_scalar ( new, place . into ( ) ) ?;
129
129
}
130
130
}
131
131
@@ -159,18 +159,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
159
159
"atomic_xsub_rel" |
160
160
"atomic_xsub_acqrel" |
161
161
"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 ( ) {
164
164
bug ! ( "Atomic arithmetic operations only work on integer types" ) ;
165
165
}
166
166
let rhs = this. read_immediate ( args[ 1 ] ) ?;
167
- let old = this. read_immediate ( ptr . into ( ) ) ?;
167
+ let old = this. read_immediate ( place . into ( ) ) ?;
168
168
169
169
// Check alignment requirements. Atomics must always be aligned to their size,
170
170
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
171
171
// 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) ?;
174
174
175
175
this. write_immediate ( * old, dest) ?; // old value is returned
176
176
let ( op, neg) = match intrinsic_name. split ( '_' ) . nth ( 1 ) . unwrap ( ) {
@@ -189,7 +189,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
189
189
} else {
190
190
val
191
191
} ;
192
- this. write_scalar ( val, ptr . into ( ) ) ?;
192
+ this. write_scalar ( val, place . into ( ) ) ?;
193
193
}
194
194
195
195
"breakpoint" => unimplemented ! ( ) , // halt miri
0 commit comments