summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Mueller <smueller@cpan.org>2013-02-28 18:23:32 +0100
committerSteffen Mueller <smueller@cpan.org>2013-03-06 18:48:58 +0100
commitddf23d4a1ae98daa8608179f83aad311d03898ef (patch)
treed179e7c93aae15671f6265dbba2d083c031223a8
parentf615be485d8c90f01432a39e678e01c615e2c15e (diff)
downloadperl-ddf23d4a1ae98daa8608179f83aad311d03898ef.tar.gz
Prepare PL_sv_objcount removal
This used to keep track of all objects. At least by now, that is for no particularly good reason. Just because it could avoid a bit of work during global destruction if no objects remained. Let's do less work at run-time instead. The interpreter global will remain for one deprecation cycle.
-rw-r--r--intrpvar.h4
-rw-r--r--perl.c15
-rw-r--r--sv.c10
3 files changed, 9 insertions, 20 deletions
diff --git a/intrpvar.h b/intrpvar.h
index 92d8e9275a..6865ab97cc 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -383,7 +383,9 @@ PERLVAR(I, forkprocess, int) /* so do_open |- can return proc# */
/* memory management */
PERLVAR(I, sv_count, IV) /* how many SV* are currently allocated */
-PERLVAR(I, sv_objcount, IV) /* how many objects are currently allocated */
+PERLVAR(I, sv_objcount, IV) /* DEPRECATED AND UNMAINTAINED.
+ * Will be removed in Perl 5.20.
+ * Used to be: how many objects are currently allocated. */
PERLVAR(I, sv_root, SV *) /* storage for SVs belonging to interp */
PERLVAR(I, sv_arenaroot, SV *) /* list of areas for garbage collection */
diff --git a/perl.c b/perl.c
index a27962d5c6..e9549d5735 100644
--- a/perl.c
+++ b/perl.c
@@ -758,15 +758,12 @@ perl_destruct(pTHXx)
PerlIO_destruct(aTHX);
- if (PL_sv_objcount) {
- /*
- * Try to destruct global references. We do this first so that the
- * destructors and destructees still exist. Some sv's might remain.
- * Non-referenced objects are on their own.
- */
- sv_clean_objs();
- PL_sv_objcount = 0;
- }
+ /*
+ * Try to destruct global references. We do this first so that the
+ * destructors and destructees still exist. Some sv's might remain.
+ * Non-referenced objects are on their own.
+ */
+ sv_clean_objs();
/* unhook hooks which will soon be, or use, destroyed data */
SvREFCNT_dec(PL_warnhook);
diff --git a/sv.c b/sv.c
index 09b180ff31..f58389bb4c 100644
--- a/sv.c
+++ b/sv.c
@@ -6513,8 +6513,6 @@ S_curse(pTHX_ SV * const sv, const bool check_refcnt) {
SvOBJECT_off(sv); /* Curse the object. */
SvSTASH_set(sv,0); /* SvREFCNT_dec may try to read this */
SvREFCNT_dec(stash); /* possibly of changed persuasion */
- if (SvTYPE(sv) != SVt_PVIO)
- --PL_sv_objcount;/* XXX Might want something more general */
}
return TRUE;
}
@@ -9694,14 +9692,10 @@ Perl_sv_bless(pTHX_ SV *const sv, HV *const stash)
if (SvREADONLY(tmpRef) && !SvIsCOW(tmpRef))
Perl_croak_no_modify();
if (SvOBJECT(tmpRef)) {
- if (SvTYPE(tmpRef) != SVt_PVIO)
- --PL_sv_objcount;
SvREFCNT_dec(SvSTASH(tmpRef));
}
}
SvOBJECT_on(tmpRef);
- if (SvTYPE(tmpRef) != SVt_PVIO)
- ++PL_sv_objcount;
SvUPGRADE(tmpRef, SVt_PVMG);
SvSTASH_set(tmpRef, MUTABLE_HV(SvREFCNT_inc_simple(stash)));
@@ -12437,9 +12431,6 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
}
}
- if (SvOBJECT(dstr) && SvTYPE(dstr) != SVt_PVIO)
- ++PL_sv_objcount;
-
return dstr;
}
@@ -13136,7 +13127,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
Zero(&PL_body_roots, 1, PL_body_roots);
PL_sv_count = 0;
- PL_sv_objcount = 0;
PL_sv_root = NULL;
PL_sv_arenaroot = NULL;