Convert all the scope save functions of the form
Nicholas Clark [Sun, 30 Nov 2008 22:46:37 +0000 (22:46 +0000)]
SSCHECK(2);
SSPUSHPTR(o);
SSPUSHINT(SAVEt_FREEOP);
into a single function Perl_save_pushptr(ptr, type), which the others
call. Implement the others as macros. This reduces the object code size.

p4raw-id: //depot/perl@34956

embed.fnc
embed.h
global.sym
mathoms.c
proto.h
scope.c
scope.h

index 1a44a50..e645ab7 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -891,10 +891,10 @@ Ap        |void   |save_clearsv   |NN SV** svp
 Ap     |void   |save_delete    |NN HV *hv|NN char *key|I32 klen
 Ap     |void   |save_destructor|DESTRUCTORFUNC_NOCONTEXT_t f|NN void* p
 Ap     |void   |save_destructor_x|DESTRUCTORFUNC_t f|NULLOK void* p
-Ap     |void   |save_freesv    |NULLOK SV* sv
+Apmb   |void   |save_freesv    |NULLOK SV* sv
 : Used in SAVEFREOP(), used in op.c, pp_ctl.c
-p      |void   |save_freeop    |NULLOK OP* o
-Ap     |void   |save_freepv    |NULLOK char* pv
+pmb    |void   |save_freeop    |NULLOK OP* o
+Apmb   |void   |save_freepv    |NULLOK char* pv
 Ap     |void   |save_generic_svref|NN SV** sptr
 Ap     |void   |save_generic_pvref|NN char** str
 Ap     |void   |save_shared_pvref|NN char** str
@@ -911,10 +911,10 @@ Ap        |void   |save_item      |NN SV* item
 Ap     |void   |save_iv        |NN IV *ivp
 Ap     |void   |save_list      |NN SV** sarg|I32 maxsarg
 Ap     |void   |save_long      |NN long* longp
-Ap     |void   |save_mortalizesv|NN SV* sv
+Apmb   |void   |save_mortalizesv|NN SV* sv
 Ap     |void   |save_nogv      |NN GV* gv
 : Used in SAVEFREOP(), used in gv.c, op.c, perl.c, pp_ctl.c, pp_sort.c
-p      |void   |save_op
+pmb    |void   |save_op
 Ap     |SV*    |save_scalar    |NN GV* gv
 Ap     |void   |save_pptr      |NN char** pptr
 Ap     |void   |save_vptr      |NN void *ptr
@@ -922,6 +922,7 @@ Ap  |void   |save_re_context
 Ap     |void   |save_padsv_and_mortalize|PADOFFSET off
 Ap     |void   |save_sptr      |NN SV** sptr
 Ap     |SV*    |save_svref     |NN SV** sptr
+Ap     |void   |save_pushptr   |NULLOK void *const ptr|const int type
 : Used in perly.y
 p      |OP*    |sawparens      |NULLOK OP* o
 : Used in perly.y
diff --git a/embed.h b/embed.h
index 480652b..bce4460 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define save_delete            Perl_save_delete
 #define save_destructor                Perl_save_destructor
 #define save_destructor_x      Perl_save_destructor_x
-#define save_freesv            Perl_save_freesv
-#ifdef PERL_CORE
-#define save_freeop            Perl_save_freeop
-#endif
-#define save_freepv            Perl_save_freepv
 #define save_generic_svref     Perl_save_generic_svref
 #define save_generic_pvref     Perl_save_generic_pvref
 #define save_shared_pvref      Perl_save_shared_pvref
 #define save_iv                        Perl_save_iv
 #define save_list              Perl_save_list
 #define save_long              Perl_save_long
-#define save_mortalizesv       Perl_save_mortalizesv
 #define save_nogv              Perl_save_nogv
-#ifdef PERL_CORE
-#define save_op                        Perl_save_op
-#endif
 #define save_scalar            Perl_save_scalar
 #define save_pptr              Perl_save_pptr
 #define save_vptr              Perl_save_vptr
 #define save_padsv_and_mortalize       Perl_save_padsv_and_mortalize
 #define save_sptr              Perl_save_sptr
 #define save_svref             Perl_save_svref
+#define save_pushptr           Perl_save_pushptr
 #ifdef PERL_CORE
 #define sawparens              Perl_sawparens
 #define scalar                 Perl_scalar
 #define save_delete(a,b,c)     Perl_save_delete(aTHX_ a,b,c)
 #define save_destructor(a,b)   Perl_save_destructor(aTHX_ a,b)
 #define save_destructor_x(a,b) Perl_save_destructor_x(aTHX_ a,b)
