In perl.git, the branch smoke-me/davem/ss_push_pop has been created
<http://perl5.git.perl.org/perl.git/commitdiff/f05e43025cf028ea6d9c510f6075e7bb92c97e2d?hp=0000000000000000000000000000000000000000>
at f05e43025cf028ea6d9c510f6075e7bb92c97e2d (commit)
- Log -----------------------------------------------------------------
commit f05e43025cf028ea6d9c510f6075e7bb92c97e2d
Author: David Mitchell <[email protected]>
Date: Thu Nov 29 11:37:08 2012 +0000
Optimise magic handling in save*
There are several places that have code similar to
if (SvMAGICAL(sv)) {
PL_localizing = 2;
SvSETMAGIC(sv)
PL_localizing = 0;
}
The condition 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 fb5315dba64f5e4ac8f5180b7c0abaff9d3739e2
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.c (-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 cf3181c827544068eaa01af9f2f0ddba337ff7d1
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 ae4361a251065ab6ec7c4447dec45ca17274f5e1
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