This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
convert CX_{PUSH|POP}{WHEN|GIVEN} to inline fns
authorDavid Mitchell <davem@iabyn.com>
Wed, 30 Dec 2015 14:33:51 +0000 (14:33 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:19:20 +0000 (09:19 +0000)
Replace CX_PUSHGIVEN() with cx_pushgiven() etc.

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

diff --git a/cop.h b/cop.h
index d346d87..b62e84c 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -707,26 +707,6 @@ struct block_givwhen {
         SV *defsv_save; /* the original $_ */
 };
 
-#define CX_PUSHWHEN(cx)                                                \
-       cx->blk_givwhen.leave_op = cLOGOP->op_other;
-
-#define CX_PUSHGIVEN(cx, orig_var)                                      \
-        CX_PUSHWHEN(cx);                                                \
-        cx->blk_givwhen.defsv_save = orig_var;
-
-#define CX_POPWHEN(cx)                                                  \
-        assert(CxTYPE(cx) == CXt_WHEN);                                 \
-       NOOP;
-
-#define CX_POPGIVEN(cx)                                                 \
-    STMT_START {                                                       \
-        SV *sv = GvSV(PL_defgv);                                        \
-        assert(CxTYPE(cx) == CXt_GIVEN);                                \
-        GvSV(PL_defgv) = cx->blk_givwhen.defsv_save;                    \
-        cx->blk_givwhen.defsv_save = NULL;                              \
-        SvREFCNT_dec(sv);                                               \
-    } STMT_END
-
 
 
 /* context common to subroutines, evals and loops */
index 61a4bad..0398075 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2899,6 +2899,10 @@ AiM      |void   |cx_pushloop_plain|NN PERL_CONTEXT *cx
 AiM    |void   |cx_pushloop_for |NN PERL_CONTEXT *cx \
                                 |NN void *itervarp|NULLOK SV *itersave
 AiM    |void   |cx_poploop      |NN PERL_CONTEXT *cx
+AiM    |void   |cx_pushwhen     |NN PERL_CONTEXT *cx
+AiM    |void   |cx_popwhen      |NN PERL_CONTEXT *cx
+AiM    |void   |cx_pushgiven    |NN PERL_CONTEXT *cx|NULLOK SV *orig_defsv
+AiM    |void   |cx_popgiven     |NN PERL_CONTEXT *cx
 #endif
 
 : ex: set ts=8 sts=4 sw=4 noet:
diff --git a/embed.h b/embed.h
index a394333..24b61bf 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define cx_popblock(a)         S_cx_popblock(aTHX_ a)
 #define cx_popeval(a)          S_cx_popeval(aTHX_ a)
 #define cx_popformat(a)                S_cx_popformat(aTHX_ a)
+#define cx_popgiven(a)         S_cx_popgiven(aTHX_ a)
 #define cx_poploop(a)          S_cx_poploop(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_popwhen(a)          S_cx_popwhen(aTHX_ a)
 #define cx_pushblock(a,b,c,d)  S_cx_pushblock(aTHX_ a,b,c,d)
 #define cx_pusheval(a,b,c)     S_cx_pusheval(aTHX_ a,b,c)
 #define cx_pushformat(a,b,c,d) S_cx_pushformat(aTHX_ a,b,c,d)
+#define cx_pushgiven(a,b)      S_cx_pushgiven(aTHX_ a,b)
 #define cx_pushloop_for(a,b,c) S_cx_pushloop_for(aTHX_ a,b,c)
 #define cx_pushloop_plain(a)   S_cx_pushloop_plain(aTHX_ a)
 #define cx_pushsub(a,b,c,d)    S_cx_pushsub(aTHX_ a,b,c,d)
+#define cx_pushwhen(a)         S_cx_pushwhen(aTHX_ a)
 #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)
 #endif
index 99fe4ad..87b3d13 100644 (file)
--- a/inline.h
+++ b/inline.h
@@ -708,6 +708,54 @@ S_cx_poploop(pTHX_ PERL_CONTEXT *cx)
     }
 }
 
+
+PERL_STATIC_INLINE void
+S_cx_pushwhen(pTHX_ PERL_CONTEXT *cx)
+{
+    PERL_ARGS_ASSERT_CX_PUSHWHEN;
+
+    cx->blk_givwhen.leave_op = cLOGOP->op_other;
+}
+
+
+PERL_STATIC_INLINE void
+S_cx_popwhen(pTHX_ PERL_CONTEXT *cx)
+{
+    PERL_ARGS_ASSERT_CX_POPWHEN;
+    assert(CxTYPE(cx) == CXt_WHEN);
+
+    PERL_UNUSED_ARG(cx);
+    /* currently NOOP */
+}
+
+
+PERL_STATIC_INLINE void
+S_cx_pushgiven(pTHX_ PERL_CONTEXT *cx, SV *orig_defsv)
+{
+    PERL_ARGS_ASSERT_CX_PUSHGIVEN;
+
+    cx->blk_givwhen.leave_op = cLOGOP->op_other;
+    cx->blk_givwhen.defsv_save = orig_defsv;
+}
+
+
+PERL_STATIC_INLINE void
+S_cx_popgiven(pTHX_ PERL_CONTEXT *cx)
+{
+    SV *sv;
+
+    PERL_ARGS_ASSERT_CX_POPGIVEN;
+    assert(CxTYPE(cx) == CXt_GIVEN);
+
+    sv = GvSV(PL_defgv);
+    GvSV(PL_defgv) = cx->blk_givwhen.defsv_save;
+    cx->blk_givwhen.defsv_save = NULL;
+    SvREFCNT_dec(sv);
+}
+
+
+
+
 /*
  * ex: set ts=8 sts=4 sw=4 et:
  */
