OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3861 // If the divisor is positive, things are easy: There can be no deopts and we | 3861 // If the divisor is positive, things are easy: There can be no deopts and we |
3862 // can simply do an arithmetic right shift. | 3862 // can simply do an arithmetic right shift. |
3863 if (divisor == 1) return; | 3863 if (divisor == 1) return; |
3864 int32_t shift = WhichPowerOf2Abs(divisor); | 3864 int32_t shift = WhichPowerOf2Abs(divisor); |
3865 if (divisor > 1) { | 3865 if (divisor > 1) { |
3866 __ Mov(result, Operand(dividend, ASR, shift)); | 3866 __ Mov(result, Operand(dividend, ASR, shift)); |
3867 return; | 3867 return; |
3868 } | 3868 } |
3869 | 3869 |
3870 // If the divisor is negative, we have to negate and handle edge cases. | 3870 // If the divisor is negative, we have to negate and handle edge cases. |
3871 Label not_kmin_int, done; | |
3872 __ Negs(result, dividend); | 3871 __ Negs(result, dividend); |
3873 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3872 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3874 DeoptimizeIf(eq, instr->environment()); | 3873 DeoptimizeIf(eq, instr->environment()); |
3875 } | 3874 } |
3876 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { | 3875 |
3877 // Note that we could emit branch-free code, but that would need one more | 3876 // If the negation could not overflow, simply shifting is OK. |
3878 // register. | 3877 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
3879 if (divisor == -1) { | 3878 __ Mov(result, Operand(dividend, ASR, shift)); |
3880 DeoptimizeIf(vs, instr->environment()); | 3879 return; |
3881 } else { | |
3882 __ B(vc, ¬_kmin_int); | |
3883 __ Mov(result, kMinInt / divisor); | |
3884 __ B(&done); | |
3885 } | |
3886 } | 3880 } |
| 3881 |
| 3882 // Dividing by -1 is basically negation, unless we overflow. |
| 3883 if (divisor == -1) { |
| 3884 DeoptimizeIf(vs, instr->environment()); |
| 3885 return; |
| 3886 } |
| 3887 |
| 3888 // Using a conditional data processing instruction would need 1 more register. |
| 3889 Label not_kmin_int, done; |
| 3890 __ B(vc, ¬_kmin_int); |
| 3891 __ Mov(result, kMinInt / divisor); |
| 3892 __ B(&done); |
3887 __ bind(¬_kmin_int); | 3893 __ bind(¬_kmin_int); |
3888 __ Mov(result, Operand(dividend, ASR, shift)); | 3894 __ Mov(result, Operand(dividend, ASR, shift)); |
3889 __ bind(&done); | 3895 __ bind(&done); |
3890 } | 3896 } |
3891 | 3897 |
3892 | 3898 |
3893 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { | 3899 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { |
3894 Register dividend = ToRegister32(instr->dividend()); | 3900 Register dividend = ToRegister32(instr->dividend()); |
3895 int32_t divisor = instr->divisor(); | 3901 int32_t divisor = instr->divisor(); |
3896 Register result = ToRegister32(instr->result()); | 3902 Register result = ToRegister32(instr->result()); |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5892 __ Bind(&out_of_object); | 5898 __ Bind(&out_of_object); |
5893 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5899 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
5894 // Index is equal to negated out of object property index plus 1. | 5900 // Index is equal to negated out of object property index plus 1. |
5895 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5901 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
5896 __ Ldr(result, FieldMemOperand(result, | 5902 __ Ldr(result, FieldMemOperand(result, |
5897 FixedArray::kHeaderSize - kPointerSize)); | 5903 FixedArray::kHeaderSize - kPointerSize)); |
5898 __ Bind(&done); | 5904 __ Bind(&done); |
5899 } | 5905 } |
5900 | 5906 |
5901 } } // namespace v8::internal | 5907 } } // namespace v8::internal |
OLD | NEW |