Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 077fc65907e63b3326f77afb51154cea24f8ec32
      
https://github.com/Perl/perl5/commit/077fc65907e63b3326f77afb51154cea24f8ec32
  Author: Richard Leach <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M pp_ctl.c

  Log Message:
  -----------
  pp_caller: use OPf_KIDS rather than MAXARG to free up bits


  Commit: db4bdadc137fb3b6c52f312ecd047005c889753c
      
https://github.com/Perl/perl5/commit/db4bdadc137fb3b6c52f312ecd047005c889753c
  Author: Richard Leach <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M pp_ctl.c

  Log Message:
  -----------
  pp_caller: do the EXTEND check once and early


  Commit: 3e4797081845be64542fc0816985eba12b4aad28
      
https://github.com/Perl/perl5/commit/3e4797081845be64542fc0816985eba12b4aad28
  Author: Richard Leach <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M pp_ctl.c

  Log Message:
  -----------
  pp_caller: minor refactoring ahead of PP unwrapping


  Commit: 88b9ff6e2f1f65e2a87f13dcb6bdced524cdeddc
      
https://github.com/Perl/perl5/commit/88b9ff6e2f1f65e2a87f13dcb6bdced524cdeddc
  Author: Richard Leach <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M pp_ctl.c

  Log Message:
  -----------
  pp_caller - RC stack unwrapped


  Commit: 1f866fac6f5504fe6b008bee870bbccd74eaa8e7
      
https://github.com/Perl/perl5/commit/1f866fac6f5504fe6b008bee870bbccd74eaa8e7
  Author: Richard Leach <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M embed.h
    M lib/B/Deparse.pm
    M lib/B/Deparse.t
    M lib/B/Op_private.pm
    M op.c
    M opcode.h
    M pp_ctl.c
    M proto.h
    M regen/embed.pl
    M regen/op_private
    M regen/opcodes
    M t/op/caller.t
    M t/perf/opcount.t

  Log Message:
  -----------
  OP_CALLER: handle common list slices of return values internally

It's common for `caller()` to be called in list context and immediately
sliced to get a particular return value or a subset thereof. For example:

    my $sub = (caller)[3];

or

    my ($file, $line) = (caller 1)[1,2];

Historically, this meant producing the full set of caller's return values
(3 if no EXPR was provided, 11 if it was), often requiring the creation
and population of new SVs, only for some/most of them to be immediately
discarded by the list slice.

This commit makes use of available `op_private` bits to encode what seem
like the most commonly used (in core and on CPAN) subscripts inside
an OP_CALLER instance that will be immediately sliced. When this occurs,
the actual OP_LSLICE OP and it's OP_CONST children are freed.

Those common & supported subscripts are:
*  0 (package)
*  1 (filename)
*  2 (line)
*  3 (subroutine)
*  8 (hints)
*  9 (bitmask)
* 10 (hinthash)

Ascending runs of these are also supported. So these will be optimized:

* (caller)[3]
* (caller)[1,2,3]
* (caller)[0,3,9] - this one not seen in the wild!

But these will not:

* (caller)[4]
* (caller)[2,1,3]
* (caller)[2,3,4]

At runtime, `pp_caller` checks if any of the relevant bits are set and,
if so, generates and emits only the requested values. (If multiple
subscripts are requested but the OP has scalar context applied, the
set of `op_private` bits will be scanned and only the highest kept.)

This turns `my $sub = caller)[3];` from:

    7        <2> lslice sK/2 ->8
    -           <1> ex-list lK ->5
    3              <0> pushmark s ->4
    4              <$> const[IV 0] s ->5
    -           <1> ex-list lK ->7
    5              <0> pushmark s ->6
    6              <0> caller[t2] l ->7

into:

    <0> caller[t2] s

And `my ($file, $line) = (caller 1)[1,2];` from:

    c     <2> aassign[t4] vKS ->d
    -        <1> ex-list lK ->b
    3           <0> pushmark s ->4
    a           <2> lslice lK/2 ->b
    -              <1> ex-list lK ->7
    4                 <0> pushmark s ->5
    5                 <$> const[IV 1] s ->6
    6                 <$> const[IV 2] s ->7
    -              <1> ex-list lK ->a
    7                 <0> pushmark s ->8
    9                 <1> caller[t3] lK/1 ->a
    8                    <$> const[IV 1] s ->9
    -        <1> ex-list lKPRM* ->c
    b           <0> padrange[$file:1,2; $line:1,2] RM/LVINTRO,range=2 ->c

into:

    7     <2> aassign[t4] vKS ->8
    -        <1> ex-list lK ->6
    3           <0> pushmark s ->4
    5           <1> caller[t3] lK/LINE,FILE ->6
    4              <$> const(IV 1) s ->5
    -        <1> ex-list lKPRM* ->7
    6           <0> padrange[$file:1,2; $line:1,2] RM/LVINTRO,range=2 ->7


  Commit: 34544d98731c39f11472c581db1e568727540952
      
https://github.com/Perl/perl5/commit/34544d98731c39f11472c581db1e568727540952
  Author: Richard Leach <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M pod/perldelta.pod

  Log Message:
  -----------
  Perldelta entry for optimized caller() list slices [GH #23369]


Compare: https://github.com/Perl/perl5/compare/b33c44533bcf...34544d98731c

To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to