diff options
author | Stephen McCamant <smcc@mit.edu> | 2001-01-13 19:00:13 -0800 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-15 13:02:38 +0000 |
commit | 117dada22e1a48990acd498dee229f361feda1fa (patch) | |
tree | 3525af71c58aea698d075ed94da359307434b2f1 | |
parent | 9d96b2e75ff1733e38cb57edc6d33908d11ecd49 (diff) | |
download | perl-117dada22e1a48990acd498dee229f361feda1fa.tar.gz |
[PATCH @8436] Eliminate op_children
Date: Sun, 14 Jan 2001 03:00:13 -0800 (PST)
Message-ID: <14945.32919.44271.685122@soda.csua.berkeley.edu>
Subject: [PATCH @8436] Re: Eliminate op_children
From: Stephen McCamant <smcc@CSUA.Berkeley.EDU>
Date: Sun, 14 Jan 2001 03:23:56 -0800 (PST)
Message-ID: <14945.35680.571387.810763@soda.csua.berkeley.edu>
p4raw-id: //depot/perl@8442
-rw-r--r-- | bytecode.pl | 1 | ||||
-rw-r--r-- | ext/B/B/Asmdata.pm | 55 | ||||
-rw-r--r-- | ext/B/B/Bytecode.pm | 9 | ||||
-rw-r--r-- | ext/B/B/C.pm | 13 | ||||
-rw-r--r-- | ext/ByteLoader/byterun.c | 61 | ||||
-rw-r--r-- | ext/ByteLoader/byterun.h | 57 | ||||
-rw-r--r-- | op.c | 20 | ||||
-rw-r--r-- | op.h | 3 |
8 files changed, 92 insertions, 127 deletions
diff --git a/bytecode.pl b/bytecode.pl index 8d77620be7..4b00e14b9a 100644 --- a/bytecode.pl +++ b/bytecode.pl @@ -379,7 +379,6 @@ op_private PL_op->op_private U8 op_first cUNOP->op_first opindex op_last cBINOP->op_last opindex op_other cLOGOP->op_other opindex -op_children cLISTOP->op_children U32 op_pmreplroot cPMOP->op_pmreplroot opindex op_pmreplrootgv *(SV**)&cPMOP->op_pmreplroot svindex op_pmreplstart cPMOP->op_pmreplstart opindex diff --git a/ext/B/B/Asmdata.pm b/ext/B/B/Asmdata.pm index b412927ab4..dc176be962 100644 --- a/ext/B/B/Asmdata.pm +++ b/ext/B/B/Asmdata.pm @@ -114,34 +114,33 @@ $insn_data{op_private} = [90, \&PUT_U8, "GET_U8"]; $insn_data{op_first} = [91, \&PUT_opindex, "GET_opindex"]; $insn_data{op_last} = [92, \&PUT_opindex, "GET_opindex"]; $insn_data{op_other} = [93, \&PUT_opindex, "GET_opindex"]; -$insn_data{op_children} = [94, \&PUT_U32, "GET_U32"]; -$insn_data{op_pmreplroot} = [95, \&PUT_opindex, "GET_opindex"]; -$insn_data{op_pmreplrootgv} = [96, \&PUT_svindex, "GET_svindex"]; -$insn_data{op_pmreplstart} = [97, \&PUT_opindex, "GET_opindex"]; -$insn_data{op_pmnext} = [98, \&PUT_opindex, "GET_opindex"]; -$insn_data{pregcomp} = [99, \&PUT_pvcontents, "GET_pvcontents"]; -$insn_data{op_pmflags} = [100, \&PUT_U16, "GET_U16"]; -$insn_data{op_pmpermflags} = [101, \&PUT_U16, "GET_U16"]; -$insn_data{op_sv} = [102, \&PUT_svindex, "GET_svindex"]; -$insn_data{op_padix} = [103, \&PUT_U32, "GET_U32"]; -$insn_data{op_pv} = [104, \&PUT_pvcontents, "GET_pvcontents"]; -$insn_data{op_pv_tr} = [105, \&PUT_op_tr_array, "GET_op_tr_array"]; -$insn_data{op_redoop} = [106, \&PUT_opindex, "GET_opindex"]; -$insn_data{op_nextop} = [107, \&PUT_opindex, "GET_opindex"]; -$insn_data{op_lastop} = [108, \&PUT_opindex, "GET_opindex"]; -$insn_data{cop_label} = [109, \&PUT_pvindex, "GET_pvindex"]; -$insn_data{cop_stashpv} = [110, \&PUT_pvindex, "GET_pvindex"]; -$insn_data{cop_file} = [111, \&PUT_pvindex, "GET_pvindex"]; -$insn_data{cop_seq} = [112, \&PUT_U32, "GET_U32"]; -$insn_data{cop_arybase} = [113, \&PUT_I32, "GET_I32"]; -$insn_data{cop_line} = [114, \&PUT_U16, "GET_U16"]; -$insn_data{cop_warnings} = [115, \&PUT_svindex, "GET_svindex"]; -$insn_data{main_start} = [116, \&PUT_opindex, "GET_opindex"]; -$insn_data{main_root} = [117, \&PUT_opindex, "GET_opindex"]; -$insn_data{curpad} = [118, \&PUT_svindex, "GET_svindex"]; -$insn_data{push_begin} = [119, \&PUT_svindex, "GET_svindex"]; -$insn_data{push_init} = [120, \&PUT_svindex, "GET_svindex"]; -$insn_data{push_end} = [121, \&PUT_svindex, "GET_svindex"]; +$insn_data{op_pmreplroot} = [94, \&PUT_opindex, "GET_opindex"]; +$insn_data{op_pmreplrootgv} = [95, \&PUT_svindex, "GET_svindex"]; +$insn_data{op_pmreplstart} = [96, \&PUT_opindex, "GET_opindex"]; +$insn_data{op_pmnext} = [97, \&PUT_opindex, "GET_opindex"]; +$insn_data{pregcomp} = [98, \&PUT_pvcontents, "GET_pvcontents"]; +$insn_data{op_pmflags} = [99, \&PUT_U16, "GET_U16"]; +$insn_data{op_pmpermflags} = [100, \&PUT_U16, "GET_U16"]; +$insn_data{op_sv} = [101, \&PUT_svindex, "GET_svindex"]; +$insn_data{op_padix} = [102, \&PUT_U32, "GET_U32"]; +$insn_data{op_pv} = [103, \&PUT_pvcontents, "GET_pvcontents"]; +$insn_data{op_pv_tr} = [104, \&PUT_op_tr_array, "GET_op_tr_array"]; +$insn_data{op_redoop} = [105, \&PUT_opindex, "GET_opindex"]; +$insn_data{op_nextop} = [106, \&PUT_opindex, "GET_opindex"]; +$insn_data{op_lastop} = [107, \&PUT_opindex, "GET_opindex"]; +$insn_data{cop_label} = [108, \&PUT_pvindex, "GET_pvindex"]; +$insn_data{cop_stashpv} = [109, \&PUT_pvindex, "GET_pvindex"]; +$insn_data{cop_file} = [110, \&PUT_pvindex, "GET_pvindex"]; +$insn_data{cop_seq} = [111, \&PUT_U32, "GET_U32"]; +$insn_data{cop_arybase} = [112, \&PUT_I32, "GET_I32"]; +$insn_data{cop_line} = [113, \&PUT_U16, "GET_U16"]; +$insn_data{cop_warnings} = [114, \&PUT_svindex, "GET_svindex"]; +$insn_data{main_start} = [115, \&PUT_opindex, "GET_opindex"]; +$insn_data{main_root} = [116, \&PUT_opindex, "GET_opindex"]; +$insn_data{curpad} = [117, \&PUT_svindex, "GET_svindex"]; +$insn_data{push_begin} = [118, \&PUT_svindex, "GET_svindex"]; +$insn_data{push_init} = [119, \&PUT_svindex, "GET_svindex"]; +$insn_data{push_end} = [120, \&PUT_svindex, "GET_svindex"]; my ($insn_name, $insn_data); while (($insn_name, $insn_data) = each %insn_data) { diff --git a/ext/B/B/Bytecode.pm b/ext/B/B/Bytecode.pm index bea023a038..54d7c533c8 100644 --- a/ext/B/B/Bytecode.pm +++ b/ext/B/B/Bytecode.pm @@ -312,15 +312,6 @@ sub B::BINOP::bytecode { } } -sub B::LISTOP::bytecode { - my $op = shift; - my $children = $op->children unless $strip_syntree; - $op->B::BINOP::bytecode; - if (($op->type || !$compress_nullops) && !$strip_syntree) { - asm "op_children $children\n"; - } -} - sub B::LOOP::bytecode { my $op = shift; my $redoopix = $op->redoop->objix; diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm index dac9417806..54fa46fb4f 100644 --- a/ext/B/B/C.pm +++ b/ext/B/B/C.pm @@ -225,11 +225,10 @@ sub B::LISTOP::save { my ($op, $level) = @_; my $sym = objsym($op); return $sym if defined $sym; - $listopsect->add(sprintf("s\\_%x, s\\_%x, NULL, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x, %u", + $listopsect->add(sprintf("s\\_%x, s\\_%x, NULL, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x", ${$op->next}, ${$op->sibling}, $op->targ, $op->type, $op_seq, $op->flags, - $op->private, ${$op->first}, ${$op->last}, - $op->children)); + $op->private, ${$op->first}, ${$op->last})); my $ix = $listopsect->index; $init->add(sprintf("listop_list[$ix].op_ppaddr = %s;", $op->ppaddr)); savesym($op, "(OP*)&listop_list[$ix]"); @@ -255,11 +254,11 @@ sub B::LOOP::save { #warn sprintf("LOOP: redoop %s, nextop %s, lastop %s\n", # peekop($op->redoop), peekop($op->nextop), # peekop($op->lastop)); # debug - $loopsect->add(sprintf("s\\_%x, s\\_%x, NULL, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x, %u, s\\_%x, s\\_%x, s\\_%x", + $loopsect->add(sprintf("s\\_%x, s\\_%x, NULL, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x, s\\_%x, s\\_%x, s\\_%x", ${$op->next}, ${$op->sibling}, $op->targ, $op->type, $op_seq, $op->flags, $op->private, ${$op->first}, ${$op->last}, - $op->children, ${$op->redoop}, ${$op->nextop}, + ${$op->redoop}, ${$op->nextop}, ${$op->lastop})); my $ix = $loopsect->index; $init->add(sprintf("loop_list[$ix].op_ppaddr = %s;", $op->ppaddr)); @@ -351,10 +350,10 @@ sub B::PMOP::save { # pmnext handling is broken in perl itself, I think. Bad op_pmnext # fields aren't noticed in perl's runtime (unless you try reset) but we # segfault when trying to dereference it to find op->op_pmnext->op_type - $pmopsect->add(sprintf("s\\_%x, s\\_%x, NULL, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x, %u, %s, %s, 0, 0, 0x%x, 0x%x", + $pmopsect->add(sprintf("s\\_%x, s\\_%x, NULL, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x, %s, %s, 0, 0, 0x%x, 0x%x", ${$op->next}, ${$op->sibling}, $op->targ, $op->type, $op_seq, $op->flags, $op->private, - ${$op->first}, ${$op->last}, $op->children, + ${$op->first}, ${$op->last}, $replrootfield, $replstartfield, $op->pmflags, $op->pmpermflags,)); my $pm = sprintf("pmop_list[%d]", $pmopsect->index); diff --git a/ext/ByteLoader/byterun.c b/ext/ByteLoader/byterun.c index 3e12790fb0..71cd8aa084 100644 --- a/ext/ByteLoader/byterun.c +++ b/ext/ByteLoader/byterun.c @@ -719,196 +719,189 @@ byterun(pTHXo_ register struct byteloader_state *bstate) cLOGOP->op_other = arg; break; } - case INSN_OP_CHILDREN: /* 94 */ - { - U32 arg; - BGET_U32(arg); - cLISTOP->op_children = arg; - break; - } - case INSN_OP_PMREPLROOT: /* 95 */ + case INSN_OP_PMREPLROOT: /* 94 */ { opindex arg; BGET_opindex(arg); cPMOP->op_pmreplroot = arg; break; } - case INSN_OP_PMREPLROOTGV: /* 96 */ + case INSN_OP_PMREPLROOTGV: /* 95 */ { svindex arg; BGET_svindex(arg); *(SV**)&cPMOP->op_pmreplroot = arg; break; } - case INSN_OP_PMREPLSTART: /* 97 */ + case INSN_OP_PMREPLSTART: /* 96 */ { opindex arg; BGET_opindex(arg); cPMOP->op_pmreplstart = arg; break; } - case INSN_OP_PMNEXT: /* 98 */ + case INSN_OP_PMNEXT: /* 97 */ { opindex arg; BGET_opindex(arg); *(OP**)&cPMOP->op_pmnext = arg; break; } - case INSN_PREGCOMP: /* 99 */ + case INSN_PREGCOMP: /* 98 */ { pvcontents arg; BGET_pvcontents(arg); BSET_pregcomp(PL_op, arg); break; } - case INSN_OP_PMFLAGS: /* 100 */ + case INSN_OP_PMFLAGS: /* 99 */ { U16 arg; BGET_U16(arg); cPMOP->op_pmflags = arg; break; } - case INSN_OP_PMPERMFLAGS: /* 101 */ + case INSN_OP_PMPERMFLAGS: /* 100 */ { U16 arg; BGET_U16(arg); cPMOP->op_pmpermflags = arg; break; } - case INSN_OP_SV: /* 102 */ + case INSN_OP_SV: /* 101 */ { svindex arg; BGET_svindex(arg); cSVOP->op_sv = arg; break; } - case INSN_OP_PADIX: /* 103 */ + case INSN_OP_PADIX: /* 102 */ { PADOFFSET arg; BGET_U32(arg); cPADOP->op_padix = arg; break; } - case INSN_OP_PV: /* 104 */ + case INSN_OP_PV: /* 103 */ { pvcontents arg; BGET_pvcontents(arg); cPVOP->op_pv = arg; break; } - case INSN_OP_PV_TR: /* 105 */ + case INSN_OP_PV_TR: /* 104 */ { op_tr_array arg; BGET_op_tr_array(arg); cPVOP->op_pv = arg; break; } - case INSN_OP_REDOOP: /* 106 */ + case INSN_OP_REDOOP: /* 105 */ { opindex arg; BGET_opindex(arg); cLOOP->op_redoop = arg; break; } - case INSN_OP_NEXTOP: /* 107 */ + case INSN_OP_NEXTOP: /* 106 */ { opindex arg; BGET_opindex(arg); cLOOP->op_nextop = arg; break; } - case INSN_OP_LASTOP: /* 108 */ + case INSN_OP_LASTOP: /* 107 */ { opindex arg; BGET_opindex(arg); cLOOP->op_lastop = arg; break; } - case INSN_COP_LABEL: /* 109 */ + case INSN_COP_LABEL: /* 108 */ { pvindex arg; BGET_pvindex(arg); cCOP->cop_label = arg; break; } - case INSN_COP_STASHPV: /* 110 */ + case INSN_COP_STASHPV: /* 109 */ { pvindex arg; BGET_pvindex(arg); BSET_cop_stashpv(cCOP, arg); break; } - case INSN_COP_FILE: /* 111 */ + case INSN_COP_FILE: /* 110 */ { pvindex arg; BGET_pvindex(arg); BSET_cop_file(cCOP, arg); break; } - case INSN_COP_SEQ: /* 112 */ + case INSN_COP_SEQ: /* 111 */ { U32 arg; BGET_U32(arg); cCOP->cop_seq = arg; break; } - case INSN_COP_ARYBASE: /* 113 */ + case INSN_COP_ARYBASE: /* 112 */ { I32 arg; BGET_I32(arg); cCOP->cop_arybase = arg; break; } - case INSN_COP_LINE: /* 114 */ + case INSN_COP_LINE: /* 113 */ { line_t arg; BGET_U16(arg); BSET_cop_line(cCOP, arg); break; } - case INSN_COP_WARNINGS: /* 115 */ + case INSN_COP_WARNINGS: /* 114 */ { svindex arg; BGET_svindex(arg); cCOP->cop_warnings = arg; break; } - case INSN_MAIN_START: /* 116 */ + case INSN_MAIN_START: /* 115 */ { opindex arg; BGET_opindex(arg); PL_main_start = arg; break; } - case INSN_MAIN_ROOT: /* 117 */ + case INSN_MAIN_ROOT: /* 116 */ { opindex arg; BGET_opindex(arg); PL_main_root = arg; break; } - case INSN_CURPAD: /* 118 */ + case INSN_CURPAD: /* 117 */ { svindex arg; BGET_svindex(arg); BSET_curpad(PL_curpad, arg); break; } - case INSN_PUSH_BEGIN: /* 119 */ + case INSN_PUSH_BEGIN: /* 118 */ { svindex arg; BGET_svindex(arg); BSET_push_begin(PL_beginav, arg); break; } - case INSN_PUSH_INIT: /* 120 */ + case INSN_PUSH_INIT: /* 119 */ { svindex arg; BGET_svindex(arg); BSET_push_init(PL_initav, arg); break; } - case INSN_PUSH_END: /* 121 */ + case INSN_PUSH_END: /* 120 */ { svindex arg; BGET_svindex(arg); diff --git a/ext/ByteLoader/byterun.h b/ext/ByteLoader/byterun.h index 1e67b8967e..f074f2d6cf 100644 --- a/ext/ByteLoader/byterun.h +++ b/ext/ByteLoader/byterun.h @@ -122,35 +122,34 @@ enum { INSN_OP_FIRST, /* 91 */ INSN_OP_LAST, /* 92 */ INSN_OP_OTHER, /* 93 */ - INSN_OP_CHILDREN, /* 94 */ - INSN_OP_PMREPLROOT, /* 95 */ - INSN_OP_PMREPLROOTGV, /* 96 */ - INSN_OP_PMREPLSTART, /* 97 */ - INSN_OP_PMNEXT, /* 98 */ - INSN_PREGCOMP, /* 99 */ - INSN_OP_PMFLAGS, /* 100 */ - INSN_OP_PMPERMFLAGS, /* 101 */ - INSN_OP_SV, /* 102 */ - INSN_OP_PADIX, /* 103 */ - INSN_OP_PV, /* 104 */ - INSN_OP_PV_TR, /* 105 */ - INSN_OP_REDOOP, /* 106 */ - INSN_OP_NEXTOP, /* 107 */ - INSN_OP_LASTOP, /* 108 */ - INSN_COP_LABEL, /* 109 */ - INSN_COP_STASHPV, /* 110 */ - INSN_COP_FILE, /* 111 */ - INSN_COP_SEQ, /* 112 */ - INSN_COP_ARYBASE, /* 113 */ - INSN_COP_LINE, /* 114 */ - INSN_COP_WARNINGS, /* 115 */ - INSN_MAIN_START, /* 116 */ - INSN_MAIN_ROOT, /* 117 */ - INSN_CURPAD, /* 118 */ - INSN_PUSH_BEGIN, /* 119 */ - INSN_PUSH_INIT, /* 120 */ - INSN_PUSH_END, /* 121 */ - MAX_INSN = 121 + INSN_OP_PMREPLROOT, /* 94 */ + INSN_OP_PMREPLROOTGV, /* 95 */ + INSN_OP_PMREPLSTART, /* 96 */ + INSN_OP_PMNEXT, /* 97 */ + INSN_PREGCOMP, /* 98 */ + INSN_OP_PMFLAGS, /* 99 */ + INSN_OP_PMPERMFLAGS, /* 100 */ + INSN_OP_SV, /* 101 */ + INSN_OP_PADIX, /* 102 */ + INSN_OP_PV, /* 103 */ + INSN_OP_PV_TR, /* 104 */ + INSN_OP_REDOOP, /* 105 */ + INSN_OP_NEXTOP, /* 106 */ + INSN_OP_LASTOP, /* 107 */ + INSN_COP_LABEL, /* 108 */ + INSN_COP_STASHPV, /* 109 */ + INSN_COP_FILE, /* 110 */ + INSN_COP_SEQ, /* 111 */ + INSN_COP_ARYBASE, /* 112 */ + INSN_COP_LINE, /* 113 */ + INSN_COP_WARNINGS, /* 114 */ + INSN_MAIN_START, /* 115 */ + INSN_MAIN_ROOT, /* 116 */ + INSN_CURPAD, /* 117 */ + INSN_PUSH_BEGIN, /* 118 */ + INSN_PUSH_INIT, /* 119 */ + INSN_PUSH_END, /* 120 */ + MAX_INSN = 120 }; enum { @@ -2410,13 +2410,6 @@ Perl_convert(pTHX_ I32 type, I32 flags, OP *o) if (o->op_type != type) return o; - if (cLISTOPo->op_children < 7) { - /* XXX do we really need to do this if we're done appending?? */ - for (kid = cLISTOPo->op_first; kid; kid = kid->op_sibling) - last = kid; - cLISTOPo->op_last = last; /* in case check substituted last arg */ - } - return fold_constants(o); } @@ -2444,7 +2437,6 @@ Perl_append_elem(pTHX_ I32 type, OP *first, OP *last) ((LISTOP*)first)->op_first = last; } ((LISTOP*)first)->op_last = last; - ((LISTOP*)first)->op_children++; return first; } @@ -2465,9 +2457,7 @@ Perl_append_list(pTHX_ I32 type, LISTOP *first, LISTOP *last) first->op_last->op_sibling = last->op_first; first->op_last = last->op_last; - first->op_children += last->op_children; - if (first->op_children) - first->op_flags |= OPf_KIDS; + first->op_flags |= (last->op_flags & OPf_KIDS); #ifdef PL_OP_SLAB_ALLOC #else @@ -2500,7 +2490,7 @@ Perl_prepend_elem(pTHX_ I32 type, OP *first, OP *last) first->op_sibling = ((LISTOP*)last)->op_first; ((LISTOP*)last)->op_first = first; } - ((LISTOP*)last)->op_children++; + last->op_flags |= OPf_KIDS; return last; } @@ -2533,7 +2523,8 @@ Perl_newLISTOP(pTHX_ I32 type, I32 flags, OP *first, OP *last) listop->op_type = type; listop->op_ppaddr = PL_ppaddr[type]; - listop->op_children = (first != 0) + (last != 0); + if (first || last) + flags |= OPf_KIDS; listop->op_flags = flags; if (!last && first) @@ -2553,8 +2544,6 @@ Perl_newLISTOP(pTHX_ I32 type, I32 flags, OP *first, OP *last) if (!last) listop->op_last = pushop; } - else if (listop->op_children) - listop->op_flags |= OPf_KIDS; return (OP*)listop; } @@ -6309,7 +6298,6 @@ S_simplify_sort(pTHX_ OP *o) kid = cLISTOPo->op_first->op_sibling; cLISTOPo->op_first->op_sibling = kid->op_sibling; /* bypass old block */ op_free(kid); /* then delete it */ - cLISTOPo->op_children--; } OP * @@ -229,14 +229,12 @@ struct listop { BASEOP OP * op_first; OP * op_last; - U32 op_children; }; struct pmop { BASEOP OP * op_first; OP * op_last; - U32 op_children; OP * op_pmreplroot; OP * op_pmreplstart; PMOP * op_pmnext; /* list of all scanpats */ @@ -292,7 +290,6 @@ struct loop { BASEOP OP * op_first; OP * op_last; - U32 op_children; OP * op_redoop; OP * op_nextop; OP * op_lastop; |