@@ -70,7 +70,7 @@ pub struct AllocExtra {
70
70
71
71
/// Extra global memory data
72
72
#[ derive( Clone , Debug ) ]
73
- pub struct MemoryExtra < ' tcx > {
73
+ pub struct MemoryExtra {
74
74
pub stacked_borrows : Option < stacked_borrows:: MemoryExtra > ,
75
75
pub intptrcast : intptrcast:: MemoryExtra ,
76
76
@@ -84,12 +84,9 @@ pub struct MemoryExtra<'tcx> {
84
84
/// An allocation ID to report when it is being allocated
85
85
/// (helps for debugging memory leaks).
86
86
tracked_alloc_id : Option < AllocId > ,
87
-
88
- /// Place where the `environ` static is stored. Lazily initialized, but then never changes.
89
- pub ( crate ) environ : Option < MPlaceTy < ' tcx , Tag > > ,
90
87
}
91
88
92
- impl < ' tcx > MemoryExtra < ' tcx > {
89
+ impl MemoryExtra {
93
90
pub fn new ( rng : StdRng , stacked_borrows : bool , tracked_pointer_tag : Option < PtrId > , tracked_alloc_id : Option < AllocId > ) -> Self {
94
91
let stacked_borrows = if stacked_borrows {
95
92
Some ( Rc :: new ( RefCell :: new ( stacked_borrows:: GlobalState :: new ( tracked_pointer_tag) ) ) )
@@ -102,12 +99,11 @@ impl<'tcx> MemoryExtra<'tcx> {
102
99
extern_statics : FxHashMap :: default ( ) ,
103
100
rng : RefCell :: new ( rng) ,
104
101
tracked_alloc_id,
105
- environ : None ,
106
102
}
107
103
}
108
104
109
105
/// Sets up the "extern statics" for this machine.
110
- pub fn init_extern_statics < ' mir > (
106
+ pub fn init_extern_statics < ' tcx , ' mir > (
111
107
this : & mut MiriEvalContext < ' mir , ' tcx > ,
112
108
) -> InterpResult < ' tcx > {
113
109
let target_os = this. tcx . sess . target . target . target_os . as_str ( ) ;
@@ -127,7 +123,7 @@ impl<'tcx> MemoryExtra<'tcx> {
127
123
this. memory
128
124
. extra
129
125
. extern_statics
130
- . insert ( Symbol :: intern ( "environ" ) , this. memory . extra . environ . unwrap ( ) . ptr . assert_ptr ( ) . alloc_id )
126
+ . insert ( Symbol :: intern ( "environ" ) , this. machine . env_vars . environ . unwrap ( ) . ptr . assert_ptr ( ) . alloc_id )
131
127
. unwrap_none ( ) ;
132
128
}
133
129
_ => { } // No "extern statics" supported on this platform
@@ -140,7 +136,7 @@ impl<'tcx> MemoryExtra<'tcx> {
140
136
pub struct Evaluator < ' tcx > {
141
137
/// Environment variables set by `setenv`.
142
138
/// Miri does not expose env vars from the host to the emulated program.
143
- pub ( crate ) env_vars : EnvVars ,
139
+ pub ( crate ) env_vars : EnvVars < ' tcx > ,
144
140
145
141
/// Program arguments (`Option` because we can only initialize them after creating the ecx).
146
142
/// These are *pointers* to argc/argv because macOS.
@@ -214,7 +210,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
214
210
type MemoryKinds = MiriMemoryKind ;
215
211
216
212
type FrameExtra = FrameData < ' tcx > ;
217
- type MemoryExtra = MemoryExtra < ' tcx > ;
213
+ type MemoryExtra = MemoryExtra ;
218
214
type AllocExtra = AllocExtra ;
219
215
type PointerTag = Tag ;
220
216
type ExtraFnVal = Dlsym ;
@@ -340,7 +336,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
340
336
}
341
337
342
338
fn init_allocation_extra < ' b > (
343
- memory_extra : & MemoryExtra < ' tcx > ,
339
+ memory_extra : & MemoryExtra ,
344
340
id : AllocId ,
345
341
alloc : Cow < ' b , Allocation > ,
346
342
kind : Option < MemoryKind < Self :: MemoryKinds > > ,
@@ -377,7 +373,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
377
373
}
378
374
379
375
#[ inline( always) ]
380
- fn tag_static_base_pointer ( memory_extra : & MemoryExtra < ' tcx > , id : AllocId ) -> Self :: PointerTag {
376
+ fn tag_static_base_pointer ( memory_extra : & MemoryExtra , id : AllocId ) -> Self :: PointerTag {
381
377
if let Some ( stacked_borrows) = memory_extra. stacked_borrows . as_ref ( ) {
382
378
stacked_borrows. borrow_mut ( ) . static_base_ptr ( id)
383
379
} else {
0 commit comments