summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-02-07 18:01:26 +0000
committerNicholas Clark <nick@ccl4.org>2006-02-07 18:01:26 +0000
commit3658c1f1e67f531ad4ee20e8c748aec14b993c44 (patch)
tree32b3f67e0e63185b74168c07ec6bac15029030db
parentd4ac975eac140a6fda54f99664f15120fd97e7be (diff)
downloadperl-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.c5
-rw-r--r--opcode.h2
-rwxr-xr-xopcode.pl1
-rw-r--r--pp.c44
-rw-r--r--pp.h6
5 files changed, 25 insertions, 33 deletions
diff --git a/mathoms.c b/mathoms.c
index a96c75268d..6cc018b30a 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 849b7d2318..6dd31c3810 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 61ab824d24..3316fd9a9f 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 8d6421c7cd..d861bf39af 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 c4a700e221..5c2fbc8080 100644
--- a/pp.h
+++ b/pp.h
@@ -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) \