Apparently I was mistaken about the stack frame (unless it's changed since Larry wrote that). But the "heavy lifting" I meant was loading @_ onto the stack. For purposes of comparison:
$ perl -MO=Concise,-exec,named,refcall,goto1,goto2 -we'my $ref = \&bar
+; sub bar {}
sub named { bar(@_) } sub refcall { $ref->(@_) } sub goto1 { goto &$re
+f } sub goto2 { goto $ref }'
main::named:
1 <;> nextstate(main 3 -e:2) v
2 <0> pushmark s
3 <$> gv(*_) s
4 <1> rv2av[t1] lKM/1
5 <$> gv(*bar) s
6 <1> entersub[t2] KS/TARG,1
7 <1> leavesub[1 ref] K/REFC,1
main::refcall:
8 <;> nextstate(main 4 -e:2) v
9 <0> pushmark s
a <$> gv(*_) s
b <1> rv2av[t2] lKM/1
c <0> padsv[$ref:FAKE] s
d <1> entersub[t3] KS/TARG,1
e <1> leavesub[1 ref] K/REFC,1
main::goto1:
f <;> nextstate(main 5 -e:2) v
g <0> pushmark sRM
h <0> padsv[$ref:FAKE] s
i <1> rv2cv[t2] lKRM/33
j <1> refgen sK/1
k <1> goto sKS/1
l <1> leavesub[1 ref] K/REFC,1
main::goto2:
m <;> nextstate(main 6 -e:2) v
n <0> padsv[$ref:FAKE] s
o <1> goto sKS/1
p <1> leavesub[1 ref] K/REFC,1
-e syntax OK
Miscellaneous points:
You can see that goto $ref bypasses an unnecessary deref/refgen that goto &$ref does.
refcall and named have to load @_ onto the stack; the gotos don't.
refcall and named differ only by one operation: gv vs. padsv. gv and padsv are both trivial ops (except when padsv has flags set that it doesn't here) that just push a value on the stack, so I wouldn't expect any significant difference between them. |