@@ -143,6 +143,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
143
143
}
144
144
}
145
145
146
+ /// Call this to turn untagged "global" pointers (obtained via `tcx`) into
147
+ /// the *canonical* machine pointer to the allocation. This represents a *direct*
148
+ /// access to that memory, as opposed to access through a pointer that was created
149
+ /// by the program. Must never be used for derived (program-created) pointers!
146
150
#[ inline]
147
151
pub fn tag_static_base_pointer ( & self , ptr : Pointer ) -> Pointer < M :: PointerTag > {
148
152
ptr. with_tag ( M :: tag_static_base_pointer ( & self . extra , ptr. alloc_id ) )
@@ -191,9 +195,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
191
195
kind : MemoryKind < M :: MemoryKinds > ,
192
196
) -> Pointer < M :: PointerTag > {
193
197
let id = self . tcx . alloc_map . lock ( ) . reserve ( ) ;
194
- let ( alloc, tag ) = M :: tag_allocation ( & self . extra , id, Cow :: Owned ( alloc) , Some ( kind) ) ;
198
+ let alloc = M :: init_allocation_extra ( & self . extra , id, Cow :: Owned ( alloc) , Some ( kind) ) ;
195
199
self . alloc_map . insert ( id, ( kind, alloc. into_owned ( ) ) ) ;
196
- Pointer :: from ( id) . with_tag ( tag )
200
+ self . tag_static_base_pointer ( Pointer :: from ( id) )
197
201
}
198
202
199
203
pub fn reallocate (
@@ -473,14 +477,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
473
477
}
474
478
}
475
479
} ;
476
- // We got tcx memory. Let the machine figure out whether and how to
477
- // turn that into memory with the right pointer tag.
478
- Ok ( M :: tag_allocation (
480
+ // We got tcx memory. Let the machine initialize its "extra" stuff.
481
+ Ok ( M :: init_allocation_extra (
479
482
memory_extra,
480
483
id, // always use the ID we got as input, not the "hidden" one.
481
484
alloc,
482
485
M :: STATIC_KIND . map ( MemoryKind :: Machine ) ,
483
- ) . 0 )
486
+ ) )
484
487
}
485
488
486
489
/// Gives raw access to the `Allocation`, without bounds or alignment checks.
0 commit comments