-#define save_freesv(a)         Perl_save_freesv(aTHX_ a)
 #ifdef PERL_CORE
-#define save_freeop(a)         Perl_save_freeop(aTHX_ a)
 #endif
-#define save_freepv(a)         Perl_save_freepv(aTHX_ a)
 #define save_generic_svref(a)  Perl_save_generic_svref(aTHX_ a)
 #define save_generic_pvref(a)  Perl_save_generic_pvref(aTHX_ a)
 #define save_shared_pvref(a)   Perl_save_shared_pvref(aTHX_ a)
 #define save_iv(a)             Perl_save_iv(aTHX_ a)
 #define save_list(a,b)         Perl_save_list(aTHX_ a,b)
 #define save_long(a)           Perl_save_long(aTHX_ a)
-#define save_mortalizesv(a)    Perl_save_mortalizesv(aTHX_ a)
 #define save_nogv(a)           Perl_save_nogv(aTHX_ a)
 #ifdef PERL_CORE
-#define save_op()              Perl_save_op(aTHX)
 #endif
 #define save_scalar(a)         Perl_save_scalar(aTHX_ a)
 #define save_pptr(a)           Perl_save_pptr(aTHX_ a)
 #define save_padsv_and_mortalize(a)    Perl_save_padsv_and_mortalize(aTHX_ a)
 #define save_sptr(a)           Perl_save_sptr(aTHX_ a)
 #define save_svref(a)          Perl_save_svref(aTHX_ a)
+#define save_pushptr(a,b)      Perl_save_pushptr(aTHX_ a,b)
 #ifdef PERL_CORE
 #define sawparens(a)           Perl_sawparens(aTHX_ a)
 #define scalar(a)              Perl_scalar(aTHX_ a)
index acd525f..fe26578 100644 (file)
@@ -443,6 +443,7 @@ Perl_save_delete
 Perl_save_destructor
 Perl_save_destructor_x
 Perl_save_freesv
+Perl_save_freeop
 Perl_save_freepv
 Perl_save_generic_svref
 Perl_save_generic_pvref
@@ -461,6 +462,7 @@ Perl_save_list
 Perl_save_long
 Perl_save_mortalizesv
 Perl_save_nogv
+Perl_save_op
 Perl_save_scalar
 Perl_save_pptr
 Perl_save_vptr
@@ -468,6 +470,7 @@ Perl_save_re_context
 Perl_save_padsv_and_mortalize
 Perl_save_sptr
 Perl_save_svref
+Perl_save_pushptr
 Perl_scan_bin
 Perl_scan_hex
 Perl_scan_num
index 2b765b8..3bdba65 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -1429,6 +1429,44 @@ Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
     sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
 }
 
+void
+Perl_save_freesv(pTHX_ SV *sv)
+{
+    dVAR;
+    save_freesv(sv);
+}
+
+void
+Perl_save_mortalizesv(pTHX_ SV *sv)
+{
+    dVAR;
+
+    PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
+
+    save_mortalizesv(sv);
+}
+
+void
+Perl_save_freeop(pTHX_ OP *o)
+{
+    dVAR;
+    save_freeop(o);
+}
+
+void
+Perl_save_freepv(pTHX_ char *pv)
+{
+    dVAR;
+    save_freepv(pv);
+}
+
+void
+Perl_save_op(pTHX)
+{
+    dVAR;
+    save_op();
+}
+
 #endif /* NO_MATHOMS */
 
 /*
diff --git a/proto.h b/proto.h
index 59192ea..3b4404b 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -2787,9 +2787,9 @@ PERL_CALLCONV void        Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void
        assert(p)
 
 PERL_CALLCONV void     Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p);
-PERL_CALLCONV void     Perl_save_freesv(pTHX_ SV* sv);
-PERL_CALLCONV void     Perl_save_freeop(pTHX_ OP* o);
-PERL_CALLCONV void     Perl_save_freepv(pTHX_ char* pv);
+/* PERL_CALLCONV void  Perl_save_freesv(pTHX_ SV* sv); */
+/* PERL_CALLCONV void  Perl_save_freeop(pTHX_ OP* o); */
+/* PERL_CALLCONV void  Perl_save_freepv(pTHX_ char* pv); */
 PERL_CALLCONV void     Perl_save_generic_svref(pTHX_ SV** sptr)
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_SAVE_GENERIC_SVREF    \
@@ -2874,8 +2874,8 @@ PERL_CALLCONV void        Perl_save_long(pTHX_ long* longp)
 #define PERL_ARGS_ASSERT_SAVE_LONG     \
        assert(longp)
 
