Move the implmentation of SAVEHINTS() into a new Perl_save_hints() in
authorNicholas Clark <nick@ccl4.org>
Mon, 1 Dec 2008 11:06:05 +0000 (11:06 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 30 Mar 2009 14:06:45 +0000 (15:06 +0100)
scope.c. "Inlined" macro functions in scope.h are actually space
inefficient.

(cherry-picked from commit da8315f8f4d9d4df8cbebe108ef0ddb4795856d7,
but modified to allow for the fact that the body of SAVEHINTS()
hasn't been reordered by the blead-only commit 601cee3b44)

p4raw-id: //depot/perl@34965

embed.fnc
embed.h
proto.h
scope.c
scope.h

index 38db486..59f3f4d 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -881,6 +881,7 @@ Ap  |void   |save_generic_pvref|NN char** str
 Ap     |void   |save_shared_pvref|NN char** str
 Ap     |void   |save_gp        |NN GV* gv|I32 empty
 Ap     |HV*    |save_hash      |NN GV* gv
+p      |void   |save_hints
 Ap     |void   |save_helem     |NN HV *hv|NN SV *key|NN SV **sptr
 Ap     |void   |save_hptr      |NN HV** hptr
 Ap     |void   |save_I16       |NN I16* intp
diff --git a/embed.h b/embed.h
index 523b599..74d4431 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define save_shared_pvref      Perl_save_shared_pvref
 #define save_gp                        Perl_save_gp
 #define save_hash              Perl_save_hash
+#ifdef PERL_CORE
+#define save_hints             Perl_save_hints
+#endif
 #define save_helem             Perl_save_helem
 #define save_hptr              Perl_save_hptr
 #define save_I16               Perl_save_I16
 #define save_shared_pvref(a)   Perl_save_shared_pvref(aTHX_ a)
 #define save_gp(a,b)           Perl_save_gp(aTHX_ a,b)
 #define save_hash(a)           Perl_save_hash(aTHX_ a)
+#ifdef PERL_CORE
+#define save_hints()           Perl_save_hints(aTHX)
+#endif
 #define save_helem(a,b,c)      Perl_save_helem(aTHX_ a,b,c)
 #define save_hptr(a)           Perl_save_hptr(aTHX_ a)
 #define save_I16(a)            Perl_save_I16(aTHX_ a)
diff --git a/proto.h b/proto.h
index 510e9b4..772c8bd 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -2830,6 +2830,7 @@ PERL_CALLCONV HV* Perl_save_hash(pTHX_ GV* gv)
 #define PERL_ARGS_ASSERT_SAVE_HASH     \
        assert(gv)
 
+PERL_CALLCONV void     Perl_save_hints(pTHX);
 PERL_CALLCONV void     Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2)
diff --git a/scope.c b/scope.c
index e058433..c0a1ddb 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -535,6 +535,25 @@ Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
     SSPUSHINT(SAVEt_DESTRUCTOR_X);
 }
 
+void
+Perl_save_hints(pTHX)
+{
+    dVAR;
+    SSCHECK(4);
+    if (PL_hints & HINT_LOCALIZE_HH) {
+       SSPUSHPTR(GvHV(PL_hintgv));
+       GvHV(PL_hintgv) = Perl_hv_copy_hints_hv(aTHX_ GvHV(PL_hintgv));
+    }
+    if (PL_compiling.cop_hints_hash) {
+       HINTS_REFCNT_LOCK;
+       PL_compiling.cop_hints_hash->refcounted_he_refcnt++;
+       HINTS_REFCNT_UNLOCK;
+    }
+    SSPUSHPTR(PL_compiling.cop_hints_hash);
+    SSPUSHINT(PL_hints);
+    SSPUSHINT(SAVEt_HINTS);
+}
+
 void
 Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
 {
diff --git a/scope.h b/scope.h
index a0e0d0d..ebfe7b3 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -155,22 +155,7 @@ Closing bracket on a callback.  See C<ENTER> and L<perlcall>.
 
 #define SAVEOP()       save_op()
 
-#define SAVEHINTS() \
-    STMT_START {                                       \
-       SSCHECK(4);                                     \
-       if (PL_hints & HINT_LOCALIZE_HH) {              \
-           SSPUSHPTR(GvHV(PL_hintgv));                 \
-           GvHV(PL_hintgv) = Perl_hv_copy_hints_hv(aTHX_ GvHV(PL_hintgv)); \
-       }                                               \
-       if (PL_compiling.cop_hints_hash) {              \
-           HINTS_REFCNT_LOCK;                          \
-           PL_compiling.cop_hints_hash->refcounted_he_refcnt++;        \
-           HINTS_REFCNT_UNLOCK;                        \
-       }                                               \
-       SSPUSHPTR(PL_compiling.cop_hints_hash);         \
-       SSPUSHINT(PL_hints);                            \
-       SSPUSHINT(SAVEt_HINTS);                         \
-    } STMT_END
+#define SAVEHINTS()    save_hints()
 
 #define SAVECOMPPAD() save_pushptr(MUTABLE_SV(PL_comppad), SAVEt_COMPPAD)