Commit c005319
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 51f2346.
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).1 parent 5079c52 commit c005319
3 files changed
+8
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
704 | 707 | | |
705 | 708 | | |
706 | 709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11102 | 11102 | | |
11103 | 11103 | | |
11104 | 11104 | | |
11105 | | - | |
11106 | | - | |
11107 | 11105 | | |
11108 | 11106 | | |
11109 | 11107 | | |
11110 | | - | |
11111 | 11108 | | |
11112 | 11109 | | |
11113 | 11110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 401 | + | |
405 | 402 | | |
406 | 403 | | |
407 | 404 | | |
| |||
0 commit comments