OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); | 1129 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); |
1130 } | 1130 } |
1131 __ Branch(USE_DELAY_SLOT, &done); | 1131 __ Branch(USE_DELAY_SLOT, &done); |
1132 __ subu(result_reg, zero_reg, result_reg); | 1132 __ subu(result_reg, zero_reg, result_reg); |
1133 } | 1133 } |
1134 | 1134 |
1135 __ bind(&left_is_not_negative); | 1135 __ bind(&left_is_not_negative); |
1136 __ And(result_reg, scratch, divisor - 1); | 1136 __ And(result_reg, scratch, divisor - 1); |
1137 __ bind(&done); | 1137 __ bind(&done); |
1138 | 1138 |
1139 } else { | 1139 } else if (hmod->fixed_right_arg().has_value) { |
1140 // TODO(svenpanne) Add right->has_fixed_right_arg() case. | |
1141 | |
1142 const Register scratch = scratch0(); | 1140 const Register scratch = scratch0(); |
1143 const Register left_reg = ToRegister(instr->left()); | 1141 const Register left_reg = ToRegister(instr->left()); |
1144 const Register result_reg = ToRegister(instr->result()); | 1142 const Register result_reg = ToRegister(instr->result()); |
| 1143 |
| 1144 Register right_reg = EmitLoadRegister(instr->right(), scratch); |
| 1145 |
| 1146 int32_t divisor = hmod->fixed_right_arg().value; |
| 1147 ASSERT(IsPowerOf2(divisor)); |
| 1148 |
| 1149 // Check if our assumption of a fixed right operand still holds. |
| 1150 DeoptimizeIf(ne, instr->environment(), right_reg, Operand(divisor)); |
| 1151 |
| 1152 Label left_is_not_negative, done; |
| 1153 if (left->CanBeNegative()) { |
| 1154 __ Branch(USE_DELAY_SLOT, &left_is_not_negative, |
| 1155 ge, left_reg, Operand(zero_reg)); |
| 1156 __ subu(result_reg, zero_reg, left_reg); |
| 1157 __ And(result_reg, result_reg, divisor - 1); |
| 1158 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1159 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); |
| 1160 } |
| 1161 __ Branch(USE_DELAY_SLOT, &done); |
| 1162 __ subu(result_reg, zero_reg, result_reg); |
| 1163 } |
| 1164 |
| 1165 __ bind(&left_is_not_negative); |
| 1166 __ And(result_reg, left_reg, divisor - 1); |
| 1167 __ bind(&done); |
| 1168 |
| 1169 } else { |
| 1170 const Register scratch = scratch0(); |
| 1171 const Register left_reg = ToRegister(instr->left()); |
| 1172 const Register result_reg = ToRegister(instr->result()); |
1145 | 1173 |
1146 // div runs in the background while we check for special cases. | 1174 // div runs in the background while we check for special cases. |
1147 Register right_reg = EmitLoadRegister(instr->right(), scratch); | 1175 Register right_reg = EmitLoadRegister(instr->right(), scratch); |
1148 __ div(left_reg, right_reg); | 1176 __ div(left_reg, right_reg); |
1149 | 1177 |
1150 Label done; | 1178 Label done; |
1151 // Check for x % 0, we have to deopt in this case because we can't return a | 1179 // Check for x % 0, we have to deopt in this case because we can't return a |
1152 // NaN. | 1180 // NaN. |
1153 if (right->CanBeZero()) { | 1181 if (right->CanBeZero()) { |
1154 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(zero_reg)); | 1182 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(zero_reg)); |
(...skipping 4735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5890 __ Subu(scratch, result, scratch); | 5918 __ Subu(scratch, result, scratch); |
5891 __ lw(result, FieldMemOperand(scratch, | 5919 __ lw(result, FieldMemOperand(scratch, |
5892 FixedArray::kHeaderSize - kPointerSize)); | 5920 FixedArray::kHeaderSize - kPointerSize)); |
5893 __ bind(&done); | 5921 __ bind(&done); |
5894 } | 5922 } |
5895 | 5923 |
5896 | 5924 |
5897 #undef __ | 5925 #undef __ |
5898 | 5926 |
5899 } } // namespace v8::internal | 5927 } } // namespace v8::internal |
OLD | NEW |