From 9aa350eb0f0c75e5d5ac3fbccd708064f23d6795 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Thu, 16 Jul 2015 14:44:06 +0100 Subject: [PATCH] CXt_FORMAT: save ss_ix and tmps_floor in CX struct To match the recent work in this branch on CXt_SUB, make CXt_FORMAT save PL_savestack_ix and PL_tmps_floor in the context structure rather than doing ENTER/SAVETMPS. It's more efficient and more consistent. --- cop.h | 16 +++++++++++----- pp_sys.c | 4 ---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cop.h b/cop.h index e260689..f455d59 100644 --- a/cop.h +++ b/cop.h @@ -551,13 +551,13 @@ be zero. struct block_sub { OP * retop; /* op to execute on exit from sub */ /* Above here is the same for sub, format and eval. */ + I32 old_savestack_ix; /* saved PL_savestack_ix (also CXt_NULL) */ + SSize_t old_tmpsfloor; /* also used in CXt_NULL sort block */ + PAD *prevcomppad; /* the caller's PL_comppad */ CV * cv; /* Above here is the same for sub and format. */ I32 olddepth; - I32 old_savestack_ix; /* saved PL_savestack_ix (also CXt_NULL) */ AV *savearray; - SSize_t old_tmpsfloor; /* also used in CXt_NULL sort block */ - PAD *prevcomppad; /* the caller's PL_comppad */ }; @@ -565,11 +565,13 @@ struct block_sub { struct block_format { OP * retop; /* op to execute on exit from sub */ /* Above here is the same for sub, format and eval. */ + I32 old_savestack_ix; /* saved PL_savestack_ix (also CXt_NULL) */ + SSize_t old_tmpsfloor; /* also used in CXt_NULL sort block */ + PAD *prevcomppad; /* the caller's PL_comppad */ CV * cv; /* Above here is the same for sub and format. */ GV * gv; GV * dfoutgv; - PAD *prevcomppad; /* the caller's PL_comppad */ }; /* base for the next two macros. Don't use directly. @@ -624,6 +626,9 @@ struct block_format { cx->blk_format.dfoutgv = PL_defoutgv; \ cx->blk_format.prevcomppad = PL_comppad; \ cx->blk_u16 = 0; \ + cx->blk_format.old_savestack_ix = PL_savestack_ix; \ + cx->blk_format.old_tmpsfloor = PL_tmps_floor; \ + PL_tmps_floor = PL_tmps_ix; \ SvREFCNT_inc_simple_void_NN(cv); \ CvDEPTH(cv)++; \ SvREFCNT_inc_void(cx->blk_format.dfoutgv) @@ -686,12 +691,13 @@ struct block_format { #define POPFORMAT(cx) \ STMT_START { \ + LEAVE_SCOPE(cx->blk_format.old_savestack_ix); \ if (!(cx->blk_u16 & CxPOPSUB_DONE)) { \ CV * const cv = cx->blk_format.cv; \ GV * const dfuot = cx->blk_format.dfoutgv; \ cx->blk_u16 |= CxPOPSUB_DONE; \ + PL_tmps_floor = cx->blk_format.old_tmpsfloor; \ setdefout(dfuot); \ - LEAVE_SCOPE(PL_scopestack[cx->blk_oldscopesp-1]); \ PL_comppad = cx->blk_format.prevcomppad; \ PL_curpad = LIKELY(PL_comppad) ? AvARRAY(PL_comppad) : NULL; \ --CvDEPTH(cv); \ diff --git a/pp_sys.c b/pp_sys.c index 83cf32b..62287b9 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1386,9 +1386,6 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop) if (CvCLONE(cv)) cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv)))); - ENTER; - SAVETMPS; - PUSHBLOCK(cx, CXt_FORMAT, PL_stack_sp); PUSHFORMAT(cx, retop); if (CvDEPTH(cv) >= 2) { @@ -1529,7 +1526,6 @@ PP(pp_leavewrite) retop = cx->blk_sub.retop; POPFORMAT(cx); SP = newsp; /* ignore retval of formline */ - LEAVE; if (is_return) /* XXX the semantics of doing 'return' in a format aren't documented. -- 1.8.3.1