Skip to content

Commit

Permalink
Specialize compilation of defor to fix bugs.
Browse files Browse the repository at this point in the history
This makes defor use a call to .defined, not go via the Parrot v-table
function. There were some inconsistencies there somehow for roles and
modules; this makes sure defor will never give results inconsistent
with .defined.
  • Loading branch information
jnthn committed Jan 11, 2013
1 parent 46913d6 commit dfefd94
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Perl6/Ops.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ $ops.add_hll_op('perl6', 'p6bool', :inlinable(1), -> $qastcomp, $op {
$ops
});

# Override defor to avoid v-table call.
$ops.add_hll_op('perl6', 'defor', :inlinable(1), -> $qastcomp, $op {
if +$op.list != 2 {
nqp::die("Operation 'defor' needs 2 operands");
}
my $ops := PIRT::Ops.new();
my $lbl := PIRT::Label.new(:name('defor'));
my $dreg := $*REGALLOC.fresh_p();
my $rreg := $*REGALLOC.fresh_p();
my $test := $qastcomp.coerce($qastcomp.as_post($op[0]), 'P');
my $then := $qastcomp.coerce($qastcomp.as_post($op[1]), 'P');
$ops.push($test);
$ops.push_pirop('set', $rreg, $test);
$ops.push_pirop('callmethod', "'defined'", $rreg, :result($dreg));
$ops.push_pirop('if', $dreg, $lbl);
$ops.push($then);
$ops.push_pirop('set', $rreg, $then);
$ops.push($lbl);
$ops.result($rreg);
$ops
});

# Boxing and unboxing configuration.
QAST::Operations.add_hll_box('perl6', 'i', -> $qastcomp, $post {
my $reg := $*REGALLOC.fresh_p();
Expand Down

0 comments on commit dfefd94

Please sign in to comment.