In perl.git, the branch smoke-me/davem/ss_push_pop3 has been created

<http://perl5.git.perl.org/perl.git/commitdiff/ab71e19be827bc497a645fefe7afa18dc6edb657?hp=0000000000000000000000000000000000000000>

        at  ab71e19be827bc497a645fefe7afa18dc6edb657 (commit)

- Log -----------------------------------------------------------------
commit ab71e19be827bc497a645fefe7afa18dc6edb657
Author: David Mitchell <[email protected]>
Date:   Thu Nov 29 11:37:08 2012 +0000

    Optimise magic handling in save* and leave_scope
    
    There are several places that have code similar to
    
        if (SvMAGICAL(sv)) {
            PL_localizing = 2;
            SvSETMAGIC(sv)
            PL_localizing = 0;
        }
    
    The condition is sub-optimal (it should only test for set magic), and the
    SvSETMAGIC repeats a similar test.
    Other places didn't have the outer condition, so they set PL_localizing
    twice even when not needed.

M       scope.c

commit 4f6fb7975d2f2ba120ce926fcb73c712aea106a2
Author: David Mitchell <[email protected]>
Date:   Sun Nov 25 23:08:11 2012 +0000

    refactor Perl_leave_scope
    
    This is a large and hot function. The main problem with it is that
    there is code to pop a few args repeated in just about every branch.
    Also, there are a whole bunch of local vars (sv, av, hv, gv etc)
    that are never all used simultaneously, but are really just there for
    casting convenience. Together, they defeat the compiler's register
    allocation algorithms (well, they did for gcc anyway).
    
    We fix this by just declaring three general vars, arg0,1,2 of type ANY, and
    move the popping code to above the switch(). We sort the SAVEt_*
    indices in order of number of args, so it's quick to determine how many
    args we need to pop for a particular type.
    
    Together with the previous commits which added the SS_ADD_* macros, this
    reduces the size of scope.o (-O2, gcc x86_64) by about 9% (threaded)
    or 17% (unthreaded), and seems to speed up simple loops / function calls
    by around 5%.

M       scope.c
M       scope.h

commit 54f71b70e346c75cb28b7f3bfcf8acff41085fc7
Author: David Mitchell <[email protected]>
Date:   Sun Nov 25 16:36:43 2012 +0000

    save_int/i32 inline the long version
    
    Both these functions were structured as
    
        if (int will fit in type)
        SS_ADD(...);
        else
        save_pushi32ptr(...)
    
    Inline the call of the "long" version of the save. With refactoring, the
    machine code (x86_64, gcc -O2) is no larger than before, and saves time
    on the long version.

M       scope.c

commit bc57511565aee1381ab62b99340eab996af10d84
Author: David Mitchell <[email protected]>
Date:   Sun Nov 25 15:22:19 2012 +0000

    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 */

M       pp_hot.c
M       scope.c
M       scope.h
-----------------------------------------------------------------------

--
Perl5 Master Repository

Reply via email to