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

[perl #120441] Lexical subs used for AUTOLOAD

From:
Father Chrysostomos via RT
Date:
August 28, 2014 19:32
Subject:
[perl #120441] Lexical subs used for AUTOLOAD
Message ID:
rt-4.0.18-23837-1409254316-218.120441-15-0@perl.org
On Sat Nov 02 17:32:46 2013, perl5-porters@perl.org wrote:
> Peter Martini wrote:
> > On Nov 2, 2013, at 14:18, Father Chrysostomos <sprout@cpan.org> 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
https://rt.perl.org/Ticket/Display.html?id=120441



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About