@@ -955,79 +955,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
955
955
}
956
956
}
957
957
958
- /// Relocations
959
- impl < ' a , ' mir , ' tcx , M : Machine < ' a , ' mir , ' tcx > > Memory < ' a , ' mir , ' tcx , M > {
960
- /// Return all relocations overlapping with the given ptr-offset pair.
961
- fn relocations (
962
- & self ,
963
- ptr : Pointer < M :: PointerTag > ,
964
- size : Size ,
965
- ) -> EvalResult < ' tcx , & [ ( Size , ( M :: PointerTag , AllocId ) ) ] > {
966
- // We have to go back `pointer_size - 1` bytes, as that one would still overlap with
967
- // the beginning of this range.
968
- let start = ptr. offset . bytes ( ) . saturating_sub ( self . pointer_size ( ) . bytes ( ) - 1 ) ;
969
- let end = ptr. offset + size; // this does overflow checking
970
- Ok ( self . get ( ptr. alloc_id ) ?. relocations . range ( Size :: from_bytes ( start) ..end) )
971
- }
972
-
973
- /// Check that there ar eno relocations overlapping with the given range.
974
- #[ inline( always) ]
975
- fn check_relocations ( & self , ptr : Pointer < M :: PointerTag > , size : Size ) -> EvalResult < ' tcx > {
976
- if self . relocations ( ptr, size) ?. len ( ) != 0 {
977
- err ! ( ReadPointerAsBytes )
978
- } else {
979
- Ok ( ( ) )
980
- }
981
- }
982
-
983
- /// Remove all relocations inside the given range.
984
- /// If there are relocations overlapping with the edges, they
985
- /// are removed as well *and* the bytes they cover are marked as
986
- /// uninitialized. This is a somewhat odd "spooky action at a distance",
987
- /// but it allows strictly more code to run than if we would just error
988
- /// immediately in that case.
989
- fn clear_relocations ( & mut self , ptr : Pointer < M :: PointerTag > , size : Size ) -> EvalResult < ' tcx > {
990
- // Find the start and end of the given range and its outermost relocations.
991
- let ( first, last) = {
992
- // Find all relocations overlapping the given range.
993
- let relocations = self . relocations ( ptr, size) ?;
994
- if relocations. is_empty ( ) {
995
- return Ok ( ( ) ) ;
996
- }
997
-
998
- ( relocations. first ( ) . unwrap ( ) . 0 ,
999
- relocations. last ( ) . unwrap ( ) . 0 + self . pointer_size ( ) )
1000
- } ;
1001
- let start = ptr. offset ;
1002
- let end = start + size;
1003
-
1004
- let alloc = self . get_mut ( ptr. alloc_id ) ?;
1005
-
1006
- // Mark parts of the outermost relocations as undefined if they partially fall outside the
1007
- // given range.
1008
- if first < start {
1009
- alloc. undef_mask . set_range ( first, start, false ) ;
1010
- }
1011
- if last > end {
1012
- alloc. undef_mask . set_range ( end, last, false ) ;
1013
- }
1014
-
1015
- // Forget all the relocations.
1016
- alloc. relocations . remove_range ( first..last) ;
1017
-
1018
- Ok ( ( ) )
1019
- }
1020
-
1021
- /// Error if there are relocations overlapping with the edges of the
1022
- /// given memory range.
1023
- #[ inline]
1024
- fn check_relocation_edges ( & self , ptr : Pointer < M :: PointerTag > , size : Size ) -> EvalResult < ' tcx > {
1025
- self . check_relocations ( ptr, Size :: ZERO ) ?;
1026
- self . check_relocations ( ptr. offset ( size, self ) ?, Size :: ZERO ) ?;
1027
- Ok ( ( ) )
1028
- }
1029
- }
1030
-
1031
958
/// Undefined bytes
1032
959
impl < ' a , ' mir , ' tcx , M : Machine < ' a , ' mir , ' tcx > > Memory < ' a , ' mir , ' tcx , M > {
1033
960
// FIXME: Add a fast version for the common, nonoverlapping case
0 commit comments