@@ -7,7 +7,7 @@ use std::hash::Hash;
7
7
8
8
use rustc:: mir;
9
9
use rustc:: ty:: { self , Ty } ;
10
- use rustc_span:: Span ;
10
+ use rustc_span:: { def_id :: DefId , Span } ;
11
11
12
12
use super :: {
13
13
AllocId , Allocation , AllocationExtra , Frame , ImmTy , InterpCx , InterpResult , Memory , MemoryKind ,
@@ -79,7 +79,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
79
79
/// and some use case dependent behaviour can instead be applied.
80
80
pub trait Machine < ' mir , ' tcx > : Sized {
81
81
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
82
- type MemoryKinds : :: std:: fmt:: Debug + MayLeak + Eq + ' static ;
82
+ type MemoryKind : :: std:: fmt:: Debug + MayLeak + Eq + ' static ;
83
83
84
84
/// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows"
85
85
/// <https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html>.
@@ -105,16 +105,17 @@ pub trait Machine<'mir, 'tcx>: Sized {
105
105
/// Memory's allocation map
106
106
type MemoryMap : AllocMap <
107
107
AllocId ,
108
- ( MemoryKind < Self :: MemoryKinds > , Allocation < Self :: PointerTag , Self :: AllocExtra > ) ,
108
+ ( MemoryKind < Self :: MemoryKind > , Allocation < Self :: PointerTag , Self :: AllocExtra > ) ,
109
109
> + Default
110
110
+ Clone ;
111
111
112
- /// The memory kind to use for copied statics -- or None if statics should not be mutated
113
- /// and thus any such attempt will cause a `ModifiedStatic` error to be raised.
112
+ /// The memory kind to use for copied global memory (held in `tcx`) --
113
+ /// or None if such memory should not be mutated and thus any such attempt will cause
114
+ /// a `ModifiedStatic` error to be raised.
114
115
/// Statics are copied under two circumstances: When they are mutated, and when
115
- /// `tag_allocation` or `find_foreign_static` (see below) returns an owned allocation
116
+ /// `tag_allocation` (see below) returns an owned allocation
116
117
/// that is added to the memory so that the work is not done twice.
117
- const STATIC_KIND : Option < Self :: MemoryKinds > ;
118
+ const GLOBAL_KIND : Option < Self :: MemoryKind > ;
118
119
119
120
/// Whether memory accesses should be alignment-checked.
120
121
const CHECK_ALIGN : bool ;
@@ -207,11 +208,15 @@ pub trait Machine<'mir, 'tcx>: Sized {
207
208
Ok ( ( ) )
208
209
}
209
210
210
- /// Called before a `Static` value is accessed.
211
+ /// Called before a global allocation is accessed.
212
+ /// `def_id` is `Some` if this is the "lazy" allocation of a static.
211
213
#[ inline]
212
- fn before_access_static (
214
+ fn before_access_global (
213
215
_memory_extra : & Self :: MemoryExtra ,
216
+ _alloc_id : AllocId ,
214
217
_allocation : & Allocation ,
218
+ _def_id : Option < DefId > ,
219
+ _is_write : bool ,
215
220
) -> InterpResult < ' tcx > {
216
221
Ok ( ( ) )
217
222
}
@@ -231,10 +236,10 @@ pub trait Machine<'mir, 'tcx>: Sized {
231
236
/// it contains (in relocations) tagged. The way we construct allocations is
232
237
/// to always first construct it without extra and then add the extra.
233
238
/// This keeps uniform code paths for handling both allocations created by CTFE
234
- /// for statics , and allocations created by Miri during evaluation.
239
+ /// for globals , and allocations created by Miri during evaluation.
235
240
///
236
241
/// `kind` is the kind of the allocation being tagged; it can be `None` when
237
- /// it's a static and `STATIC_KIND ` is `None`.
242
+ /// it's a global and `GLOBAL_KIND ` is `None`.
238
243
///
239
244
/// This should avoid copying if no work has to be done! If this returns an owned
240
245
/// allocation (because a copy had to be done to add tags or metadata), machine memory will
@@ -243,20 +248,20 @@ pub trait Machine<'mir, 'tcx>: Sized {
243
248
///
244
249
/// Also return the "base" tag to use for this allocation: the one that is used for direct
245
250
/// accesses to this allocation. If `kind == STATIC_KIND`, this tag must be consistent
246
- /// with `tag_static_base_pointer `.
251
+ /// with `tag_global_base_pointer `.
247
252
fn init_allocation_extra < ' b > (
248
253
memory_extra : & Self :: MemoryExtra ,
249
254
id : AllocId ,
250
255
alloc : Cow < ' b , Allocation > ,
251
- kind : Option < MemoryKind < Self :: MemoryKinds > > ,
256
+ kind : Option < MemoryKind < Self :: MemoryKind > > ,
252
257
) -> ( Cow < ' b , Allocation < Self :: PointerTag , Self :: AllocExtra > > , Self :: PointerTag ) ;
253
258
254
- /// Return the "base" tag for the given *static * allocation: the one that is used for direct
255
- /// accesses to this static/const/fn allocation. If `id` is not a static allocation,
259
+ /// Return the "base" tag for the given *global * allocation: the one that is used for direct
260
+ /// accesses to this static/const/fn allocation. If `id` is not a global allocation,
256
261
/// this will return an unusable tag (i.e., accesses will be UB)!
257
262
///
258
263
/// Expects `id` to be already canonical, if needed.
259
- fn tag_static_base_pointer ( memory_extra : & Self :: MemoryExtra , id : AllocId ) -> Self :: PointerTag ;
264
+ fn tag_global_base_pointer ( memory_extra : & Self :: MemoryExtra , id : AllocId ) -> Self :: PointerTag ;
260
265
261
266
/// Executes a retagging operation
262
267
#[ inline]
0 commit comments