Skip to content

Commit

Permalink
Start to lower $_ from lexical to local
Browse files Browse the repository at this point in the history
This almost passes spectest, thanks to the various preparatory changes
that were done. It also gives a quite nice speedup on the empty range
benchmark, since the unused `$_` now uses a local, which we can in turn
see is completely unused, and therefore throw out a boxing operation,
thus meaning it can JIT into a rather tighter loop. Alas, it seems that
despite the wins, this costs us something on some benchmarks, which will
need further examination.
  • Loading branch information
jnthn committed Jan 3, 2019
1 parent 6b44c58 commit eb3917c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Perl6/Optimizer.nqp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -666,13 +666,14 @@ my class BlockVarOptimizer {
my str $name := $_.key; my str $name := $_.key;
unless nqp::existskey(%!usages_inner, $name) || unless nqp::existskey(%!usages_inner, $name) ||
nqp::existskey(%!used_in_handle_handler, $name) { nqp::existskey(%!used_in_handle_handler, $name) {
# Lowerable if it's a normal variable. # Lowerable if it's a normal variable, including $_.
next if nqp::chars($name) < 1; next if nqp::chars($name) < 1;
unless nqp::iscclass(nqp::const::CCLASS_ALPHABETIC, $name, 0) { unless nqp::iscclass(nqp::const::CCLASS_ALPHABETIC, $name, 0) {
my str $sigil := nqp::substr($name, 0, 1); my str $sigil := nqp::substr($name, 0, 1);
next unless $sigil eq '$' || $sigil eq '@' || $sigil eq '%'; next unless $sigil eq '$' || $sigil eq '@' || $sigil eq '%';
next unless nqp::chars($name) >= 2 && next unless nqp::chars($name) >= 2 &&
nqp::iscclass(nqp::const::CCLASS_ALPHABETIC, $name, 1); (nqp::iscclass(nqp::const::CCLASS_ALPHABETIC, $name, 1) ||
nqp::eqat($name, '_', 1));
} }


# Also must not lexicalref it. # Also must not lexicalref it.
Expand Down

0 comments on commit eb3917c

Please sign in to comment.