[Perl/perl5] 06e421: S_fold_constants: remove early SvREADONLY(sv) to a...

2024-06-11 Thread Richard Leach via perl5-changes
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 06e421c559c63975f29c35ba3588a0e6b0c75eca
  
https://github.com/Perl/perl5/commit/06e421c559c63975f29c35ba3588a0e6b0c75eca
  Author: Richard Leach 
  Date:   2024-06-11 (Tue, 11 Jun 2024)

  Changed paths:
M ext/Devel-Peek/t/Peek.t
M op.c
M t/op/undef.t

  Log Message:
  ---
  S_fold_constants: remove early SvREADONLY(sv) to allow SvIsCOW(sv)

Standard CONST PVs have the IsCOW flag set, meaning that COW can
be used when assigning the CONST to a variable, rather than making
a copy of the buffer. CONST PVs arising from constant folding have
been lacking this flag, leading to unnecessary copying of PV buffers.

This seems to have occurred because a common branch in S_fold_constants
marks SVs as READONLY before the new CONST OP is created. When the OP
is created, the Perl_ck_svconst() check function is called - this is
the same as when a standard CONST OP is created. If the SV is not
already marked as READONLY, the check function will try to set IsCOW
if it is safe to do so, then in either case will make sure that the
READONLY flag is set.

This commit therefore removes the SvREADONLY(sv) statement from
S_fold_constants(), allowing Perl_ck_svconst() to set the IsCOW
and READONLY flags itself. Minor test updates are also included.



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


[Perl/perl5] 845643: Perl_leave_adjust_stacks: additional efficiency fo...

2024-06-11 Thread Richard Leach via perl5-changes
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 84564318489ffdf8dcabe85187fe28b06d0c7537
  
https://github.com/Perl/perl5/commit/84564318489ffdf8dcabe85187fe28b06d0c7537
  Author: Richard Leach 
  Date:   2024-06-11 (Tue, 11 Jun 2024)

  Changed paths:
M pp_hot.c

  Log Message:
  ---
  Perl_leave_adjust_stacks: additional efficiency for mortal copies

The existing code has a fast path for copying a SVt_NULL or SVt_IV. For all
other types, a new SVt_NULL is passed into sv_setsv_flags, where it will
be upgraded into the required type by sv_upgrade().

This commit makes two changes:
1) Special case copying a SVt_NV where possible, as sv_setsv_flags does.
2) It's safe and more efficient to directly create a new type of SVt_PVNV
   or below, rather than upgrade it later, so do that.



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