@@ -21,7 +21,7 @@ use rustc_span::source_map::{self, Span, DUMMY_SP};
21
21
22
22
use super :: {
23
23
Immediate , MPlaceTy , Machine , MemPlace , MemPlaceMeta , Memory , OpTy , Operand , Place , PlaceTy ,
24
- ScalarMaybeUndef , StackPopInfo ,
24
+ ScalarMaybeUndef , StackPopJump ,
25
25
} ;
26
26
27
27
pub struct InterpCx < ' mir , ' tcx , M : Machine < ' mir , ' tcx > > {
@@ -623,31 +623,24 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
623
623
624
624
:: log_settings:: settings ( ) . indentation -= 1 ;
625
625
let frame = self . stack . pop ( ) . expect ( "tried to pop a stack frame, but there were none" ) ;
626
- let stack_pop_info = M :: stack_pop ( self , frame. extra , unwinding) ?;
627
- if let ( false , StackPopInfo :: StopUnwinding ) = ( unwinding, stack_pop_info) {
628
- bug ! ( "Attempted to stop unwinding while there is no unwinding!" ) ;
629
- }
630
626
631
627
// Now where do we jump next?
632
628
633
- // Determine if we leave this function normally or via unwinding.
634
- let cur_unwinding =
635
- if let StackPopInfo :: StopUnwinding = stack_pop_info { false } else { unwinding } ;
636
-
637
629
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
638
630
// In that case, we return early. We also avoid validation in that case,
639
631
// because this is CTFE and the final value will be thoroughly validated anyway.
640
632
let ( cleanup, next_block) = match frame. return_to_block {
641
633
StackPopCleanup :: Goto { ret, unwind } => {
642
- ( true , Some ( if cur_unwinding { unwind } else { ret } ) )
634
+ ( true , Some ( if unwinding { unwind } else { ret } ) )
643
635
}
644
636
StackPopCleanup :: None { cleanup, .. } => ( cleanup, None ) ,
645
637
} ;
646
638
647
639
if !cleanup {
648
640
assert ! ( self . stack. is_empty( ) , "only the topmost frame should ever be leaked" ) ;
649
641
assert ! ( next_block. is_none( ) , "tried to skip cleanup when we have a next block!" ) ;
650
- // Leak the locals, skip validation.
642
+ assert ! ( !unwinding, "tried to skip cleanup during unwinding" ) ;
643
+ // Leak the locals, skip validation, skip machine hook.
651
644
return Ok ( ( ) ) ;
652
645
}
653
646
@@ -656,13 +649,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
656
649
self . deallocate_local ( local. value ) ?;
657
650
}
658
651
659
- trace ! (
660
- "StackPopCleanup: {:?} StackPopInfo: {:?} cur_unwinding = {:?}" ,
661
- frame . return_to_block ,
662
- stack_pop_info ,
663
- cur_unwinding
664
- ) ;
665
- if cur_unwinding {
652
+ if M :: stack_pop ( self , frame . extra , unwinding ) ? == StackPopJump :: NoJump {
653
+ // The hook already did everything.
654
+ // We want to skip the `info!` below, hence early return.
655
+ return Ok ( ( ) ) ;
656
+ }
657
+ // Normal return.
658
+ if unwinding {
666
659
// Follow the unwind edge.
667
660
let unwind = next_block. expect ( "Encountered StackPopCleanup::None when unwinding!" ) ;
668
661
self . unwind_to_block ( unwind) ;
@@ -697,7 +690,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
697
690
"CONTINUING({}) {} (unwinding = {})" ,
698
691
self . cur_frame( ) ,
699
692
self . frame( ) . instance,
700
- cur_unwinding
693
+ unwinding
701
694
) ;
702
695
}
703
696
0 commit comments