@@ -70,7 +70,7 @@ pub struct AllocExtra {
70
70
71
71
/// Extra global memory data
72
72
#[ derive( Clone , Debug ) ]
73
- pub struct MemoryExtra {
73
+ pub struct MemoryExtra < ' tcx > {
74
74
pub stacked_borrows : Option < stacked_borrows:: MemoryExtra > ,
75
75
pub intptrcast : intptrcast:: MemoryExtra ,
76
76
@@ -80,11 +80,11 @@ pub struct MemoryExtra {
80
80
/// The random number generator used for resolving non-determinism.
81
81
/// Needs to be queried by ptr_to_int, hence needs interior mutability.
82
82
pub ( crate ) rng : RefCell < StdRng > ,
83
- /// The `AllocId` for the `environ` static.
84
- pub ( crate ) environ : Option < Scalar < Tag > > ,
83
+ /// Place where the `environ` static is stored .
84
+ pub ( crate ) environ : Option < MPlaceTy < ' tcx , Tag > > ,
85
85
}
86
86
87
- impl MemoryExtra {
87
+ impl < ' tcx > MemoryExtra < ' tcx > {
88
88
pub fn new ( rng : StdRng , stacked_borrows : bool , tracked_pointer_tag : Option < PtrId > ) -> Self {
89
89
let stacked_borrows = if stacked_borrows {
90
90
Some ( Rc :: new ( RefCell :: new ( stacked_borrows:: GlobalState :: new ( tracked_pointer_tag) ) ) )
@@ -101,7 +101,7 @@ impl MemoryExtra {
101
101
}
102
102
103
103
/// Sets up the "extern statics" for this machine.
104
- pub fn init_extern_statics < ' mir , ' tcx > (
104
+ pub fn init_extern_statics < ' mir > (
105
105
this : & mut MiriEvalContext < ' mir , ' tcx > ,
106
106
) -> InterpResult < ' tcx > {
107
107
match this. tcx . sess . target . target . target_os . as_str ( ) {
@@ -120,12 +120,13 @@ impl MemoryExtra {
120
120
// "environ"
121
121
let layout = this. layout_of ( this. tcx . types . usize ) ?;
122
122
let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
123
- this. write_scalar ( this. memory . extra . environ . unwrap ( ) , place. into ( ) ) ?;
123
+ this. write_scalar ( Scalar :: from_machine_usize ( 0 , & * this. tcx ) , place. into ( ) ) ?;
124
124
this. memory
125
125
. extra
126
126
. extern_statics
127
127
. insert ( "environ" , place. ptr . assert_ptr ( ) . alloc_id )
128
128
. unwrap_none ( ) ;
129
+ this. memory . extra . environ = Some ( place) ;
129
130
}
130
131
_ => { } // No "extern statics" supported on this platform
131
132
}
@@ -211,7 +212,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
211
212
type MemoryKinds = MiriMemoryKind ;
212
213
213
214
type FrameExtra = FrameData < ' tcx > ;
214
- type MemoryExtra = MemoryExtra ;
215
+ type MemoryExtra = MemoryExtra < ' tcx > ;
215
216
type AllocExtra = AllocExtra ;
216
217
type PointerTag = Tag ;
217
218
type ExtraFnVal = Dlsym ;
@@ -337,7 +338,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
337
338
}
338
339
339
340
fn init_allocation_extra < ' b > (
340
- memory_extra : & MemoryExtra ,
341
+ memory_extra : & MemoryExtra < ' tcx > ,
341
342
id : AllocId ,
342
343
alloc : Cow < ' b , Allocation > ,
343
344
kind : Option < MemoryKind < Self :: MemoryKinds > > ,
@@ -370,7 +371,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
370
371
}
371
372
372
373
#[ inline( always) ]
373
- fn tag_static_base_pointer ( memory_extra : & MemoryExtra , id : AllocId ) -> Self :: PointerTag {
374
+ fn tag_static_base_pointer ( memory_extra : & MemoryExtra < ' tcx > , id : AllocId ) -> Self :: PointerTag {
374
375
if let Some ( stacked_borrows) = memory_extra. stacked_borrows . as_ref ( ) {
375
376
stacked_borrows. borrow_mut ( ) . static_base_ptr ( id)
376
377
} else {
0 commit comments