i = 1;
clearsv:
for (; i; i--, svp--) {
- sv = *svp;
-
- DEBUG_Xv(PerlIO_printf(Perl_debug_log,
- "Pad 0x%"UVxf"[0x%"UVxf"] clearsv: %ld sv=0x%"UVxf"<%"IVdf"> %s\n",
- PTR2UV(PL_comppad), PTR2UV(PL_curpad),
- (long)(svp-PL_curpad), PTR2UV(sv), (IV)SvREFCNT(sv),
- (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) ? "clear" : "abandon"
- ));
-
- /* Can clear pad variable in place? */
- if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
- /*
- * if a my variable that was made readonly is going out of
- * scope, we want to remove the readonlyness so that it can
- * go out of scope quietly
- */
- if (SvPADMY(sv) && !SvFAKE(sv))
- SvREADONLY_off(sv);
-
- if (SvTHINKFIRST(sv))
- sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF
- |SV_COW_DROP_PV);
- if (SvTYPE(sv) == SVt_PVHV)
- Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv));
- if (SvMAGICAL(sv))
- {
- sv_unmagic(sv, PERL_MAGIC_backref);
- if (SvTYPE(sv) != SVt_PVCV)
- mg_free(sv);
- }
-
- switch (SvTYPE(sv)) {
- case SVt_NULL:
- break;
- case SVt_PVAV:
- av_clear(MUTABLE_AV(sv));
- break;
- case SVt_PVHV:
- hv_clear(MUTABLE_HV(sv));
- break;
- case SVt_PVCV:
- {
- HEK * const hek = CvNAME_HEK((CV *)sv);
- assert(hek);
- share_hek_hek(hek);
- cv_undef((CV *)sv);
- CvNAME_HEK_set(sv, hek);
- break;
- }
- default:
- SvOK_off(sv);
- break;
- }
- SvPADSTALE_on(sv); /* mark as no longer live */
- }
- else { /* Someone has a claim on this, so abandon it. */
- assert( SvFLAGS(sv) & SVs_PADMY);
- assert(!(SvFLAGS(sv) & SVs_PADTMP));
- switch (SvTYPE(sv)) { /* Console ourselves with a new value */
- case SVt_PVAV: *svp = MUTABLE_SV(newAV()); break;
- case SVt_PVHV: *svp = MUTABLE_SV(newHV()); break;
- case SVt_PVCV:
- {
- /* Create a stub */
- *svp = newSV_type(SVt_PVCV);
-
- /* Share name */
- assert(CvNAMED(sv));
- CvNAME_HEK_set(*svp,
- share_hek_hek(CvNAME_HEK((CV *)sv)));
- break;
- }
- default: *svp = newSV(0); break;
- }
- SvREFCNT_dec(sv); /* Cast current value to the winds. */
- /* preserve pad nature, but also mark as not live
- * for any closure capturing */
- SvFLAGS(*svp) |= (SVs_PADMY|SVs_PADSTALE);
- }
+ sv = *svp;
+
+ DEBUG_Xv(PerlIO_printf(Perl_debug_log,
+ "Pad 0x%"UVxf"[0x%"UVxf"] clearsv: %ld sv=0x%"UVxf"<%"IVdf"> %s\n",
+ PTR2UV(PL_comppad), PTR2UV(PL_curpad),
+ (long)(svp-PL_curpad), PTR2UV(sv), (IV)SvREFCNT(sv),
+ (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) ? "clear" : "abandon"
+ ));
+
+ /* Can clear pad variable in place? */
+ if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
+ /*
+ * if a my variable that was made readonly is going out of
+ * scope, we want to remove the readonlyness so that it can
+ * go out of scope quietly
+ */
+ if (SvPADMY(sv) && !SvFAKE(sv))
+ SvREADONLY_off(sv);
+
+ if (SvTHINKFIRST(sv))
+ sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF
+ |SV_COW_DROP_PV);
+ if (SvTYPE(sv) == SVt_PVHV)
+ Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv));
+ if (SvMAGICAL(sv))
+ {
+ sv_unmagic(sv, PERL_MAGIC_backref);
+ if (SvTYPE(sv) != SVt_PVCV)
+ mg_free(sv);
+ }
+
+ switch (SvTYPE(sv)) {
+ case SVt_NULL:
+ break;
+ case SVt_PVAV:
+ av_clear(MUTABLE_AV(sv));
+ break;
+ case SVt_PVHV:
+ hv_clear(MUTABLE_HV(sv));
+ break;
+ case SVt_PVCV:
+ {
+ HEK * const hek = CvNAME_HEK((CV *)sv);
+ assert(hek);
+ share_hek_hek(hek);
+ cv_undef((CV *)sv);
+ CvNAME_HEK_set(sv, hek);
+ break;
+ }
+ default:
+ SvOK_off(sv);
+ break;
+ }
+ SvPADSTALE_on(sv); /* mark as no longer live */
+ }
+ else { /* Someone has a claim on this, so abandon it. */
+ assert( SvFLAGS(sv) & SVs_PADMY);
+ assert(!(SvFLAGS(sv) & SVs_PADTMP));
+ switch (SvTYPE(sv)) { /* Console ourselves with a new value */
+ case SVt_PVAV: *svp = MUTABLE_SV(newAV()); break;
+ case SVt_PVHV: *svp = MUTABLE_SV(newHV()); break;
+ case SVt_PVCV:
+ {
+ /* Create a stub */
+ *svp = newSV_type(SVt_PVCV);
+
+ /* Share name */
+ assert(CvNAMED(sv));
+ CvNAME_HEK_set(*svp,
+ share_hek_hek(CvNAME_HEK((CV *)sv)));
+ break;
+ }
+ default: *svp = newSV(0); break;
+ }
+ SvREFCNT_dec(sv); /* Cast current value to the winds. */
+ /* preserve pad nature, but also mark as not live
+ * for any closure capturing */
+ SvFLAGS(*svp) |= (SVs_PADMY|SVs_PADSTALE);
+ }
}
break;
}