Shave sizeof(NV) bytes from formats, by using the same offset
Nicholas Clark [Sun, 19 Feb 2006 22:35:24 +0000 (22:35 +0000)]
manoeuvre as PVs, PVIVs, PVAVs and PVHVs.

p4raw-id: //depot/perl@27231

sv.c
sv.h

diff --git a/sv.c b/sv.c
index 966b1d7..4ba7b95 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -973,9 +973,11 @@ static const struct body_details bodies_by_type[] = {
     { sizeof(XPVCV), sizeof(XPVCV), 0, TRUE, HADNV,
       HASARENA, FIT_ARENA(0, sizeof(XPVCV)) },
 
-    /* XPVFM is 80 bytes, fits 51x */
-    { sizeof(XPVFM), sizeof(XPVFM), 0, TRUE, HADNV, 
-      HASARENA, FIT_ARENA(20, sizeof(XPVFM)) },
+    { sizeof(xpvfm_allocated),
+      sizeof(xpvfm_allocated)
+      - relative_STRUCT_OFFSET(xpvfm_allocated, XPVFM, xpv_cur),
+      + relative_STRUCT_OFFSET(xpvfm_allocated, XPVFM, xpv_cur),
+      TRUE, HADNV, NOARENA, FIT_ARENA(20, sizeof(xpvfm_allocated)) },
 
     /* XPVIO is 84 bytes, fits 48x */
     { sizeof(XPVIO), sizeof(XPVIO), 0, TRUE, HADNV,
diff --git a/sv.h b/sv.h
index d3ce22f..44803bc 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -446,6 +446,34 @@ struct xpvfm {
     IV         xfm_lines;
 };
 
+typedef struct {
+    STRLEN     xpv_cur;        /* length of svu_pv as a C string */
+    STRLEN     xpv_len;        /* allocated size */
+    union {
+       IV      xivu_iv;        /* integer value or pv offset */
+       UV      xivu_uv;
+       void *  xivu_p1;
+    }          xiv_u;
+    MAGIC*     xmg_magic;      /* linked list of magicalness */
+    HV*                xmg_stash;      /* class package */
+
+    HV *       xcv_stash;
+    OP *       xcv_start;
+    OP *       xcv_root;
+    void      (*xcv_xsub)(pTHX_ CV*);
+    ANY                xcv_xsubany;
+    GV *       xcv_gv;
+    char *     xcv_file;
+    long       xcv_depth;      /* >= 2 indicates recursive call */
+    AV *       xcv_padlist;
+    CV *       xcv_outside;
+    cv_flags_t xcv_flags;
+    U32                xcv_outside_seq; /* the COP sequence (at the point of our
+                                 * compilation) in the lexically enclosing
+                                 * sub */
+    IV         xfm_lines;
+} xpvfm_allocated;
+
 struct xpvio {
     NV         xnv_nv;         /* numeric value, if any */
     STRLEN     xpv_cur;        /* length of svu_pv as a C string */
@@ -923,6 +951,7 @@ in gv.h: */
            assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \
            assert(SvTYPE(_svi) != SVt_PVAV);                           \
            assert(SvTYPE(_svi) != SVt_PVHV);                           \
+           assert(SvTYPE(_svi) != SVt_PVFM);                           \
           &(((XPVNV*) SvANY(_svi))->xnv_nv);                           \
         }))
 #    define SvMAGIC(sv)                                                        \