Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 76c1b2dcaa80e9f5acc43c0adeb0f656b9a9092c
      
https://github.com/Perl/perl5/commit/76c1b2dcaa80e9f5acc43c0adeb0f656b9a9092c
  Author: Richard Leach <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M embed.fnc
    M embed.h
    M proto.h
    M sv.c

  Log Message:
  -----------
  Add newSV_type_generic, a non-inline function for creating new SVs

`Perl_newSV_type` was introduced as an inline function several releases
back in order to overcome the inefficiencies of doing things like:

    SV* sv = newSV(0);
    sv_upgrade(sv, SVt_PV);

It somewhat achieved its objectives, but with lingering shortcomings:
* It was still quite large, reducing the chance of inlining
* Moving `bodies_by_type[]` into a header file caused bloatage

Really, `Perl_newSV_type` is of most use for types that are going to
regularly created in large quantities at runtime, such as `SVt_IV` and
`SVt_PV`. Something like `SVt_PVIO` isn't going to be created in the
same sort of quantities, and other types are mostly going to be created
in smaller quantities at compile time.

This commit duplicates the body of `Perl_newSV_type` into a new
function (`Perl_newSV_type_generic`) in _sv.c_. This function will be
able to create all SV types, with `Perl_newSV_type` then able to
specialize in types that are most in-demand at runtime.

A follow-up commit will also move `bodies_by_type[]` into _globals.c_.


  Commit: 3ba9d2634f6ec3c24d1e1f762801ef04af65dc99
      
https://github.com/Perl/perl5/commit/3ba9d2634f6ec3c24d1e1f762801ef04af65dc99
  Author: Richard Leach <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M sv_inline.h

  Log Message:
  -----------
  Perl_newSV_type: only hot SV types are created inline

`SVt_PV` and below are handled by this function, with every other case
being passed to `Perl_newSV_type_generic`.

These types were largely selected as a result of a _gcov_ build, but it
might be that some other types should come back in. (e.g. `SVt_PVCV` for
things like _Future::AsyncAwait_?)

The function has also been microoptimized to keep its size low,
maximising the opportunities for inlining.


  Commit: 2bba42e77b5d8628ea0d0bde688608e4a7b4ac1a
      
https://github.com/Perl/perl5/commit/2bba42e77b5d8628ea0d0bde688608e4a7b4ac1a
  Author: Richard Leach <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M sv.c

  Log Message:
  -----------
  Neaten up Perl_newSV_type_generic

Get rid of some duplicate initializations, avoid unnecessary work, reduce
the need to repeatedly chase `SvANY(sv)`.


  Commit: 322735f711b4c101644ff5dff294a2ab81937fe2
      
https://github.com/Perl/perl5/commit/322735f711b4c101644ff5dff294a2ab81937fe2
  Author: Richard Leach <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M globvar.sym
    M sv.c
    M sv_inline.h

  Log Message:
  -----------
  Add PL_ prefix to bodies_by_type[] and have one copy in globals.c

`Perl_newSV_type` originally needed the `bodies_by_type[]` structure to
be located inside _sv_inline.h_ for type values to be propagated at
compile time. Unfortunately, this led to some binary bloating.

`Perl_newSV_type` doesn't have this dependency any more, though it does
still need the structure to be accessible under `DEBUGGING` or `PURIFY`
builds. This commit declares it `EXTCONST` to make it available in
all compilation units but only be populated in _globals.c_.

The `PL_` has been added to keep namespace pollution to the usual
prefixes.


  Commit: c79142873c2be7d205e65da030f70db8ab8f48ba
      
https://github.com/Perl/perl5/commit/c79142873c2be7d205e65da030f70db8ab8f48ba
  Author: Richard Leach <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M gv.c
    M pad.c
    M sv.c
    M sv.h
    M toke.c

  Log Message:
  -----------
  Use newSV_type_generic when type is unknown or rare

Avoid binary bloating when the target type is not known at compile time,
or the call site/type is pretty cold.


  Commit: b44006803c1548c8e3356d07ad58017258f51736
      
https://github.com/Perl/perl5/commit/b44006803c1548c8e3356d07ad58017258f51736
  Author: Richard Leach <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M pod/perldelta.pod

  Log Message:
  -----------
  Perldelta entry for Perl_newSV_type/_generic changes


Compare: https://github.com/Perl/perl5/compare/edea3e96c6e8...b44006803c15

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

Reply via email to