diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-10-29 03:00:21 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-10-29 03:00:21 +0000 |
commit | 7934575e193741c310ddb7f01d6d07c9981c3d29 (patch) | |
tree | 9b9135ad0559f0da22a2bb159f0a38bb81777f07 /ext | |
parent | a1f333424726116552fec059c74f91eae67b2820 (diff) | |
download | perl-7934575e193741c310ddb7f01d6d07c9981c3d29.tar.gz |
usurp GVOP slot for new PADOP (one small step to making optree
shareable across interpreters)
p4raw-id: //depot/perl@4484
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B.pm | 10 | ||||
-rw-r--r-- | ext/B/B.xs | 42 | ||||
-rw-r--r-- | ext/B/B/Asmdata.pm | 4 | ||||
-rw-r--r-- | ext/B/B/Bytecode.pm | 8 | ||||
-rw-r--r-- | ext/B/B/C.pm | 16 | ||||
-rw-r--r-- | ext/B/B/Debug.pm | 5 | ||||
-rw-r--r-- | ext/B/B/Deparse.pm | 2 | ||||
-rw-r--r-- | ext/B/B/Lint.pm | 12 | ||||
-rw-r--r-- | ext/B/B/Terse.pm | 5 | ||||
-rw-r--r-- | ext/B/typemap | 3 | ||||
-rw-r--r-- | ext/ByteLoader/byterun.c | 10 | ||||
-rw-r--r-- | ext/ByteLoader/byterun.h | 4 |
12 files changed, 68 insertions, 53 deletions
diff --git a/ext/B/B.pm b/ext/B/B.pm index 2187e59a72..08361d7eff 100644 --- a/ext/B/B.pm +++ b/ext/B/B.pm @@ -40,7 +40,7 @@ use strict; @B::LOGOP::ISA = 'B::UNOP'; @B::LISTOP::ISA = 'B::BINOP'; @B::SVOP::ISA = 'B::OP'; -@B::GVOP::ISA = 'B::OP'; +@B::PADOP::ISA = 'B::OP'; @B::PVOP::ISA = 'B::OP'; @B::CVOP::ISA = 'B::OP'; @B::LOOP::ISA = 'B::LISTOP'; @@ -549,7 +549,7 @@ C<REFCNT> (corresponding to the C function C<SvREFCNT>). =head2 OP-RELATED CLASSES B::OP, B::UNOP, B::BINOP, B::LOGOP, B::LISTOP, B::PMOP, -B::SVOP, B::GVOP, B::PVOP, B::CVOP, B::LOOP, B::COP. +B::SVOP, B::PADOP, B::PVOP, B::CVOP, B::LOOP, B::COP. These classes correspond in the obvious way to the underlying C structures of similar names. The inheritance hierarchy mimics the underlying C "inheritance". Access @@ -648,13 +648,15 @@ This returns the op description from the global C PL_op_desc array =item sv +=item gv + =back -=head2 B::GVOP METHOD +=head2 B::PADOP METHOD =over 4 -=item gv +=item padix =back diff --git a/ext/B/B.xs b/ext/B/B.xs index 2d6145da66..73f35ae5f2 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -56,7 +56,7 @@ typedef enum { OPc_LISTOP, /* 5 */ OPc_PMOP, /* 6 */ OPc_SVOP, /* 7 */ - OPc_GVOP, /* 8 */ + OPc_PADOP, /* 8 */ OPc_PVOP, /* 9 */ OPc_CVOP, /* 10 */ OPc_LOOP, /* 11 */ @@ -72,7 +72,7 @@ static char *opclassnames[] = { "B::LISTOP", "B::PMOP", "B::SVOP", - "B::GVOP", + "B::PADOP", "B::PVOP", "B::CVOP", "B::LOOP", @@ -117,8 +117,8 @@ cc_opclass(pTHX_ OP *o) case OA_SVOP: return OPc_SVOP; - case OA_GVOP: - return OPc_GVOP; + case OA_PADOP: + return OPc_PADOP; case OA_PVOP_OR_SVOP: /* @@ -155,10 +155,10 @@ cc_opclass(pTHX_ OP *o) * return OPc_UNOP so that walkoptree can find our children. If * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set * (no argument to the operator) it's an OP; with OPf_REF set it's - * a GVOP (and op_gv is the GV for the filehandle argument). + * an SVOP (and op_sv is the GV for the filehandle argument). */ return ((o->op_flags & OPf_KIDS) ? OPc_UNOP : - (o->op_flags & OPf_REF) ? OPc_GVOP : OPc_BASEOP); + (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP); case OA_LOOPEXOP: /* @@ -345,7 +345,7 @@ typedef LOGOP *B__LOGOP; typedef LISTOP *B__LISTOP; typedef PMOP *B__PMOP; typedef SVOP *B__SVOP; -typedef GVOP *B__GVOP; +typedef PADOP *B__PADOP; typedef PVOP *B__PVOP; typedef LOOP *B__LOOP; typedef COP *B__COP; @@ -575,7 +575,7 @@ char * OP_desc(o) B::OP o -U16 +PADOFFSET OP_targ(o) B::OP o @@ -680,22 +680,38 @@ PMOP_precomp(o) sv_setpvn(ST(0), rx->precomp, rx->prelen); #define SVOP_sv(o) o->op_sv +#define SVOP_gv(o) ((SvTYPE(o->op_sv) == SVt_PVGV) \ + ? (GV*)o->op_sv : Nullgv) MODULE = B PACKAGE = B::SVOP PREFIX = SVOP_ - B::SV SVOP_sv(o) B::SVOP o -#define GVOP_gv(o) o->op_gv +B::GV +SVOP_gv(o) + B::SVOP o -MODULE = B PACKAGE = B::GVOP PREFIX = GVOP_ +#define PADOP_padix(o) o->op_padix +#define PADOP_sv(o) (o->op_padix ? PL_curpad[o->op_padix] : Nullsv) +#define PADOP_gv(o) ((o->op_padix \ + && SvTYPE(PL_curpad[o->op_padix]) == SVt_PVGV) \ + ? (GV*)PL_curpad[o->op_padix] : Nullgv) +MODULE = B PACKAGE = B::PADOP PREFIX = PADOP_ + +PADOFFSET +PADOP_padix(o) + B::PADOP o + +B::SV +PADOP_sv(o) + B::PADOP o B::GV -GVOP_gv(o) - B::GVOP o +PADOP_gv(o) + B::PADOP o MODULE = B PACKAGE = B::PVOP PREFIX = PVOP_ diff --git a/ext/B/B/Asmdata.pm b/ext/B/B/Asmdata.pm index 1d0e7eddaa..e0d61322cf 100644 --- a/ext/B/B/Asmdata.pm +++ b/ext/B/B/Asmdata.pm @@ -14,7 +14,7 @@ use Exporter; @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name); use vars qw(%insn_data @insn_name @optype @specialsv_name); -@optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP GVOP PVOP LOOP COP); +@optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP); @specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no); # XXX insn_data is initialised this way because with a large @@ -122,7 +122,7 @@ $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_gv} = [102, \&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"]; diff --git a/ext/B/B/Bytecode.pm b/ext/B/B/Bytecode.pm index 56945316e8..cde9924a23 100644 --- a/ext/B/B/Bytecode.pm +++ b/ext/B/B/Bytecode.pm @@ -226,13 +226,11 @@ sub B::SVOP::bytecode { $sv->bytecode; } -sub B::GVOP::bytecode { +sub B::PADOP::bytecode { my $op = shift; - my $gv = $op->gv; - my $gvix = $gv->objix; + my $padix = $op->padix; $op->B::OP::bytecode; - print "op_gv $gvix\n"; - $gv->bytecode; + print "op_padix $padix\n"; } sub B::PVOP::bytecode { diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm index b57d1ad2b3..31ecb53fad 100644 --- a/ext/B/B/C.pm +++ b/ext/B/B/C.pm @@ -83,7 +83,7 @@ BEGIN { # Code sections my ($init, $decl, $symsect, $binopsect, $condopsect, $copsect, - $gvopsect, $listopsect, $logopsect, $loopsect, $opsect, $pmopsect, + $padopsect, $listopsect, $logopsect, $loopsect, $opsect, $pmopsect, $pvopsect, $svopsect, $unopsect, $svsect, $xpvsect, $xpvavsect, $xpvhvsect, $xpvcvsect, $xpvivsect, $xpvnvsect, $xpvmgsect, $xpvlvsect, $xrvsect, $xpvbmsect, $xpviosect ); @@ -276,17 +276,17 @@ sub B::SVOP::save { savesym($op, sprintf("(OP*)&svop_list[%d]", $svopsect->index)); } -sub B::GVOP::save { +sub B::PADOP::save { my ($op, $level) = @_; my $sym = objsym($op); return $sym if defined $sym; - my $gvsym = $op->gv->save; - $gvopsect->add(sprintf("s\\_%x, s\\_%x, %s,$handle_VC_problem %u, %u, %u, 0x%x, 0x%x, Nullgv", + $padopsect->add(sprintf("s\\_%x, s\\_%x, %s,$handle_VC_problem %u, %u, %u, 0x%x, 0x%x, Nullgv", ${$op->next}, ${$op->sibling}, $op->ppaddr, $op->targ, $op->type, $op_seq, $op->flags, $op->private)); - $init->add(sprintf("gvop_list[%d].op_gv = %s;", $gvopsect->index, $gvsym)); - savesym($op, sprintf("(OP*)&gvop_list[%d]", $gvopsect->index)); + $init->add(sprintf("padop_list[%d].op_padix = %ld;", + $padopsect->index, $op->padix)); + savesym($op, sprintf("(OP*)&padop_list[%d]", $padopsect->index)); } sub B::COP::save { @@ -951,7 +951,7 @@ sub output_all { my $init_name = shift; my $section; my @sections = ($opsect, $unopsect, $binopsect, $logopsect, $condopsect, - $listopsect, $pmopsect, $svopsect, $gvopsect, $pvopsect, + $listopsect, $pmopsect, $svopsect, $padopsect, $pvopsect, $loopsect, $copsect, $svsect, $xpvsect, $xpvavsect, $xpvhvsect, $xpvcvsect, $xpvivsect, $xpvnvsect, $xpvmgsect, $xpvlvsect, $xrvsect, $xpvbmsect, $xpviosect); @@ -1399,7 +1399,7 @@ sub save_main { sub init_sections { my @sections = (init => \$init, decl => \$decl, sym => \$symsect, binop => \$binopsect, condop => \$condopsect, - cop => \$copsect, gvop => \$gvopsect, + cop => \$copsect, padop => \$padopsect, listop => \$listopsect, logop => \$logopsect, loop => \$loopsect, op => \$opsect, pmop => \$pmopsect, pvop => \$pvopsect, svop => \$svopsect, unop => \$unopsect, diff --git a/ext/B/B/Debug.pm b/ext/B/B/Debug.pm index 89100689a8..a61f6df5da 100644 --- a/ext/B/B/Debug.pm +++ b/ext/B/B/Debug.pm @@ -86,11 +86,10 @@ sub B::PVOP::debug { printf "\top_pv\t\t0x%x\n", $op->pv; } -sub B::GVOP::debug { +sub B::PADOP::debug { my ($op) = @_; $op->B::OP::debug(); - printf "\top_gv\t\t0x%x\n", ${$op->gv}; - $op->gv->debug; + printf "\top_padix\t\t%ld\n", $op->padix; } sub B::CVOP::debug { diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index ede68f5a8d..c5d3ce9504 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -1109,7 +1109,7 @@ sub ftst { # Genuine `-X' filetests are exempt from the LLAFR, but not # l?stat(); for the sake of clarity, give'em all parens return $self->maybe_parens_unop($name, $op->first, $cx); - } elsif (class($op) eq "GVOP") { + } elsif (class($op) eq "SVOP") { return $self->maybe_parens_func($name, $self->pp_gv($op, 1), $cx, 16); } else { # I don't think baseop filetests ever survive ck_ftst, but... return $name; diff --git a/ext/B/B/Lint.pm b/ext/B/B/Lint.pm index 67abe3d145..3a4714226e 100644 --- a/ext/B/B/Lint.pm +++ b/ext/B/B/Lint.pm @@ -232,7 +232,7 @@ sub B::LOOP::lint { } } -sub B::GVOP::lint { +sub B::SVOP::lint { my $op = shift; if ($check{dollar_underscore} && $op->name eq "gvsv" && $op->gv->NAME eq "_") @@ -241,11 +241,11 @@ sub B::GVOP::lint { } if ($check{private_names}) { my $opname = $op->name; - my $gv = $op->gv; - if (($opname eq "gv" || $opname eq "gvsv") - && $gv->NAME =~ /^_./ && $gv->STASH->NAME ne $curstash) - { - warning('Illegal reference to private name %s', $gv->NAME); + if (($opname eq "gv" || $opname eq "gvsv") { + my $gv = $op->gv; + if ($gv->NAME =~ /^_./ && $gv->STASH->NAME ne $curstash) { + warning('Illegal reference to private name %s', $gv->NAME); + } } } if ($check{undefined_subs}) { diff --git a/ext/B/B/Terse.pm b/ext/B/B/Terse.pm index bc9d9434c9..66b5cfc2f2 100644 --- a/ext/B/B/Terse.pm +++ b/ext/B/B/Terse.pm @@ -54,10 +54,9 @@ sub B::SVOP::terse { $op->sv->terse(0); } -sub B::GVOP::terse { +sub B::PADOP::terse { my ($op, $level) = @_; - print indent($level), peekop($op), " "; - $op->gv->terse(0); + print indent($level), peekop($op), " ", $op->padix, "\n"; } sub B::PMOP::terse { diff --git a/ext/B/typemap b/ext/B/typemap index febadf8d62..bafba1c8e4 100644 --- a/ext/B/typemap +++ b/ext/B/typemap @@ -7,7 +7,7 @@ B::LOGOP T_OP_OBJ B::LISTOP T_OP_OBJ B::PMOP T_OP_OBJ B::SVOP T_OP_OBJ -B::GVOP T_OP_OBJ +B::PADOP T_OP_OBJ B::PVOP T_OP_OBJ B::CVOP T_OP_OBJ B::LOOP T_OP_OBJ @@ -30,6 +30,7 @@ B::IO T_SV_OBJ B::MAGIC T_MG_OBJ SSize_t T_IV STRLEN T_IV +PADOFFSET T_UV INPUT T_OP_OBJ diff --git a/ext/ByteLoader/byterun.c b/ext/ByteLoader/byterun.c index 60dc98d3cc..19b79ac3f1 100644 --- a/ext/ByteLoader/byterun.c +++ b/ext/ByteLoader/byterun.c @@ -34,7 +34,7 @@ static int optype_size[] = { sizeof(LISTOP), sizeof(PMOP), sizeof(SVOP), - sizeof(GVOP), + sizeof(PADOP), sizeof(PVOP), sizeof(LOOP), sizeof(COP) @@ -779,11 +779,11 @@ byterun(pTHXo_ struct bytestream bs) cSVOP->op_sv = arg; break; } - case INSN_OP_GV: /* 102 */ + case INSN_OP_PADIX: /* 102 */ { - svindex arg; - BGET_svindex(arg); - *(SV**)&cGVOP->op_gv = arg; + PADOFFSET arg; + BGET_U32(arg); + cPADOP->op_padix = arg; break; } case INSN_OP_PV: /* 103 */ diff --git a/ext/ByteLoader/byterun.h b/ext/ByteLoader/byterun.h index 3b8f77642c..d8f6c0e155 100644 --- a/ext/ByteLoader/byterun.h +++ b/ext/ByteLoader/byterun.h @@ -118,7 +118,7 @@ enum { INSN_OP_PMFLAGS, /* 99 */ INSN_OP_PMPERMFLAGS, /* 100 */ INSN_OP_SV, /* 101 */ - INSN_OP_GV, /* 102 */ + INSN_OP_PADIX, /* 102 */ INSN_OP_PV, /* 103 */ INSN_OP_PV_TR, /* 104 */ INSN_OP_REDOOP, /* 105 */ @@ -145,7 +145,7 @@ enum { OPt_LISTOP, /* 4 */ OPt_PMOP, /* 5 */ OPt_SVOP, /* 6 */ - OPt_GVOP, /* 7 */ + OPt_PADOP, /* 7 */ OPt_PVOP, /* 8 */ OPt_LOOP, /* 9 */ OPt_COP /* 10 */ |