Skip to content

Commit 9772e45

Browse files
committed
Optimize out the string heap when we are not cross compiling.
1 parent ad67a7d commit 9772e45

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/vm/moar/QAST/QASTCompilerMAST.nqp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ my class MASTCompilerInstance {
640640
}
641641
}
642642

643+
# this method is a hook point so that we can override serialization when cross-compiling
643644
method serialize_sc($sc) {
644645
# Serialize it.
645646
my $sh := nqp::list_s();
@@ -648,7 +649,7 @@ my class MASTCompilerInstance {
648649
# Now it's serialized, pop this SC off the compiling SC stack.
649650
nqp::popcompsc();
650651

651-
[$serialized,$sh];
652+
[$serialized, nqp::null()];
652653
}
653654

654655
method deserialization_code($sc, @code_ref_blocks, $repo_conf_res) {
@@ -657,14 +658,21 @@ my class MASTCompilerInstance {
657658
my $sh := $sc_tuple[1];
658659

659660
# String heap QAST.
660-
my $sh_ast := QAST::Op.new( :op('list_s') );
661-
my $sh_elems := nqp::elems($sh);
662-
my $i := 0;
663-
while $i < $sh_elems {
664-
$sh_ast.push(nqp::isnull_s(nqp::atpos_s($sh, $i))
665-
?? QAST::Op.new( :op('null_s') )
666-
!! QAST::SVal.new( :value(nqp::atpos_s($sh, $i)) ));
667-
$i := $i + 1;
661+
my $sh_ast;
662+
663+
if nqp::islist($sh) {
664+
$sh_ast := QAST::Op.new( :op('list_s') );
665+
my $sh_elems := nqp::elems($sh);
666+
my $i := 0;
667+
while $i < $sh_elems {
668+
$sh_ast.push(nqp::isnull_s(nqp::atpos_s($sh, $i))
669+
?? QAST::Op.new( :op('null_s') )
670+
!! QAST::SVal.new( :value(nqp::atpos_s($sh, $i)) ));
671+
$i := $i + 1;
672+
}
673+
}
674+
else {
675+
$sh_ast := QAST::Op.new( :op('null') );
668676
}
669677

670678
# Code references.

0 commit comments

Comments
 (0)