diff options
author | David Mitchell <davem@iabyn.com> | 2012-11-25 15:22:19 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-12-04 10:22:19 +0000 |
commit | a3444cc5f8f286b7d8760d1675a39eb29de51067 (patch) | |
tree | ca5a97164d459136f66ae71f685a233194ece2ed /pp_hot.c | |
parent | 424fc9e3ff7e2b61439423cfd429177ceceb5b3b (diff) | |
download | perl-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 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -376,8 +376,11 @@ PP(pp_padrange) | SAVEt_CLEARPADRANGE); assert(OPpPADRANGE_COUNTMASK + 1 == (1 <<OPpPADRANGE_COUNTSHIFT)); assert((payload >> (OPpPADRANGE_COUNTSHIFT+SAVE_TIGHT_SHIFT)) == base); - SSCHECK(1); - SSPUSHUV(payload); + { + dSS_ADD; + SS_ADD_UV(payload); + SS_ADD_END(1); + } for (i = 0; i <count; i++) SvPADSTALE_off(*svp++); /* mark lexical as active */ |