Skip to content
Permalink
Browse files

Correct tracking of vars used in `handle` handler

We need to propagate information about this outward. A previous fix for
this issue actually wasn't a real fix, and just pessimized enough in
order to not run into the real problem. This fixes it properly, gaining
back lost performance.
  • Loading branch information...
jnthn committed Jan 7, 2019
1 parent 541a4f1 commit d2df5b805db39e1deee23a62d4d7b1c444ca9c7c
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/Perl6/Optimizer.nqp
@@ -519,6 +519,17 @@ my class BlockVarOptimizer {

method is_poisoned() { $!poisoned }

method get_escaping_handler_vars() {
my @esc;
for %!used_in_handle_handler {
my $name := $_.key;
unless %!decls{$name} {
@esc.push($name);
}
}
return @esc;
}

method incorporate_inner($vars_info, $flattened) {
# We'll exclude anything that the inner or flattened thing has as
# a declaration, since those are its own.
@@ -549,6 +560,11 @@ my class BlockVarOptimizer {
nqp::push(%target{$name}, $_);
}

# Also need to copy handler usages.
for $vars_info.get_escaping_handler_vars() {
%!used_in_handle_handler{$_} := 1;
}

# Add up call counts.
$!calls := $!calls + $vars_info.get_calls;

@@ -2797,7 +2813,7 @@ class Perl6::Optimizer {
else {
note("Non-QAST node visited " ~ $visit.HOW.name($visit)) if $!debug;
}
if $handle {
if $handle && $i > 0 {
@!block_var_stack[nqp::elems(@!block_var_stack) - 1].entering_handle_handler();
}
if nqp::istype($visit, QAST::Op) {

0 comments on commit d2df5b8

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