OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 5806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5817 | 5817 |
5818 OS::SNPrintF(Vector<char>(name_, len), | 5818 OS::SNPrintF(Vector<char>(name_, len), |
5819 "GenericBinaryOpStub_%s_%s%s", | 5819 "GenericBinaryOpStub_%s_%s%s", |
5820 op_name, | 5820 op_name, |
5821 overwrite_name, | 5821 overwrite_name, |
5822 specialized_on_rhs_ ? "_ConstantRhs" : 0); | 5822 specialized_on_rhs_ ? "_ConstantRhs" : 0); |
5823 return name_; | 5823 return name_; |
5824 } | 5824 } |
5825 | 5825 |
5826 | 5826 |
| 5827 |
5827 void GenericBinaryOpStub::Generate(MacroAssembler* masm) { | 5828 void GenericBinaryOpStub::Generate(MacroAssembler* masm) { |
5828 // r1 : x | 5829 // r1 : x |
5829 // r0 : y | 5830 // r0 : y |
5830 // result : r0 | 5831 // result : r0 |
5831 | 5832 |
5832 // All ops need to know whether we are dealing with two Smis. Set up r2 to | 5833 // All ops need to know whether we are dealing with two Smis. Set up r2 to |
5833 // tell us that. | 5834 // tell us that. |
5834 __ orr(r2, r1, Operand(r0)); // r2 = x | y; | 5835 __ orr(r2, r1, Operand(r0)); // r2 = x | y; |
5835 | 5836 |
5836 switch (op_) { | 5837 switch (op_) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6009 Label slow; | 6010 Label slow; |
6010 ASSERT(kSmiTag == 0); // adjust code below | 6011 ASSERT(kSmiTag == 0); // adjust code below |
6011 __ tst(r2, Operand(kSmiTagMask)); | 6012 __ tst(r2, Operand(kSmiTagMask)); |
6012 __ b(ne, &slow); | 6013 __ b(ne, &slow); |
6013 switch (op_) { | 6014 switch (op_) { |
6014 case Token::BIT_OR: __ orr(r0, r0, Operand(r1)); break; | 6015 case Token::BIT_OR: __ orr(r0, r0, Operand(r1)); break; |
6015 case Token::BIT_AND: __ and_(r0, r0, Operand(r1)); break; | 6016 case Token::BIT_AND: __ and_(r0, r0, Operand(r1)); break; |
6016 case Token::BIT_XOR: __ eor(r0, r0, Operand(r1)); break; | 6017 case Token::BIT_XOR: __ eor(r0, r0, Operand(r1)); break; |
6017 case Token::SAR: | 6018 case Token::SAR: |
6018 // Remove tags from right operand. | 6019 // Remove tags from right operand. |
6019 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // y | 6020 __ GetLeastBitsFromSmi(r2, r0, 5); |
6020 // Use only the 5 least significant bits of the shift count. | |
6021 __ and_(r2, r2, Operand(0x1f)); | |
6022 __ mov(r0, Operand(r1, ASR, r2)); | 6021 __ mov(r0, Operand(r1, ASR, r2)); |
6023 // Smi tag result. | 6022 // Smi tag result. |
6024 __ bic(r0, r0, Operand(kSmiTagMask)); | 6023 __ bic(r0, r0, Operand(kSmiTagMask)); |
6025 break; | 6024 break; |
6026 case Token::SHR: | 6025 case Token::SHR: |
6027 // Remove tags from operands. We can't do this on a 31 bit number | 6026 // Remove tags from operands. We can't do this on a 31 bit number |
6028 // because then the 0s get shifted into bit 30 instead of bit 31. | 6027 // because then the 0s get shifted into bit 30 instead of bit 31. |
6029 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x | 6028 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x |
6030 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // y | 6029 __ GetLeastBitsFromSmi(r2, r0, 5); |
6031 // Use only the 5 least significant bits of the shift count. | |
6032 __ and_(r2, r2, Operand(0x1f)); | |
6033 __ mov(r3, Operand(r3, LSR, r2)); | 6030 __ mov(r3, Operand(r3, LSR, r2)); |
6034 // Unsigned shift is not allowed to produce a negative number, so | 6031 // Unsigned shift is not allowed to produce a negative number, so |
6035 // check the sign bit and the sign bit after Smi tagging. | 6032 // check the sign bit and the sign bit after Smi tagging. |
6036 __ tst(r3, Operand(0xc0000000)); | 6033 __ tst(r3, Operand(0xc0000000)); |
6037 __ b(ne, &slow); | 6034 __ b(ne, &slow); |
6038 // Smi tag result. | 6035 // Smi tag result. |
6039 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); | 6036 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); |
6040 break; | 6037 break; |
6041 case Token::SHL: | 6038 case Token::SHL: |
6042 // Remove tags from operands. | 6039 // Remove tags from operands. |
6043 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x | 6040 __ mov(r3, Operand(r1, ASR, kSmiTagSize)); // x |
6044 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // y | 6041 __ GetLeastBitsFromSmi(r2, r0, 5); |
6045 // Use only the 5 least significant bits of the shift count. | |
6046 __ and_(r2, r2, Operand(0x1f)); | |
6047 __ mov(r3, Operand(r3, LSL, r2)); | 6042 __ mov(r3, Operand(r3, LSL, r2)); |
6048 // Check that the signed result fits in a Smi. | 6043 // Check that the signed result fits in a Smi. |
6049 __ add(r2, r3, Operand(0x40000000), SetCC); | 6044 __ add(r2, r3, Operand(0x40000000), SetCC); |
6050 __ b(mi, &slow); | 6045 __ b(mi, &slow); |
6051 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); | 6046 __ mov(r0, Operand(r3, LSL, kSmiTagSize)); |
6052 break; | 6047 break; |
6053 default: UNREACHABLE(); | 6048 default: UNREACHABLE(); |
6054 } | 6049 } |
6055 __ Ret(); | 6050 __ Ret(); |
6056 __ bind(&slow); | 6051 __ bind(&slow); |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6870 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 6865 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
6871 // tagged as a small integer. | 6866 // tagged as a small integer. |
6872 __ bind(&runtime); | 6867 __ bind(&runtime); |
6873 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); | 6868 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); |
6874 } | 6869 } |
6875 | 6870 |
6876 | 6871 |
6877 #undef __ | 6872 #undef __ |
6878 | 6873 |
6879 } } // namespace v8::internal | 6874 } } // namespace v8::internal |
OLD | NEW |