@@ -39,9 +39,6 @@ pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
39
39
/// The virtual memory system.
40
40
pub memory : Memory < ' mir , ' tcx , M > ,
41
41
42
- /// The virtual call stack.
43
- pub ( crate ) stack : Vec < Frame < ' mir , ' tcx , M :: PointerTag , M :: FrameExtra > > ,
44
-
45
42
/// A cache for deduplicating vtables
46
43
pub ( super ) vtables :
47
44
FxHashMap < ( Ty < ' tcx > , Option < ty:: PolyExistentialTraitRef < ' tcx > > ) , Pointer < M :: PointerTag > > ,
@@ -295,7 +292,7 @@ pub(super) fn from_known_layout<'tcx>(
295
292
}
296
293
}
297
294
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 > {
299
296
pub fn new (
300
297
tcx : TyCtxtAt < ' tcx > ,
301
298
param_env : ty:: ParamEnv < ' tcx > ,
@@ -307,7 +304,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
307
304
tcx,
308
305
param_env,
309
306
memory : Memory :: new ( tcx, memory_extra) ,
310
- stack : Vec :: new ( ) ,
311
307
vtables : FxHashMap :: default ( ) ,
312
308
}
313
309
}
@@ -348,23 +344,29 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
348
344
349
345
#[ inline( always) ]
350
346
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 )
352
353
}
353
354
354
355
#[ inline( always) ]
355
356
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
358
360
}
359
361
360
362
#[ inline( always) ]
361
363
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" )
363
365
}
364
366
365
367
#[ inline( always) ]
366
368
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" )
368
370
}
369
371
370
372
#[ inline( always) ]
@@ -595,7 +597,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
595
597
return_place : Option < PlaceTy < ' tcx , M :: PointerTag > > ,
596
598
return_to_block : StackPopCleanup ,
597
599
) -> InterpResult < ' tcx > {
598
- if !self . stack . is_empty ( ) {
600
+ if !self . stack ( ) . is_empty ( ) {
599
601
info ! ( "PAUSING({}) {}" , self . cur_frame( ) , self . frame( ) . instance) ;
600
602
}
601
603
:: log_settings:: settings ( ) . indentation += 1 ;
@@ -614,7 +616,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
614
616
extra : ( ) ,
615
617
} ;
616
618
let frame = M :: init_frame_extra ( self , pre_frame) ?;
617
- self . stack . push ( frame) ;
619
+ self . stack_mut ( ) . push ( frame) ;
618
620
619
621
// don't allocate at all for trivial constants
620
622
if body. local_decls . len ( ) > 1 {
@@ -649,7 +651,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
649
651
M :: after_stack_push ( self ) ?;
650
652
info ! ( "ENTERING({}) {}" , self . cur_frame( ) , self . frame( ) . instance) ;
651
653
652
- if self . stack . len ( ) > * self . tcx . sess . recursion_limit . get ( ) {
654
+ if self . stack ( ) . len ( ) > * self . tcx . sess . recursion_limit . get ( ) {
653
655
throw_exhaust ! ( StackFrameLimitReached )
654
656
} else {
655
657
Ok ( ( ) )
@@ -719,7 +721,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
719
721
) ;
720
722
721
723
:: 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" ) ;
723
726
724
727
// Now where do we jump next?
725
728
@@ -734,7 +737,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
734
737
} ;
735
738
736
739
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" ) ;
738
741
assert ! ( next_block. is_none( ) , "tried to skip cleanup when we have a next block!" ) ;
739
742
assert ! ( !unwinding, "tried to skip cleanup during unwinding" ) ;
740
743
// Leak the locals, skip validation, skip machine hook.
@@ -783,7 +786,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
783
786
}
784
787
}
785
788
786
- if !self . stack . is_empty ( ) {
789
+ if !self . stack ( ) . is_empty ( ) {
787
790
info ! (
788
791
"CONTINUING({}) {} (unwinding = {})" ,
789
792
self . cur_frame( ) ,
@@ -899,7 +902,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
899
902
}
900
903
write ! ( msg, ":" ) . unwrap ( ) ;
901
904
902
- match self . stack [ frame] . locals [ local] . value {
905
+ match self . stack ( ) [ frame] . locals [ local] . value {
903
906
LocalValue :: Dead => write ! ( msg, " is dead" ) . unwrap ( ) ,
904
907
LocalValue :: Uninitialized => write ! ( msg, " is uninitialized" ) . unwrap ( ) ,
905
908
LocalValue :: Live ( Operand :: Indirect ( mplace) ) => match mplace. ptr {
0 commit comments