On Sat, Jun 18, 2005 at 12:15:39PM -0600, Jim Cromie wrote:
> 
> we now have
> 
> struct STRUCT_SV {              /* struct sv { */
>      void*       sv_any;         /* pointer to something */
>      U32         sv_refcnt;      /* how many references to us */
>      U32         sv_flags;       /* what we are */
>      union {
>          IV      svu_iv;
>          UV      svu_uv;
>          SV*     svu_rv;         /* pointer to another SV */
>          char*   svu_pv;         /* pointer to malloced string */
>          SV**    svu_array;
>      }           sv_u;
> }
> 
> 
> wherein the 2 'data' fields are separated by the 'management' fields.
> 
> It seems potentially useful to juggle them so that the 2 data are
> contiguous, then we could (after a bit more tweaking)
> store doubles, complex numbers, and other nasties.

The problem with doing this is that all the access macros assume that the
thing they are accessing are at some offset in the structure that sv_any
points to. Hence the offset games for IVs, so that svu_iv still is at the
offset the compiler would expect to find it in

struct xpviv {
    NV          xnv_nv;         /* numeric value, if any */
    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;
};


So it's not going to be possible to store an NV in the head, if SvNVX() still
looks like this:

#  define SvNVX(sv) ((XPVNV*) SvANY(sv))->xnv_nv


I'm not sure how much slowdown there would be from implementing a conditional
in that based on some other flag.

Nicholas Clark

Reply via email to