Re: op_seq (was: Freeing code)
[p5sagit/p5-mst-13.2.git] / ext / B / B / Concise.pm
index 5c5fd5d..e664970 100644 (file)
@@ -14,7 +14,7 @@ use warnings; # uses #3 and #4, since warnings uses Carp
 
 use Exporter (); # use #5
 
-our $VERSION   = "0.58";
+our $VERSION   = "0.59";
 our @ISA       = qw(Exporter);
 our @EXPORT_OK = qw(set_style set_style_standard add_callback
                    concise_subref concise_cv concise_main);
@@ -40,8 +40,8 @@ my %style =
     "(?(#seq)?)#noise#arg(?([#targarg])?)"],
    "debug" =>
    ["#class (#addr)\n\top_next\t\t#nextaddr\n\top_sibling\t#sibaddr\n\t"
-    . "op_ppaddr\tPL_ppaddr[OP_#NAME]\n\top_type\t\t#typenum\n\top_seq\t\t"
-    . "#seqnum\n\top_flags\t#flagval\n\top_private\t#privval\n"
+    . "op_ppaddr\tPL_ppaddr[OP_#NAME]\n\top_type\t\t#typenum\n"
+    . "\top_flags\t#flagval\n\top_private\t#privval\n"
     . "(?(\top_first\t#firstaddr\n)?)(?(\top_last\t\t#lastaddr\n)?)"
     . "(?(\top_sv\t\t#svaddr\n)?)",
     "    GOTO #addr\n",
@@ -315,9 +315,9 @@ sub walk_exec {
                push @$targ, $ar;
                push @todo, [$op->pmreplstart, $ar];
            } elsif ($name =~ /^enter(loop|iter)$/) {
-               $labels{$op->nextop->seq} = "NEXT";
-               $labels{$op->lastop->seq} = "LAST";
-               $labels{$op->redoop->seq} = "REDO";             
+               $labels{${$op->nextop}} = "NEXT";
+               $labels{${$op->lastop}} = "LAST";
+               $labels{${$op->redoop}} = "REDO";
            }
        }
     }
@@ -583,7 +583,8 @@ sub concise_op {
     }
     $h{seq} = $h{hyphseq} = seq($op);
     $h{seq} = "" if $h{seq} eq "-";
-    $h{seqnum} = $op->seq;
+    $h{opt} = $op->opt;
+    $h{static} = $op->static;
     $h{next} = $op->next;
     $h{next} = (class($h{next}) eq "NULL") ? "(end)" : seq($h{next});
     $h{nextaddr} = sprintf("%#x", $ {$op->next});
@@ -597,7 +598,7 @@ sub concise_op {
     $h{privval} = $op->private;
     $h{private} = private_flags($h{name}, $op->private);
     $h{addr} = sprintf("%#x", $$op);
-    $h{label} = $labels{$op->seq};
+    $h{label} = $labels{$$op};
     $h{typenum} = $op->type;
     $h{noise} = $linenoise[$op->type];
     $_->(\%h, $op, \$format, \$level) for @callbacks;
@@ -675,28 +676,21 @@ sub tree {
 
 # *** Warning: fragile kludge ahead ***
 # Because the B::* modules run in the same interpreter as the code
-# they're compiling, their presence tends to distort the view we have
-# of the code we're looking at. In particular, perl gives sequence
-# numbers to both OPs in general and COPs in particular. If the
-# program we're looking at were run on its own, these numbers would
-# start at 1. Because all of B::Concise and all the modules it uses
-# are compiled first, though, by the time we get to the user's program
-# the sequence numbers are alreay at pretty high numbers, which would
-# be distracting if you're trying to tell OPs apart. Therefore we'd
-# like to subtract an offset from all the sequence numbers we display,
-# to restore the simpler view of the world. The trick is to know what
-# that offset will be, when we're still compiling B::Concise!  If we
+# they're compiling, their presence tends to distort the view we have of
+# the code we're looking at. In particular, perl gives sequence numbers
+# to COPs. If the program we're looking at were run on its own, this
+# would start at 1. Because all of B::Concise and all the modules it
+# uses are compiled first, though, by the time we get to the user's
+# program the sequence number is already pretty high, which could be
+# distracting if you're trying to tell OPs apart. Therefore we'd like to
+# subtract an offset from all the sequence numbers we display, to
+# restore the simpler view of the world. The trick is to know what that
+# offset will be, when we're still compiling B::Concise!  If we
 # hardcoded a value, it would have to change every time B::Concise or
-# other modules we use do. To help a little, what we do here is
-# compile a little code at the end of the module, and compute the base
-# sequence number for the user's program as being a small offset
-# later, so all we have to worry about are changes in the offset.
-# (Note that we now only play this game with COP sequence numbers. OP
-# sequence numbers aren't used to refer to OPs from a distance, and
-# they don't have much significance, so we just generate our own
-# sequence numbers which are easier to control. This way we also don't
-# stand in the way of a possible future removal of OP sequence
-# numbers).
+# other modules we use do. To help a little, what we do here is compile
+# a little code at the end of the module, and compute the base sequence
+# number for the user's program as being a small offset later, so all we
+# have to worry about are changes in the offset.
 
 # When you say "perl -MO=Concise -e '$a'", the output should look like:
 
@@ -1023,16 +1017,17 @@ The numeric value of the OP's private flags.
 
 =item B<#seq>
 
-The sequence number of the OP. Note that this is now a sequence number
-generated by B::Concise, rather than the real op_seq value (for which
-see B<#seqnum>).
+The sequence number of the OP. Note that this is a sequence number
+generated by B::Concise.
 
-=item B<#seqnum>
+=item B<#opt>
 
-The real sequence number of the OP, as a regular number and not adjusted
-to be relative to the start of the real program. (This will generally be
-a fairly large number because all of B<B::Concise> is compiled before
-your program is).
+Whether or not the op has been optimised by the peephole optimiser.
+
+=item B<#static>
+
+Whether or not the op is statically defined.  This flag is used by the
+B::C compiler backend and indicates that the op should not be freed.
 
 =item B<#sibaddr>