@@ -159,6 +159,21 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
159
159
}
160
160
}
161
161
162
+ impl < ' mir , ' tcx , Tag > Frame < ' mir , ' tcx , Tag > {
163
+ pub fn with_extra < Extra > ( self , extra : Extra ) -> Frame < ' mir , ' tcx , Tag , Extra > {
164
+ Frame {
165
+ body : self . body ,
166
+ instance : self . instance ,
167
+ return_to_block : self . return_to_block ,
168
+ return_place : self . return_place ,
169
+ locals : self . locals ,
170
+ block : self . block ,
171
+ stmt : self . stmt ,
172
+ extra,
173
+ }
174
+ }
175
+ }
176
+
162
177
impl < ' mir , ' tcx , Tag , Extra > Frame < ' mir , ' tcx , Tag , Extra > {
163
178
/// Return the `SourceInfo` of the current instruction.
164
179
pub fn current_source_info ( & self ) -> Option < mir:: SourceInfo > {
@@ -586,8 +601,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
586
601
:: log_settings:: settings ( ) . indentation += 1 ;
587
602
588
603
// first push a stack frame so we have access to the local substs
589
- let extra = M :: stack_push ( self ) ?;
590
- self . stack . push ( Frame {
604
+ let pre_frame = Frame {
591
605
body,
592
606
block : Some ( mir:: START_BLOCK ) ,
593
607
return_to_block,
@@ -597,8 +611,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
597
611
locals : IndexVec :: new ( ) ,
598
612
instance,
599
613
stmt : 0 ,
600
- extra,
601
- } ) ;
614
+ extra : ( ) ,
615
+ } ;
616
+ let frame = M :: init_frame_extra ( self , pre_frame) ?;
617
+ self . stack . push ( frame) ;
602
618
603
619
// don't allocate at all for trivial constants
604
620
if body. local_decls . len ( ) > 1 {
@@ -725,11 +741,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
725
741
}
726
742
727
743
// Cleanup: deallocate all locals that are backed by an allocation.
728
- for local in frame. locals {
744
+ for local in & frame. locals {
729
745
self . deallocate_local ( local. value ) ?;
730
746
}
731
747
732
- if M :: stack_pop ( self , frame. extra , unwinding) ? == StackPopJump :: NoJump {
748
+ let return_place = frame. return_place ;
749
+ if M :: after_stack_pop ( self , frame, unwinding) ? == StackPopJump :: NoJump {
733
750
// The hook already did everything.
734
751
// We want to skip the `info!` below, hence early return.
735
752
return Ok ( ( ) ) ;
@@ -743,7 +760,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
743
760
// Follow the normal return edge.
744
761
// Validate the return value. Do this after deallocating so that we catch dangling
745
762
// references.
746
- if let Some ( return_place) = frame . return_place {
763
+ if let Some ( return_place) = return_place {
747
764
if M :: enforce_validity ( self ) {
748
765
// Data got changed, better make sure it matches the type!
749
766
// It is still possible that the return place held invalid data while
0 commit comments