Change 27312 by [EMAIL PROTECTED] on 2006/02/24 13:59:57

        Store the stash for our in the magic slot. This will allow us to use
        PVMGs in pad names where previously PVGVs were used. In turn, this
        gives much greater flexibility for the layout of PVGVs.

Affected files ...

... //depot/perl/av.h#35 edit
... //depot/perl/cv.h#62 edit
... //depot/perl/hv.h#85 edit
... //depot/perl/pad.c#92 edit
... //depot/perl/sv.c#1167 edit
... //depot/perl/sv.h#255 edit

Differences ...

==== //depot/perl/av.h#35 (text) ====
Index: perl/av.h
--- perl/av.h#34~25417~ 2005-09-15 07:48:37.000000000 -0700
+++ perl/av.h   2006-02-24 05:59:57.000000000 -0800
@@ -17,7 +17,10 @@
        UV      xivu_uv;
        void *  xivu_p1;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* magic for scalar array */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 };
 
@@ -32,7 +35,10 @@
        UV      xivu_uv;
        void *  xivu_p1;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* magic for scalar array */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 } xpvav_allocated;
 #endif

==== //depot/perl/cv.h#62 (text) ====
Index: perl/cv.h
--- perl/cv.h#61~27260~ 2006-02-21 08:12:37.000000000 -0800
+++ perl/cv.h   2006-02-24 05:59:57.000000000 -0800
@@ -20,7 +20,10 @@
        void *  xivu_p1;
        I32     xivu_i32;       /* depth, >= 2 indicates recursive call */
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* magic for scalar array */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     HV *       xcv_stash;
@@ -51,7 +54,10 @@
        void *  xivu_p1;
        I32     xivu_i32;       /* depth, >= 2 indicates recursive call */
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* magic for scalar array */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     HV *       xcv_stash;

==== //depot/perl/hv.h#85 (text) ====
Index: perl/hv.h
--- perl/hv.h#84~27065~ 2006-02-03 08:03:01.000000000 -0800
+++ perl/hv.h   2006-02-24 05:59:57.000000000 -0800
@@ -57,7 +57,10 @@
        UV      xivu_uv;
        void *  xivu_p1;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* magic for scalar array */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 };
 
@@ -74,7 +77,10 @@
        UV      xivu_uv;
        void *  xivu_p1;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* magic for scalar array */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 } xpvhv_allocated;
 #endif

==== //depot/perl/pad.c#92 (text) ====
Index: perl/pad.c
--- perl/pad.c#91~27306~        2006-02-24 03:52:28.000000000 -0800
+++ perl/pad.c  2006-02-24 05:59:57.000000000 -0800
@@ -348,7 +348,7 @@
     if (ourstash) {
        SvPAD_OUR_on(namesv);
        OURSTASH_set(namesv, ourstash);
-       Perl_sv_add_backref(aTHX_ (SV*)ourstash, namesv);
+       SvREFCNT_inc(ourstash);
     }
 
     av_store(PL_comppad_name, offset, namesv);

==== //depot/perl/sv.c#1167 (text) ====
Index: perl/sv.c
--- perl/sv.c#1166~27300~       2006-02-24 02:41:53.000000000 -0800
+++ perl/sv.c   2006-02-24 05:59:57.000000000 -0800
@@ -1309,7 +1309,7 @@
        SvPV_set(sv, NULL);
 
        if (old_type >= SVt_PVMG) {
-           SvMAGIC_set(sv, ((XPVMG*)old_body)->xmg_magic);
+           SvMAGIC_set(sv, ((XPVMG*)old_body)->xmg_u.xmg_magic);
            SvSTASH_set(sv, ((XPVMG*)old_body)->xmg_stash);
        }
        break;
@@ -5043,7 +5043,11 @@
        }
     }
     if (type >= SVt_PVMG) {
-       if (SvMAGIC(sv))
+       HV *ourstash;
+       if ((type == SVt_PVMG || type == SVt_PVGV) &&
+           (ourstash = OURSTASH(sv))) {
+           SvREFCNT_dec(ourstash);
+       } else if (SvMAGIC(sv))
            mg_free(sv);
        if (type == SVt_PVMG && SvPAD_TYPED(sv))
            SvREFCNT_dec(SvSTASH(sv));
@@ -9779,7 +9783,11 @@
               missing by always going for the destination.
               FIXME - instrument and check that assumption  */
            if (sv_type >= SVt_PVMG) {
-               if (SvMAGIC(dstr))
+               HV *ourstash;
+               if ((sv_type == SVt_PVMG || sv_type == SVt_PVGV) &&
+                   (ourstash = OURSTASH(dstr))) {
+                   OURSTASH_set(dstr, hv_dup_inc(ourstash, param));
+               } else if (SvMAGIC(dstr))
                    SvMAGIC_set(dstr, mg_dup(SvMAGIC(dstr), param));
                if (SvSTASH(dstr))
                    SvSTASH_set(dstr, hv_dup_inc(SvSTASH(dstr), param));

==== //depot/perl/sv.h#255 (text) ====
Index: perl/sv.h
--- perl/sv.h#254~27306~        2006-02-24 03:52:28.000000000 -0800
+++ perl/sv.h   2006-02-24 05:59:57.000000000 -0800
@@ -379,7 +379,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 };
 
@@ -393,7 +396,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     /* a full glob fits into this */
@@ -420,7 +426,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     GP*                xgv_gp;
@@ -440,7 +449,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     I32                xbm_useful;     /* is this constant pattern being 
useful? */
@@ -462,7 +474,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     HV *       xcv_stash;
@@ -494,7 +509,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     HV *       xcv_stash;
@@ -527,7 +545,10 @@
        void *  xivu_p1;
        I32     xivu_i32;
     }          xiv_u;
