@@ -547,11 +547,15 @@ for ('', 'repeat_') -> $repness {
547
547
# Emit the prelude.
548
548
my $ ops := PIRT::Ops. new ();
549
549
$ ops . result($ res_reg );
550
- my $ exc_reg := $ * REGALLOC . fresh_p();
551
- $ ops . push_pirop(' new' , $ exc_reg , " 'ExceptionHandler'" ,
552
- ' [.CONTROL_LOOP_NEXT;.CONTROL_LOOP_REDO;.CONTROL_LOOP_LAST]' );
553
- $ ops . push_pirop(' set_label' , $ exc_reg , $ hand_lbl );
554
- $ ops . push_pirop(' push_eh' , $ exc_reg );
550
+
551
+ my $ exc_reg ;
552
+ if $ handler {
553
+ $ exc_reg := $ * REGALLOC . fresh_p();
554
+ $ ops . push_pirop(' new' , $ exc_reg , " 'ExceptionHandler'" ,
555
+ ' [.CONTROL_LOOP_NEXT;.CONTROL_LOOP_REDO;.CONTROL_LOOP_LAST]' );
556
+ $ ops . push_pirop(' set_label' , $ exc_reg , $ hand_lbl );
557
+ $ ops . push_pirop(' push_eh' , $ exc_reg );
558
+ }
555
559
556
560
# Test the condition and jump to the loop end if it's
557
561
# not met.
@@ -590,15 +594,17 @@ for ('', 'repeat_') -> $repness {
590
594
$ ops . push_pirop(' goto ' ~ $ test_lbl . result);
591
595
592
596
# Emit postlude, with exception handlers.
593
- $ ops . push ($ hand_lbl );
594
- $ ops . push_pirop(' .get_results' , ' (' ~ $ exc_reg ~ ' )' );
595
- $ ops . push_pirop(' pop_upto_eh' , $ exc_reg );
596
- $ ops . push_pirop(' getattribute' , $ exc_reg , $ exc_reg , " 'type'" );
597
- $ ops . push_pirop(' eq' , $ exc_reg , ' .CONTROL_LOOP_NEXT' ,
598
- $ operands == 3 ?? $ next_lbl !! $ test_lbl );
599
- $ ops . push_pirop(' eq' , $ exc_reg , ' .CONTROL_LOOP_REDO' , $ redo_lbl );
600
- $ ops . push ($ done_lbl );
601
- $ ops . push_pirop(' pop_eh' );
597
+ if $ handler {
598
+ $ ops . push ($ hand_lbl );
599
+ $ ops . push_pirop(' .get_results' , ' (' ~ $ exc_reg ~ ' )' );
600
+ $ ops . push_pirop(' pop_upto_eh' , $ exc_reg );
601
+ $ ops . push_pirop(' getattribute' , $ exc_reg , $ exc_reg , " 'type'" );
602
+ $ ops . push_pirop(' eq' , $ exc_reg , ' .CONTROL_LOOP_NEXT' ,
603
+ $ operands == 3 ?? $ next_lbl !! $ test_lbl );
604
+ $ ops . push_pirop(' eq' , $ exc_reg , ' .CONTROL_LOOP_REDO' , $ redo_lbl );
605
+ $ ops . push ($ done_lbl );
606
+ $ ops . push_pirop(' pop_eh' );
607
+ }
602
608
603
609
$ ops ;
604
610
});
0 commit comments