summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-12-01 11:27:31 +0000
committerNicholas Clark <nick@ccl4.org>2008-12-01 11:27:31 +0000
commitbe84297eef8d269e574a1aac0dbf18f3c3b7341d (patch)
tree5d9d8f823e02dd8bd4e9645a1f486b82ab9095dc
parentda8315f8f4d9d4df8cbebe108ef0ddb4795856d7 (diff)
downloadperl-be84297eef8d269e574a1aac0dbf18f3c3b7341d.tar.gz
Add S_save_pushptri32ptr() and use it to re-implement Perl_save_hints()
and Perl_save_aelem(). p4raw-id: //depot/perl@34966
-rw-r--r--embed.fnc4
-rw-r--r--embed.h14
-rw-r--r--proto.h3
-rw-r--r--scope.c26
4 files changed, 38 insertions, 9 deletions
diff --git a/embed.fnc b/embed.fnc
index 1e4d31533e..4c735c3192 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -929,6 +929,10 @@ p |void |save_pushi32ptr|I32 i|NULLOK void *const ptr|const int type
: Used by SAVESWITCHSTACK() in pp.c
p |void |save_pushptrptr|NULLOK void *const ptr1 \
|NULLOK void *const ptr2|const int type
+#if defined(PERL_IN_SCOPE_C) || defined(PERL_DECL_PROT)
+s |void |save_pushptri32ptr|NULLOK void *const ptr1|const I32 i \
+ |NULLOK void *const ptr2|const int type
+#endif
: Used in perly.y
p |OP* |sawparens |NULLOK OP* o
: Used in perly.y
diff --git a/embed.h b/embed.h
index e56244cd8c..cf453acd98 100644
--- a/embed.h
+++ b/embed.h
@@ -812,6 +812,13 @@
#ifdef PERL_CORE
#define save_pushi32ptr Perl_save_pushi32ptr
#define save_pushptrptr Perl_save_pushptrptr
+#endif
+#if defined(PERL_IN_SCOPE_C) || defined(PERL_DECL_PROT)
+#ifdef PERL_CORE
+#define save_pushptri32ptr S_save_pushptri32ptr
+#endif
+#endif
+#ifdef PERL_CORE
#define sawparens Perl_sawparens
#define scalar Perl_scalar
#endif
@@ -3161,6 +3168,13 @@
#ifdef PERL_CORE
#define save_pushi32ptr(a,b,c) Perl_save_pushi32ptr(aTHX_ a,b,c)
#define save_pushptrptr(a,b,c) Perl_save_pushptrptr(aTHX_ a,b,c)
+#endif
+#if defined(PERL_IN_SCOPE_C) || defined(PERL_DECL_PROT)
+#ifdef PERL_CORE
+#define save_pushptri32ptr(a,b,c,d) S_save_pushptri32ptr(aTHX_ a,b,c,d)
+#endif
+#endif
+#ifdef PERL_CORE
#define sawparens(a) Perl_sawparens(aTHX_ a)
#define scalar(a) Perl_scalar(aTHX_ a)
#endif
diff --git a/proto.h b/proto.h
index b7e77370e5..5f07ad4fae 100644
--- a/proto.h
+++ b/proto.h
@@ -2916,6 +2916,9 @@ PERL_CALLCONV SV* Perl_save_svref(pTHX_ SV** sptr)
PERL_CALLCONV void Perl_save_pushptr(pTHX_ void *const ptr, const int type);
PERL_CALLCONV void Perl_save_pushi32ptr(pTHX_ I32 i, void *const ptr, const int type);
PERL_CALLCONV void Perl_save_pushptrptr(pTHX_ void *const ptr1, void *const ptr2, const int type);
+#if defined(PERL_IN_SCOPE_C) || defined(PERL_DECL_PROT)
+STATIC void S_save_pushptri32ptr(pTHX_ void *const ptr1, const I32 i, void *const ptr2, const int type);
+#endif
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 9f53549650..7845fc5a6b 100644
--- a/scope.c
+++ b/scope.c
@@ -546,12 +546,23 @@ Perl_save_hints(pTHX)
}
SSCHECK(4);
if (PL_hints & HINT_LOCALIZE_HH) {
- SSPUSHPTR(GvHV(PL_hintgv));
+ save_pushptri32ptr(GvHV(PL_hintgv), PL_hints,
+ PL_compiling.cop_hints_hash, SAVEt_HINTS);
GvHV(PL_hintgv) = Perl_hv_copy_hints_hv(aTHX_ GvHV(PL_hintgv));
+ } else {
+ save_pushi32ptr(PL_hints, PL_compiling.cop_hints_hash, SAVEt_HINTS);
}
- SSPUSHINT(PL_hints);
- SSPUSHPTR(PL_compiling.cop_hints_hash);
- SSPUSHINT(SAVEt_HINTS);
+}
+
+static void
+S_save_pushptri32ptr(pTHX_ void *const ptr1, const I32 i, void *const ptr2,
+ const int type)
+{
+ SSCHECK(4);
+ SSPUSHPTR(ptr1);
+ SSPUSHINT(i);
+ SSPUSHPTR(ptr2);
+ SSPUSHINT(type);
}
void
@@ -563,11 +574,8 @@ Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
PERL_ARGS_ASSERT_SAVE_AELEM;
SvGETMAGIC(*sptr);
- SSCHECK(4);
- SSPUSHPTR(SvREFCNT_inc_simple(av));
- SSPUSHINT(idx);
- SSPUSHPTR(SvREFCNT_inc(*sptr));
- SSPUSHINT(SAVEt_AELEM);
+ save_pushptri32ptr(SvREFCNT_inc_simple(av), idx, SvREFCNT_inc(*sptr),
+ SAVEt_AELEM);
/* if it gets reified later, the restore will have the wrong refcnt */
if (!AvREAL(av) && AvREIFY(av))
SvREFCNT_inc_void(*sptr);