develooper Front page | perl.perl5.porters | Postings from January 2001

B::Concise -- an improved replacement for B::Terse

Thread Next
Stephen McCamant
January 6, 2001 20:18
B::Concise -- an improved replacement for B::Terse
Message ID:
Working on op.c and B::Deparse, I've done a fair amount of staring at
OP trees, and was never very satisfied with the various tools around
for visualizing them. Perl's -Dx switch was probably the most
structured and informative, but I find all of its curly braces ugly,
and it uses so many lines per OP that any even moderately complicated
example scrolls of the screen and is hard to understand as a unit.
B::Terse is better in that it only devotes one line per OP, but it
didn't have much of the information that was useful to me -- usually I 
couldn't care less what an OP's address is in hex, but it's useful to
know what its private flags are. At first I just hacked B::Terse to
give the information that I wanted, but then I had a fateful
`hmm.. this could be more general' thought, and the project snowballed 
into a rewritten module I've tentatively named `B::Concise'. Here's
how B::Concise renders perlguts's `$a = $b + $c' example:

8  <@> leave vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v ->3
7     <2> sassign vKS/2 ->8
5        <2> add[t1] sK/2 ->6
-           <1> ex-rv2sv sK/1 ->4
3              <$> gvsv(*b) s ->4
-           <1> ex-rv2sv sK/1 ->5
4              <$> gvsv(*c) s ->5
-        <1> ex-rv2sv sKRM*/1 ->7
6           <$> gvsv(*a) s ->7

or, in a pstree(1)-like form,

         |-<2>nextstate(main 1 -e:1)
                      |            `-ex-rv2sv---<4>gvsv(*c)

Here's `my $a++ while $b--' in a form that shows the execution order
(like B::Terse,exec):

1  <0> enter 
2  <;> nextstate(main 1 -e:1) v
3  <0> enter v
4  <$> gvsv(*b) s
5  <1> postdec[t3] sK/1
6  <|> and(other->7) vK/1
7      <0> padsv[$a:1,end] sRM/LVINTRO
8      <1> preinc[t2] vK/1
9      <0> unstack v
           goto 4
a  <@> leave vK*
b  <@> leave vKP/REFC

These formats are specified in a mini-language that looks like 

(?(#label =>\n)?)(*(    )*)#class (#addr) pp_#name (?([#targ])?)

and allows B::Concise to emulate other formats (like B::Terse's)
fairly easily.

After playing with this as my own personal toy for a while, I thought
other people might find it useful, and I finally got around to adding
command line options and a little documentation. What I'm wondering
now is whether this should go in the core (to either supplement or
replace B::Terse) or whether it should go on CPAN. Its functionality
is pretty much a strict superset of B::Terse's (and it could emulate
it very well if compatibility is important), but it's a lot bigger
(25k versus 3k), and it would only be useful to a few core hackers
(and compiler backend hackers, an even smaller group). It seemed a
little big to send to the list, but you can see a recent version at (or I could send it to
anyone who's interested).

 -- Stephen

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About