@@ -22,9 +22,9 @@ use rustc_span::{Pos, Span};
2222use rustc_target:: abi:: { call:: FnAbi , Align , HasDataLayout , Size , TargetDataLayout } ;
2323
2424use 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 ,
2828} ;
2929use crate :: transform:: validate:: equal_up_to_regions;
3030
@@ -413,13 +413,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
413413 root_span : Span ,
414414 param_env : ty:: ParamEnv < ' tcx > ,
415415 machine : M ,
416- memory_extra : M :: MemoryExtra ,
417416 ) -> Self {
418417 InterpCx {
419418 machine,
420419 tcx : tcx. at ( root_span) ,
421420 param_env,
422- memory : Memory :: new ( tcx , memory_extra ) ,
421+ memory : Memory :: new ( ) ,
423422 recursion_limit : tcx. recursion_limit ( ) ,
424423 }
425424 }
@@ -433,49 +432,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
433432 . map_or ( self . tcx . span , |f| f. current_span ( ) )
434433 }
435434
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-
479435 #[ inline( always) ]
480436 pub ( crate ) fn stack ( & self ) -> & [ Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > ] {
481437 M :: stack ( self )
@@ -949,9 +905,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
949905 trace ! (
950906 "deallocating local {:?}: {:?}" ,
951907 local,
952- self . memory . dump_alloc( ptr. provenance. unwrap( ) . get_alloc_id( ) )
908+ self . dump_alloc( ptr. provenance. unwrap( ) . get_alloc_id( ) )
953909 ) ;
954- self . memory . deallocate ( ptr, None , MemoryKind :: Stack ) ?;
910+ self . deallocate_ptr ( ptr, None , MemoryKind :: Stack ) ?;
955911 } ;
956912 Ok ( ( ) )
957913 }
@@ -1057,15 +1013,15 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug
10571013 }
10581014 }
10591015
1060- write ! ( fmt, ": {:?}" , self . ecx. memory . dump_allocs( allocs) )
1016+ write ! ( fmt, ": {:?}" , self . ecx. dump_allocs( allocs) )
10611017 }
10621018 Place :: Ptr ( mplace) => match mplace. ptr . provenance . map ( Provenance :: get_alloc_id) {
10631019 Some ( alloc_id) => write ! (
10641020 fmt,
10651021 "by align({}) ref {:?}: {:?}" ,
10661022 mplace. align. bytes( ) ,
10671023 mplace. ptr,
1068- self . ecx. memory . dump_alloc( alloc_id)
1024+ self . ecx. dump_alloc( alloc_id)
10691025 ) ,
10701026 ptr => write ! ( fmt, " integral by ref: {:?}" , ptr) ,
10711027 } ,
0 commit comments