Skip to content

Commit e76f290

Browse files
committed
replace op throwlabel by throwdyn for labels
1 parent 6d8fc83 commit e76f290

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/vm/moar/QAST/QASTOperationsMAST.nqp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,14 +1629,20 @@ QAST::MASTOperations.add_core_op('control', -> $qastcomp, $op {
16291629

16301630
if nqp::existskey(%control_map, $name) {
16311631
if $label {
1632-
my $where := nqp::where($label.value);
1633-
my $res := $*REGALLOC.fresh_register($MVM_reg_obj);
1634-
MAST::InstructionList.new(
1635-
[MAST::Op.new( :op('throwlabel'), $res,
1636-
MAST::IVal.new( :value(%control_map{$name} + $HandlerCategory::labeled) ),
1637-
MAST::IVal.new( :value($where) )
1638-
)],
1639-
$res, $MVM_reg_obj)
1632+
# Create an exception object, and attach the label to its payload.
1633+
my $res := $*REGALLOC.fresh_register($MVM_reg_obj);
1634+
my $ex := $*REGALLOC.fresh_register($MVM_reg_obj);
1635+
my $lbl := $qastcomp.as_mast($label, :want($MVM_reg_obj));
1636+
my $cat := $*REGALLOC.fresh_register($MVM_reg_int64);
1637+
my $il := MAST::InstructionList.new(nqp::list(), $res, $MVM_reg_obj);
1638+
$il.append($lbl);
1639+
push_op($il.instructions, 'newexception', $ex);
1640+
push_op($il.instructions, 'bindexpayload', $ex, $lbl.result_reg );
1641+
push_op($il.instructions, 'const_i64', $cat,
1642+
MAST::IVal.new( :value(%control_map{$name} + $HandlerCategory::labeled) ) );
1643+
push_op($il.instructions, 'bindexcategory', $ex, $cat );
1644+
push_op($il.instructions, 'throwdyn', $res, $ex);
1645+
$il
16401646
}
16411647
else {
16421648
my $il := nqp::list();

0 commit comments

Comments
 (0)