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 /sv.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 'sv.c')
-rw-r--r-- | sv.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -13942,9 +13942,7 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param) ncx->blk_oldcop = (COP*)any_dup(ncx->blk_oldcop, param->proto_perl); switch (CxTYPE(ncx)) { case CXt_SUB: - ncx->blk_sub.cv = (ncx->blk_sub.olddepth == 0 - ? cv_dup_inc(ncx->blk_sub.cv, param) - : cv_dup(ncx->blk_sub.cv,param)); + ncx->blk_sub.cv = cv_dup_inc(ncx->blk_sub.cv, param); if(CxHASARGS(ncx)){ ncx->blk_sub.argarray = av_dup_inc(ncx->blk_sub.argarray,param); ncx->blk_sub.savearray = av_dup_inc(ncx->blk_sub.savearray,param); |