Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disable an optimization on Moar that pessimizes.
What is on most backends a help gets in the way of spesh doing its
thing with multi-dispatches and inlining. For now, just don't do it
on Moar.
  • Loading branch information
jnthn committed Jul 26, 2014
1 parent 1d2bb62 commit 9a56a2c
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions src/Perl6/Optimizer.nqp
Expand Up @@ -1665,28 +1665,39 @@ class Perl6::Optimizer {
}

# If we decide a dispatch at compile time, this emits the direct call.
# Note that we do not do this on MoarVM, since it can actually make a
# much better job of these than we are able to here and we don't have a
# way to convey the choice.
method call_ct_chosen_multi($call, $proto, $chosen) {
my @cands := $proto.dispatchees();
my int $idx := 0;
for @cands {
if $_ =:= $chosen {
$call.unshift(QAST::Op.new(
:op('atpos'),
QAST::Var.new(
:name('$!dispatchees'), :scope('attribute'),
QAST::Var.new( :name($call.name), :scope('lexical') ),
QAST::WVal.new( :value($!symbols.find_lexical('Routine')) )
),
QAST::IVal.new( :value($idx) )
));
$call.name(NQPMu);
$call.op('call');
#say("# Compile-time resolved a call to " ~ $proto.name);
last;
if nqp::getcomp('perl6').backend.name ne 'moar' {
my @cands := $proto.dispatchees();
my int $idx := 0;
for @cands {
if $_ =:= $chosen {
$call.unshift(QAST::Op.new(
:op('atpos'),
QAST::Var.new(
:name('$!dispatchees'), :scope('attribute'),
QAST::Var.new( :name($call.name), :scope('lexical') ),
QAST::WVal.new( :value($!symbols.find_lexical('Routine')) )
),
QAST::IVal.new( :value($idx) )
));
$call.name(NQPMu);
$call.op('call');
#say("# Compile-time resolved a call to " ~ $proto.name);
last;
}
$idx := $idx + 1;
}
$call := copy_returns($call, $chosen);
}
else {
my $scopes := $!symbols.scopes_in($call.name);
if $scopes == 0 || $scopes == 1 && nqp::can($proto, 'soft') && !$proto.soft {
$call.op('callstatic');
}
$idx := $idx + 1;
}
$call := copy_returns($call, $chosen);
$call
}

Expand Down

0 comments on commit 9a56a2c

Please sign in to comment.