@@ -22,9 +22,9 @@ use rustc_span::{Pos, Span};
22
22
use rustc_target:: abi:: { call:: FnAbi , Align , HasDataLayout , Size , TargetDataLayout } ;
23
23
24
24
use super :: {
25
- AllocCheck , AllocId , GlobalId , Immediate , InterpErrorInfo , InterpResult , MPlaceTy , Machine ,
26
- MemPlace , MemPlaceMeta , Memory , MemoryKind , Operand , Place , PlaceTy , Pointer ,
27
- PointerArithmetic , Provenance , Scalar , ScalarMaybeUninit , StackPopJump ,
25
+ AllocId , GlobalId , Immediate , InterpErrorInfo , InterpResult , MPlaceTy , Machine , MemPlace ,
26
+ MemPlaceMeta , Memory , MemoryKind , Operand , Place , PlaceTy , PointerArithmetic , Provenance ,
27
+ Scalar , ScalarMaybeUninit , StackPopJump ,
28
28
} ;
29
29
use crate :: transform:: validate:: equal_up_to_regions;
30
30
@@ -413,13 +413,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
413
413
root_span : Span ,
414
414
param_env : ty:: ParamEnv < ' tcx > ,
415
415
machine : M ,
416
- memory_extra : M :: MemoryExtra ,
417
416
) -> Self {
418
417
InterpCx {
419
418
machine,
420
419
tcx : tcx. at ( root_span) ,
421
420
param_env,
422
- memory : Memory :: new ( tcx , memory_extra ) ,
421
+ memory : Memory :: new ( ) ,
423
422
recursion_limit : tcx. recursion_limit ( ) ,
424
423
}
425
424
}
@@ -433,49 +432,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
433
432
. map_or ( self . tcx . span , |f| f. current_span ( ) )
434
433
}
435
434
436
- #[ inline( always) ]
437
- pub fn scalar_to_ptr ( & self , scalar : Scalar < M :: PointerTag > ) -> Pointer < Option < M :: PointerTag > > {
438
- self . memory . scalar_to_ptr ( scalar)
439
- }
440
-
441
- /// Test if this value might be null.
442
- /// If the machine does not support ptr-to-int casts, this is conservative.
443
- pub fn scalar_may_be_null ( & self , scalar : Scalar < M :: PointerTag > ) -> bool {
444
- match scalar. try_to_int ( ) {
445
- Ok ( int) => int. is_null ( ) ,
446
- Err ( _) => {
447
- // Can only happen during CTFE.
448
- let ptr = self . scalar_to_ptr ( scalar) ;
449
- match self . memory . ptr_try_get_alloc ( ptr) {
450
- Ok ( ( alloc_id, offset, _) ) => {
451
- let ( size, _align) = self
452
- . memory
453
- . get_size_and_align ( alloc_id, AllocCheck :: MaybeDead )
454
- . expect ( "alloc info with MaybeDead cannot fail" ) ;
455
- // If the pointer is out-of-bounds, it may be null.
456
- // Note that one-past-the-end (offset == size) is still inbounds, and never null.
457
- offset > size
458
- }
459
- Err ( _offset) => bug ! ( "a non-int scalar is always a pointer" ) ,
460
- }
461
- }
462
- }
463
- }
464
-
465
- /// Call this to turn untagged "global" pointers (obtained via `tcx`) into
466
- /// the machine pointer to the allocation. Must never be used
467
- /// for any other pointers, nor for TLS statics.
468
- ///
469
- /// Using the resulting pointer represents a *direct* access to that memory
470
- /// (e.g. by directly using a `static`),
471
- /// as opposed to access through a pointer that was created by the program.
472
- ///
473
- /// This function can fail only if `ptr` points to an `extern static`.
474
- #[ inline( always) ]
475
- pub fn global_base_pointer ( & self , ptr : Pointer ) -> InterpResult < ' tcx , Pointer < M :: PointerTag > > {
476
- self . memory . global_base_pointer ( ptr)
477
- }
478
-
479
435
#[ inline( always) ]
480
436
pub ( crate ) fn stack ( & self ) -> & [ Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > ] {
481
437
M :: stack ( self )
@@ -949,9 +905,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
949
905
trace ! (
950
906
"deallocating local {:?}: {:?}" ,
951
907
local,
952
- self . memory . dump_alloc( ptr. provenance. unwrap( ) . get_alloc_id( ) )
908
+ self . dump_alloc( ptr. provenance. unwrap( ) . get_alloc_id( ) )
953
909
) ;
954
- self . memory . deallocate ( ptr, None , MemoryKind :: Stack ) ?;
910
+ self . deallocate_ptr ( ptr, None , MemoryKind :: Stack ) ?;
955
911
} ;
956
912
Ok ( ( ) )
957
913
}
@@ -1057,15 +1013,15 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug
1057
1013
}
1058
1014
}
1059
1015
1060
- write ! ( fmt, ": {:?}" , self . ecx. memory . dump_allocs( allocs) )
1016
+ write ! ( fmt, ": {:?}" , self . ecx. dump_allocs( allocs) )
1061
1017
}
1062
1018
Place :: Ptr ( mplace) => match mplace. ptr . provenance . map ( Provenance :: get_alloc_id) {
1063
1019
Some ( alloc_id) => write ! (
1064
1020
fmt,
1065
1021
"by align({}) ref {:?}: {:?}" ,
1066
1022
mplace. align. bytes( ) ,
1067
1023
mplace. ptr,
1068
- self . ecx. memory . dump_alloc( alloc_id)
1024
+ self . ecx. dump_alloc( alloc_id)
1069
1025
) ,
1070
1026
ptr => write ! ( fmt, " integral by ref: {:?}" , ptr) ,
1071
1027
} ,
0 commit comments