Add SS_ADD_* macros and replace most SSPUSH* uses
authorDavid Mitchell <davem@iabyn.com>
Sun, 25 Nov 2012 15:22:19 +0000 (15:22 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 4 Dec 2012 10:22:19 +0000 (10:22 +0000)
commita3444cc5f8f286b7d8760d1675a39eb29de51067
treeca5a97164d459136f66ae71f685a233194ece2ed
parent424fc9e3ff7e2b61439423cfd429177ceceb5b3b
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 */
pp_hot.c
scope.c
scope.h
sv.c