@@ -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 = ecx. get_alloc_info ( alloc_id) . 0 ;
137
+ let size = ecx. 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 ecx = self . eval_context_ref ( ) ;
159
159
let mut rng = ecx. machine . rng . borrow_mut ( ) ;
160
- let ( size , align , kind ) = ecx. get_alloc_info ( alloc_id) ;
160
+ let info = ecx. 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 ecx. 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 ecx. 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.
@@ -204,7 +204,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
204
204
}
205
205
// We are not in native lib mode, so we control the addresses ourselves.
206
206
if let Some ( ( reuse_addr, clock) ) =
207
- global_state. reuse . take_addr ( & mut * rng, size, align, memory_kind, ecx. active_thread ( ) )
207
+ global_state. reuse . take_addr ( & mut * rng, info . size , info . align , memory_kind, ecx. active_thread ( ) )
208
208
{
209
209
if let Some ( clock) = clock {
210
210
ecx. acquire_clock ( & clock) ;
@@ -220,14 +220,14 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
220
220
. next_base_addr
221
221
. checked_add ( slack)
222
222
. ok_or_else ( || err_exhaust ! ( AddressSpaceFull ) ) ?;
223
- let base_addr = align_addr ( base_addr, align. bytes ( ) ) ;
223
+ let base_addr = align_addr ( base_addr, info . align . bytes ( ) ) ;
224
224
225
225
// Remember next base address. If this allocation is zero-sized, leave a gap of at
226
226
// least 1 to avoid two allocations having the same base address. (The logic in
227
227
// `alloc_id_from_addr` assumes unique addresses, and different function/vtable pointers
228
228
// need to be distinguishable!)
229
229
global_state. next_base_addr = base_addr
230
- . checked_add ( max ( size. bytes ( ) , 1 ) )
230
+ . checked_add ( max ( info . size . bytes ( ) , 1 ) )
231
231
. ok_or_else ( || err_exhaust ! ( AddressSpaceFull ) ) ?;
232
232
// Even if `Size` didn't overflow, we might still have filled up the address space.
233
233
if global_state. next_base_addr > ecx. target_usize_max ( ) {
0 commit comments