This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
convert CX_PUSHFORMAT/POPFORMAT to inline fns
authorDavid Mitchell <davem@iabyn.com>
Wed, 30 Dec 2015 13:09:36 +0000 (13:09 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:19:20 +0000 (09:19 +0000)
Replace CX_PUSHFORMAT() with cx_pushformat() etc.

No functional changes.

cop.h
embed.fnc
embed.h
inline.h
pp_ctl.c
pp_sys.c
proto.h

diff --git a/cop.h b/cop.h
index d7ae2d6..ac0e8b4 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -606,17 +606,6 @@ struct block_format {
                   ? 0 : (U8)func(aTHX)                                 \
        )
 
-#define CX_PUSHFORMAT(cx, cv, gv, retop)                               \
-       cx->blk_format.cv = cv;                                         \
-       cx->blk_format.gv = gv;                                         \
-       cx->blk_format.retop = (retop);                                 \
-       cx->blk_format.dfoutgv = PL_defoutgv;                           \
-       cx->blk_format.prevcomppad = PL_comppad;                        \
-       cx->blk_u16 = 0;                                                \
-       SvREFCNT_inc_simple_void_NN(cv);                                \
-       CvDEPTH(cv)++;                                                  \
-       SvREFCNT_inc_void(cx->blk_format.dfoutgv)
-
 /* Restore old @_ */
 #define CX_POP_SAVEARRAY(cx)                                           \
     STMT_START {                                                       \
@@ -636,22 +625,6 @@ struct block_format {
     } STMT_END
 
 
-#define CX_POPFORMAT(cx)                                               \
-    STMT_START {                                                       \
-       CV *cv;                                                         \
-       GV * const dfout = cx->blk_format.dfoutgv;                      \
-        assert(CxTYPE(cx) == CXt_FORMAT);                               \
-       setdefout(dfout);                                               \
-        cx->blk_format.dfoutgv = NULL;                                  \
-       SvREFCNT_dec_NN(dfout); /* the cx->defoutgv ref */              \
-        PL_comppad = cx->blk_format.prevcomppad;                        \
-        PL_curpad = LIKELY(PL_comppad) ? AvARRAY(PL_comppad) : NULL;    \
-        cv = cx->blk_format.cv;                                                \
-       cx->blk_format.cv = NULL;;                                      \
-       --CvDEPTH(cv);                                                  \
-       SvREFCNT_dec_NN(cv);                                            \
-    } STMT_END
-
 /* eval context */
 struct block_eval {
     OP *       retop;  /* op to execute on exit from eval */
index 8aa2f0b..4ed7de1 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2884,11 +2884,14 @@ ApM     |void   |leave_adjust_stacks|NN SV **from_sp|NN SV **to_sp \
 AiM    |PERL_CONTEXT * |cx_pushblock|U8 type|U8 gimme|NN SV** sp|I32 saveix
 AiM    |void   |cx_popblock|NN PERL_CONTEXT *cx
 AiM    |void   |cx_topblock|NN PERL_CONTEXT *cx
-AiM    |void   |cx_pushsub |NN PERL_CONTEXT *cx|NN CV *cv|NULLOK OP *retop \
-               |bool hasargs
+AiM    |void   |cx_pushsub      |NN PERL_CONTEXT *cx|NN CV *cv \
+                                |NULLOK OP *retop|bool hasargs
 AiM    |void   |cx_popsub_common|NN PERL_CONTEXT *cx
 AiM    |void   |cx_popsub_args  |NN PERL_CONTEXT *cx
 AiM    |void   |cx_popsub       |NN PERL_CONTEXT *cx
+AiM    |void   |cx_pushformat   |NN PERL_CONTEXT *cx|NN CV *cv \
+                                |NULLOK OP *retop|NULLOK GV *gv
+AiM    |void   |cx_popformat    |NN PERL_CONTEXT *cx
 #endif
 
 : ex: set ts=8 sts=4 sw=4 noet:
diff --git a/embed.h b/embed.h
index 54c0a64..6833eef 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define append_utf8_from_native_byte   S_append_utf8_from_native_byte
 #define av_top_index(a)                S_av_top_index(aTHX_ a)
 #define cx_popblock(a)         S_cx_popblock(aTHX_ a)
+#define cx_popformat(a)                S_cx_popformat(aTHX_ a)
 #define cx_popsub(a)           S_cx_popsub(aTHX_ a)
 #define cx_popsub_args(a)      S_cx_popsub_args(aTHX_ a)
 #define cx_popsub_common(a)    S_cx_popsub_common(aTHX_ a)
 #define cx_pushblock(a,b,c,d)  S_cx_pushblock(aTHX_ a,b,c,d)
+#define cx_pushformat(a,b,c,d) S_cx_pushformat(aTHX_ a,b,c,d)
 #define cx_pushsub(a,b,c,d)    S_cx_pushsub(aTHX_ a,b,c,d)
 #define cx_topblock(a)         S_cx_topblock(aTHX_ a)
 #define is_safe_syscall(a,b,c,d)       S_is_safe_syscall(aTHX_ a,b,c,d)
index 2e76626..4b6e7bb 100644 (file)
--- a/inline.h
+++ b/inline.h
@@ -558,6 +558,48 @@ S_cx_popsub(pTHX_ PERL_CONTEXT *cx)
 }
 
 
+PERL_STATIC_INLINE void
+S_cx_pushformat(pTHX_ PERL_CONTEXT *cx, CV *cv, OP *retop, GV *gv)
+{
+    PERL_ARGS_ASSERT_CX_PUSHFORMAT;
+
+    cx->blk_format.cv          = cv;
+    cx->blk_format.retop       = retop;
+    cx->blk_format.gv          = gv;
+    cx->blk_format.dfoutgv     = PL_defoutgv;
+    cx->blk_format.prevcomppad = PL_comppad;
+    cx->blk_u16                = 0;
+
+    SvREFCNT_inc_simple_void_NN(cv);
+    CvDEPTH(cv)++;
+    SvREFCNT_inc_void(cx->blk_format.dfoutgv);
+}
+
+
+PERL_STATIC_INLINE void
+S_cx_popformat(pTHX_ PERL_CONTEXT *cx)
+{
+    CV *cv;
+    GV *dfout;
+
+    PERL_ARGS_ASSERT_CX_POPFORMAT;
+    assert(CxTYPE(cx) == CXt_FORMAT);
+
+    dfout = cx->blk_format.dfoutgv;
+    setdefout(dfout);
+    cx->blk_format.dfoutgv = NULL;
+    SvREFCNT_dec_NN(dfout);
+
+    PL_comppad = cx->blk_format.prevcomppad;
+    PL_curpad = LIKELY(PL_comppad) ? AvARRAY(PL_comppad) : NULL;
+    cv = cx->blk_format.cv;
+    cx->blk_format.cv = NULL;
+    --CvDEPTH(cv);
+    SvREFCNT_dec_NN(cv);
+}
+
+
+
 
 /*
  * ex: set ts=8 sts=4 sw=4 et:
index bc14287..6c02bbf 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1554,7 +1554,7 @@ Perl_dounwind(pTHX_ I32 cxix)
             /* these two don't have a POPFOO() */
            break;
        case CXt_FORMAT:
-           CX_POPFORMAT(cx);
+           cx_popformat(cx);
            break;
        }
         if (cxstack_ix == cxix + 1) {
index 95c7d8b..dd14bac 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1390,7 +1390,7 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop)
        cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv))));
 
     cx = cx_pushblock(CXt_FORMAT, gimme, PL_stack_sp, PL_savestack_ix);
