1
+ //! This module is responsible for managing the absolute addresses that allocations are located at,
2
+ //! and for casting between pointers and integers based on those addresses.
3
+
1
4
use std:: cell:: RefCell ;
2
5
use std:: cmp:: max;
3
6
use std:: collections:: hash_map:: Entry ;
@@ -96,7 +99,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
96
99
// or `None` if the addr is out of bounds
97
100
fn alloc_id_from_addr ( & self , addr : u64 ) -> Option < AllocId > {
98
101
let ecx = self . eval_context_ref ( ) ;
99
- let global_state = ecx. machine . intptrcast . borrow ( ) ;
102
+ let global_state = ecx. machine . alloc_addresses . borrow ( ) ;
100
103
assert ! ( global_state. provenance_mode != ProvenanceMode :: Strict ) ;
101
104
102
105
let pos = global_state. int_to_ptr_map . binary_search_by_key ( & addr, |( addr, _) | * addr) ;
@@ -133,7 +136,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
133
136
134
137
fn addr_from_alloc_id ( & self , alloc_id : AllocId ) -> InterpResult < ' tcx , u64 > {
135
138
let ecx = self . eval_context_ref ( ) ;
136
- let mut global_state = ecx. machine . intptrcast . borrow_mut ( ) ;
139
+ let mut global_state = ecx. machine . alloc_addresses . borrow_mut ( ) ;
137
140
let global_state = & mut * global_state;
138
141
139
142
Ok ( match global_state. base_addr . entry ( alloc_id) {
@@ -196,7 +199,7 @@ impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir,
196
199
pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriInterpCxExt < ' mir , ' tcx > {
197
200
fn expose_ptr ( & mut self , alloc_id : AllocId , tag : BorTag ) -> InterpResult < ' tcx > {
198
201
let ecx = self . eval_context_mut ( ) ;
199
- let global_state = ecx. machine . intptrcast . get_mut ( ) ;
202
+ let global_state = ecx. machine . alloc_addresses . get_mut ( ) ;
200
203
// In strict mode, we don't need this, so we can save some cycles by not tracking it.
201
204
if global_state. provenance_mode == ProvenanceMode :: Strict {
202
205
return Ok ( ( ) ) ;
@@ -207,7 +210,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
207
210
return Ok ( ( ) ) ;
208
211
}
209
212
trace ! ( "Exposing allocation id {alloc_id:?}" ) ;
210
- let global_state = ecx. machine . intptrcast . get_mut ( ) ;
213
+ let global_state = ecx. machine . alloc_addresses . get_mut ( ) ;
211
214
global_state. exposed . insert ( alloc_id) ;
212
215
if ecx. machine . borrow_tracker . is_some ( ) {
213
216
ecx. expose_tag ( alloc_id, tag) ?;
@@ -219,7 +222,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
219
222
trace ! ( "Casting {:#x} to a pointer" , addr) ;
220
223
221
224
let ecx = self . eval_context_ref ( ) ;
222
- let global_state = ecx. machine . intptrcast . borrow ( ) ;
225
+ let global_state = ecx. machine . alloc_addresses . borrow ( ) ;
223
226
224
227
// Potentially emit a warning.
225
228
match global_state. provenance_mode {
0 commit comments