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+
14use std:: cell:: RefCell ;
25use std:: cmp:: max;
36use std:: collections:: hash_map:: Entry ;
@@ -96,7 +99,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
9699 // or `None` if the addr is out of bounds
97100 fn alloc_id_from_addr ( & self , addr : u64 ) -> Option < AllocId > {
98101 let ecx = self . eval_context_ref ( ) ;
99- let global_state = ecx. machine . intptrcast . borrow ( ) ;
102+ let global_state = ecx. machine . alloc_addresses . borrow ( ) ;
100103 assert ! ( global_state. provenance_mode != ProvenanceMode :: Strict ) ;
101104
102105 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> {
133136
134137 fn addr_from_alloc_id ( & self , alloc_id : AllocId ) -> InterpResult < ' tcx , u64 > {
135138 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 ( ) ;
137140 let global_state = & mut * global_state;
138141
139142 Ok ( match global_state. base_addr . entry ( alloc_id) {
@@ -196,7 +199,7 @@ impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir,
196199pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriInterpCxExt < ' mir , ' tcx > {
197200 fn expose_ptr ( & mut self , alloc_id : AllocId , tag : BorTag ) -> InterpResult < ' tcx > {
198201 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 ( ) ;
200203 // In strict mode, we don't need this, so we can save some cycles by not tracking it.
201204 if global_state. provenance_mode == ProvenanceMode :: Strict {
202205 return Ok ( ( ) ) ;
@@ -207,7 +210,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
207210 return Ok ( ( ) ) ;
208211 }
209212 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 ( ) ;
211214 global_state. exposed . insert ( alloc_id) ;
212215 if ecx. machine . borrow_tracker . is_some ( ) {
213216 ecx. expose_tag ( alloc_id, tag) ?;
@@ -219,7 +222,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
219222 trace ! ( "Casting {:#x} to a pointer" , addr) ;
220223
221224 let ecx = self . eval_context_ref ( ) ;
222- let global_state = ecx. machine . intptrcast . borrow ( ) ;
225+ let global_state = ecx. machine . alloc_addresses . borrow ( ) ;
223226
224227 // Potentially emit a warning.
225228 match global_state. provenance_mode {
0 commit comments