-    CX_PUSHFORMAT(cx, cv, gv, retop);
+    cx_pushformat(cx, cv, retop, gv);
     if (CvDEPTH(cv) >= 2)
        pad_push(CvPADLIST(cv), CvDEPTH(cv));
     PAD_SET_CUR_NOSAVE(CvPADLIST(cv), CvDEPTH(cv));
@@ -1525,7 +1525,7 @@ PP(pp_leavewrite)
     assert(CxTYPE(cx) == CXt_FORMAT);
     SP = PL_stack_base + cx->blk_oldsp; /* ignore retval of formline */
     CX_LEAVE_SCOPE(cx);
-    CX_POPFORMAT(cx);
+    cx_popformat(cx);
     cx_popblock(cx);
     retop = cx->blk_sub.retop;
     CX_POP(cx);
diff --git a/proto.h b/proto.h
index 925b631..a799842 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -3721,6 +3721,9 @@ PERL_STATIC_INLINE SSize_t        S_av_top_index(pTHX_ AV *av)
 PERL_STATIC_INLINE void        S_cx_popblock(pTHX_ PERL_CONTEXT *cx);
 #define PERL_ARGS_ASSERT_CX_POPBLOCK   \
        assert(cx)
+PERL_STATIC_INLINE void        S_cx_popformat(pTHX_ PERL_CONTEXT *cx);
+#define PERL_ARGS_ASSERT_CX_POPFORMAT  \
+       assert(cx)
 PERL_STATIC_INLINE void        S_cx_popsub(pTHX_ PERL_CONTEXT *cx);
 #define PERL_ARGS_ASSERT_CX_POPSUB     \
        assert(cx)
@@ -3733,6 +3736,9 @@ PERL_STATIC_INLINE void   S_cx_popsub_common(pTHX_ PERL_CONTEXT *cx);
 PERL_STATIC_INLINE PERL_CONTEXT *      S_cx_pushblock(pTHX_ U8 type, U8 gimme, SV** sp, I32 saveix);
 #define PERL_ARGS_ASSERT_CX_PUSHBLOCK  \
        assert(sp)
+PERL_STATIC_INLINE void        S_cx_pushformat(pTHX_ PERL_CONTEXT *cx, CV *cv, OP *retop, GV *gv);
+#define PERL_ARGS_ASSERT_CX_PUSHFORMAT \
+       assert(cx); assert(cv)
 PERL_STATIC_INLINE void        S_cx_pushsub(pTHX_ PERL_CONTEXT *cx, CV *cv, OP *retop, bool hasargs);
 #define PERL_ARGS_ASSERT_CX_PUSHSUB    \
        assert(cx); assert(cv)