This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
B::Concise: Give sequence numbers for null ops
authorFather Chrysostomos <sprout@cpan.org>
Sat, 18 Oct 2014 20:50:25 +0000 (13:50 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 18 Oct 2014 20:52:28 +0000 (13:52 -0700)
B::Concise was not giving sequence numbers to null ops even if they
were part of the execution order.  Ideally, there should be no null
ops in the execution order, but, if it did happen, B::Concise was not
helpful in debugging it.  In fact, its output was quite confusing:

1        <;> nextstate(main 1 -e:1) v ->-

You can’t tell which ops it’s pointing at and where the optimisations
need to be tweaked.

(See the thread starting at
<20141016220840.29774.qmail@lists-nntp.develooper.com>.)

ext/B/B/Concise.pm

index 96869c7..bef112f 100644 (file)
@@ -528,29 +528,15 @@ sub sequence {
     for (; $$op; $op = $op->next) {
        last if exists $sequence_num{$$op};
        my $name = $op->name;
-       if ($name =~ /^(null|scalar|lineseq|scope)$/) {
-           next if $oldop and $ {$op->next};
-       } else {
-           $sequence_num{$$op} = $seq_max++;
-           if (class($op) eq "LOGOP") {
-               my $other = $op->other;
-               $other = $other->next while $other->name eq "null";
-               sequence($other);
-           } elsif (class($op) eq "LOOP") {
-               my $redoop = $op->redoop;
-               $redoop = $redoop->next while $redoop->name eq "null";
-               sequence($redoop);
-               my $nextop = $op->nextop;
-               $nextop = $nextop->next while $nextop->name eq "null";
-               sequence($nextop);
-               my $lastop = $op->lastop;
-               $lastop = $lastop->next while $lastop->name eq "null";
-               sequence($lastop);
-           } elsif ($name eq "subst" and $ {$op->pmreplstart}) {
-               my $replstart = $op->pmreplstart;
-               $replstart = $replstart->next while $replstart->name eq "null";
-               sequence($replstart);
-           }
+       $sequence_num{$$op} = $seq_max++;
+       if (class($op) eq "LOGOP") {
+           sequence($op->other);
+       } elsif (class($op) eq "LOOP") {
+           sequence($op->redoop);
+           sequence( $op->nextop);
+           sequence($op->lastop);
+       } elsif ($name eq "subst" and $ {$op->pmreplstart}) {
+           sequence($op->pmreplstart);
        }
        $oldop = $op;
     }