Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't allocate result reg for void calls.
  • Loading branch information
jnthn committed Oct 15, 2012
1 parent 86b5b43 commit ffd25c9
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/QAST/Operations.nqp
Expand Up @@ -876,16 +876,17 @@ QAST::Operations.add_core_op('call', -> $qastcomp, $op {
handle_arg($_, $qastcomp, $ops, @pos_arg_results, @named_arg_results);
}

# Figure out result register type and allocate a register for it.
my $res_type := $qastcomp.type_to_register_type($op.returns);
my $res_reg := $*REGALLOC."fresh_{nqp::lc($res_type)}"();

# Generate call.
# Generate call, with a result register if we're not in void context.
$ops.push($callee);
$ops.push_pirop('call', $callee.result, |@pos_arg_results, |@named_arg_results, :result($res_reg));

# Result is the result of the call.
$ops.result($res_reg);
if $*WANT eq 'v' {
$ops.push_pirop('call', $callee.result, |@pos_arg_results, |@named_arg_results);
}
else {
my $res_type := $qastcomp.type_to_register_type($op.returns);
my $res_reg := $*REGALLOC."fresh_{nqp::lc($res_type)}"();
$ops.push_pirop('call', $callee.result, |@pos_arg_results, |@named_arg_results, :result($res_reg));
$ops.result($res_reg);
}
$ops
});
QAST::Operations.add_core_op('callmethod', :inlinable(1), -> $qastcomp, $op {
Expand Down Expand Up @@ -925,16 +926,18 @@ QAST::Operations.add_core_op('callmethod', :inlinable(1), -> $qastcomp, $op {
}
}

# Figure out result register type and allocate a register for it.
my $res_type := $qastcomp.type_to_register_type($op.returns);
my $res_reg := $*REGALLOC."fresh_{nqp::lc($res_type)}"();

# Generate method call.
# Generate call, with a result register if we're not in void context.
$ops.push($name);
$ops.push_pirop('callmethod', $name.result, |@pos_arg_results, |@named_arg_results, :result($res_reg));

# Result is the result of the call.
$ops.result($res_reg);
if $*WANT eq 'v' {
$ops.push_pirop('callmethod', $name.result, |@pos_arg_results, |@named_arg_results);
}
else {
my $res_type := $qastcomp.type_to_register_type($op.returns);
my $res_reg := $*REGALLOC."fresh_{nqp::lc($res_type)}"();
$ops.push_pirop('callmethod', $name.result, |@pos_arg_results, |@named_arg_results, :result($res_reg));
$ops.result($res_reg);
}

$ops
});

Expand Down

0 comments on commit ffd25c9

Please sign in to comment.