index 113c2c4..454a66f 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1544,10 +1544,10 @@ Perl_dounwind(pTHX_ I32 cxix)
            cx_poploop(cx);
            break;
        case CXt_WHEN:
-           CX_POPWHEN(cx);
+           cx_popwhen(cx);
            break;
        case CXt_GIVEN:
-           CX_POPGIVEN(cx);
+           cx_popgiven(cx);
            break;
        case CXt_BLOCK:
        case CXt_NULL:
@@ -4349,7 +4349,7 @@ PP(pp_entergiven)
     GvSV(PL_defgv) = SvREFCNT_inc(newsv);
 
     cx = cx_pushblock(CXt_GIVEN, gimme, SP, PL_savestack_ix);
-    CX_PUSHGIVEN(cx, origsv);
+    cx_pushgiven(cx, origsv);
 
     RETURN;
 }
@@ -4372,7 +4372,7 @@ PP(pp_leavegiven)
         leave_adjust_stacks(oldsp, oldsp, gimme, 1);
 
     CX_LEAVE_SCOPE(cx);
-    CX_POPGIVEN(cx);
+    cx_popgiven(cx);
     cx_popblock(cx);
     CX_POP(cx);
 
@@ -4929,7 +4929,7 @@ PP(pp_enterwhen)
        RETURNOP(cLOGOP->op_other->op_next);
 
     cx = cx_pushblock(CXt_WHEN, gimme, SP, PL_savestack_ix);
-    CX_PUSHWHEN(cx);
+    cx_pushwhen(cx);
 
     RETURN;
 }
@@ -4995,7 +4995,7 @@ PP(pp_continue)
     assert(CxTYPE(cx) == CXt_WHEN);
     PL_stack_sp = PL_stack_base + cx->blk_oldsp;
     CX_LEAVE_SCOPE(cx);
-    CX_POPWHEN(cx);
+    cx_popwhen(cx);
     cx_popblock(cx);
     nextop = cx->blk_givwhen.leave_op->op_next;
     CX_POP(cx);
diff --git a/proto.h b/proto.h
index ebbd4e7..b041959 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -3727,6 +3727,9 @@ PERL_STATIC_INLINE void   S_cx_popeval(pTHX_ PERL_CONTEXT *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_popgiven(pTHX_ PERL_CONTEXT *cx);
+#define PERL_ARGS_ASSERT_CX_POPGIVEN   \
+       assert(cx)
 PERL_STATIC_INLINE void        S_cx_poploop(pTHX_ PERL_CONTEXT *cx);
 #define PERL_ARGS_ASSERT_CX_POPLOOP    \
        assert(cx)
@@ -3739,6 +3742,9 @@ PERL_STATIC_INLINE void   S_cx_popsub_args(pTHX_ PERL_CONTEXT *cx);
 PERL_STATIC_INLINE void        S_cx_popsub_common(pTHX_ PERL_CONTEXT *cx);
 #define PERL_ARGS_ASSERT_CX_POPSUB_COMMON      \
        assert(cx)
+PERL_STATIC_INLINE void        S_cx_popwhen(pTHX_ PERL_CONTEXT *cx);
+#define PERL_ARGS_ASSERT_CX_POPWHEN    \
+       assert(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)
@@ -3748,6 +3754,9 @@ PERL_STATIC_INLINE void   S_cx_pusheval(pTHX_ PERL_CONTEXT *cx, OP *retop, SV *nam
 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_pushgiven(pTHX_ PERL_CONTEXT *cx, SV *orig_defsv);
+#define PERL_ARGS_ASSERT_CX_PUSHGIVEN  \
+       assert(cx)
 PERL_STATIC_INLINE void        S_cx_pushloop_for(pTHX_ PERL_CONTEXT *cx, void *itervarp, SV *itersave);
 #define PERL_ARGS_ASSERT_CX_PUSHLOOP_FOR       \
        assert(cx); assert(itervarp)
@@ -3757,6 +3766,9 @@ PERL_STATIC_INLINE void   S_cx_pushloop_plain(pTHX_ PERL_CONTEXT *cx);
 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)
+PERL_STATIC_INLINE void        S_cx_pushwhen(pTHX_ PERL_CONTEXT *cx);
+#define PERL_ARGS_ASSERT_CX_PUSHWHEN   \
+       assert(cx)
 PERL_STATIC_INLINE void        S_cx_topblock(pTHX_ PERL_CONTEXT *cx);
 #define PERL_ARGS_ASSERT_CX_TOPBLOCK   \
        assert(cx)