@@ -210,7 +210,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
210
210
let new_ptr = self . allocate ( new_size, new_align, kind) ;
211
211
let old_size = match old_size_and_align {
212
212
Some ( ( size, _align) ) => size,
213
- None => self . get ( ptr. alloc_id ) ?. size ,
213
+ None => self . get_raw ( ptr. alloc_id ) ?. size ,
214
214
} ;
215
215
self . copy (
216
216
ptr,
@@ -478,7 +478,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
478
478
) . 0 )
479
479
}
480
480
481
- pub fn get (
481
+ /// Gives raw access to the `Allocation`, without bounds or alignment checks.
482
+ /// Use the higher-level, `PlaceTy`- and `OpTy`-based APIs in `InterpCtx` instead!
483
+ pub fn get_raw (
482
484
& self ,
483
485
id : AllocId ,
484
486
) -> InterpResult < ' tcx , & Allocation < M :: PointerTag , M :: AllocExtra > > {
@@ -511,7 +513,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
511
513
}
512
514
}
513
515
514
- pub fn get_mut (
516
+ /// Gives raw mutable access to the `Allocation`, without bounds or alignment checks.
517
+ /// Use the higher-level, `PlaceTy`- and `OpTy`-based APIs in `InterpCtx` instead!
518
+ pub fn get_raw_mut (
515
519
& mut self ,
516
520
id : AllocId ,
517
521
) -> InterpResult < ' tcx , & mut Allocation < M :: PointerTag , M :: AllocExtra > > {
@@ -553,7 +557,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
553
557
liveness : AllocCheck ,
554
558
) -> InterpResult < ' static , ( Size , Align ) > {
555
559
// # Regular allocations
556
- // Don't use `self.get ` here as that will
560
+ // Don't use `self.get_raw ` here as that will
557
561
// a) cause cycles in case `id` refers to a static
558
562
// b) duplicate a static's allocation in miri
559
563
if let Some ( ( _, alloc) ) = self . alloc_map . get ( id) {
@@ -625,7 +629,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
625
629
}
626
630
627
631
pub fn mark_immutable ( & mut self , id : AllocId ) -> InterpResult < ' tcx > {
628
- self . get_mut ( id) ?. mutability = Mutability :: Immutable ;
632
+ self . get_raw_mut ( id) ?. mutability = Mutability :: Immutable ;
629
633
Ok ( ( ) )
630
634
}
631
635
@@ -774,15 +778,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
774
778
Some ( ptr) => ptr,
775
779
None => return Ok ( & [ ] ) , // zero-sized access
776
780
} ;
777
- self . get ( ptr. alloc_id ) ?. get_bytes ( self , ptr, size)
781
+ self . get_raw ( ptr. alloc_id ) ?. get_bytes ( self , ptr, size)
778
782
}
779
783
780
784
/// Reads a 0-terminated sequence of bytes from memory. Returns them as a slice.
781
785
///
782
786
/// Performs appropriate bounds checks.
783
787
pub fn read_c_str ( & self , ptr : Scalar < M :: PointerTag > ) -> InterpResult < ' tcx , & [ u8 ] > {
784
788
let ptr = self . force_ptr ( ptr) ?; // We need to read at least 1 byte, so we *need* a ptr.
785
- self . get ( ptr. alloc_id ) ?. read_c_str ( self , ptr)
789
+ self . get_raw ( ptr. alloc_id ) ?. read_c_str ( self , ptr)
786
790
}
787
791
788
792
/// Writes the given stream of bytes into memory.
@@ -802,7 +806,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
802
806
None => return Ok ( ( ) ) , // zero-sized access
803
807
} ;
804
808
let tcx = self . tcx . tcx ;
805
- self . get_mut ( ptr. alloc_id ) ?. write_bytes ( & tcx, ptr, src)
809
+ self . get_raw_mut ( ptr. alloc_id ) ?. write_bytes ( & tcx, ptr, src)
806
810
}
807
811
808
812
/// Expects the caller to have checked bounds and alignment.
@@ -830,16 +834,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
830
834
// since we don't want to keep any relocations at the target.
831
835
// (`get_bytes_with_undef_and_ptr` below checks that there are no
832
836
// relocations overlapping the edges; those would not be handled correctly).
833
- let relocations = self . get ( src. alloc_id ) ?
837
+ let relocations = self . get_raw ( src. alloc_id ) ?
834
838
. prepare_relocation_copy ( self , src, size, dest, length) ;
835
839
836
840
let tcx = self . tcx . tcx ;
837
841
838
842
// This checks relocation edges on the src.
839
- let src_bytes = self . get ( src. alloc_id ) ?
843
+ let src_bytes = self . get_raw ( src. alloc_id ) ?
840
844
. get_bytes_with_undef_and_ptr ( & tcx, src, size) ?
841
845
. as_ptr ( ) ;
842
- let dest_bytes = self . get_mut ( dest. alloc_id ) ?
846
+ let dest_bytes = self . get_raw_mut ( dest. alloc_id ) ?
843
847
. get_bytes_mut ( & tcx, dest, size * length) ?
844
848
. as_mut_ptr ( ) ;
845
849
@@ -878,7 +882,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
878
882
// copy definedness to the destination
879
883
self . copy_undef_mask ( src, dest, size, length) ?;
880
884
// copy the relocations to the destination
881
- self . get_mut ( dest. alloc_id ) ?. mark_relocation_range ( relocations) ;
885
+ self . get_raw_mut ( dest. alloc_id ) ?. mark_relocation_range ( relocations) ;
882
886
883
887
Ok ( ( ) )
884
888
}
@@ -897,11 +901,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
897
901
// The bits have to be saved locally before writing to dest in case src and dest overlap.
898
902
assert_eq ! ( size. bytes( ) as usize as u64 , size. bytes( ) ) ;
899
903
900
- let src_alloc = self . get ( src. alloc_id ) ?;
904
+ let src_alloc = self . get_raw ( src. alloc_id ) ?;
901
905
let compressed = src_alloc. compress_undef_range ( src, size) ;
902
906
903
907
// now fill in all the data
904
- let dest_allocation = self . get_mut ( dest. alloc_id ) ?;
908
+ let dest_allocation = self . get_raw_mut ( dest. alloc_id ) ?;
905
909
dest_allocation. mark_compressed_undef_range ( & compressed, dest, size, repeat) ;
906
910
907
911
Ok ( ( ) )
0 commit comments