diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2014-06-04 23:17:39 -0400 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2014-06-09 10:11:19 +1000 |
commit | ba5248fcde21acfb9d93220ec07256804525c18e (patch) | |
tree | 8513fc452f279ecad1f828028aca927dd99be72e /scope.c | |
parent | 94d4006a6dfdde1becb6ac3d43bd51a5b9ffd95f (diff) | |
download | perl-ba5248fcde21acfb9d93220ec07256804525c18e.tar.gz |
remove 1 read of interp var from PUSHMARK
PL_markstack_ptr was read once to do the ++ and comparison. Then after
the markstack_grow call, or not, depending on the branch. The code reads
PL_markstack_ptr a 2nd time. It has to be reread in case (or always does)
markstack_grow reallocs the mark stack. markstack_grow has a void retval.
That is a waste of a register. Let us put it to use to return the new
PL_markstack_ptr. In markstack_grow the contents that will be assigned to
PL_markstack_ptr are already in a register. So let the I32* flow out from
markstack_grow to its caller.
In VC2003 32 bit asm, mark_stack_entry is register eax. The retval of
markstack_grow is in eax. So the assignment "=" in
"mark_stack_entry = markstack_grow();" has no overhead. Since the other,
not extend branch, is function call free,
"(mark_stack_entry = ++PL_markstack_ptr)" assigns to eax. Ultimatly with
this patch a 3 byte mov instruction is saved for each instance of PUSHMARK,
and 1 interp var read is removed. I observed 42 callers of markstack_grow
with my disassembler, so theoretically 3*42 bytes of machine code was
removed for me.
Perl_pp_pushmark dropped from 0x2b to 0x28 bytes of x86 VC 2003
machine code. [perl #122034]
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -110,7 +110,7 @@ Perl_pop_scope(pTHX) LEAVE_SCOPE(oldsave); } -void +I32 * Perl_markstack_grow(pTHX) { dVAR; @@ -118,8 +118,9 @@ Perl_markstack_grow(pTHX) const I32 newmax = GROW(oldmax); Renew(PL_markstack, newmax, I32); - PL_markstack_ptr = PL_markstack + oldmax; PL_markstack_max = PL_markstack + newmax; + PL_markstack_ptr = PL_markstack + oldmax; + return PL_markstack_ptr; } void |