| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 5825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5836 | 5836 |
| 5837 OS::SNPrintF(Vector<char>(name_, len), | 5837 OS::SNPrintF(Vector<char>(name_, len), |
| 5838 "GenericBinaryOpStub_%s_%s%s", | 5838 "GenericBinaryOpStub_%s_%s%s", |
| 5839 op_name, | 5839 op_name, |
| 5840 overwrite_name, | 5840 overwrite_name, |
| 5841 specialized_on_rhs_ ? "_ConstantRhs" : 0); | 5841 specialized_on_rhs_ ? "_ConstantRhs" : 0); |
| 5842 return name_; | 5842 return name_; |
| 5843 } | 5843 } |
| 5844 | 5844 |
| 5845 | 5845 |
| 5846 |
| 5846 void GenericBinaryOpStub::Generate(MacroAssembler* masm) { | 5847 void GenericBinaryOpStub::Generate(MacroAssembler* masm) { |
| 5847 // r1 : x | 5848 // r1 : x |
| 5848 // r0 : y | 5849 // r0 : y |
| 5849 // result : r0 | 5850 // result : r0 |
| 5850 | 5851 |
| 5851 // All ops need to know whether we are dealing with two Smis. Set up r2 to | 5852 // All ops need to know whether we are dealing with two Smis. Set up r2 to |
| 5852 // tell us that. | 5853 // tell us that. |
| 5853 __ orr(r2, r1, Operand(r0)); // r2 = x | y; | 5854 __ orr(r2, r1, Operand(r0)); // r2 = x | y; |
| 5854 | 5855 |
| 5855 switch (op_) { | 5856 switch (op_) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6028 Label slow; | 6029 Label slow; |
| 6029 ASSERT(kSmiTag == 0); // adjust code below | 6030 ASSERT(kSmiTag == 0); // adjust code below |
| 6030 __ tst(r2, Operand(kSmiTagMask)); | 6031 __ tst(r2, Operand(kSmiTagMask)); |
| 6031 __ b(ne, &slow); | 6032 __ b(ne, &slow); |
| 6032 switch (op_) { | 6033 switch (op_) { |
| 6033 case Token::BIT_OR: __ orr(r0, r0, Operand(r1)); break; | 6034 case Token::BIT_OR: __ orr(r0, r0, Operand(r1)); break; |
| 6034 case Token::BIT_AND: __ and_(r0, r0, Operand(r1)); break; | 6035 case Token::BIT_AND: __ and_(r0, r0, Operand(r1)); break; |
| 6035 case Token::BIT_XOR: __ eor(r0, r0, Operand(r1)); break; | 6036 case Token::BIT_XOR: __ eor(r0, r0, Operand(r1)); break; |
| 6036 case Token::SAR: | 6037 case Token::SAR: |
| 6037 // Remove tags from right operand. | 6038 // Remove tags from right operand. |
| 6038 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // y | 6039 __ GetLeastBitsFromSmi(r2, r0, 5); |
| 6039 // Use only the 5 least significant bits of the shift count. | |
| 6040 __ and_(r2, r2, Operand(0x1f)); | |
| 6041 __ mov(r0, Operand(r1, ASR, r2)); | 6040 __ mov(r0, Operand(r1, ASR, r2)); |
| 6042 // Smi tag result. | 6041 // Smi tag result. |
| 6043 __ bic(r0, r0, Operand(kSmiTagMask)); | 6042 __ bic(r0, r0, Operand(kSmiTagMask)); |
| 6044 break; | 6043 break; |
| 6045 case Token::SHR: | 6044 case Token::SHR: |
| 6046 // Remove tags from operands. We can't do this on a 31 bit number | 6045 // Remove tags from operands. We can't do this on a 31 bit number |
| 6047 // because then the 0s get shifted into bit 30 instead of bit 31. | 6046 // because then the 0s get shifted into bit 30 instead of bit 31. |
| 6048 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x | 6047 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x |
| 6049 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // y | 6048 __ GetLeastBitsFromSmi(r2, r0, 5); |
| 6050 // Use only the 5 least significant bits of the shift count. | |
| 6051 __ and_(r2, r2, Operand(0x1f)); | |
| 6052 __ mov(r3, Operand(r3, LSR, r2)); | 6049 __ mov(r3, Operand(r3, LSR, r2)); |
| 6053 // Unsigned shift is not allowed to produce a negative number, so | 6050 // Unsigned shift is not allowed to produce a negative number, so |
| 6054 // check the sign bit and the sign bit after Smi tagging. | 6051 // check the sign bit and the sign bit after Smi tagging. |
| 6055 __ tst(r3, Operand(0xc0000000)); | 6052 __ tst(r3, Operand(0xc0000000)); |
| 6056 __ b(ne, &slow); | 6053 __ b(ne, &slow); |
| 6057 // Smi tag result. | 6054 // Smi tag result. |
| 6058 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); | 6055 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); |
| 6059 break; | 6056 break; |
| 6060 case Token::SHL: | 6057 case Token::SHL: |
| 6061 // Remove tags from operands. | 6058 // Remove tags from operands. |
| 6062 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x | 6059 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x |
| 6063 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // y | 6060 __ GetLeastBitsFromSmi(r2, r0, 5); |
| 6064 // Use only the 5 least significant bits of the shift count. | |
| 6065 __ and_(r2, r2, Operand(0x1f)); | |
| 6066 __ mov(r3, Operand(r3, LSL, r2)); | 6061 __ mov(r3, Operand(r3, LSL, r2)); |
| 6067 // Check that the signed result fits in a Smi. | 6062 // Check that the signed result fits in a Smi. |
| 6068 __ add(r2, r3, Operand(0x40000000), SetCC); | 6063 __ add(r2, r3, Operand(0x40000000), SetCC); |
| 6069 __ b(mi, &slow); | 6064 __ b(mi, &slow); |
| 6070 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); | 6065 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); |
| 6071 break; | 6066 break; |
| 6072 default: UNREACHABLE(); | 6067 default: UNREACHABLE(); |
| 6073 } | 6068 } |
| 6074 __ Ret(); | 6069 __ Ret(); |
| 6075 __ bind(&slow); | 6070 __ bind(&slow); |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7253 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 7248 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 7254 // tagged as a small integer. | 7249 // tagged as a small integer. |
| 7255 __ bind(&runtime); | 7250 __ bind(&runtime); |
| 7256 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); | 7251 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); |
| 7257 } | 7252 } |
| 7258 | 7253 |
| 7259 | 7254 |
| 7260 #undef __ | 7255 #undef __ |
| 7261 | 7256 |
| 7262 } } // namespace v8::internal | 7257 } } // namespace v8::internal |
| OLD | NEW |