diff options
author | David Mitchell <davem@iabyn.com> | 2012-11-25 16:36:43 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-12-04 10:22:20 +0000 |
commit | d172696c35223548e4cde3868d91bd72b7c7c195 (patch) | |
tree | 0f86dd28fc008da2bd85eedbd6d49ef7992111c7 /scope.c | |
parent | a3444cc5f8f286b7d8760d1675a39eb29de51067 (diff) | |
download | perl-d172696c35223548e4cde3868d91bd72b7c7c195.tar.gz |
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.
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -391,17 +391,21 @@ void Perl_save_int(pTHX_ int *intp) { dVAR; - const UV shifted = (UV)*intp << SAVE_TIGHT_SHIFT; + const int i = *intp; + UV type = ((UV)(i << SAVE_TIGHT_SHIFT) | SAVEt_INT_SMALL); + int size = 2; + dSS_ADD; PERL_ARGS_ASSERT_SAVE_INT; - if ((int)(shifted >> SAVE_TIGHT_SHIFT) == *intp) { - dSS_ADD; - SS_ADD_PTR(intp); - SS_ADD_UV(SAVEt_INT_SMALL | shifted); - SS_ADD_END(2); - } else - save_pushi32ptr(*intp, intp, SAVEt_INT); + if ((int)(type >> SAVE_TIGHT_SHIFT) != i) { + SS_ADD_INT(i); + type = SAVEt_INT; + size++; + } + SS_ADD_PTR(intp); + SS_ADD_UV(type); + SS_ADD_END(size); } void @@ -434,17 +438,21 @@ void Perl_save_I32(pTHX_ I32 *intp) { dVAR; - const UV shifted = (UV)*intp << SAVE_TIGHT_SHIFT; + const I32 i = *intp; + UV type = ((I32)(i << SAVE_TIGHT_SHIFT) | SAVEt_I32_SMALL); + int size = 2; + dSS_ADD; PERL_ARGS_ASSERT_SAVE_I32; - if ((I32)(shifted >> SAVE_TIGHT_SHIFT) == *intp) { - dSS_ADD; - SS_ADD_PTR(intp); - SS_ADD_UV(SAVEt_I32_SMALL | shifted); - SS_ADD_END(2); - } else - save_pushi32ptr(*intp, intp, SAVEt_I32); + if ((I32)(type >> SAVE_TIGHT_SHIFT) != i) { + SS_ADD_INT(i); + type = SAVEt_I32; + size++; + } + SS_ADD_PTR(intp); + SS_ADD_UV(type); + SS_ADD_END(size); } /* Cannot use save_sptr() to store a char* since the SV** cast will |