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