@@ -210,7 +210,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
210210 let new_ptr = self . allocate ( new_size, new_align, kind) ;
211211 let old_size = match old_size_and_align {
212212 Some ( ( size, _align) ) => size,
213- None => self . get ( ptr. alloc_id ) ?. size ,
213+ None => self . get_raw ( ptr. alloc_id ) ?. size ,
214214 } ;
215215 self . copy (
216216 ptr,
@@ -478,7 +478,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
478478 ) . 0 )
479479 }
480480
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 (
482484 & self ,
483485 id : AllocId ,
484486 ) -> InterpResult < ' tcx , & Allocation < M :: PointerTag , M :: AllocExtra > > {
@@ -511,7 +513,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
511513 }
512514 }
513515
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 (
515519 & mut self ,
516520 id : AllocId ,
517521 ) -> InterpResult < ' tcx , & mut Allocation < M :: PointerTag , M :: AllocExtra > > {
@@ -553,7 +557,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
553557 liveness : AllocCheck ,
554558 ) -> InterpResult < ' static , ( Size , Align ) > {
555559 // # Regular allocations
556- // Don't use `self.get ` here as that will
560+ // Don't use `self.get_raw ` here as that will
557561 // a) cause cycles in case `id` refers to a static
558562 // b) duplicate a static's allocation in miri
559563 if let Some ( ( _, alloc) ) = self . alloc_map . get ( id) {
@@ -625,7 +629,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
625629 }
626630
627631 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 ;
629633 Ok ( ( ) )
630634 }
631635
@@ -774,15 +778,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
774778 Some ( ptr) => ptr,
775779 None => return Ok ( & [ ] ) , // zero-sized access
776780 } ;
777- self . get ( ptr. alloc_id ) ?. get_bytes ( self , ptr, size)
781+ self . get_raw ( ptr. alloc_id ) ?. get_bytes ( self , ptr, size)
778782 }
779783
780784 /// Reads a 0-terminated sequence of bytes from memory. Returns them as a slice.
781785 ///
782786 /// Performs appropriate bounds checks.
783787 pub fn read_c_str ( & self , ptr : Scalar < M :: PointerTag > ) -> InterpResult < ' tcx , & [ u8 ] > {
784788 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)
786790 }
787791
788792 /// Writes the given stream of bytes into memory.
@@ -802,7 +806,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
802806 None => return Ok ( ( ) ) , // zero-sized access
803807 } ;
804808 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)
806810 }
807811
808812 /// Expects the caller to have checked bounds and alignment.
@@ -830,16 +834,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
830834 // since we don't want to keep any relocations at the target.
831835 // (`get_bytes_with_undef_and_ptr` below checks that there are no
832836 // 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 ) ?
834838 . prepare_relocation_copy ( self , src, size, dest, length) ;
835839
836840 let tcx = self . tcx . tcx ;
837841
838842 // 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 ) ?
840844 . get_bytes_with_undef_and_ptr ( & tcx, src, size) ?
841845 . as_ptr ( ) ;
842- let dest_bytes = self . get_mut ( dest. alloc_id ) ?
846+ let dest_bytes = self . get_raw_mut ( dest. alloc_id ) ?
843847 . get_bytes_mut ( & tcx, dest, size * length) ?
844848 . as_mut_ptr ( ) ;
845849
@@ -878,7 +882,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
878882 // copy definedness to the destination
879883 self . copy_undef_mask ( src, dest, size, length) ?;
880884 // 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) ;
882886
883887 Ok ( ( ) )
884888 }
@@ -897,11 +901,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
897901 // The bits have to be saved locally before writing to dest in case src and dest overlap.
898902 assert_eq ! ( size. bytes( ) as usize as u64 , size. bytes( ) ) ;
899903
900- let src_alloc = self . get ( src. alloc_id ) ?;
904+ let src_alloc = self . get_raw ( src. alloc_id ) ?;
901905 let compressed = src_alloc. compress_undef_range ( src, size) ;
902906
903907 // 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 ) ?;
905909 dest_allocation. mark_compressed_undef_range ( & compressed, dest, size, repeat) ;
906910
907911 Ok ( ( ) )
0 commit comments