From: Nicholas Clark Date: Tue, 7 Feb 2006 18:01:26 +0000 (+0000) Subject: Merging pp_bit_or and pp_bit_xor shrinks the object code by about .7K. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3658c1f1e67f531ad4ee20e8c748aec14b993c44;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/mathoms.c b/mathoms.c index a96c752..6cc018b 100644 --- a/mathoms.c +++ b/mathoms.c @@ -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) { diff --git a/opcode.h b/opcode.h index 849b7d2..6dd31c3 100644 --- a/opcode.h +++ b/opcode.h @@ -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), diff --git a/opcode.pl b/opcode.pl index 61ab824..3316fd9 100755 --- a/opcode.pl +++ b/opcode.pl @@ -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) { diff --git a/pp.c b/pp.c index 8d6421c..d861bf3 100644 --- a/pp.c +++ b/pp.c @@ -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; diff --git a/pp.h b/pp.h index c4a700e..5c2fbc8 100644 --- a/pp.h +++ b/pp.h @@ -414,7 +414,11 @@ and C. #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) \