@@ -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 ( ptr. alloc_id , & self ) )
120
+ ptr. with_tag ( M :: tag_static_base_pointer ( ptr. alloc_id , & self . extra ) )
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 ( id, Cow :: Owned ( alloc) , Some ( kind) , & self ) ;
153
+ let ( alloc, tag) = M :: tag_allocation ( id, Cow :: Owned ( alloc) , Some ( kind) , & self . extra ) ;
154
154
self . alloc_map . insert ( id, ( kind, alloc. into_owned ( ) ) ) ;
155
155
Pointer :: from ( id) . with_tag ( tag)
156
156
}
@@ -367,7 +367,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
367
367
fn get_static_alloc (
368
368
id : AllocId ,
369
369
tcx : TyCtxtAt < ' tcx > ,
370
- memory : & Memory < ' mir , ' tcx , M > ,
370
+ memory_extra : & M :: MemoryExtra ,
371
371
) -> InterpResult < ' tcx , Cow < ' tcx , Allocation < M :: PointerTag , M :: AllocExtra > > > {
372
372
let alloc = tcx. alloc_map . lock ( ) . get ( id) ;
373
373
let alloc = match alloc {
@@ -414,7 +414,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
414
414
id, // always use the ID we got as input, not the "hidden" one.
415
415
alloc,
416
416
M :: STATIC_KIND . map ( MemoryKind :: Machine ) ,
417
- memory
417
+ memory_extra
418
418
) . 0 )
419
419
}
420
420
@@ -427,7 +427,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
427
427
// `get_static_alloc` that we can actually use directly without inserting anything anywhere.
428
428
// So the error type is `InterpResult<'tcx, &Allocation<M::PointerTag>>`.
429
429
let a = self . alloc_map . get_or ( id, || {
430
- let alloc = Self :: get_static_alloc ( id, self . tcx , & self ) . map_err ( Err ) ?;
430
+ let alloc = Self :: get_static_alloc ( id, self . tcx , & self . extra ) . map_err ( Err ) ?;
431
431
match alloc {
432
432
Cow :: Borrowed ( alloc) => {
433
433
// We got a ref, cheaply return that as an "error" so that the
@@ -456,11 +456,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
456
456
id : AllocId ,
457
457
) -> InterpResult < ' tcx , & mut Allocation < M :: PointerTag , M :: AllocExtra > > {
458
458
let tcx = self . tcx ;
459
- let alloc = Self :: get_static_alloc ( id , tcx , & self ) ;
459
+ let memory_extra = & self . extra ;
460
460
let a = self . alloc_map . get_mut_or ( id, || {
461
461
// Need to make a copy, even if `get_static_alloc` is able
462
462
// to give us a cheap reference.
463
- let alloc = alloc ?;
463
+ let alloc = Self :: get_static_alloc ( id , tcx , memory_extra ) ?;
464
464
if alloc. mutability == Mutability :: Immutable {
465
465
return err ! ( ModifiedConstantMemory ) ;
466
466
}
@@ -887,7 +887,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
887
887
) -> InterpResult < ' tcx , Pointer < M :: PointerTag > > {
888
888
match scalar {
889
889
Scalar :: Ptr ( ptr) => Ok ( ptr) ,
890
- _ => M :: int_to_ptr ( scalar. to_usize ( self ) ?, self )
890
+ _ => M :: int_to_ptr ( scalar. to_usize ( self ) ?, & self . extra )
891
891
}
892
892
}
893
893
@@ -898,7 +898,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
898
898
) -> InterpResult < ' tcx , u128 > {
899
899
match scalar. to_bits_or_ptr ( size, self ) {
900
900
Ok ( bits) => Ok ( bits) ,
901
- Err ( ptr) => Ok ( M :: ptr_to_int ( ptr, self ) ? as u128 )
901
+ Err ( ptr) => Ok ( M :: ptr_to_int ( ptr, & self . extra ) ? as u128 )
902
902
}
903
903
}
904
904
}
0 commit comments