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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 void LCodeGen::DeoptimizeIf(Condition cond, LEnvironment* environment) { | 1050 void LCodeGen::DeoptimizeIf(Condition cond, LEnvironment* environment) { |
1051 DeoptimizeBranch(environment, static_cast<BranchType>(cond)); | 1051 DeoptimizeBranch(environment, static_cast<BranchType>(cond)); |
1052 } | 1052 } |
1053 | 1053 |
1054 | 1054 |
1055 void LCodeGen::DeoptimizeIfZero(Register rt, LEnvironment* environment) { | 1055 void LCodeGen::DeoptimizeIfZero(Register rt, LEnvironment* environment) { |
1056 DeoptimizeBranch(environment, reg_zero, rt); | 1056 DeoptimizeBranch(environment, reg_zero, rt); |
1057 } | 1057 } |
1058 | 1058 |
1059 | 1059 |
| 1060 void LCodeGen::DeoptimizeIfNotZero(Register rt, LEnvironment* environment) { |
| 1061 DeoptimizeBranch(environment, reg_not_zero, rt); |
| 1062 } |
| 1063 |
| 1064 |
1060 void LCodeGen::DeoptimizeIfNegative(Register rt, LEnvironment* environment) { | 1065 void LCodeGen::DeoptimizeIfNegative(Register rt, LEnvironment* environment) { |
1061 int sign_bit = rt.Is64Bits() ? kXSignBit : kWSignBit; | 1066 int sign_bit = rt.Is64Bits() ? kXSignBit : kWSignBit; |
1062 DeoptimizeBranch(environment, reg_bit_set, rt, sign_bit); | 1067 DeoptimizeBranch(environment, reg_bit_set, rt, sign_bit); |
1063 } | 1068 } |
1064 | 1069 |
1065 | 1070 |
1066 void LCodeGen::DeoptimizeIfSmi(Register rt, | 1071 void LCodeGen::DeoptimizeIfSmi(Register rt, |
1067 LEnvironment* environment) { | 1072 LEnvironment* environment) { |
1068 DeoptimizeBranch(environment, reg_bit_clear, rt, MaskToBit(kSmiTagMask)); | 1073 DeoptimizeBranch(environment, reg_bit_clear, rt, MaskToBit(kSmiTagMask)); |
1069 } | 1074 } |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 __ Add(result, dividend, Operand(dividend, LSR, 31)); | 2608 __ Add(result, dividend, Operand(dividend, LSR, 31)); |
2604 } else { | 2609 } else { |
2605 __ Mov(result, Operand(dividend, ASR, 31)); | 2610 __ Mov(result, Operand(dividend, ASR, 31)); |
2606 __ Add(result, dividend, Operand(result, LSR, 32 - shift)); | 2611 __ Add(result, dividend, Operand(result, LSR, 32 - shift)); |
2607 } | 2612 } |
2608 if (shift > 0) __ Mov(result, Operand(result, ASR, shift)); | 2613 if (shift > 0) __ Mov(result, Operand(result, ASR, shift)); |
2609 if (divisor < 0) __ Neg(result, result); | 2614 if (divisor < 0) __ Neg(result, result); |
2610 } | 2615 } |
2611 | 2616 |
2612 | 2617 |
| 2618 void LCodeGen::DoDivByConstI(LDivByConstI* instr) { |
| 2619 Register dividend = ToRegister32(instr->dividend()); |
| 2620 int32_t divisor = instr->divisor(); |
| 2621 Register result = ToRegister32(instr->result()); |
| 2622 ASSERT(!AreAliased(dividend, result)); |
| 2623 |
| 2624 if (divisor == 0) { |
| 2625 Deoptimize(instr->environment()); |
| 2626 return; |
| 2627 } |
| 2628 |
| 2629 // Check for (0 / -x) that will produce negative zero. |
| 2630 HDiv* hdiv = instr->hydrogen(); |
| 2631 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && |
| 2632 hdiv->left()->RangeCanInclude(0) && divisor < 0) { |
| 2633 __ Cmp(dividend, 0); |
| 2634 DeoptimizeIf(eq, instr->environment()); |
| 2635 } |
| 2636 |
| 2637 __ FlooringDiv(result, dividend, Abs(divisor)); |
| 2638 if (divisor < 0) __ Neg(result, result); |
| 2639 |
| 2640 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { |
| 2641 Register temp = ToRegister32(instr->temp()); |
| 2642 ASSERT(!AreAliased(dividend, result, temp)); |
| 2643 __ Sxtw(dividend.X(), dividend); |
| 2644 __ Mov(temp, divisor); |
| 2645 __ Smsubl(temp.X(), result, temp, dividend.X()); |
| 2646 DeoptimizeIfNotZero(temp, instr->environment()); |
| 2647 } |
| 2648 } |
| 2649 |
| 2650 |
2613 void LCodeGen::DoDivI(LDivI* instr) { | 2651 void LCodeGen::DoDivI(LDivI* instr) { |
2614 Register dividend = ToRegister32(instr->left()); | 2652 Register dividend = ToRegister32(instr->left()); |
2615 Register divisor = ToRegister32(instr->right()); | 2653 Register divisor = ToRegister32(instr->right()); |
2616 Register result = ToRegister32(instr->result()); | 2654 Register result = ToRegister32(instr->result()); |
2617 HValue* hdiv = instr->hydrogen_value(); | 2655 HValue* hdiv = instr->hydrogen_value(); |
2618 | 2656 |
2619 // Issue the division first, and then check for any deopt cases whilst the | 2657 // Issue the division first, and then check for any deopt cases whilst the |
2620 // result is computed. | 2658 // result is computed. |
2621 __ Sdiv(result, dividend, divisor); | 2659 __ Sdiv(result, dividend, divisor); |
2622 | 2660 |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3813 __ Mov(dividend, kMinInt / divisor); | 3851 __ Mov(dividend, kMinInt / divisor); |
3814 __ B(&done); | 3852 __ B(&done); |
3815 } | 3853 } |
3816 } | 3854 } |
3817 __ bind(¬_kmin_int); | 3855 __ bind(¬_kmin_int); |
3818 __ Mov(dividend, Operand(dividend, ASR, shift)); | 3856 __ Mov(dividend, Operand(dividend, ASR, shift)); |
3819 __ bind(&done); | 3857 __ bind(&done); |
3820 } | 3858 } |
3821 | 3859 |
3822 | 3860 |
| 3861 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { |
| 3862 Register dividend = ToRegister32(instr->dividend()); |
| 3863 int32_t divisor = instr->divisor(); |
| 3864 Register result = ToRegister32(instr->result()); |
| 3865 ASSERT(!AreAliased(dividend, result)); |
| 3866 |
| 3867 if (divisor == 0) { |
| 3868 Deoptimize(instr->environment()); |
| 3869 return; |
| 3870 } |
| 3871 |
| 3872 // Check for (0 / -x) that will produce negative zero. |
| 3873 HMathFloorOfDiv* hdiv = instr->hydrogen(); |
| 3874 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && |
| 3875 hdiv->left()->RangeCanInclude(0) && divisor < 0) { |
| 3876 __ Cmp(dividend, 0); |
| 3877 DeoptimizeIf(eq, instr->environment()); |
| 3878 } |
| 3879 |
| 3880 __ FlooringDiv(result, dividend, divisor); |
| 3881 } |
| 3882 |
| 3883 |
3823 void LCodeGen::DoFlooringDivI(LFlooringDivI* instr) { | 3884 void LCodeGen::DoFlooringDivI(LFlooringDivI* instr) { |
3824 Register dividend = ToRegister32(instr->dividend()); | 3885 Register dividend = ToRegister32(instr->dividend()); |
3825 Register divisor = ToRegister32(instr->divisor()); | 3886 Register divisor = ToRegister32(instr->divisor()); |
3826 Register remainder = ToRegister32(instr->temp()); | 3887 Register remainder = ToRegister32(instr->temp()); |
3827 Register result = ToRegister32(instr->result()); | 3888 Register result = ToRegister32(instr->result()); |
3828 | 3889 |
3829 // This can't cause an exception on ARM, so we can speculatively | 3890 // This can't cause an exception on ARM, so we can speculatively |
3830 // execute it already now. | 3891 // execute it already now. |
3831 __ Sdiv(result, dividend, divisor); | 3892 __ Sdiv(result, dividend, divisor); |
3832 | 3893 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4072 } | 4133 } |
4073 __ B(&done); | 4134 __ B(&done); |
4074 } | 4135 } |
4075 | 4136 |
4076 __ bind(÷nd_is_not_negative); | 4137 __ bind(÷nd_is_not_negative); |
4077 __ And(dividend, dividend, Operand(mask)); | 4138 __ And(dividend, dividend, Operand(mask)); |
4078 __ bind(&done); | 4139 __ bind(&done); |
4079 } | 4140 } |
4080 | 4141 |
4081 | 4142 |
| 4143 void LCodeGen::DoModByConstI(LModByConstI* instr) { |
| 4144 Register dividend = ToRegister32(instr->dividend()); |
| 4145 int32_t divisor = instr->divisor(); |
| 4146 Register result = ToRegister32(instr->result()); |
| 4147 Register temp = ToRegister32(instr->temp()); |
| 4148 ASSERT(!AreAliased(dividend, result, temp)); |
| 4149 |
| 4150 if (divisor == 0) { |
| 4151 Deoptimize(instr->environment()); |
| 4152 return; |
| 4153 } |
| 4154 |
| 4155 __ FlooringDiv(result, dividend, Abs(divisor)); |
| 4156 __ Sxtw(dividend.X(), dividend); |
| 4157 __ Mov(temp, Abs(divisor)); |
| 4158 __ Smsubl(result.X(), result, temp, dividend.X()); |
| 4159 |
| 4160 // Check for negative zero. |
| 4161 HMod* hmod = instr->hydrogen(); |
| 4162 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero) && |
| 4163 hmod->left()->CanBeNegative()) { |
| 4164 Label remainder_not_zero; |
| 4165 __ Cbnz(result, &remainder_not_zero); |
| 4166 DeoptimizeIfNegative(dividend, instr->environment()); |
| 4167 __ bind(&remainder_not_zero); |
| 4168 } |
| 4169 } |
| 4170 |
| 4171 |
4082 void LCodeGen::DoModI(LModI* instr) { | 4172 void LCodeGen::DoModI(LModI* instr) { |
4083 Register dividend = ToRegister32(instr->left()); | 4173 Register dividend = ToRegister32(instr->left()); |
4084 Register divisor = ToRegister32(instr->right()); | 4174 Register divisor = ToRegister32(instr->right()); |
4085 Register result = ToRegister32(instr->result()); | 4175 Register result = ToRegister32(instr->result()); |
4086 | 4176 |
4087 Label deopt, done; | 4177 Label deopt, done; |
4088 // modulo = dividend - quotient * divisor | 4178 // modulo = dividend - quotient * divisor |
4089 __ Sdiv(result, dividend, divisor); | 4179 __ Sdiv(result, dividend, divisor); |
4090 if (instr->hydrogen()->right()->CanBeZero()) { | 4180 if (instr->hydrogen()->right()->CanBeZero()) { |
4091 // Combine the deoptimization sites. | 4181 // Combine the deoptimization sites. |
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5712 __ Bind(&out_of_object); | 5802 __ Bind(&out_of_object); |
5713 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5803 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
5714 // Index is equal to negated out of object property index plus 1. | 5804 // Index is equal to negated out of object property index plus 1. |
5715 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5805 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
5716 __ Ldr(result, FieldMemOperand(result, | 5806 __ Ldr(result, FieldMemOperand(result, |
5717 FixedArray::kHeaderSize - kPointerSize)); | 5807 FixedArray::kHeaderSize - kPointerSize)); |
5718 __ Bind(&done); | 5808 __ Bind(&done); |
5719 } | 5809 } |
5720 | 5810 |
5721 } } // namespace v8::internal | 5811 } } // namespace v8::internal |
OLD | NEW |