@@ -117,7 +117,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
117
117
118
118
#[ inline]
119
119
pub fn tag_static_base_pointer ( & self , ptr : Pointer ) -> Pointer < M :: PointerTag > {
120
- ptr. with_tag ( M :: tag_static_base_pointer ( & self , ptr. alloc_id ) )
120
+ ptr. with_tag ( M :: tag_static_base_pointer ( & self . extra , ptr. alloc_id ) )
121
121
}
122
122
123
123
pub fn create_fn_alloc ( & mut self , instance : Instance < ' tcx > ) -> Pointer < M :: PointerTag > {
@@ -150,7 +150,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
150
150
kind : MemoryKind < M :: MemoryKinds > ,
151
151
) -> Pointer < M :: PointerTag > {
152
152
let id = self . tcx . alloc_map . lock ( ) . reserve ( ) ;
153
- let ( alloc, tag) = M :: tag_allocation ( & self , id, Cow :: Owned ( alloc) , Some ( kind) ) ;
153
+ let ( alloc, tag) = M :: tag_allocation ( & self . extra , id, Cow :: Owned ( alloc) , Some ( kind) ) ;
154
154
self . alloc_map . insert ( id, ( kind, alloc. into_owned ( ) ) ) ;
155
155
Pointer :: from ( id) . with_tag ( tag)
156
156
}
@@ -368,9 +368,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
368
368
/// contains a reference to memory that was created during its evaluation (i.e., not to
369
369
/// another static), those inner references only exist in "resolved" form.
370
370
fn get_static_alloc (
371
- id : AllocId ,
371
+ memory_extra : & M :: MemoryExtra ,
372
372
tcx : TyCtxtAt < ' tcx > ,
373
- memory : & Memory < ' mir , ' tcx , M > ,
373
+ id : AllocId ,
374
374
) -> InterpResult < ' tcx , Cow < ' tcx , Allocation < M :: PointerTag , M :: AllocExtra > > > {
375
375
let alloc = tcx. alloc_map . lock ( ) . get ( id) ;
376
376
let alloc = match alloc {
@@ -414,7 +414,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
414
414
// We got tcx memory. Let the machine figure out whether and how to
415
415
// turn that into memory with the right pointer tag.
416
416
Ok ( M :: tag_allocation (
417
- memory ,
417
+ memory_extra ,
418
418
id, // always use the ID we got as input, not the "hidden" one.
419
419
alloc,
420
420
M :: STATIC_KIND . map ( MemoryKind :: Machine ) ,
@@ -430,7 +430,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
430
430
// `get_static_alloc` that we can actually use directly without inserting anything anywhere.
431
431
// So the error type is `InterpResult<'tcx, &Allocation<M::PointerTag>>`.
432
432
let a = self . alloc_map . get_or ( id, || {
433
- let alloc = Self :: get_static_alloc ( id , self . tcx , & self ) . map_err ( Err ) ?;
433
+ let alloc = Self :: get_static_alloc ( & self . extra , self . tcx , id ) . map_err ( Err ) ?;
434
434
match alloc {
435
435
Cow :: Borrowed ( alloc) => {
436
436
// We got a ref, cheaply return that as an "error" so that the
@@ -459,11 +459,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
459
459
id : AllocId ,
460
460
) -> InterpResult < ' tcx , & mut Allocation < M :: PointerTag , M :: AllocExtra > > {
461
461
let tcx = self . tcx ;
462
- let alloc = Self :: get_static_alloc ( id , tcx , & self ) ;
462
+ let memory_extra = & self . extra ;
463
463
let a = self . alloc_map . get_mut_or ( id, || {
464
464
// Need to make a copy, even if `get_static_alloc` is able
465
465
// to give us a cheap reference.
466
- let alloc = alloc ?;
466
+ let alloc = Self :: get_static_alloc ( memory_extra , tcx , id ) ?;
467
467
if alloc. mutability == Mutability :: Immutable {
468
468
return err ! ( ModifiedConstantMemory ) ;
469
469
}
0 commit comments