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