Skip to content
Permalink
Browse files

Start to lower $_ from lexical to local

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 eb3917c260bce1cb56e2ee40abebd12c4dbcd9b2
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Perl6/Optimizer.nqp
@@ -666,13 +666,14 @@ my class BlockVarOptimizer {
my str $name := $_.key;
unless nqp::existskey(%!usages_inner, $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;
unless nqp::iscclass(nqp::const::CCLASS_ALPHABETIC, $name, 0) {
my str $sigil := nqp::substr($name, 0, 1);
next unless $sigil eq '$' || $sigil eq '@' || $sigil eq '%';
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.

0 comments on commit eb3917c

Please sign in to comment.
You can’t perform that action at this time.