This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
aelemfast optimization opclass problem (c.f. [perl #38279])
[perl5.git] / ext / B / t / optree_misc.t
CommitLineData
c60fdceb
SM
1#!perl
2
3BEGIN {
4 if ($ENV{PERL_CORE}){
5 chdir('t') if -d 't';
6 @INC = ('.', '../lib', '../ext/B/t');
7 } else {
8 unshift @INC, 't';
9 push @INC, "../../t";
10 }
11 require Config;
12 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
13 print "1..0 # Skip -- Perl configured without B module\n";
14 exit 0;
15 }
16}
17use OptreeCheck;
18use Config;
19plan tests => 1;
20
21SKIP: {
22skip "no perlio in this build", 1 unless $Config::Config{useperlio};
23
24# The regression this is testing is that the first aelemfast, derived
25# from a lexical array, is supposed to be a BASEOP "<0>", while the
26# second, from a global, is an SVOP "<$>" or a PADOP "<#>" depending
27# on threading. In buggy versions, both showed up as SVOPs/PADOPs. See
28# B.xs:cc_opclass() for the relevant code.
29
30checkOptree ( name => 'OP_AELEMFAST opclass',
31 code => sub { my @x; our @y; $x[0] + $y[0]},
32 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
33# a <1> leavesub[1 ref] K/REFC,1 ->(end)
34# - <@> lineseq KP ->a
35# 1 <;> nextstate(main 634 optree_misc.t:25) v ->2
36# 2 <0> padav[@x:634,636] vM/LVINTRO ->3
37# 3 <;> nextstate(main 635 optree_misc.t:25) v ->4
38# 5 <1> rv2av[t4] vK/OURINTR,1 ->6
39# 4 <#> gv[*y] s ->5
40# 6 <;> nextstate(main 636 optree_misc.t:25) v ->7
41# 9 <2> add[t6] sK/2 ->a
42# - <1> ex-aelem sK/2 ->8
43# 7 <0> aelemfast[@x:634,636] sR* ->8
44# - <0> ex-const s ->-
45# - <1> ex-aelem sK/2 ->9
46# - <1> ex-rv2av sKR/1 ->-
47# 8 <#> aelemfast[*y] s ->9
48# - <0> ex-const s ->-
49EOT_EOT
50# a <1> leavesub[1 ref] K/REFC,1 ->(end)
51# - <@> lineseq KP ->a
52# 1 <;> nextstate(main 634 optree_misc.t:27) v ->2
53# 2 <0> padav[@x:634,636] vM/LVINTRO ->3
54# 3 <;> nextstate(main 635 optree_misc.t:27) v ->4
55# 5 <1> rv2av[t3] vK/OURINTR,1 ->6
56# 4 <$> gv(*y) s ->5
57# 6 <;> nextstate(main 636 optree_misc.t:27) v ->7
58# 9 <2> add[t4] sK/2 ->a
59# - <1> ex-aelem sK/2 ->8
60# 7 <0> aelemfast[@x:634,636] sR* ->8
61# - <0> ex-const s ->-
62# - <1> ex-aelem sK/2 ->9
63# - <1> ex-rv2av sKR/1 ->-
64# 8 <$> aelemfast(*y) s ->9
65# - <0> ex-const s ->-
66EONT_EONT
67
68
69} #skip
70
71__END__
72