optimize/tie.pm untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 107 SCAR -
1  
2 if($op->name eq 'sassign') {
3 my $dst = $state->next->next;
4 my $src = $state->next;
5 if($dst->name eq 'padsv' && $dst->next->name eq 'sassign') {
6 my $cv = $op->find_cv();
7 if(exists($pads{$cv->ROOT->seq}) &&
8 exists($pads{$cv->ROOT->seq}->[$dst->targ]) &&
9 $pads{$cv->ROOT->seq}->[$dst->targ]->[1]->{tied}
10 ) {
11 # print "sassign tied optimization possible\n";
12  
13  
14 # return;
15 my $n = $op->next;
16 # $op->next(0);
17 $op->first(0);
18 $op->null();
19 # $op->dump();
20  
21 my $pushmark = B::OP->new("pushmark",2);
22 $state->next($pushmark);
23 $pushmark->next($dst);
24 $pushmark->seq(optimizer::op_seqmax_inc());
25 my $tied = B::UNOP->new('tied',38,$dst);
26 $tied->seq(optimizer::op_seqmax_inc());
27 $pushmark->sibling($tied);
28 # $dst->flags(50);
29 $dst->next($tied);
30 $tied->next($src);
31 $tied->sibling($src);
32 # $src->flags(34);
33
34 my $method_named = B::SVOP->new('method_named',0,"STORE");
35 $method_named->seq(optimizer::op_seqmax_inc());
36 $src->next($method_named);
37 $src->sibling($method_named);
38  
39  
40 my $entersub = B::UNOP->new('entersub',69,0);
41 $entersub->seq(optimizer::op_seqmax_inc());
42 $method_named->next($entersub);
43 $entersub->next($n);
44 $entersub->first($pushmark);
45 $state->sibling($entersub);
46  
47 if($n->flags & OPf_KIDS) {
48 my $no_sibling = 1;
49 for (my $kid = $n->first; $$kid; $kid = $kid->sibling) {
50 if($kid->seq == $entersub->seq) {
51 $no_sibling = 0;
52 last;
53 }
54 }
55 if($no_sibling) {
56 $entersub->sibling($n);
57 }
58 } else {
59 $entersub->sibling($n);
60 }
61 # print $tied->next->name . "\n";
62 # print $src->next->name . "\n";
63 # print $dst->next->name . "\n";
64  
65 }
66 }
67 } elsif($op->name eq 'padsv' && !($op->flags & OPf_MOD)) {
68 my $cv = $op->find_cv();
69 if(exists($pads{$cv->ROOT->seq}) &&
70 exists($pads{$cv->ROOT->seq}->[$op->targ]) &&
71 $pads{$cv->ROOT->seq}->[$op->targ]->[1]->{tied}
72 ) {
73 # print $old_op->seq . " - " . $state->seq . "\n";
74 # $old_op->dump();
75 # $op->dump();
76 my $sibling = $op->sibling();
77  
78 my $pushmark = B::OP->new("pushmark",2);
79 my $n = $op->next();
80 $old_op->next($pushmark);
81 $pushmark->seq(optimizer::op_seqmax_inc());
82 $pushmark->next($op);
83 $op->sibling(0);
84 my $tied = B::UNOP->new('tied',38,$op);
85 $pushmark->sibling($tied);
86 $op->next($tied);
87 my $method_named = B::SVOP->new('method_named',OPf_WANT_SCALAR,"FETCH");
88 $tied->sibling($method_named);
89 # $tied->seq(optimizer::op_seqmax_inc());
90 $tied->next($method_named);
91 my $entersub = B::UNOP->new('entersub',OPf_WANT_SCALAR| OPf_PARENS | OPf_STACKED,0);
92 # $method_named->seq(optimizer::op_seqmax_inc());
93 $method_named->next($entersub);
94 $entersub->first($pushmark);
95 # $entersub->seq(optimizer::op_seqmax_inc());
96 $entersub->next($n);
97 $entersub->sibling($sibling);
98 $n->next->first($entersub);
99 # $old_op->sibling($entersub);
100 }
101 }
102  
103 };