Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Further analysis to prepare for variable opts.
Track EVAL, getlexouter, and calls.
  • Loading branch information
jnthn committed Apr 11, 2014
1 parent 5bc6b91 commit 48983c2
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Perl6/Optimizer.nqp
Expand Up @@ -372,6 +372,12 @@ my class BlockVarOptimizer {
# immediate block or a declaration block.
has %!usages_inner;

# Have we seen this block (or an inner one) making calls?
has int $!calls;

# Usages of getouterlex.
has @!getlexouter_usages;

# If lowering is, for some reason, poisoned.
has $!poisoned;

Expand All @@ -393,6 +399,12 @@ my class BlockVarOptimizer {
}
}

method register_call() { $!calls++; }

method register_getlexouter($node) {
nqp::push(@!getlexouter_usages, $node);
}

method poison_lowering() { $!poisoned := 1; }

method get_decls() { %!decls }
Expand Down Expand Up @@ -775,7 +787,19 @@ class Perl6::Optimizer {
my $*VOID_CONTEXT := 0;
self.visit_children($op);
}


# Some ops are significant for variable analysis/lowering.
if $optype eq 'getlexouter' {
@!block_var_stack[nqp::elems(@!block_var_stack) - 1].register_getlexouter($op);
}
elsif $optype eq 'call' || $optype eq 'callmethod' || $optype eq 'chain' {
@!block_var_stack[nqp::elems(@!block_var_stack) - 1].register_call();
my str $callee := $op.name;
if $callee eq 'EVAL' || $callee eq 'eval' {
self.poison_var_lowering();
}
}

# Calls are especially interesting as we may wish to do some
# kind of inlining.
if $optype eq 'call' && $op.name ne '' {
Expand Down

0 comments on commit 48983c2

Please sign in to comment.