This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: pmdynflags and thread safety
[perl5.git] / pad.c
diff --git a/pad.c b/pad.c
index c4b8e5e..8560d9a 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -1,6 +1,6 @@
 /*    pad.c
  *
- *    Copyright (C) 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
+ *    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -347,12 +347,11 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake
 {
     dVAR;
     const PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY);
-    SV* const namesv = newSV(0);
+    SV* const namesv
+       = newSV_type((ourstash || typestash) ? SVt_PVMG : SVt_PVNV);
 
     ASSERT_CURPAD_ACTIVE("pad_add_name");
 
-
-    sv_upgrade(namesv, (ourstash || typestash) ? SVt_PVMG : SVt_PVNV);
     sv_setpv(namesv, name);
 
     if (typestash) {
@@ -485,9 +484,8 @@ Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type)
 {
     dVAR;
     PADOFFSET ix;
-    SV* const name = newSV(0);
+    SV* const name = newSV_type(SVt_PVNV);
     pad_peg("add_anon");
-    sv_upgrade(name, SVt_PVNV);
     sv_setpvn(name, "&", 1);
     /* Are these two actually ever read? */
     COP_SEQ_RANGE_HIGH_set(name, ~0);
@@ -1043,7 +1041,7 @@ Perl_pad_leavemy(pTHX)
                    && !SvFAKE(sv) && ckWARN_d(WARN_INTERNAL))
                Perl_warner(aTHX_ packWARN(WARN_INTERNAL),
                            "%"SVf" never introduced",
-                           (void*)sv);
+                           SVfARG(sv));
        }
     }
     /* "Deintroduce" my variables that are leaving with this scope. */
@@ -1457,8 +1455,7 @@ Perl_cv_clone(pTHX_ CV *proto)
     ENTER;
     SAVESPTR(PL_compcv);
 
-    cv = PL_compcv = (CV*)newSV(0);
-    sv_upgrade((SV *)cv, SvTYPE(proto));
+    cv = PL_compcv = (CV*)newSV_type(SvTYPE(proto));
     CvFLAGS(cv) = CvFLAGS(proto) & ~(CVf_CLONE|CVf_WEAKOUTSIDE);
     CvCLONED_on(cv);
 
@@ -1622,7 +1619,10 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth)
        for ( ;ix > 0; ix--) {
            if (names_fill >= ix && names[ix] != &PL_sv_undef) {
                const char sigil = SvPVX_const(names[ix])[0];
-               if ((SvFLAGS(names[ix]) & SVf_FAKE) || sigil == '&') {
+               if ((SvFLAGS(names[ix]) & SVf_FAKE)
+                       || (SvFLAGS(names[ix]) & SVpad_STATE)
+                       || sigil == '&')
+               {
                    /* outer lexical or anon code */
                    av_store(newpad, ix, SvREFCNT_inc(oldpad[ix]));
                }