summaryrefslogtreecommitdiff
path: root/ext/B
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2012-11-02 14:37:29 +0000
committerDavid Mitchell <davem@iabyn.com>2012-11-10 13:39:33 +0000
commit4774ee0a8f9bc16a2ee4d1603401c927d02c41bc (patch)
treead7a99dc1415fd9cd536d4612c591c7fd0b0a44e /ext/B
parentd5524600caf9e8c470e731c4f5a924868154645a (diff)
downloadperl-4774ee0a8f9bc16a2ee4d1603401c927d02c41bc.tar.gz
Consolidate adjacent padrange ops
In something like my ($a,$b); my ($c,$d); when converting $c,$d into a padrange op, check first whether we're immediately preceded by a similar padrange (and nextstate) op, and if so re-use the existing padrange op (by increasing the count). Also, skip the first nextstate and only use the second nextstate. So pushmark; padsv[$a]; padsv[$b]; list; nextstate 1; pushmark; padsv[$c]; padsv[$c]; list; nextstate 2; becomes padrange[$a,$b] nextstate 1; pushmark; padsv[$c]; padsv[$c]; list; nextstate 2; which then becomes padrange[$a,$b,$c,$d]; nextstate 2;
Diffstat (limited to 'ext/B')
-rw-r--r--ext/B/t/optree_misc.t39
1 files changed, 38 insertions, 1 deletions
diff --git a/ext/B/t/optree_misc.t b/ext/B/t/optree_misc.t
index 277d315ee1..648539b508 100644
--- a/ext/B/t/optree_misc.t
+++ b/ext/B/t/optree_misc.t
@@ -10,7 +10,7 @@ BEGIN {
}
use OptreeCheck;
use Config;
-plan tests => 12;
+plan tests => 14;
SKIP: {
skip "no perlio in this build", 4 unless $Config::Config{useperlio};
@@ -330,4 +330,41 @@ EOT_EOT
# - <0> padsv[$f:3,4] lRM*/LVINTRO ->-
EONT_EONT
+checkOptree ( name => 'consolidate padranges',
+ code => sub { my ($a,$b); my ($c,$d); 1 },
+ strip_open_hints => 1,
+ skip => ($] < 5.017006),
+ expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
+# 5 <1> leavesub[1 ref] K/REFC,1 ->(end)
+# - <@> lineseq KP ->5
+# 1 <;> nextstate(main 900 optree_misc.t:334) v ->2
+# - <@> list vKP ->-
+# 2 <0> padrange[$a:900,902; $b:900,902; $c:901,902; $d:901,902] vM/LVINTRO,4 ->3
+# - <0> padsv[$a:900,902] vM/LVINTRO ->-
+# - <0> padsv[$b:900,902] vM/LVINTRO ->-
+# - <;> nextstate(main 901 optree_misc.t:334) v ->-
+# - <@> list vKP ->3
+# - <0> pushmark vM/LVINTRO ->-
+# - <0> padsv[$c:901,902] vM/LVINTRO ->-
+# - <0> padsv[$d:901,902] vM/LVINTRO ->-
+# 3 <;> nextstate(main 902 optree_misc.t:334) v:{ ->4
+# 4 <$> const[IV 1] s ->5
+EOT_EOT
+# 5 <1> leavesub[1 ref] K/REFC,1 ->(end)
+# - <@> lineseq KP ->5
+# 1 <;> nextstate(main 900 optree_misc.t:334) v ->2
+# - <@> list vKP ->-
+# 2 <0> padrange[$a:900,902; $b:900,902; $c:901,902; $d:901,902] vM/LVINTRO,4 ->3
+# - <0> padsv[$a:900,902] vM/LVINTRO ->-
+# - <0> padsv[$b:900,902] vM/LVINTRO ->-
+# - <;> nextstate(main 901 optree_misc.t:334) v ->-
+# - <@> list vKP ->3
+# - <0> pushmark vM/LVINTRO ->-
+# - <0> padsv[$c:901,902] vM/LVINTRO ->-
+# - <0> padsv[$d:901,902] vM/LVINTRO ->-
+# 3 <;> nextstate(main 902 optree_misc.t:334) v:{ ->4
+# 4 <$> const(IV 1) s ->5
+EONT_EONT
+
+
unlink $tmpfile;