OK, thanks. I grok the aliasing, I think (some sort of NULL pointer changes to be a pointer to a CV, which new pointer holds the same address as Base::f's pointer?) With the Devel::Peek output, is this what's going on?

(Looking at P5 source, the real magic behind Devel::Peek seems to be in Perl_do_sv_dump() in dump.c.)

Which translates to (first 2 calls):

SV = PVGV(0x816c6e8) at 0x814f6d8 GP = 0x816c720 CV = 0x814f714 SV = PVGV(0x816f938) at 0x814f810 GP = 0x81709f8 CV = 0x0 <-- &Child::f doesn't exist CVGEN = 0x0

(last):

SV = PVGV(0x816f938) at 0x814f810 GP = 0x81709f8 CV = 0x814f714 <-- &Child::f aliased to &Base::f CVGEN = 0x4d <-- ...for method dispatch only

Within the pared-down Devel::Peek output:

SV = PVGV(0x816c6e8) at 0x814f6d8 # Reference (at 0x814f6d8) to typ +eglob (at 0x816c6e8)? GP = 0x816c720 # Address of typeglob? Has AV, HV +, CV. CV = 0x814f714 # Address of CV of f() SV = PVGV(0x816f938) at 0x814f810 # Akin to above GP = 0x81709f8 # "" CV = 0x0 # Child::f()'s pointer to CV, equ +iv place to Base::f() CVGEN = 0x0 # "generated CV"? do you mean "th +is CVGEN 'slot' is used for nothing else than method dispatch"?

Please ignore beyond here, massive tangent :)
No idea what 0x4d is, but within struct gp in gp.h, there is this:

U32        gp_cvgen;    /* generational validity of cached gv_cv */

... and I can find stuff like this:

gv.c 453: GvCVGEN(topgv) = PL_sub_generation;

... and PL_sub_generation seems to be incremented all over the place in the source. Furthermore:

gv.c 457- else if (topgv && GvREFCNT(topgv) == 1) { 458- /* cache the fact that the method is not defined */ 459: GvCVGEN(topgv) = PL_sub_generation; ... 1433- /* Adding a new name to a subroutine invalidates method ca +che */ 1434: PL_sub_generation++;

GvCVGEN is a macro that gets at the CVGEN in the Devel::Peek output:

dump.c 1544: Perl_dump_indent(aTHX_ level, file, " CVGEN = 0x%"UVxf"\n", + (UV)GvCVGEN(sv));

... so line 3330 would relate to your "&Child::f doesn't exist" above:

sv.c 3330- GvCVGEN(dstr) = 0; /* Switch off cacheness. */

The zeroeth step in writing a module is to make sure that there isn't already a decent one in CPAN. (-- Pod::Simple::Subclassing)

In reply to Re^2: Can you speed up method calls by eliminating method dispatch? by missingthepoint
in thread Can you speed up method calls by eliminating method dispatch? by missingthepoint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.