Skip to content

Commit 54df5ca

Browse files
committed
Make the code refs list generation a bunch more efficient. Shaves a little more off CORE.setting compilation.
1 parent 6238e27 commit 54df5ca

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/QAST/Compiler.nqp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class QAST::Compiler is HLL::Compiler {
270270
$block_post
271271
}
272272

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

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

298295
# Overall deserialization QAST.
299296
QAST::Stmt.new(

src/QAST/Operations.nqp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,23 @@ QAST::Operations.add_core_op('list_s', -> $qastcomp, $op {
235235
$ops
236236
});
237237

238+
QAST::Operations.add_core_op('list_b', -> $qastcomp, $op {
239+
# Create register for the resulting list and make an empty one.
240+
my $list_reg := $*REGALLOC.fresh_p();
241+
my $ops := $qastcomp.post_new('Ops', :result($list_reg));
242+
$ops.push_pirop('new', $list_reg, "'ResizablePMCArray'");
243+
244+
# Push all the things.
245+
my $block_reg := $*REGALLOC.fresh_p();
246+
for $op.list {
247+
my $cuid := $_.cuid;
248+
$ops.push_pirop(".const 'Sub' $block_reg = \"$cuid\"");
249+
$ops.push_pirop('push', $list_reg, $block_reg);
250+
}
251+
252+
$ops
253+
});
254+
238255
QAST::Operations.add_core_op('hash', -> $qastcomp, $op {
239256
# Create register for the resulting hash and make an empty one.
240257
my $hash_reg := $*REGALLOC.fresh_p();

0 commit comments

Comments
 (0)