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.


In reply to Re^3: named sub, subref and magic goto speed by ysth
in thread named sub, subref and magic goto speed by shmem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.