summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-06-25 12:05:50 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 08:59:32 +0000
commit2c50b7edd16542f4ebaaeeeb1c34aa0bd92bfe2c (patch)
tree3df9d4be28e3f6a3780bfd48a75d6d85f79ecdfa /pp_sort.c
parentd6911e1bba3263b621e7a00f0f7018145216080f (diff)
downloadperl-2c50b7edd16542f4ebaaeeeb1c34aa0bd92bfe2c.tar.gz
SvREFCNT_inc(cv) recursive subs
A CXt_SUB context frame owns 1 reference count to the CV being called, but only if it's the bottom-level call to that CV; recursive calls don't count. This commit changes it so that every CXt_SUB frame owns a reference count. This removes a lot of "if (CvDEPTH(cv) < 2)" type tests from the code and makes things generally simpler and less bug-prone. For ordinary (non-recursive) sub calls it will now be slightly faster, as it no longer has to do the CvDEPTH check on sub entry and exit; for subs being recursed into, it will probably be slightly slower, as although it no longer has to the CvDEPTH check on entry and exit, it now has to do a refcnt ++/-- instead. This also means that a deeply recursing sub will have a very high ref count; but there is no new additional danger of overflow, as sv_refcnt is U32 while xcv_depth is I32: so the latter will still overflow earlier anyway.
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c5
1 files changed, 0 insertions, 5 deletions
diff --git a/pp_sort.c b/pp_sort.c
index 51742f6c35..ace0a0559e 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1672,11 +1672,6 @@ PP(pp_sort)
PUSHBLOCK(cx, CXt_NULL, PL_stack_base);
if (!(flags & OPf_SPECIAL)) {
cx->cx_type = CXt_SUB;
- /* If our comparison routine is already active (CvDEPTH is
- * is not 0), then PUSHSUB does not increase the refcount,
- * so we have to do it ourselves, because the LEAVESUB fur-
- * ther down lowers it. */
- if (CvDEPTH(cv)) SvREFCNT_inc_simple_void_NN(cv);
PUSHSUB(cx);
if (!is_xsub) {
PADLIST * const padlist = CvPADLIST(cv);