Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perform the immediate block inlining more often.
Previously, dynamic compilation meant we didn't do it as we might
mess up closures taking at BEGIN time. However, that was overly
pessimistic. We can in fact perform the optimization provided no
possible closures exist to have been taken at BEGIN time. Improves
quality of code in CORE.setting a good bit, knocking 4 GC runs and
2.5% of the runtime off Text::CSV, for example.
  • Loading branch information
jnthn committed Sep 14, 2015
1 parent b4a9f56 commit 7e265b6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Perl6/Optimizer.nqp
Expand Up @@ -927,8 +927,7 @@ class Perl6::Optimizer {
my int $flattened := 0;
my $result := $block;
if $block.blocktype eq 'immediate' && $block.arity == 0
&& !$*DYNAMICALLY_COMPILED && !$vars_info.is_poisoned
&& !$block.has_exit_handler {
&& !$vars_info.is_poisoned && !$block.has_exit_handler {
# Scan symbols for any non-interesting ones.
my @sigsyms;
for $block.symtable() {
Expand All @@ -937,6 +936,16 @@ class Perl6::Optimizer {
@sigsyms.push($name);
}
}

# If we dynamically compiled it, then it must not contain
# any nested blocks.
if $*DYNAMICALLY_COMPILED {
for $block[0].list {
if nqp::istype($_, QAST::Block) && $_.blocktype ne 'raw' {
@sigsyms.push('');
}
}
}

# If we have no interesting ones, then we can inline the
# statements.
Expand Down

0 comments on commit 7e265b6

Please sign in to comment.