Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: c0053197fb3c4bbe8d0582fb502ab99e6edc1881 https://github.com/Perl/perl5/commit/c0053197fb3c4bbe8d0582fb502ab99e6edc1881 Author: Lukas Mai <lukasmai....@gmail.com> Date: 2025-07-31 (Thu, 31 Jul 2025)
Changed paths: M class.c M op.c M t/op/sub.t Log Message: ----------- Reapply "op.c: re-enable coderef-in-stash optimization" When seeing 'sub foo { ... }', perl does not need to allocate a full typeglob (with the subroutine being stored in the CODE slot). Instead, it can just store a coderef directly in the stash. This optimization was first announced in perl5220delta: > - Subroutines in packages no longer need to be stored in typeglobs: > declaring a subroutine will now put a simple sub reference directly > in the stash if possible, saving memory. The typeglob still > notionally exists, so accessing it will cause the stash entry to be > upgraded to a typeglob (i.e. this is just an internal implementation > detail). This optimization does not currently apply to XSUBs or > exported subroutines, and method calls will undo it, since they > cache things in typeglobs. [GH #13392] However, due to a bug this optimization didn't actually work except for package main (GH #15671). The issue was fixed in v5.27.5, but the fix was backed out again in v5.27.9 because of CPAN breakage. It was enabled again in v5.41.9, but backed out again again in v5.41.10 because of too much CPAN breakage this late in the development cycle. This reverts commit 51f234647f80e4fd56b09f001aab877f4edf1c18. Also fix class_cleanup_definition: We actually store a reference-to-CV in the stash, not a bare CV, so we need to dereference once to recognize methods defined this way. See #23131 for details (and expected CPAN breakage). To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications