Skip to content

Revert "op.c: re-enable coderef-in-stash optimization" #23029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -11061,9 +11061,12 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
Also, we may be called from load_module at run time, so
PL_curstash (which sets CvSTASH) may not point to the stash the
sub is stored in. */
/* XXX This optimization is currently disabled for packages other
than main, since there was too much CPAN breakage. */
const I32 flags =
ec ? GV_NOADD_NOINIT
: (IN_PERL_RUNTIME && PL_curstash != CopSTASH(PL_curcop))
|| PL_curstash != PL_defstash
|| memchr(name, ':', namlen) || memchr(name, '\'', namlen)
? gv_fetch_flags
: GV_ADDMULTI | GV_NOINIT | GV_NOTQUAL;
Expand Down
5 changes: 4 additions & 1 deletion t/op/sub.t
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ is ref($main::{rt_129916}), 'CODE', 'simple sub stored as CV in stash (main::)';
package RT129916;
sub foo { 42 }
}
is ref($RT129916::{foo}), 'CODE', 'simple sub stored as CV in stash (non-main::)';
{
local $::TODO = "disabled for now";
is ref($RT129916::{foo}), 'CODE', 'simple sub stored as CV in stash (non-main::)';
}

# Calling xsub via ampersand syntax when @_ has holes
SKIP: {
Expand Down