Skip to content

Commit 50cae66

Browse files
committed
fix regressions by adding exception category for labels
1 parent 5e3e216 commit 50cae66

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ my $EX_CAT_PROCEED := 256;
8181
my $EX_CAT_CONTROL := $EX_CAT_NEXT +| $EX_CAT_REDO +| $EX_CAT_LAST +|
8282
$EX_CAT_TAKE +| $EX_CAT_WARN +|
8383
$EX_CAT_SUCCEED +| $EX_CAT_PROCEED;
84+
my $EX_CAT_LABELED := 4096;
8485

8586
# Exception handler kinds.
8687
my $EX_UNWIND_SIMPLE := 0;
@@ -1066,7 +1067,7 @@ for ('', 'repeat_') -> $repness {
10661067
my $l_handler_id;
10671068
my $nr_handler_id;
10681069
if $handler {
1069-
$l_handler_id := &*REGISTER_UNWIND_HANDLER($*HANDLER_IDX, $EX_CAT_LAST, :ex_obj(1));
1070+
$l_handler_id := &*REGISTER_UNWIND_HANDLER($*HANDLER_IDX, $EX_CAT_LAST, :ex_obj(1));
10701071
$nr_handler_id := &*REGISTER_UNWIND_HANDLER($l_handler_id, $EX_CAT_NEXT +| $EX_CAT_REDO, :ex_obj(1));
10711072
}
10721073

@@ -1133,6 +1134,8 @@ for ('', 'repeat_') -> $repness {
11331134
$qastcomp.unwind_check($catch, $nr_handler_id, :$label, :outer($l_handler_id));
11341135
$catch.append(JAST::Instruction.new( :op('getfield'), $TYPE_EX_UNWIND, 'category', 'Long' ));
11351136
$catch.append(JAST::PushIVal.new( :value($EX_CAT_REDO) ));
1137+
$catch.append(JAST::Instruction.new( :op('land') ));
1138+
$catch.append(JAST::PushIVal.new( :value($EX_CAT_REDO) ));
11361139
$catch.append($LCMP);
11371140
$catch.append(JAST::Instruction.new( :op('ifeq'), $redo_lbl ));
11381141
$body_il := $qastcomp.delimit_handler(
@@ -1712,7 +1715,10 @@ QAST::OperationsJAST.add_core_op('handle', :!inlinable, sub ($qastcomp, $op) {
17121715
my %control_map := nqp::hash(
17131716
'next', $EX_CAT_NEXT,
17141717
'last', $EX_CAT_LAST,
1715-
'redo', $EX_CAT_REDO
1718+
'redo', $EX_CAT_REDO,
1719+
'next_label', $EX_CAT_NEXT +| $EX_CAT_LABELED,
1720+
'last_label', $EX_CAT_LAST +| $EX_CAT_LABELED,
1721+
'redo_label', $EX_CAT_REDO +| $EX_CAT_LABELED
17161722
);
17171723
QAST::OperationsJAST.add_core_op('control', -> $qastcomp, $op {
17181724
my $label;
@@ -1721,10 +1727,10 @@ QAST::OperationsJAST.add_core_op('control', -> $qastcomp, $op {
17211727
}
17221728
my $name := $op.name;
17231729
if nqp::existskey(%control_map, $name) {
1724-
my $cat := %control_map{$name};
17251730
my $il := JAST::InstructionList.new();
17261731
$*STACK.spill_to_locals($il);
17271732
if $label {
1733+
my $cat := %control_map{$name ~ '_label'};
17281734
my $new_ex := $*TA.fresh_o();
17291735

17301736
# Create a new exception object
@@ -1758,6 +1764,7 @@ QAST::OperationsJAST.add_core_op('control', -> $qastcomp, $op {
17581764
'_throw_c', 'Void', $TYPE_SMO, $TYPE_TC )));
17591765
}
17601766
else {
1767+
my $cat := %control_map{$name};
17611768
$il.append(JAST::PushIVal.new( :value($cat) ));
17621769
$il.append($ALOAD_1);
17631770
$il.append(savesite(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS,

src/vm/jvm/runtime/org/perl6/nqp/runtime/ExceptionHandling.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ExceptionHandling {
1818
public static final int EX_CAT_TAKE = 32;
1919
public static final int EX_CAT_WARN = 64;
2020
public static final int EX_CAT_SUCCEED = 128;
21-
public static final int EX_CAT_PROCEED = 256;
21+
public static final int EX_CAT_LABELED = 4096;
2222

2323
/* Exception handler kinds. */
2424
public static final int EX_UNWIND_SIMPLE = 0;
@@ -139,7 +139,6 @@ private static void invokeHandler(ThreadContext tc, long[] handlerInfo,
139139
tc.unwinder.unwindTarget = handlerInfo[0];
140140
tc.unwinder.unwindCompUnit = handlerFrame.codeRef.staticInfo.compUnit;
141141
tc.unwinder.category = category;
142-
tc.unwinder.result = null;
143142
throw tc.unwinder;
144143
case EX_UNWIND_OBJECT:
145144
tc.unwinder.unwindTarget = handlerInfo[0];

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4529,9 +4529,12 @@ public static void _throw_c(SixModelObject obj, ThreadContext tc) {
45294529
}
45304530
}
45314531
public static void _is_same_label(UnwindException uwex, long where, long outerHandler, ThreadContext tc) {
4532+
if ((uwex.category & ExceptionHandling.EX_CAT_LABELED) == 0)
4533+
return;
4534+
45324535
if (uwex instanceof UnwindException) {
45334536
VMExceptionInstance vmex = (VMExceptionInstance)uwex.result;
4534-
if (vmex == null)
4537+
if (vmex == null || (vmex.category & ExceptionHandling.EX_CAT_LABELED) == 0)
45354538
return;
45364539

45374540
if (vmex instanceof VMExceptionInstance) {

0 commit comments

Comments
 (0)