1
- use std:: cmp:: max;
2
1
use std:: collections:: hash_map:: Entry ;
3
2
use std:: sync:: RwLock ;
4
3
@@ -22,11 +21,12 @@ pub struct GlobalAllocationHandler {
22
21
/// This contains more or less a subset of the functionality of `struct GlobalStateInner` in `alloc_addresses`.
23
22
#[ derive( Clone , Debug ) ]
24
23
struct GlobalStateInner {
24
+ // FIXME(genmc): Decide on an API for GenMC to access this (to check if access to global memory is valid), or decide we don't need that.
25
+ #[ allow( unused) ]
25
26
/// This is used as a map between the address of each allocation and its `AllocId`. It is always
26
27
/// sorted by address. We cannot use a `HashMap` since we can be given an address that is offset
27
28
/// from the base address, and we need to find the `AllocId` it belongs to. This is not the
28
29
/// *full* inverse of `base_addr`; dead allocations have been removed.
29
- #[ allow( unused) ] // FIXME(GenMC): do we need this?
30
30
int_to_ptr_map : Vec < ( u64 , AllocId ) > ,
31
31
/// The base address for each allocation.
32
32
/// This is the inverse of `int_to_ptr_map`.
@@ -35,7 +35,7 @@ struct GlobalStateInner {
35
35
/// is always larger than any address that was previously made part of a block.
36
36
next_base_addr : u64 ,
37
37
/// To add some randomness to the allocations
38
- /// FIXME(GenMC ): maybe seed this from the rng in MiriMachine?
38
+ /// FIXME(genmc ): maybe seed this from the rng in MiriMachine?
39
39
rng : StdRng ,
40
40
}
41
41
@@ -97,19 +97,19 @@ impl GlobalStateInner {
97
97
// `alloc_id_from_addr` assumes unique addresses, and different function/vtable pointers
98
98
// need to be distinguishable!)
99
99
self . next_base_addr = base_addr
100
- . checked_add ( max ( info. size . bytes ( ) , 1 ) )
100
+ . checked_add ( info. size . bytes ( ) . max ( 1 ) )
101
101
. ok_or_else ( || err_exhaust ! ( AddressSpaceFull ) ) ?;
102
102
103
103
assert_ne ! ( 0 , base_addr & GENMC_GLOBAL_ADDRESSES_MASK ) ;
104
104
assert_ne ! ( 0 , self . next_base_addr & GENMC_GLOBAL_ADDRESSES_MASK ) ;
105
+
105
106
// Cache the address for future use.
106
107
entry. insert ( base_addr) ;
107
108
108
109
interp_ok ( base_addr)
109
110
}
110
111
}
111
112
112
- // FIXME(GenMC): "ExtPriv" or "PrivExt"?
113
113
impl < ' tcx > EvalContextExtPriv < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
114
114
pub ( super ) trait EvalContextExtPriv < ' tcx > : crate :: MiriInterpCxExt < ' tcx > {
115
115
fn get_global_allocation_address (
0 commit comments