From: Nicholas Clark Date: Fri, 24 Feb 2006 14:19:37 +0000 (+0000) Subject: Use PVMGs rather than PVGVs to store the names of our variables in the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2892acdbbc776bf121eaec9d93ea404f7afc54b8;p=p5sagit%2Fp5-mst-13.2.git Use PVMGs rather than PVGVs to store the names of our variables in the pad. p4raw-id: //depot/perl@27313 --- diff --git a/pad.c b/pad.c index 1cad444..3a35673 100644 --- a/pad.c +++ b/pad.c @@ -74,10 +74,10 @@ in PL_op->op_targ), wasting a name SV for them doesn't make sense. The SVs in the names AV have their PV being the name of the variable. NV+1..IV inclusive is a range of cop_seq numbers for which the name is valid. For typed lexicals name SV is SVt_PVMG and SvSTASH points at the -type. For C lexicals, the type is SVt_PVGV, and GvSTASH points at the -stash of the associated global (so that duplicate C declarations in the -same package can be detected). SvCUR is sometimes hijacked to -store the generation number during compilation. +type. For C lexicals, the type is also SVt_PVGV, with the MAGIC slot +pointing at the stash of the associated global (so that duplicate C +declarations in the same package can be detected). SvCUR is sometimes +hijacked to store the generation number during compilation. If SvFAKE is set on the name SV, then that slot in the frame AV is a REFCNT'ed reference to a lexical from "outside". In this case, @@ -338,7 +338,7 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake ASSERT_CURPAD_ACTIVE("pad_add_name"); - sv_upgrade(namesv, ourstash ? SVt_PVGV : typestash ? SVt_PVMG : SVt_PVNV); + sv_upgrade(namesv, (ourstash || typestash) ? SVt_PVMG : SVt_PVNV); sv_setpv(namesv, name); if (typestash) { diff --git a/sv.c b/sv.c index ca61ada..3ef19cf 100644 --- a/sv.c +++ b/sv.c @@ -9784,8 +9784,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) FIXME - instrument and check that assumption */ if (sv_type >= SVt_PVMG) { HV *ourstash; - if ((sv_type == SVt_PVMG || sv_type == SVt_PVGV) && - (ourstash = OURSTASH(dstr))) { + if ((sv_type == SVt_PVMG) && (ourstash = OURSTASH(dstr))) { OURSTASH_set(dstr, hv_dup_inc(ourstash, param)); } else if (SvMAGIC(dstr)) SvMAGIC_set(dstr, mg_dup(SvMAGIC(dstr), param)); diff --git a/sv.h b/sv.h index 159fd1a..b4926c0 100644 --- a/sv.h +++ b/sv.h @@ -962,7 +962,7 @@ in gv.h: */ (SvPAD_OUR(sv) ? ((XPVMG*) SvANY(sv))->xmg_u.xmg_ourstash : NULL) #define OURSTASH_set(sv, st) \ STMT_START { \ - assert(SvTYPE(sv) == SVt_PVGV); \ + assert(SvTYPE(sv) == SVt_PVMG); \ ((XPVMG*) SvANY(sv))->xmg_u.xmg_ourstash = st; \ } STMT_END