in reply to Re: Can you speed up method calls by eliminating method dispatch?
in thread Can you speed up method calls by eliminating method dispatch?
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:
... 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. */
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Can you speed up method calls by eliminating method dispatch?
by ikegami (Patriarch) on Jul 09, 2009 at 15:36 UTC | |
by missingthepoint (Friar) on Jul 10, 2009 at 03:40 UTC |