in reply to Circular reference testing.

Most SV structures are greater than 12 bytes, and I could reduce the overhead commensurately if (for example) there was only ever one SvNULL allocated in the system and all other SV's were multiples of 16 or 20 bytes?

But more than one SvNULL will be created, as the following shows:

$ perl -MDevel::Peek -we '$a = undef; $b = undef; Dump($a); Dump($b)' SV = NULL(0x0) at 0x8191dc4 REFCNT = 1 FLAGS = () SV = NULL(0x0) at 0x8191ddc REFCNT = 1 FLAGS = ()
And note that their addresses are 24 bytes apart, which doesn't suggest any alignment on 16 or 20 byte intervals. This:
$ perl -MDevel::Peek -we '$a = 1; $b = 2; Dump ($a); Dump ($b)' SV = IV(0x8192edc) at 0x8191dbc REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 SV = IV(0x8192ee4) at 0x8191de0 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 2
creates two SVs 36 bytes apart, which suggest you can't use anything larger than 12.

Replies are listed 'Best First'.
Re^2: Circular reference testing.
by BrowserUk (Patriarch) on Mar 08, 2005 at 17:16 UTC

    I think you may have missed the "...if (for example)..." part of my post?

    But more than one SvNULL will be created

    That's a shame. Think of the space that would be saved if all SV's that were undef, were pointers to a single, shared copy of undef with a COW flag set?

    creates two SVs 36 bytes apart, which suggest you can't use anything larger than 12.

    Yeah! Since posting, I looked at the addresses of consecutive elements of an array and 12 does appear to be the minimum I can rely upon.

    Any thoughts on discovering the lowest and highest addresses?


    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.