-PERL_CALLCONV void     Perl_save_mortalizesv(pTHX_ SV* sv)
-                       __attribute__nonnull__(pTHX_1);
+/* PERL_CALLCONV void  Perl_save_mortalizesv(pTHX_ SV* sv)
+                       __attribute__nonnull__(pTHX_1); */
 #define PERL_ARGS_ASSERT_SAVE_MORTALIZESV      \
        assert(sv)
 
@@ -2884,7 +2884,7 @@ PERL_CALLCONV void        Perl_save_nogv(pTHX_ GV* gv)
 #define PERL_ARGS_ASSERT_SAVE_NOGV     \
        assert(gv)
 
-PERL_CALLCONV void     Perl_save_op(pTHX);
+/* PERL_CALLCONV void  Perl_save_op(pTHX); */
 PERL_CALLCONV SV*      Perl_save_scalar(pTHX_ GV* gv)
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_SAVE_SCALAR   \
@@ -2912,6 +2912,7 @@ PERL_CALLCONV SV* Perl_save_svref(pTHX_ SV** sptr)
 #define PERL_ARGS_ASSERT_SAVE_SVREF    \
        assert(sptr)
 
+PERL_CALLCONV void     Perl_save_pushptr(pTHX_ void *const ptr, const int type);
 PERL_CALLCONV OP*      Perl_sawparens(pTHX_ OP* o);
 PERL_CALLCONV OP*      Perl_scalar(pTHX_ OP* o);
 #if defined(PERL_IN_OP_C)
diff --git a/scope.c b/scope.c
index 88fb53a..672faa1 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -505,42 +505,12 @@ Perl_save_aptr(pTHX_ AV **aptr)
 }
 
 void
-Perl_save_freesv(pTHX_ SV *sv)
+Perl_save_pushptr(pTHX_ void *const ptr, const int type)
 {
     dVAR;
     SSCHECK(2);
-    SSPUSHPTR(sv);
-    SSPUSHINT(SAVEt_FREESV);
-}
-
-void
-Perl_save_mortalizesv(pTHX_ SV *sv)
-{
-    dVAR;
-
-    PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
-
-    SSCHECK(2);
-    SSPUSHPTR(sv);
-    SSPUSHINT(SAVEt_MORTALIZESV);
-}
-
-void
-Perl_save_freeop(pTHX_ OP *o)
-{
-    dVAR;
-    SSCHECK(2);
-    SSPUSHPTR(o);
-    SSPUSHINT(SAVEt_FREEOP);
-}
-
-void
-Perl_save_freepv(pTHX_ char *pv)
-{
-    dVAR;
-    SSCHECK(2);
-    SSPUSHPTR(pv);
-    SSPUSHINT(SAVEt_FREEPV);
+    SSPUSHPTR(ptr);
+    SSPUSHINT(type);
 }
 
 void
@@ -660,15 +630,6 @@ Perl_save_svref(pTHX_ SV **sptr)
     return save_scalar_at(sptr, SAVEf_SETMAGIC); /* XXX - FIXME - see #60360 */
 }
 
-void
-Perl_save_op(pTHX)
-{
-    dVAR;
-    SSCHECK(2);
-    SSPUSHPTR(PL_op);
-    SSPUSHINT(SAVEt_OP);
-}
-
 I32
 Perl_save_alloc(pTHX_ I32 size, I32 pad)
 {
diff --git a/scope.h b/scope.h
index c1fa4f9..e910388 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -260,6 +260,12 @@ Closing bracket on a callback.  See C<ENTER> and L<perlcall>.
 #define SSPTR(off,type)         ((type)  ((char*)PL_savestack + off))
 #define SSPTRt(off,type)        ((type*) ((char*)PL_savestack + off))
 
+#define save_freesv(op)                save_pushptr((void *)(op), SAVEt_FREESV)
+#define save_mortalizesv(op)   save_pushptr((void *)(op), SAVEt_MORTALIZESV)
+#define save_freeop(op)                save_pushptr((void *)(op), SAVEt_FREEOP)
+#define save_freepv(pv)                save_pushptr((void *)(pv), SAVEt_FREEPV)
+#define save_op()              save_pushptr((void *)(PL_op), SAVEt_OP)
+
 /*
  * Local variables:
  * c-indentation-style: bsd