-    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    union {
+       MAGIC*  xmg_magic;      /* linked list of magicalness */
+       HV*     xmg_ourstash;   /* Stash for our (when SvPAD_OUR is true) */
+    } xmg_u;
     HV*                xmg_stash;      /* class package */
 
     PerlIO *   xio_ifp;        /* ifp and ofp are normally the same */
@@ -937,11 +958,12 @@
        ((SvFLAGS(sv) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR))
 #define SvPAD_OUR_on(sv)       (SvFLAGS(sv) |= SVpad_NAME|SVpad_OUR)
 
-#define OURSTASH(sv)   (SvPAD_OUR(sv) ? GvSTASH(sv) : NULL)
-#define OURSTASH_set(sv, st)                   \
-        STMT_START {                           \
-           assert(SvTYPE(sv) == SVt_PVGV);     \
-           GvSTASH(sv) = st;                   \
+#define OURSTASH(sv)   \
+       (SvPAD_OUR(sv) ? ((XPVMG*) SvANY(sv))->xmg_u.xmg_ourstash : NULL)
+#define OURSTASH_set(sv, st)                                   \
+        STMT_START {                                           \
+           assert(SvTYPE(sv) == SVt_PVGV);                     \
+           ((XPVMG*) SvANY(sv))->xmg_u.xmg_ourstash = st;      \
        } STMT_END
 
 #ifdef PERL_DEBUG_COW
@@ -970,16 +992,16 @@
 #  ifdef DEBUGGING
 #    ifdef PERL_IN_SV_C
 /* Can't make this RVALUE because of Perl_sv_unmagic.  */
-#      define SvMAGIC(sv)      (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*)  
SvANY(sv))->xmg_magic))
+#      define SvMAGIC(sv)      (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*)  
SvANY(sv))->xmg_u.xmg_magic))
 #    else
-#      define SvMAGIC(sv)      (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), 
&((XPVMG*)  SvANY(sv))->xmg_magic))
+#      define SvMAGIC(sv)      (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), 
&((XPVMG*)  SvANY(sv))->xmg_u.xmg_magic))
 #    endif
 #  define SvSTASH(sv)  (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*)  
SvANY(sv))->xmg_stash))
 #  else
 #    ifdef PERL_IN_SV_C
-#      define SvMAGIC(sv) ((XPVMG*)  SvANY(sv))->xmg_magic
+#      define SvMAGIC(sv) ((XPVMG*)  SvANY(sv))->xmg_u.xmg_magic
 #    else
-#      define SvMAGIC(sv) (0 + ((XPVMG*)  SvANY(sv))->xmg_magic)
+#      define SvMAGIC(sv) (0 + ((XPVMG*)  SvANY(sv))->xmg_u.xmg_magic)
 #    endif
 #  define SvSTASH(sv)     (0 + ((XPVMG*)  SvANY(sv))->xmg_stash)
 #  endif
@@ -1018,9 +1040,7 @@
 #    define SvMAGIC(sv)                                                        
\
        (*({ SV *const _svi = (SV *) sv;                                \
            assert(SvTYPE(_svi) >= SVt_PVMG);                           \
-           if (SvTYPE(_svi) == SVt_PVMG && (SvFLAGS(_svi) & SVpad_NAME)) \
-               assert (!((XPVMG*) SvANY(_svi))->xmg_magic); \
-           &(((XPVMG*) SvANY(_svi))->xmg_magic);                       \
+           &(((XPVMG*) SvANY(_svi))->xmg_u.xmg_magic);                 \
          }))
 #    define SvSTASH(sv)                                                        
\
        (*({ SV *const _svi = (SV *) sv;                                \
@@ -1031,7 +1051,7 @@
 #    define SvIVX(sv) ((XPVIV*) SvANY(sv))->xiv_iv
 #    define SvUVX(sv) ((XPVUV*) SvANY(sv))->xuv_uv
 #    define SvNVX(sv) ((XPVNV*) SvANY(sv))->xnv_nv
-#    define SvMAGIC(sv)        ((XPVMG*)  SvANY(sv))->xmg_magic
+#    define SvMAGIC(sv)        ((XPVMG*)  SvANY(sv))->xmg_u.xmg_magic
 #    define SvSTASH(sv)        ((XPVMG*)  SvANY(sv))->xmg_stash
 #  endif
 #endif
@@ -1080,7 +1100,7 @@
                 ((sv)->sv_u.svu_rv = (val)); } STMT_END
 #define SvMAGIC_set(sv, val) \
         STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
-                (((XPVMG*)SvANY(sv))->xmg_magic = (val)); } STMT_END
+                (((XPVMG*)SvANY(sv))->xmg_u.xmg_magic = (val)); } STMT_END
 #define SvSTASH_set(sv, val) \
         STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
                 (((XPVMG*)  SvANY(sv))->xmg_stash = (val)); } STMT_END
End of Patch.

Reply via email to