diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-02-07 18:01:26 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-02-07 18:01:26 +0000 |
commit | 3658c1f1e67f531ad4ee20e8c748aec14b993c44 (patch) | |
tree | 32b3f67e0e63185b74168c07ec6bac15029030db | |
parent | d4ac975eac140a6fda54f99664f15120fd97e7be (diff) | |
download | perl-3658c1f1e67f531ad4ee20e8c748aec14b993c44.tar.gz |
Merging pp_bit_or and pp_bit_xor shrinks the object code by about .7K.
The overloading tests are not free.
p4raw-id: //depot/perl@27126
-rw-r--r-- | mathoms.c | 5 | ||||
-rw-r--r-- | opcode.h | 2 | ||||
-rwxr-xr-x | opcode.pl | 1 | ||||
-rw-r--r-- | pp.c | 44 | ||||
-rw-r--r-- | pp.h | 6 |
5 files changed, 25 insertions, 33 deletions
@@ -1074,6 +1074,11 @@ PP(pp_sqrt) return pp_sin(); } +PP(pp_bit_xor) +{ + return pp_bit_or(); +} + U8 * Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv) { @@ -877,7 +877,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */ MEMBER_TO_FPTR(Perl_pp_sne), MEMBER_TO_FPTR(Perl_pp_scmp), MEMBER_TO_FPTR(Perl_pp_bit_and), - MEMBER_TO_FPTR(Perl_pp_bit_xor), + MEMBER_TO_FPTR(Perl_pp_bit_or), /* Perl_pp_bit_xor */ MEMBER_TO_FPTR(Perl_pp_bit_or), MEMBER_TO_FPTR(Perl_pp_negate), MEMBER_TO_FPTR(Perl_pp_i_negate), @@ -83,6 +83,7 @@ my @raw_alias = ( Perl_pp_oct => ['hex'], Perl_pp_shift => ['pop'], Perl_pp_sin => [qw(cos exp log sqrt)], + Perl_pp_bit_or => ['bit_xor'], ); while (my ($func, $names) = splice @raw_alias, 0, 2) { @@ -2205,50 +2205,32 @@ PP(pp_bit_and) } } -PP(pp_bit_xor) -{ - dVAR; dSP; dATARGET; tryAMAGICbin(bxor,opASSIGN); - { - dPOPTOPssrl; - SvGETMAGIC(left); - SvGETMAGIC(right); - if (SvNIOKp(left) || SvNIOKp(right)) { - if (PL_op->op_private & HINT_INTEGER) { - const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right); - SETi(i); - } - else { - const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) ^ SvUV_nomg(right); - SETu(u); - } - } - else { - do_vop(PL_op->op_type, TARG, left, right); - SETTARG; - } - RETURN; - } -} - PP(pp_bit_or) { - dVAR; dSP; dATARGET; tryAMAGICbin(bor,opASSIGN); + dVAR; dSP; dATARGET; + const int op_type = PL_op->op_type; + + tryAMAGICbin_var((op_type == OP_BIT_OR ? bor_amg : bxor_amg), opASSIGN); { dPOPTOPssrl; SvGETMAGIC(left); SvGETMAGIC(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right); - SETi(i); + const IV l = (USE_LEFT(left) ? SvIV_nomg(left) : 0); + const IV r = SvIV_nomg(right); + const IV result = op_type == OP_BIT_OR ? (l | r) : (l ^ r); + SETi(result); } else { - const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) | SvUV_nomg(right); - SETu(u); + const UV l = (USE_LEFT(left) ? SvUV_nomg(left) : 0); + const UV r = SvUV_nomg(right); + const UV result = op_type == OP_BIT_OR ? (l | r) : (l ^ r); + SETu(result); } } else { - do_vop(PL_op->op_type, TARG, left, right); + do_vop(op_type, TARG, left, right); SETTARG; } RETURN; @@ -414,7 +414,11 @@ and C<PUSHu>. #define tryAMAGICbinW(meth,assign,set) \ tryAMAGICbinW_var(CAT2(meth,_amg),assign,set) -#define tryAMAGICbin(meth,assign) tryAMAGICbinW(meth,assign,SETsv) +#define tryAMAGICbin_var(meth_enum,assign) \ + tryAMAGICbinW_var(meth_enum,assign,SETsv) +#define tryAMAGICbin(meth,assign) \ + tryAMAGICbin_var(CAT2(meth,_amg),assign) + #define tryAMAGICbinSET(meth,assign) tryAMAGICbinW(meth,assign,SETs) #define tryAMAGICbinSET_var(meth_enum,assign) \ |