Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make the code refs list generation a bunch more efficient. Shaves a l…
…ittle more off CORE.setting compilation.
  • Loading branch information
jnthn committed Jul 25, 2012
1 parent 6238e27 commit 54df5ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/QAST/Compiler.nqp
Expand Up @@ -270,7 +270,7 @@ class QAST::Compiler is HLL::Compiler {
$block_post
}

method deserialization_code($sc, $code_ref_blocks) {
method deserialization_code($sc, @code_ref_blocks) {
# Serialize it.
my $sh := pir::new__Ps('ResizableStringArray');
my $serialized := pir::nqp_serialize_sc__SPP($sc, $sh);
Expand All @@ -290,10 +290,7 @@ class QAST::Compiler is HLL::Compiler {
}

# Code references.
my $cr_past := QAST::Op.new( :op('list') );
for $code_ref_blocks -> $block {
$cr_past.push(QAST::BVal.new( :value($block) ));
}
my $cr_past := QAST::Op.new( :op('list_b'), |@code_ref_blocks );

# Overall deserialization QAST.
QAST::Stmt.new(
Expand Down
17 changes: 17 additions & 0 deletions src/QAST/Operations.nqp
Expand Up @@ -235,6 +235,23 @@ QAST::Operations.add_core_op('list_s', -> $qastcomp, $op {
$ops
});

QAST::Operations.add_core_op('list_b', -> $qastcomp, $op {
# Create register for the resulting list and make an empty one.
my $list_reg := $*REGALLOC.fresh_p();
my $ops := $qastcomp.post_new('Ops', :result($list_reg));
$ops.push_pirop('new', $list_reg, "'ResizablePMCArray'");

# Push all the things.
my $block_reg := $*REGALLOC.fresh_p();
for $op.list {
my $cuid := $_.cuid;
$ops.push_pirop(".const 'Sub' $block_reg = \"$cuid\"");
$ops.push_pirop('push', $list_reg, $block_reg);
}

$ops
});

QAST::Operations.add_core_op('hash', -> $qastcomp, $op {
# Create register for the resulting hash and make an empty one.
my $hash_reg := $*REGALLOC.fresh_p();
Expand Down

0 comments on commit 54df5ca

Please sign in to comment.