develooper Front page | perl.perl5.porters | Postings from August 2014

[perl #120441] Lexical subs used for AUTOLOAD

Father Chrysostomos via RT
August 28, 2014 19:32
[perl #120441] Lexical subs used for AUTOLOAD
Message ID:
On Sat Nov 02 17:32:46 2013, wrote:
> Peter Martini wrote:
> > On Nov 2, 2013, at 14:18, Father Chrysostomos <> wrote:
> > > As you may have noticed, I haven=92t really thought anything through in
> > > this thread.  Most of my responses are brain dumps with loose ends.
> > > 
> > 
> > Ditto :-)
> Nevertheless, this conversion has given me ideas I would not have come
> up with otherwise.
> Proposed solution:
> • Lexical subs get an extra flag indicating that the stash name must
>   be omitted from the name (CVf_LEXICAL).
> • All subs, at least conceptually, have GVs.  Lexical subs own
>   theirs, and hold a reference count on it, as it does not reside in
>   the stash.
> • Any sub can have CVf_NAMED set, indicating that xcv_gv_u holds a
>   HEK, in which case CvSTASH + CvNAME_HEK combined imply the GV.
> • CvGV will vivify a GV from CvSTASH and CvNAME_HEK when accessed.
> • Whenever GvSTASH(CvGV(cv)) would differ from CvSTASH, we skip this
>   optimisation.
> • To avoid vivifying GVs, always check !CvNAMED before using CvGV.
> • Or use cv_name, which could have this signature:
>   void Perl_cv_name(pTHX_ CV *cv, SV **svp, char **pvp, STRLEN *lenp)
>   where the last three parameters are for returning values.
> The first stage would be to switch lexical subs over to the new system.
> Then we can optimise other subs by making
>     sub foo {}
> put a code ref in $::{foo}.

Oh boy!  I had completely forgotten about this thread.  I have just fixed the original issue with 18691622911 (before finding this thread again), but the other things in the quoted message (which would make for cleaner code) have not been addressed.


Father Chrysostomos

via perlbug:  queue: perl5 status: open Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About