From: Nicholas Clark Date: Sun, 6 Jan 2008 13:35:38 +0000 (+0000) Subject: Clarify the intent of the code in Perl_op_clear. Under ithreads, avoid X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9cddf794fc52f08a145668164b1e3c15c91a713f;p=p5sagit%2Fp5-mst-13.2.git Clarify the intent of the code in Perl_op_clear. Under ithreads, avoid calling sv_ivset twice. As a side effect, eliminate PM_GETRE_SAFE and PM_SETRE_SAFE, as we're doing "safe" explicitly in Perl_op_clear(). p4raw-id: //depot/perl@32867 --- diff --git a/op.c b/op.c index c07a1a7..569a159 100644 --- a/op.c +++ b/op.c @@ -615,21 +615,23 @@ Perl_op_clear(pTHX_ OP *o) clear_pmop: forget_pmop(cPMOPo, 1); cPMOPo->op_pmreplrootu.op_pmreplroot = NULL; - /* we use the "SAFE" version of the PM_ macros here - * since sv_clean_all might release some PMOPs + /* we use the same protection as the "SAFE" version of the PM_ macros + * here since sv_clean_all might release some PMOPs * after PL_regex_padav has been cleared * and the clearing of PL_regex_padav needs to * happen before sv_clean_all */ - ReREFCNT_dec(PM_GETRE_SAFE(cPMOPo)); - PM_SETRE_SAFE(cPMOPo, NULL); #ifdef USE_ITHREADS if(PL_regex_pad) { /* We could be in destruction */ + ReREFCNT_dec(PM_GETRE(cPMOPo)); av_push((AV*) PL_regex_pad[0],(SV*) PL_regex_pad[(cPMOPo)->op_pmoffset]); SvREADONLY_off(PL_regex_pad[(cPMOPo)->op_pmoffset]); SvREPADTMP_on(PL_regex_pad[(cPMOPo)->op_pmoffset]); PM_SETRE(cPMOPo, (cPMOPo)->op_pmoffset); } +#else + ReREFCNT_dec(PM_GETRE(cPMOPo)); + PM_SETRE(cPMOPo, NULL); #endif break; diff --git a/op.h b/op.h index 14b8e6e..264dd52 100644 --- a/op.h +++ b/op.h @@ -334,13 +334,18 @@ struct pmop { SV* const sv = PL_regex_pad[(o)->op_pmoffset]; \ sv_setiv(sv, PTR2IV(r)); \ } STMT_END +# ifndef PERL_CORE +/* No longer used anywhere in the core. Migrate to Devel::PPPort? */ #define PM_GETRE_SAFE(o) (PL_regex_pad ? PM_GETRE(o) : (REGEXP*)0) #define PM_SETRE_SAFE(o,r) if (PL_regex_pad) PM_SETRE(o,r) +# endif #else #define PM_GETRE(o) ((o)->op_pmregexp) #define PM_SETRE(o,r) ((o)->op_pmregexp = (r)) +# ifndef PERL_CORE #define PM_GETRE_SAFE PM_GETRE #define PM_SETRE_SAFE PM_SETRE +# endif #endif