Skip to content

Dedicated SV copying code in place of Perl_sv_setsv_flags #23202

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

Open
wants to merge 11 commits into
base: blead
Choose a base branch
from
Open
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
10 changes: 4 additions & 6 deletions av.c
Original file line number Diff line number Diff line change
@@ -479,6 +479,8 @@ Perl_av_make(pTHX_ SSize_t size, SV **strp)
AvALLOC(av) = ary;
AvARRAY(av) = ary;
AvMAX(av) = size - 1;
SSize_t *fillp = &AvFILLp(av);

/* avoid av being leaked if croak when calling magic below */
EXTEND_MORTAL(1);
PL_tmps_stack[++PL_tmps_ix] = (SV*)av;
@@ -490,12 +492,8 @@ Perl_av_make(pTHX_ SSize_t size, SV **strp)
/* Don't let sv_setsv swipe, since our source array might
have multiple references to the same temp scalar (e.g.
from a list slice) */

SvGETMAGIC(*strp); /* before newSV, in case it dies */
AvFILLp(av)++;
ary[i] = newSV_type(SVt_NULL);
sv_setsv_flags(ary[i], *strp,
SV_DO_COW_SVSETSV|SV_NOSTEAL);
ary[i] = newSVsv_flags(*strp, SV_DO_COW_SVSETSV|SV_NOSTEAL|SV_GMAGIC);
*fillp = i;
strp++;
}
/* disarm av's leak guard */
5 changes: 4 additions & 1 deletion embed.fnc
Original file line number Diff line number Diff line change
@@ -2335,7 +2335,7 @@ ARdp |OP * |newSVREF |NN OP *o
Adp |SV * |newSVrv |NN SV * const rv \
|NULLOK const char * const classname
ARdmp |SV * |newSVsv |NULLOK SV * const old
ARdp |SV * |newSVsv_flags |NULLOK SV * const old \
ARdip |SV * |newSVsv_flags |NULLOK SV * const old \
|I32 flags
ARdm |SV * |newSVsv_nomg |NULLOK SV * const old
ARdp |SV * |newSV_true
@@ -3234,6 +3234,9 @@ Xopx |void |sv_free2 |NN SV * const sv \
|const U32 refcnt
: Used only in perl.c
dp |void |sv_free_arenas
ARdp |SV * |sv_freshcopy_flags \
|NN SV * const old \
|I32 flags
ATdpx |SV * |sv_get_backrefs|NN SV * const sv
Adip |void |SvGETMAGIC |NN SV *sv
Adp |char * |sv_gets |NN SV * const sv \
1 change: 1 addition & 0 deletions embed.h
Original file line number Diff line number Diff line change
@@ -743,6 +743,7 @@
# define sv_force_normal(a) Perl_sv_force_normal(aTHX,a)
# define sv_force_normal_flags(a,b) Perl_sv_force_normal_flags(aTHX_ a,b)
# define sv_free(a) Perl_sv_free(aTHX_ a)
# define sv_freshcopy_flags(a,b) Perl_sv_freshcopy_flags(aTHX_ a,b)
# define sv_get_backrefs Perl_sv_get_backrefs
# define sv_gets(a,b,c) Perl_sv_gets(aTHX_ a,b,c)
# define sv_grow(a,b) Perl_sv_grow(aTHX_ a,b)
9 changes: 5 additions & 4 deletions pp.c
Original file line number Diff line number Diff line change
@@ -6421,10 +6421,11 @@ PP(pp_push)
PL_delaymagic = DM_DELAY;
for (++MARK; MARK <= PL_stack_sp; MARK++) {
SV *sv;
if (*MARK) SvGETMAGIC(*MARK);
sv = newSV_type(SVt_NULL);
if (*MARK)
sv_setsv_nomg(sv, *MARK);
if (*MARK) {
sv = newSVsv_flags(*MARK, SV_DO_COW_SVSETSV|SV_GMAGIC);
} else
sv = newSV_type(SVt_NULL);

av_store(ary, AvFILLp(ary)+1, sv);
}
if (PL_delaymagic & DM_ARRAY_ISA)
9 changes: 3 additions & 6 deletions pp_ctl.c
Original file line number Diff line number Diff line change
@@ -4407,13 +4407,11 @@ S_doopen_pm(pTHX_ SV *name)
return NULL;

if (memENDPs(p, namelen, ".pm")) {
SV *const pmcsv = sv_newmortal();
PerlIO * pmcio;
SV *const pmcsv = sv_mortalcopy_flags(name, SV_GMAGIC|SV_NOSTEAL|SV_DO_COW_SVSETSV);

SvSetSV_nosteal(pmcsv,name);
sv_catpvs(pmcsv, "c");

pmcio = check_type_and_open(pmcsv);
PerlIO * pmcio = check_type_and_open(pmcsv);
if (pmcio)
return pmcio;
}
@@ -4805,8 +4803,7 @@ S_require_file(pTHX_ SV *sv)
}

if (SvPADTMP(nsv)) {
nsv = sv_newmortal();
SvSetSV_nosteal(nsv,sv);
nsv = sv_mortalcopy_flags(sv, SV_GMAGIC|SV_NOSTEAL|SV_DO_COW_SVSETSV);
}

const char *method = NULL;
3 changes: 1 addition & 2 deletions pp_hot.c
Original file line number Diff line number Diff line change
@@ -5357,8 +5357,7 @@ PP(pp_subst)
if (dstr) {
/* replacement needing upgrading? */
if (DO_UTF8(TARG) && !doutf8) {
nsv = sv_newmortal();
SvSetSV(nsv, dstr);
nsv = sv_mortalcopy_flags(dstr, SV_GMAGIC|SV_DO_COW_SVSETSV);
sv_utf8_upgrade(nsv);
c = SvPV_const(nsv, clen);
doutf8 = TRUE;
16 changes: 11 additions & 5 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading