Skip to content

Commit

Permalink
Immediate blocks don't need a $*DISPATCHER.
Browse files Browse the repository at this point in the history
This also saves the takedispatcher instruction in all of them. Adds up
34KB saving on CORE.setting.moarvm, and a some thousands less QAST
nodes during compilation. Also means less instructions to execute at
runtime.
  • Loading branch information
jnthn committed Apr 11, 2014
1 parent 99671e9 commit 319509a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Perl6/Actions.nqp
Expand Up @@ -972,13 +972,6 @@ class Perl6::Actions is HLL::Actions does STDActions {
set_default_parameter_type(@params, 'Mu');
my $signature := create_signature_object($<signature>, %sig_info, $block);
add_signature_binding_code($block, $signature, @params);

# Add a slot for a $*DISPATCHER, and a call to take one.
$block[0].push(QAST::Var.new( :name('$*DISPATCHER'), :scope('lexical'), :decl('var') ));
$block[0].push(QAST::Op.new(
:op('takedispatcher'),
QAST::SVal.new( :value('$*DISPATCHER') )
));

# We'll install PAST in current block so it gets capture_lex'd.
# Then evaluate to a reference to the block (non-closure - higher
Expand Down Expand Up @@ -1592,8 +1585,17 @@ class Perl6::Actions is HLL::Actions does STDActions {
method term:sym<type_declarator>($/) { make $<type_declarator>.ast; }
method term:sym<circumfix>($/) { make $<circumfix>.ast; }
method term:sym<statement_prefix>($/) { make $<statement_prefix>.ast; }
method term:sym<lambda>($/) { make block_closure($<pblock>.ast); }
method term:sym<sigterm>($/) { make $<sigterm>.ast; }
method term:sym<lambda>($/) {
my $ast := $<pblock>.ast;
my $block := $ast<past_block>;
$block[0].push(QAST::Var.new( :name('$*DISPATCHER'), :scope('lexical'), :decl('var') ));
$block[0].push(QAST::Op.new(
:op('takedispatcher'),
QAST::SVal.new( :value('$*DISPATCHER') )
));
make block_closure($ast);
}
method term:sym<unquote>($/) {
make QAST::Unquote.new(:position(+@*UNQUOTE_ASTS));
@*UNQUOTE_ASTS.push($<statementlist>.ast);
Expand Down Expand Up @@ -4696,6 +4698,12 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
}
else {
my $block := $past<past_block>;
$block[0].push(QAST::Var.new( :name('$*DISPATCHER'), :scope('lexical'), :decl('var') ));
$block[0].push(QAST::Op.new(
:op('takedispatcher'),
QAST::SVal.new( :value('$*DISPATCHER') )
));
$past := block_closure($past);
$past<bare_block> := QAST::Op.new(
:op('call'),
Expand Down

0 comments on commit 319509a

Please sign in to comment.