diff options
author | David Mitchell <davem@iabyn.com> | 2015-06-25 12:05:50 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-02-03 08:59:32 +0000 |
commit | 2c50b7edd16542f4ebaaeeeb1c34aa0bd92bfe2c (patch) | |
tree | 3df9d4be28e3f6a3780bfd48a75d6d85f79ecdfa /pp_sort.c | |
parent | d6911e1bba3263b621e7a00f0f7018145216080f (diff) | |
download | perl-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.c | 5 |
1 files changed, 0 insertions, 5 deletions
@@ -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); |