Subject: | 'extend-c' do not extend 'C'. Some optimizations are missing. |
The default optimized 'C' returns me this:
h <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 3147 xs.pl:10) v:{ ->3
8 <2> aassign[t2] vKS ->9
- <1> ex-list lKP ->6
3 <0> pushmark s ->4
4 <$> const(IV 3) s ->5
5 <$> const(IV 4) s ->6
- <1> ex-list lK ->8
6 <0> pushmark s ->7
7 <0> padav[@yy:3147,3149] lRM*/LVINTRO ->8
- <0> ex-nextstate v ->-
- <0> ex-const v ->-
- <0> ex-nextstate v ->-
- <0> ex-const v ->-
- <0> ex-nextstate v ->-
- <0> ex-const v ->9
9 <;> nextstate(main 3148 xs.pl:14) v:{ ->a
g <2> aassign[t5] vKS/COM_RC1,COM_AGG ->h
- <1> ex-list lKP ->f
a <0> pushmark s ->b
b <$> const(IV 1) s ->c
c <$> const(IV 2) s ->d
d <0> padav[@yy:3147,3149] l ->e
e <$> const(IV 3) s ->f
- <1> ex-list lKPRM* ->g
f <0> padrange[$x:3148,3149; @xx:3148,3149] RM/LVINTRO,2 ->g
- <0> padsv[$x:3148,3149] sRM*/LVINTRO ->-
- <0> padav[@xx:3148,3149] lRM*/LVINTRO ->-
DOC states:
extend-c
Use the standard optimizer with an extra callback. This is the most compatible optimizer version.
For next code:
#!/usr/bin/env perl
use DDP;
use optimizer 'extend-c' => sub {
my $op = shift;
print $op->name, "\n";
print 'STASH: ', $op->stash->NAME, "\n" if $op->name eq 'nextstate';
};
my @yy = ( 3, 4 );
1;
3;
4;
my( $x, @xx ) = ( 1, 2, @yy, 3 );
I got this:
m <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 3147 xs.pl:10) v:{ ->3
8 <2> aassign[t2] vKS ->9
- <1> ex-list lKP ->6
3 <0> pushmark s ->4
4 <$> const(IV 3) s ->5
5 <$> const(IV 4) s ->6
- <1> ex-list lK ->8
6 <0> pushmark s ->7
7 <0> padav[@yy:3147,3149] lRM*/LVINTRO ->8
9 <;> nextstate(main 3148 xs.pl:11) v:{ ->a
- <0> ex-const v ->a
a <;> nextstate(main 3148 xs.pl:12) v:{ ->b
- <0> ex-const v ->b
b <;> nextstate(main 3148 xs.pl:13) v:{ ->c
- <0> ex-const v ->c
c <;> nextstate(main 3148 xs.pl:14) v:{ ->d
l <2> aassign[t5] vKS ->m
- <1> ex-list lKP ->i
d <0> pushmark s ->e
e <$> const(IV 1) s ->f
f <$> const(IV 2) s ->g
g <0> padav[@yy:3147,3149] l ->h
h <$> const(IV 3) s ->i
- <1> ex-list lKPRM* ->l
i <0> pushmark sRM*/LVINTRO ->j
j <0> padsv[$x:3148,3149] sRM*/LVINTRO ->k
k <0> padav[@xx:3148,3149] lRM*/LVINTRO ->l
My sub do nothing, so I expect similar output, but it does not:
- <0> ex-nextstate v ->-
VS
9 <;> nextstate(main 3148 xs.pl:11) v:{ ->a
f <0> padrange[$x:3148,3149; @xx:3148,3149] RM/LVINTRO,2 ->g
- <0> padsv[$x:3148,3149] sRM*/LVINTRO ->-
- <0> padav[@xx:3148,3149] lRM*/LVINTRO ->-
VS
i <0> pushmark sRM*/LVINTRO ->j
j <0> padsv[$x:3148,3149] sRM*/LVINTRO ->k
k <0> padav[@xx:3148,3149] lRM*/LVINTRO ->l