I am thinking of somehow allowing the peephole optimizer or toke.c to call AUTOLOAD if AUTOLOAD CV promises to have no side effects from it being called at compile time. I found this commit, but it doesn't explain anything. http://perl5.git.perl.org/perl.git/commitdiff/70e590749aafa6e0e67a2220f53f1568bf4e16de Testing shows no CV and no inlining. ------------------------------------- #!/usr/bin/perl -w #use strict; use B::Concise; use Devel::Peek 'Dump'; #use Data::Dumper; #use constant MYCON => 1; #BEGIN { eval 'sub MYCON () {1}' } sub AUTOLOAD { eval 'sub MYCON () {1}'; goto \&MYCON; } sub tsub { my $s = MYCON(); print $s."\n"; } Dump(*MYCON); tsub(); my $walker = B::Concise::compile('-src','-exec', *tsub{CODE}); $walker->(); Dump(*MYCON); ------------------------------------ ------------------------------------ C:\perl521\src>perl n17.pl SV = PVGV(0xa52fbc) at 0x8fe98c REFCNT = 5 FLAGS = (PADSTALE,MULTI) NAME = "MYCON" NAMELEN = 5 GvSTASH = 0x388d5c "main" FLAGS = 0x2 GP = 0xa7f1e4 SV = 0x0 REFCNT = 1 IO = 0x0 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x0 CVGEN = 0x0 GPFLAGS = 0x0 () LINE = 11 FILE = "n17.pl" EGV = 0x8fe98c "MYCON" 1 B::Concise::compile(CODE(0x98c0cc)) # 15: my $s = MYCON(); 1 <;> nextstate(main 33 n17.pl:15) v 2 <0> pushmark s 3 <#> gv[*MYCON] s/EARLYCV 4 <1> entersub[t2] sKS/TARG 5 <0> padsv[$s:33,34] sRM*/LVINTRO 6 <2> sassign vKS/2 # 16: print $s."\n"; 7 <;> nextstate(main 34 n17.pl:16) v 8 <0> pushmark s 9 <0> padsv[$s:33,34] s a <$> const[PV "\n"] s b <2> concat[t5] sK/2 c <@> print sK d <1> leavesub[1 ref] K/REFC,1 SV = PVGV(0xa52fbc) at 0x8fe98c REFCNT = 5 FLAGS = (PADSTALE,RMG,MULTI) MAGIC = 0x90241c MG_VIRTUAL = &PL_vtbl_backref MG_TYPE = PERL_MAGIC_backref(<) MG_OBJ = 0x8fe66c NAME = "MYCON" NAMELEN = 5 GvSTASH = 0x388d5c "main" FLAGS = 0x2 GP = 0xa7f1e4 SV = 0x0 REFCNT = 1 IO = 0x0 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x8fe66c CVGEN = 0x0 GPFLAGS = 0x0 () LINE = 11 FILE = "n17.pl" EGV = 0x8fe98c "MYCON" C:\perl521\src> ------------------------------------ I'm thinking of modifying the gv_fetchsv() at http://perl5.git.perl.org/perl.git/blob/01b515d1d793fe9ee31ac67de850d943ce109686:/op.c#l9856 to fall back to autoload sub if it exists, and if AUTOLOAD's CV has CvCONST flag, since I dont want to add a new flag, AUTOLOAD sub will be called at compile time, not runtime from pp_entersub. Any comments?Thread Next