| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
| 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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 Register dividend = ToRegister(instr->dividend()); | 1104 Register dividend = ToRegister(instr->dividend()); |
| 1105 int32_t divisor = instr->divisor(); | 1105 int32_t divisor = instr->divisor(); |
| 1106 Register result = ToRegister(instr->result()); | 1106 Register result = ToRegister(instr->result()); |
| 1107 ASSERT(!dividend.is(result)); | 1107 ASSERT(!dividend.is(result)); |
| 1108 | 1108 |
| 1109 if (divisor == 0) { | 1109 if (divisor == 0) { |
| 1110 DeoptimizeIf(al, instr->environment()); | 1110 DeoptimizeIf(al, instr->environment()); |
| 1111 return; | 1111 return; |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 __ FlooringDiv(result, dividend, Abs(divisor)); | 1114 __ TruncatingDiv(result, dividend, Abs(divisor)); |
| 1115 __ srl(at, dividend, 31); | |
| 1116 __ Addu(result, result, at); | |
| 1117 __ Mul(result, result, Operand(Abs(divisor))); | 1115 __ Mul(result, result, Operand(Abs(divisor))); |
| 1118 __ Subu(result, dividend, Operand(result)); | 1116 __ Subu(result, dividend, Operand(result)); |
| 1119 | 1117 |
| 1120 // Check for negative zero. | 1118 // Check for negative zero. |
| 1121 HMod* hmod = instr->hydrogen(); | 1119 HMod* hmod = instr->hydrogen(); |
| 1122 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1120 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1123 Label remainder_not_zero; | 1121 Label remainder_not_zero; |
| 1124 __ Branch(&remainder_not_zero, ne, result, Operand(zero_reg)); | 1122 __ Branch(&remainder_not_zero, ne, result, Operand(zero_reg)); |
| 1125 DeoptimizeIf(lt, instr->environment(), dividend, Operand(zero_reg)); | 1123 DeoptimizeIf(lt, instr->environment(), dividend, Operand(zero_reg)); |
| 1126 __ bind(&remainder_not_zero); | 1124 __ bind(&remainder_not_zero); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 DeoptimizeIf(al, instr->environment()); | 1221 DeoptimizeIf(al, instr->environment()); |
| 1224 return; | 1222 return; |
| 1225 } | 1223 } |
| 1226 | 1224 |
| 1227 // Check for (0 / -x) that will produce negative zero. | 1225 // Check for (0 / -x) that will produce negative zero. |
| 1228 HDiv* hdiv = instr->hydrogen(); | 1226 HDiv* hdiv = instr->hydrogen(); |
| 1229 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1227 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
| 1230 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); | 1228 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); |
| 1231 } | 1229 } |
| 1232 | 1230 |
| 1233 __ FlooringDiv(result, dividend, Abs(divisor)); | 1231 __ TruncatingDiv(result, dividend, Abs(divisor)); |
| 1234 __ srl(at, dividend, 31); | |
| 1235 __ Addu(result, result, Operand(at)); | |
| 1236 if (divisor < 0) __ Subu(result, zero_reg, result); | 1232 if (divisor < 0) __ Subu(result, zero_reg, result); |
| 1237 | 1233 |
| 1238 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { | 1234 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { |
| 1239 __ Mul(scratch0(), result, Operand(divisor)); | 1235 __ Mul(scratch0(), result, Operand(divisor)); |
| 1240 __ Subu(scratch0(), scratch0(), dividend); | 1236 __ Subu(scratch0(), scratch0(), dividend); |
| 1241 DeoptimizeIf(ne, instr->environment(), scratch0(), Operand(zero_reg)); | 1237 DeoptimizeIf(ne, instr->environment(), scratch0(), Operand(zero_reg)); |
| 1242 } | 1238 } |
| 1243 } | 1239 } |
| 1244 | 1240 |
| 1245 | 1241 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 DeoptimizeIf(al, instr->environment()); | 1360 DeoptimizeIf(al, instr->environment()); |
| 1365 return; | 1361 return; |
| 1366 } | 1362 } |
| 1367 | 1363 |
| 1368 // Check for (0 / -x) that will produce negative zero. | 1364 // Check for (0 / -x) that will produce negative zero. |
| 1369 HMathFloorOfDiv* hdiv = instr->hydrogen(); | 1365 HMathFloorOfDiv* hdiv = instr->hydrogen(); |
| 1370 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1366 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
| 1371 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); | 1367 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); |
| 1372 } | 1368 } |
| 1373 | 1369 |
| 1374 __ FlooringDiv(result, dividend, divisor); | 1370 // TODO(svenpanne) Add correction terms. |
| 1371 __ TruncatingDiv(result, dividend, divisor); |
| 1375 } | 1372 } |
| 1376 | 1373 |
| 1377 | 1374 |
| 1378 void LCodeGen::DoMulI(LMulI* instr) { | 1375 void LCodeGen::DoMulI(LMulI* instr) { |
| 1379 Register scratch = scratch0(); | 1376 Register scratch = scratch0(); |
| 1380 Register result = ToRegister(instr->result()); | 1377 Register result = ToRegister(instr->result()); |
| 1381 // Note that result may alias left. | 1378 // Note that result may alias left. |
| 1382 Register left = ToRegister(instr->left()); | 1379 Register left = ToRegister(instr->left()); |
| 1383 LOperand* right_op = instr->right(); | 1380 LOperand* right_op = instr->right(); |
| 1384 | 1381 |
| (...skipping 4408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5793 __ Subu(scratch, result, scratch); | 5790 __ Subu(scratch, result, scratch); |
| 5794 __ lw(result, FieldMemOperand(scratch, | 5791 __ lw(result, FieldMemOperand(scratch, |
| 5795 FixedArray::kHeaderSize - kPointerSize)); | 5792 FixedArray::kHeaderSize - kPointerSize)); |
| 5796 __ bind(&done); | 5793 __ bind(&done); |
| 5797 } | 5794 } |
| 5798 | 5795 |
| 5799 | 5796 |
| 5800 #undef __ | 5797 #undef __ |
| 5801 | 5798 |
| 5802 } } // namespace v8::internal | 5799 } } // namespace v8::internal |
| OLD | NEW |