summaryrefslogtreecommitdiff
path: root/pp.h
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-10-10 13:29:33 -0400
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 14:30:21 -0700
commita953aca586d48d6f0b2c4db3572de328ed6d85e8 (patch)
tree244c1608b1f36a40c1c0b27105586d1d19949f65 /pp.h
parentde183bbb2f50be045697c1759931907c5e7bdf28 (diff)
downloadperl-a953aca586d48d6f0b2c4db3572de328ed6d85e8.tar.gz
optimize & rmv from public API Perl_tmps_grow and related code
Previously in PUSH_EXTEND_MORTAL__SV_C, "PL_tmps_ix + 1" would execute twice, once for the nonmutable if(>=), then again after the potential tmps_grow call. tmps_grow has an unused return register/void proto, put it to use by returning ix. Also change tmps_grow to take the result of "PL_tmps_ix + the constant (usually 1) or non-constant (EXTEND_MORTAL)". This avoid having to put the constant twice in machine code, once for the if test, 2nd time for extend length param for tmps_grow call. For non-constant/EXTEND_MORTAL usage, it allows the C optimizer to have the length var to go out of liveness sooner if possible. Also the var used for the if(>=) test is more likely to be in a register than length var. So "if test variable" is closer on hand to the CPU than length var. In some cases, if non-const len var isn't used again, it becomes the "ix" variable by having PL_tmps_ix added to it. Change sv_2mortal to return sv instead of NULL to remove a unique branch/block of machine code that assigns 0 to return variable (Visual C didn't figure out return sv == returned NULL, not sv). See also [perl #121845].
Diffstat (limited to 'pp.h')
-rw-r--r--pp.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/pp.h b/pp.h
index 00e942059a..0ced1d6111 100644
--- a/pp.h
+++ b/pp.h
@@ -391,9 +391,10 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
} STMT_END
#define EXTEND_MORTAL(n) \
- STMT_START { \
- if (UNLIKELY(PL_tmps_ix + (n) >= PL_tmps_max)) \
- tmps_grow(n); \
+ STMT_START { \
+ SSize_t eMiX = PL_tmps_ix + (n); \
+ if (UNLIKELY(eMiX >= PL_tmps_max)) \
+ (void)tmps_grow_p(eMiX); \
} STMT_END
#define AMGf_noright 1