@@ -39,9 +39,6 @@ pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
3939 /// The virtual memory system.
4040 pub memory : Memory < ' mir , ' tcx , M > ,
4141
42- /// The virtual call stack.
43- pub ( crate ) stack : Vec < Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > > ,
44-
4542 /// A cache for deduplicating vtables
4643 pub ( super ) vtables :
4744 FxHashMap < ( Ty < ' tcx > , Option < ty:: PolyExistentialTraitRef < ' tcx > > ) , Pointer < M :: PointerTag > > ,
@@ -295,7 +292,7 @@ pub(super) fn from_known_layout<'tcx>(
295292 }
296293}
297294
298- impl < ' mir , ' tcx , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
295+ impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
299296 pub fn new (
300297 tcx : TyCtxtAt < ' tcx > ,
301298 param_env : ty:: ParamEnv < ' tcx > ,
@@ -307,7 +304,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
307304 tcx,
308305 param_env,
309306 memory : Memory :: new ( tcx, memory_extra) ,
310- stack : Vec :: new ( ) ,
311307 vtables : FxHashMap :: default ( ) ,
312308 }
313309 }
@@ -348,23 +344,29 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
348344
349345 #[ inline( always) ]
350346 pub fn stack ( & self ) -> & [ Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > ] {
351- & self . stack
347+ M :: stack ( self )
348+ }
349+
350+ #[ inline( always) ]
351+ pub fn stack_mut ( & mut self ) -> & mut Vec < Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > > {
352+ M :: stack_mut ( self )
352353 }
353354
354355 #[ inline( always) ]
355356 pub fn cur_frame ( & self ) -> usize {
356- assert ! ( !self . stack. is_empty( ) ) ;
357- self . stack . len ( ) - 1
357+ let stack = self . stack ( ) ;
358+ assert ! ( !stack. is_empty( ) ) ;
359+ stack. len ( ) - 1
358360 }
359361
360362 #[ inline( always) ]
361363 pub fn frame ( & self ) -> & Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > {
362- self . stack . last ( ) . expect ( "no call frames exist" )
364+ self . stack ( ) . last ( ) . expect ( "no call frames exist" )
363365 }
364366
365367 #[ inline( always) ]
366368 pub fn frame_mut ( & mut self ) -> & mut Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > {
367- self . stack . last_mut ( ) . expect ( "no call frames exist" )
369+ self . stack_mut ( ) . last_mut ( ) . expect ( "no call frames exist" )
368370 }
369371
370372 #[ inline( always) ]
@@ -595,7 +597,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
595597 return_place : Option < PlaceTy < ' tcx , M :: PointerTag > > ,
596598 return_to_block : StackPopCleanup ,
597599 ) -> InterpResult < ' tcx > {
598- if !self . stack . is_empty ( ) {
600+ if !self . stack ( ) . is_empty ( ) {
599601 info ! ( "PAUSING({}) {}" , self . cur_frame( ) , self . frame( ) . instance) ;
600602 }
601603 :: log_settings:: settings ( ) . indentation += 1 ;
@@ -614,7 +616,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
614616 extra : ( ) ,
615617 } ;
616618 let frame = M :: init_frame_extra ( self , pre_frame) ?;
617- self . stack . push ( frame) ;
619+ self . stack_mut ( ) . push ( frame) ;
618620
619621 // don't allocate at all for trivial constants
620622 if body. local_decls . len ( ) > 1 {
@@ -649,7 +651,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
649651 M :: after_stack_push ( self ) ?;
650652 info ! ( "ENTERING({}) {}" , self . cur_frame( ) , self . frame( ) . instance) ;
651653
652- if self . stack . len ( ) > * self . tcx . sess . recursion_limit . get ( ) {
654+ if self . stack ( ) . len ( ) > * self . tcx . sess . recursion_limit . get ( ) {
653655 throw_exhaust ! ( StackFrameLimitReached )
654656 } else {
655657 Ok ( ( ) )
@@ -719,7 +721,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
719721 ) ;
720722
721723 :: log_settings:: settings ( ) . indentation -= 1 ;
722- let frame = self . stack . pop ( ) . expect ( "tried to pop a stack frame, but there were none" ) ;
724+ let frame =
725+ self . stack_mut ( ) . pop ( ) . expect ( "tried to pop a stack frame, but there were none" ) ;
723726
724727 // Now where do we jump next?
725728
@@ -734,7 +737,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
734737 } ;
735738
736739 if !cleanup {
737- assert ! ( self . stack. is_empty( ) , "only the topmost frame should ever be leaked" ) ;
740+ assert ! ( self . stack( ) . is_empty( ) , "only the topmost frame should ever be leaked" ) ;
738741 assert ! ( next_block. is_none( ) , "tried to skip cleanup when we have a next block!" ) ;
739742 assert ! ( !unwinding, "tried to skip cleanup during unwinding" ) ;
740743 // Leak the locals, skip validation, skip machine hook.
@@ -783,7 +786,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
783786 }
784787 }
785788
786- if !self . stack . is_empty ( ) {
789+ if !self . stack ( ) . is_empty ( ) {
787790 info ! (
788791 "CONTINUING({}) {} (unwinding = {})" ,
789792 self . cur_frame( ) ,
@@ -899,7 +902,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
899902 }
900903 write ! ( msg, ":" ) . unwrap ( ) ;
901904
902- match self . stack [ frame] . locals [ local] . value {
905+ match self . stack ( ) [ frame] . locals [ local] . value {
903906 LocalValue :: Dead => write ! ( msg, " is dead" ) . unwrap ( ) ,
904907 LocalValue :: Uninitialized => write ! ( msg, " is uninitialized" ) . unwrap ( ) ,
905908 LocalValue :: Live ( Operand :: Indirect ( mplace) ) => match mplace. ptr {
0 commit comments