summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2012-11-25 15:22:19 +0000
committerDavid Mitchell <davem@iabyn.com>2012-12-04 10:22:19 +0000
commita3444cc5f8f286b7d8760d1675a39eb29de51067 (patch)
treeca5a97164d459136f66ae71f685a233194ece2ed /sv.c
parent424fc9e3ff7e2b61439423cfd429177ceceb5b3b (diff)
downloadperl-a3444cc5f8f286b7d8760d1675a39eb29de51067.tar.gz
Add SS_ADD_* macros and replace most SSPUSH* uses
The current idiom for adding an entry to the savestack is SSCHECK(3); SSPUSHINT(...); SSPUSHPTR(...); SSPUSHUV(SAVEt_...); Replace this with a new idiom: { dSS_ADD; SS_ADD_INT(...); SS_ADD_PTR(...); SS_ADD_UV(SAVEt_...); SS_ADD_END(3); } This is designed to be more efficient. First, it defines some local vars, and defers updating PL_savestack_ix to the end. Second, it performs the 'is there space on the stack' check *after* pushing. Doing the check last means that values in registers will have been pushed and no longer needed, so don't need saving around the call to grow. Also, tail-call elimination of the grow() can be done. These changes reduce the code of something like save_pushptrptr() to half its former size. Of course, doing the size check *after* pushing means we must always ensure there are SS_MAXPUSH free slots on the savestack */
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index 35d295e7d5..397d9928df 100644
--- a/sv.c
+++ b/sv.c
@@ -3795,13 +3795,14 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
gain a name somehow before leave_scope. */
if (stype == SVt_PVCV) {
/* There is no save_pushptrptrptr. Creating it for this
- one call site would be overkill. So inline the ss push
+ one call site would be overkill. So inline the ss add
routines here. */
- SSCHECK(4);
- SSPUSHPTR(dstr);
- SSPUSHPTR(location);
- SSPUSHPTR(SvREFCNT_inc(*location));
- SSPUSHUV(SAVEt_GVSLOT);
+ dSS_ADD;
+ SS_ADD_PTR(dstr);
+ SS_ADD_PTR(location);
+ SS_ADD_PTR(SvREFCNT_inc(*location));
+ SS_ADD_UV(SAVEt_GVSLOT);
+ SS_ADD_END(4);
}
else SAVEGENERICSV(*location);
}