@@ -143,6 +143,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
143143 }
144144 }
145145
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!
146150 #[ inline]
147151 pub fn tag_static_base_pointer ( & self , ptr : Pointer ) -> Pointer < M :: PointerTag > {
148152 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> {
191195 kind : MemoryKind < M :: MemoryKinds > ,
192196 ) -> Pointer < M :: PointerTag > {
193197 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) ) ;
195199 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) )
197201 }
198202
199203 pub fn reallocate (
@@ -473,14 +477,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
473477 }
474478 }
475479 } ;
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 (
479482 memory_extra,
480483 id, // always use the ID we got as input, not the "hidden" one.
481484 alloc,
482485 M :: STATIC_KIND . map ( MemoryKind :: Machine ) ,
483- ) . 0 )
486+ ) )
484487 }
485488
486489 /// Gives raw access to the `Allocation`, without bounds or alignment checks.
0 commit comments