@@ -134,7 +134,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
134
134
// entered for addresses that are not the base address, so even zero-sized
135
135
// allocations will get recognized at their base address -- but all other
136
136
// allocations will *not* be recognized at their "end" address.
137
- let size = this. get_alloc_info ( alloc_id) . 0 ;
137
+ let size = this. get_alloc_info ( alloc_id) . size ;
138
138
if offset < size. bytes ( ) { Some ( alloc_id) } else { None }
139
139
}
140
140
} ?;
@@ -157,25 +157,25 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
157
157
) -> InterpResult < ' tcx , u64 > {
158
158
let this = self . eval_context_ref ( ) ;
159
159
let mut rng = this. machine . rng . borrow_mut ( ) ;
160
- let ( size , align , kind ) = this. get_alloc_info ( alloc_id) ;
160
+ let info = this. get_alloc_info ( alloc_id) ;
161
161
// This is either called immediately after allocation (and then cached), or when
162
162
// adjusting `tcx` pointers (which never get freed). So assert that we are looking
163
163
// at a live allocation. This also ensures that we never re-assign an address to an
164
164
// allocation that previously had an address, but then was freed and the address
165
165
// information was removed.
166
- assert ! ( !matches!( kind, AllocKind :: Dead ) ) ;
166
+ assert ! ( !matches!( info . kind, AllocKind :: Dead ) ) ;
167
167
168
168
// This allocation does not have a base address yet, pick or reuse one.
169
169
if this. machine . native_lib . is_some ( ) {
170
170
// In native lib mode, we use the "real" address of the bytes for this allocation.
171
171
// This ensures the interpreted program and native code have the same view of memory.
172
- let base_ptr = match kind {
172
+ let base_ptr = match info . kind {
173
173
AllocKind :: LiveData => {
174
174
if this. tcx . try_get_global_alloc ( alloc_id) . is_some ( ) {
175
175
// For new global allocations, we always pre-allocate the memory to be able use the machine address directly.
176
- let prepared_bytes = MiriAllocBytes :: zeroed ( size, align)
176
+ let prepared_bytes = MiriAllocBytes :: zeroed ( info . size , info . align )
177
177
. unwrap_or_else ( || {
178
- panic ! ( "Miri ran out of memory: cannot create allocation of {size:?} bytes" )
178
+ panic ! ( "Miri ran out of memory: cannot create allocation of {size:?} bytes" , size = info . size )
179
179
} ) ;
180
180
let ptr = prepared_bytes. as_ptr ( ) ;
181
181
// Store prepared allocation space to be picked up for use later.
@@ -203,9 +203,13 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
203
203
return interp_ok ( base_ptr. expose_provenance ( ) . try_into ( ) . unwrap ( ) ) ;
204
204
}
205
205
// We are not in native lib mode, so we control the addresses ourselves.
206
- if let Some ( ( reuse_addr, clock) ) =
207
- global_state. reuse . take_addr ( & mut * rng, size, align, memory_kind, this. active_thread ( ) )
208
- {
206
+ if let Some ( ( reuse_addr, clock) ) = global_state. reuse . take_addr (
207
+ & mut * rng,
208
+ info. size ,
209
+ info. align ,
210
+ memory_kind,
211
+ this. active_thread ( ) ,
212
+ ) {
209
213
if let Some ( clock) = clock {
210
214
this. acquire_clock ( & clock) ;
211
215
}
@@ -220,14 +224,14 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
220
224
. next_base_addr
221
225
. checked_add ( slack)
222
226
. ok_or_else ( || err_exhaust ! ( AddressSpaceFull ) ) ?;
223
- let base_addr = align_addr ( base_addr, align. bytes ( ) ) ;
227
+ let base_addr = align_addr ( base_addr, info . align . bytes ( ) ) ;
224
228
225
229
// Remember next base address. If this allocation is zero-sized, leave a gap of at
226
230
// least 1 to avoid two allocations having the same base address. (The logic in
227
231
// `alloc_id_from_addr` assumes unique addresses, and different function/vtable pointers
228
232
// need to be distinguishable!)
229
233
global_state. next_base_addr = base_addr
230
- . checked_add ( max ( size. bytes ( ) , 1 ) )
234
+ . checked_add ( max ( info . size . bytes ( ) , 1 ) )
231
235
. ok_or_else ( || err_exhaust ! ( AddressSpaceFull ) ) ?;
232
236
// Even if `Size` didn't overflow, we might still have filled up the address space.
233
237
if global_state. next_base_addr > this. target_usize_max ( ) {
0 commit comments