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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 } | 1157 } |
1158 | 1158 |
1159 | 1159 |
1160 void LCodeGen::DoModI(LModI* instr) { | 1160 void LCodeGen::DoModI(LModI* instr) { |
1161 HMod* hmod = instr->hydrogen(); | 1161 HMod* hmod = instr->hydrogen(); |
1162 const Register left_reg = ToRegister(instr->left()); | 1162 const Register left_reg = ToRegister(instr->left()); |
1163 const Register right_reg = ToRegister(instr->right()); | 1163 const Register right_reg = ToRegister(instr->right()); |
1164 const Register result_reg = ToRegister(instr->result()); | 1164 const Register result_reg = ToRegister(instr->result()); |
1165 | 1165 |
1166 // div runs in the background while we check for special cases. | 1166 // div runs in the background while we check for special cases. |
1167 __ div(left_reg, right_reg); | 1167 __ Mod(result_reg, left_reg, right_reg); |
1168 | 1168 |
1169 Label done; | 1169 Label done; |
1170 // Check for x % 0, we have to deopt in this case because we can't return a | 1170 // Check for x % 0, we have to deopt in this case because we can't return a |
1171 // NaN. | 1171 // NaN. |
1172 if (hmod->CheckFlag(HValue::kCanBeDivByZero)) { | 1172 if (hmod->CheckFlag(HValue::kCanBeDivByZero)) { |
1173 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(zero_reg)); | 1173 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(zero_reg)); |
1174 } | 1174 } |
1175 | 1175 |
1176 // Check for kMinInt % -1, div will return kMinInt, which is not what we | 1176 // Check for kMinInt % -1, div will return kMinInt, which is not what we |
1177 // want. We have to deopt if we care about -0, because we can't return that. | 1177 // want. We have to deopt if we care about -0, because we can't return that. |
1178 if (hmod->CheckFlag(HValue::kCanOverflow)) { | 1178 if (hmod->CheckFlag(HValue::kCanOverflow)) { |
1179 Label no_overflow_possible; | 1179 Label no_overflow_possible; |
1180 __ Branch(&no_overflow_possible, ne, left_reg, Operand(kMinInt)); | 1180 __ Branch(&no_overflow_possible, ne, left_reg, Operand(kMinInt)); |
1181 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1181 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1182 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(-1)); | 1182 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(-1)); |
1183 } else { | 1183 } else { |
1184 __ Branch(&no_overflow_possible, ne, right_reg, Operand(-1)); | 1184 __ Branch(&no_overflow_possible, ne, right_reg, Operand(-1)); |
1185 __ Branch(USE_DELAY_SLOT, &done); | 1185 __ Branch(USE_DELAY_SLOT, &done); |
1186 __ mov(result_reg, zero_reg); | 1186 __ mov(result_reg, zero_reg); |
1187 } | 1187 } |
1188 __ bind(&no_overflow_possible); | 1188 __ bind(&no_overflow_possible); |
1189 } | 1189 } |
1190 | 1190 |
1191 // If we care about -0, test if the dividend is <0 and the result is 0. | 1191 // If we care about -0, test if the dividend is <0 and the result is 0. |
1192 __ Branch(USE_DELAY_SLOT, &done, ge, left_reg, Operand(zero_reg)); | 1192 __ Branch(&done, ge, left_reg, Operand(zero_reg)); |
1193 __ mfhi(result_reg); | |
1194 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1193 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1195 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); | 1194 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); |
1196 } | 1195 } |
1197 __ bind(&done); | 1196 __ bind(&done); |
1198 } | 1197 } |
1199 | 1198 |
1200 | 1199 |
1201 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { | 1200 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { |
1202 Register dividend = ToRegister(instr->dividend()); | 1201 Register dividend = ToRegister(instr->dividend()); |
1203 int32_t divisor = instr->divisor(); | 1202 int32_t divisor = instr->divisor(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 } | 1268 } |
1270 } | 1269 } |
1271 | 1270 |
1272 | 1271 |
1273 // TODO(svenpanne) Refactor this to avoid code duplication with DoFlooringDivI. | 1272 // TODO(svenpanne) Refactor this to avoid code duplication with DoFlooringDivI. |
1274 void LCodeGen::DoDivI(LDivI* instr) { | 1273 void LCodeGen::DoDivI(LDivI* instr) { |
1275 HBinaryOperation* hdiv = instr->hydrogen(); | 1274 HBinaryOperation* hdiv = instr->hydrogen(); |
1276 Register dividend = ToRegister(instr->dividend()); | 1275 Register dividend = ToRegister(instr->dividend()); |
1277 Register divisor = ToRegister(instr->divisor()); | 1276 Register divisor = ToRegister(instr->divisor()); |
1278 const Register result = ToRegister(instr->result()); | 1277 const Register result = ToRegister(instr->result()); |
| 1278 Register remainder = ToRegister(instr->temp()); |
1279 | 1279 |
1280 // On MIPS div is asynchronous - it will run in the background while we | 1280 // On MIPS div is asynchronous - it will run in the background while we |
1281 // check for special cases. | 1281 // check for special cases. |
1282 __ div(dividend, divisor); | 1282 __ Div(remainder, result, dividend, divisor); |
1283 | 1283 |
1284 // Check for x / 0. | 1284 // Check for x / 0. |
1285 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { | 1285 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { |
1286 DeoptimizeIf(eq, instr->environment(), divisor, Operand(zero_reg)); | 1286 DeoptimizeIf(eq, instr->environment(), divisor, Operand(zero_reg)); |
1287 } | 1287 } |
1288 | 1288 |
1289 // Check for (0 / -x) that will produce negative zero. | 1289 // Check for (0 / -x) that will produce negative zero. |
1290 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1290 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1291 Label left_not_zero; | 1291 Label left_not_zero; |
1292 __ Branch(&left_not_zero, ne, dividend, Operand(zero_reg)); | 1292 __ Branch(&left_not_zero, ne, dividend, Operand(zero_reg)); |
1293 DeoptimizeIf(lt, instr->environment(), divisor, Operand(zero_reg)); | 1293 DeoptimizeIf(lt, instr->environment(), divisor, Operand(zero_reg)); |
1294 __ bind(&left_not_zero); | 1294 __ bind(&left_not_zero); |
1295 } | 1295 } |
1296 | 1296 |
1297 // Check for (kMinInt / -1). | 1297 // Check for (kMinInt / -1). |
1298 if (hdiv->CheckFlag(HValue::kCanOverflow) && | 1298 if (hdiv->CheckFlag(HValue::kCanOverflow) && |
1299 !hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { | 1299 !hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { |
1300 Label left_not_min_int; | 1300 Label left_not_min_int; |
1301 __ Branch(&left_not_min_int, ne, dividend, Operand(kMinInt)); | 1301 __ Branch(&left_not_min_int, ne, dividend, Operand(kMinInt)); |
1302 DeoptimizeIf(eq, instr->environment(), divisor, Operand(-1)); | 1302 DeoptimizeIf(eq, instr->environment(), divisor, Operand(-1)); |
1303 __ bind(&left_not_min_int); | 1303 __ bind(&left_not_min_int); |
1304 } | 1304 } |
1305 | 1305 |
1306 if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { | 1306 if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { |
1307 __ mfhi(result); | 1307 DeoptimizeIf(ne, instr->environment(), remainder, Operand(zero_reg)); |
1308 DeoptimizeIf(ne, instr->environment(), result, Operand(zero_reg)); | |
1309 __ mflo(result); | |
1310 } else { | |
1311 __ mflo(result); | |
1312 } | 1308 } |
1313 } | 1309 } |
1314 | 1310 |
1315 | 1311 |
1316 void LCodeGen::DoMultiplyAddD(LMultiplyAddD* instr) { | 1312 void LCodeGen::DoMultiplyAddD(LMultiplyAddD* instr) { |
1317 DoubleRegister addend = ToDoubleRegister(instr->addend()); | 1313 DoubleRegister addend = ToDoubleRegister(instr->addend()); |
1318 DoubleRegister multiplier = ToDoubleRegister(instr->multiplier()); | 1314 DoubleRegister multiplier = ToDoubleRegister(instr->multiplier()); |
1319 DoubleRegister multiplicand = ToDoubleRegister(instr->multiplicand()); | 1315 DoubleRegister multiplicand = ToDoubleRegister(instr->multiplicand()); |
1320 | 1316 |
1321 // This is computed in-place. | 1317 // This is computed in-place. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 __ bind(&done); | 1422 __ bind(&done); |
1427 } | 1423 } |
1428 | 1424 |
1429 | 1425 |
1430 // TODO(svenpanne) Refactor this to avoid code duplication with DoDivI. | 1426 // TODO(svenpanne) Refactor this to avoid code duplication with DoDivI. |
1431 void LCodeGen::DoFlooringDivI(LFlooringDivI* instr) { | 1427 void LCodeGen::DoFlooringDivI(LFlooringDivI* instr) { |
1432 HBinaryOperation* hdiv = instr->hydrogen(); | 1428 HBinaryOperation* hdiv = instr->hydrogen(); |
1433 Register dividend = ToRegister(instr->dividend()); | 1429 Register dividend = ToRegister(instr->dividend()); |
1434 Register divisor = ToRegister(instr->divisor()); | 1430 Register divisor = ToRegister(instr->divisor()); |
1435 const Register result = ToRegister(instr->result()); | 1431 const Register result = ToRegister(instr->result()); |
1436 | 1432 Register remainder = scratch0(); |
1437 // On MIPS div is asynchronous - it will run in the background while we | 1433 // On MIPS div is asynchronous - it will run in the background while we |
1438 // check for special cases. | 1434 // check for special cases. |
1439 __ div(dividend, divisor); | 1435 __ Div(remainder, result, dividend, divisor); |
1440 | 1436 |
1441 // Check for x / 0. | 1437 // Check for x / 0. |
1442 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { | 1438 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { |
1443 DeoptimizeIf(eq, instr->environment(), divisor, Operand(zero_reg)); | 1439 DeoptimizeIf(eq, instr->environment(), divisor, Operand(zero_reg)); |
1444 } | 1440 } |
1445 | 1441 |
1446 // Check for (0 / -x) that will produce negative zero. | 1442 // Check for (0 / -x) that will produce negative zero. |
1447 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1443 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1448 Label left_not_zero; | 1444 Label left_not_zero; |
1449 __ Branch(&left_not_zero, ne, dividend, Operand(zero_reg)); | 1445 __ Branch(&left_not_zero, ne, dividend, Operand(zero_reg)); |
1450 DeoptimizeIf(lt, instr->environment(), divisor, Operand(zero_reg)); | 1446 DeoptimizeIf(lt, instr->environment(), divisor, Operand(zero_reg)); |
1451 __ bind(&left_not_zero); | 1447 __ bind(&left_not_zero); |
1452 } | 1448 } |
1453 | 1449 |
1454 // Check for (kMinInt / -1). | 1450 // Check for (kMinInt / -1). |
1455 if (hdiv->CheckFlag(HValue::kCanOverflow) && | 1451 if (hdiv->CheckFlag(HValue::kCanOverflow) && |
1456 !hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { | 1452 !hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { |
1457 Label left_not_min_int; | 1453 Label left_not_min_int; |
1458 __ Branch(&left_not_min_int, ne, dividend, Operand(kMinInt)); | 1454 __ Branch(&left_not_min_int, ne, dividend, Operand(kMinInt)); |
1459 DeoptimizeIf(eq, instr->environment(), divisor, Operand(-1)); | 1455 DeoptimizeIf(eq, instr->environment(), divisor, Operand(-1)); |
1460 __ bind(&left_not_min_int); | 1456 __ bind(&left_not_min_int); |
1461 } | 1457 } |
1462 | 1458 |
1463 // We performed a truncating division. Correct the result if necessary. | 1459 // We performed a truncating division. Correct the result if necessary. |
1464 Label done; | 1460 Label done; |
1465 Register remainder = scratch0(); | |
1466 __ mfhi(remainder); | |
1467 __ mflo(result); | |
1468 __ Branch(&done, eq, remainder, Operand(zero_reg), USE_DELAY_SLOT); | 1461 __ Branch(&done, eq, remainder, Operand(zero_reg), USE_DELAY_SLOT); |
1469 __ Xor(remainder, remainder, Operand(divisor)); | 1462 __ Xor(remainder, remainder, Operand(divisor)); |
1470 __ Branch(&done, ge, remainder, Operand(zero_reg)); | 1463 __ Branch(&done, ge, remainder, Operand(zero_reg)); |
1471 __ Subu(result, result, Operand(1)); | 1464 __ Subu(result, result, Operand(1)); |
1472 __ bind(&done); | 1465 __ bind(&done); |
1473 } | 1466 } |
1474 | 1467 |
1475 | 1468 |
1476 void LCodeGen::DoMulI(LMulI* instr) { | 1469 void LCodeGen::DoMulI(LMulI* instr) { |
1477 Register scratch = scratch0(); | 1470 Register scratch = scratch0(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 } | 1539 } |
1547 | 1540 |
1548 } else { | 1541 } else { |
1549 DCHECK(right_op->IsRegister()); | 1542 DCHECK(right_op->IsRegister()); |
1550 Register right = ToRegister(right_op); | 1543 Register right = ToRegister(right_op); |
1551 | 1544 |
1552 if (overflow) { | 1545 if (overflow) { |
1553 // hi:lo = left * right. | 1546 // hi:lo = left * right. |
1554 if (instr->hydrogen()->representation().IsSmi()) { | 1547 if (instr->hydrogen()->representation().IsSmi()) { |
1555 __ SmiUntag(result, left); | 1548 __ SmiUntag(result, left); |
1556 __ mult(result, right); | 1549 __ Mul(scratch, result, result, right); |
1557 __ mfhi(scratch); | |
1558 __ mflo(result); | |
1559 } else { | 1550 } else { |
1560 __ mult(left, right); | 1551 __ Mul(scratch, result, left, right); |
1561 __ mfhi(scratch); | |
1562 __ mflo(result); | |
1563 } | 1552 } |
1564 __ sra(at, result, 31); | 1553 __ sra(at, result, 31); |
1565 DeoptimizeIf(ne, instr->environment(), scratch, Operand(at)); | 1554 DeoptimizeIf(ne, instr->environment(), scratch, Operand(at)); |
1566 } else { | 1555 } else { |
1567 if (instr->hydrogen()->representation().IsSmi()) { | 1556 if (instr->hydrogen()->representation().IsSmi()) { |
1568 __ SmiUntag(result, left); | 1557 __ SmiUntag(result, left); |
1569 __ Mul(result, result, right); | 1558 __ Mul(result, result, right); |
1570 } else { | 1559 } else { |
1571 __ Mul(result, left, right); | 1560 __ Mul(result, left, right); |
1572 } | 1561 } |
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 double_scratch0(), | 3722 double_scratch0(), |
3734 except_flag); | 3723 except_flag); |
3735 | 3724 |
3736 // Deopt if the operation did not succeed. | 3725 // Deopt if the operation did not succeed. |
3737 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); | 3726 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); |
3738 | 3727 |
3739 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3728 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3740 // Test for -0. | 3729 // Test for -0. |
3741 Label done; | 3730 Label done; |
3742 __ Branch(&done, ne, result, Operand(zero_reg)); | 3731 __ Branch(&done, ne, result, Operand(zero_reg)); |
3743 __ mfc1(scratch1, input.high()); | 3732 __ Mfhc1(scratch1, input); |
3744 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); | 3733 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); |
3745 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); | 3734 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); |
3746 __ bind(&done); | 3735 __ bind(&done); |
3747 } | 3736 } |
3748 } | 3737 } |
3749 | 3738 |
3750 | 3739 |
3751 void LCodeGen::DoMathRound(LMathRound* instr) { | 3740 void LCodeGen::DoMathRound(LMathRound* instr) { |
3752 DoubleRegister input = ToDoubleRegister(instr->value()); | 3741 DoubleRegister input = ToDoubleRegister(instr->value()); |
3753 Register result = ToRegister(instr->result()); | 3742 Register result = ToRegister(instr->result()); |
3754 DoubleRegister double_scratch1 = ToDoubleRegister(instr->temp()); | 3743 DoubleRegister double_scratch1 = ToDoubleRegister(instr->temp()); |
3755 Register scratch = scratch0(); | 3744 Register scratch = scratch0(); |
3756 Label done, check_sign_on_zero; | 3745 Label done, check_sign_on_zero; |
3757 | 3746 |
3758 // Extract exponent bits. | 3747 // Extract exponent bits. |
3759 __ mfc1(result, input.high()); | 3748 __ Mfhc1(result, input); |
3760 __ Ext(scratch, | 3749 __ Ext(scratch, |
3761 result, | 3750 result, |
3762 HeapNumber::kExponentShift, | 3751 HeapNumber::kExponentShift, |
3763 HeapNumber::kExponentBits); | 3752 HeapNumber::kExponentBits); |
3764 | 3753 |
3765 // If the number is in ]-0.5, +0.5[, the result is +/- 0. | 3754 // If the number is in ]-0.5, +0.5[, the result is +/- 0. |
3766 Label skip1; | 3755 Label skip1; |
3767 __ Branch(&skip1, gt, scratch, Operand(HeapNumber::kExponentBias - 2)); | 3756 __ Branch(&skip1, gt, scratch, Operand(HeapNumber::kExponentBias - 2)); |
3768 __ mov(result, zero_reg); | 3757 __ mov(result, zero_reg); |
3769 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3758 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3770 __ Branch(&check_sign_on_zero); | 3759 __ Branch(&check_sign_on_zero); |
3771 } else { | 3760 } else { |
3772 __ Branch(&done); | 3761 __ Branch(&done); |
3773 } | 3762 } |
3774 __ bind(&skip1); | 3763 __ bind(&skip1); |
3775 | 3764 |
3776 // The following conversion will not work with numbers | 3765 // The following conversion will not work with numbers |
3777 // outside of ]-2^32, 2^32[. | 3766 // outside of ]-2^32, 2^32[. |
3778 DeoptimizeIf(ge, instr->environment(), scratch, | 3767 DeoptimizeIf(ge, instr->environment(), scratch, |
3779 Operand(HeapNumber::kExponentBias + 32)); | 3768 Operand(HeapNumber::kExponentBias + 32)); |
3780 | 3769 |
3781 // Save the original sign for later comparison. | 3770 // Save the original sign for later comparison. |
3782 __ And(scratch, result, Operand(HeapNumber::kSignMask)); | 3771 __ And(scratch, result, Operand(HeapNumber::kSignMask)); |
3783 | 3772 |
3784 __ Move(double_scratch0(), 0.5); | 3773 __ Move(double_scratch0(), 0.5); |
3785 __ add_d(double_scratch0(), input, double_scratch0()); | 3774 __ add_d(double_scratch0(), input, double_scratch0()); |
3786 | 3775 |
3787 // Check sign of the result: if the sign changed, the input | 3776 // Check sign of the result: if the sign changed, the input |
3788 // value was in ]0.5, 0[ and the result should be -0. | 3777 // value was in ]0.5, 0[ and the result should be -0. |
3789 __ mfc1(result, double_scratch0().high()); | 3778 __ Mfhc1(result, double_scratch0()); |
3790 __ Xor(result, result, Operand(scratch)); | 3779 __ Xor(result, result, Operand(scratch)); |
3791 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3780 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3792 // ARM uses 'mi' here, which is 'lt' | 3781 // ARM uses 'mi' here, which is 'lt' |
3793 DeoptimizeIf(lt, instr->environment(), result, | 3782 DeoptimizeIf(lt, instr->environment(), result, |
3794 Operand(zero_reg)); | 3783 Operand(zero_reg)); |
3795 } else { | 3784 } else { |
3796 Label skip2; | 3785 Label skip2; |
3797 // ARM uses 'mi' here, which is 'lt' | 3786 // ARM uses 'mi' here, which is 'lt' |
3798 // Negating it results in 'ge' | 3787 // Negating it results in 'ge' |
3799 __ Branch(&skip2, ge, result, Operand(zero_reg)); | 3788 __ Branch(&skip2, ge, result, Operand(zero_reg)); |
3800 __ mov(result, zero_reg); | 3789 __ mov(result, zero_reg); |
3801 __ Branch(&done); | 3790 __ Branch(&done); |
3802 __ bind(&skip2); | 3791 __ bind(&skip2); |
3803 } | 3792 } |
3804 | 3793 |
3805 Register except_flag = scratch; | 3794 Register except_flag = scratch; |
3806 __ EmitFPUTruncate(kRoundToMinusInf, | 3795 __ EmitFPUTruncate(kRoundToMinusInf, |
3807 result, | 3796 result, |
3808 double_scratch0(), | 3797 double_scratch0(), |
3809 at, | 3798 at, |
3810 double_scratch1, | 3799 double_scratch1, |
3811 except_flag); | 3800 except_flag); |
3812 | 3801 |
3813 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); | 3802 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); |
3814 | 3803 |
3815 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3804 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3816 // Test for -0. | 3805 // Test for -0. |
3817 __ Branch(&done, ne, result, Operand(zero_reg)); | 3806 __ Branch(&done, ne, result, Operand(zero_reg)); |
3818 __ bind(&check_sign_on_zero); | 3807 __ bind(&check_sign_on_zero); |
3819 __ mfc1(scratch, input.high()); | 3808 __ Mfhc1(scratch, input); |
3820 __ And(scratch, scratch, Operand(HeapNumber::kSignMask)); | 3809 __ And(scratch, scratch, Operand(HeapNumber::kSignMask)); |
3821 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); | 3810 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); |
3822 } | 3811 } |
3823 __ bind(&done); | 3812 __ bind(&done); |
3824 } | 3813 } |
3825 | 3814 |
3826 | 3815 |
3827 void LCodeGen::DoMathFround(LMathFround* instr) { | 3816 void LCodeGen::DoMathFround(LMathFround* instr) { |
3828 DoubleRegister input = ToDoubleRegister(instr->value()); | 3817 DoubleRegister input = ToDoubleRegister(instr->value()); |
3829 DoubleRegister result = ToDoubleRegister(instr->result()); | 3818 DoubleRegister result = ToDoubleRegister(instr->result()); |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4836 if (can_convert_undefined_to_nan) { | 4825 if (can_convert_undefined_to_nan) { |
4837 __ Branch(&convert, ne, scratch, Operand(at)); | 4826 __ Branch(&convert, ne, scratch, Operand(at)); |
4838 } else { | 4827 } else { |
4839 DeoptimizeIf(ne, env, scratch, Operand(at)); | 4828 DeoptimizeIf(ne, env, scratch, Operand(at)); |
4840 } | 4829 } |
4841 // Load heap number. | 4830 // Load heap number. |
4842 __ ldc1(result_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); | 4831 __ ldc1(result_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); |
4843 if (deoptimize_on_minus_zero) { | 4832 if (deoptimize_on_minus_zero) { |
4844 __ mfc1(at, result_reg.low()); | 4833 __ mfc1(at, result_reg.low()); |
4845 __ Branch(&done, ne, at, Operand(zero_reg)); | 4834 __ Branch(&done, ne, at, Operand(zero_reg)); |
4846 __ mfc1(scratch, result_reg.high()); | 4835 __ Mfhc1(scratch, result_reg); |
4847 DeoptimizeIf(eq, env, scratch, Operand(HeapNumber::kSignMask)); | 4836 DeoptimizeIf(eq, env, scratch, Operand(HeapNumber::kSignMask)); |
4848 } | 4837 } |
4849 __ Branch(&done); | 4838 __ Branch(&done); |
4850 if (can_convert_undefined_to_nan) { | 4839 if (can_convert_undefined_to_nan) { |
4851 __ bind(&convert); | 4840 __ bind(&convert); |
4852 // Convert undefined (and hole) to NaN. | 4841 // Convert undefined (and hole) to NaN. |
4853 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 4842 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
4854 DeoptimizeIf(ne, env, input_reg, Operand(at)); | 4843 DeoptimizeIf(ne, env, input_reg, Operand(at)); |
4855 __ LoadRoot(scratch, Heap::kNanValueRootIndex); | 4844 __ LoadRoot(scratch, Heap::kNanValueRootIndex); |
4856 __ ldc1(result_reg, FieldMemOperand(scratch, HeapNumber::kValueOffset)); | 4845 __ ldc1(result_reg, FieldMemOperand(scratch, HeapNumber::kValueOffset)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4934 double_scratch2, | 4923 double_scratch2, |
4935 except_flag, | 4924 except_flag, |
4936 kCheckForInexactConversion); | 4925 kCheckForInexactConversion); |
4937 | 4926 |
4938 // Deopt if the operation did not succeed. | 4927 // Deopt if the operation did not succeed. |
4939 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); | 4928 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); |
4940 | 4929 |
4941 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 4930 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
4942 __ Branch(&done, ne, input_reg, Operand(zero_reg)); | 4931 __ Branch(&done, ne, input_reg, Operand(zero_reg)); |
4943 | 4932 |
4944 __ mfc1(scratch1, double_scratch.high()); | 4933 __ Mfhc1(scratch1, double_scratch); |
4945 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); | 4934 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); |
4946 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); | 4935 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); |
4947 } | 4936 } |
4948 } | 4937 } |
4949 __ bind(&done); | 4938 __ bind(&done); |
4950 } | 4939 } |
4951 | 4940 |
4952 | 4941 |
4953 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 4942 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
4954 class DeferredTaggedToI V8_FINAL : public LDeferredCode { | 4943 class DeferredTaggedToI V8_FINAL : public LDeferredCode { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5022 double_scratch0(), | 5011 double_scratch0(), |
5023 except_flag, | 5012 except_flag, |
5024 kCheckForInexactConversion); | 5013 kCheckForInexactConversion); |
5025 | 5014 |
5026 // Deopt if the operation did not succeed (except_flag != 0). | 5015 // Deopt if the operation did not succeed (except_flag != 0). |
5027 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); | 5016 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); |
5028 | 5017 |
5029 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5018 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
5030 Label done; | 5019 Label done; |
5031 __ Branch(&done, ne, result_reg, Operand(zero_reg)); | 5020 __ Branch(&done, ne, result_reg, Operand(zero_reg)); |
5032 __ mfc1(scratch1, double_input.high()); | 5021 __ Mfhc1(scratch1, double_input); |
5033 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); | 5022 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); |
5034 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); | 5023 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); |
5035 __ bind(&done); | 5024 __ bind(&done); |
5036 } | 5025 } |
5037 } | 5026 } |
5038 } | 5027 } |
5039 | 5028 |
5040 | 5029 |
5041 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { | 5030 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { |
5042 Register result_reg = ToRegister(instr->result()); | 5031 Register result_reg = ToRegister(instr->result()); |
(...skipping 12 matching lines...) Expand all Loading... |
5055 double_scratch0(), | 5044 double_scratch0(), |
5056 except_flag, | 5045 except_flag, |
5057 kCheckForInexactConversion); | 5046 kCheckForInexactConversion); |
5058 | 5047 |
5059 // Deopt if the operation did not succeed (except_flag != 0). | 5048 // Deopt if the operation did not succeed (except_flag != 0). |
5060 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); | 5049 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); |
5061 | 5050 |
5062 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5051 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
5063 Label done; | 5052 Label done; |
5064 __ Branch(&done, ne, result_reg, Operand(zero_reg)); | 5053 __ Branch(&done, ne, result_reg, Operand(zero_reg)); |
5065 __ mfc1(scratch1, double_input.high()); | 5054 __ Mfhc1(scratch1, double_input); |
5066 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); | 5055 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); |
5067 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); | 5056 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); |
5068 __ bind(&done); | 5057 __ bind(&done); |
5069 } | 5058 } |
5070 } | 5059 } |
5071 __ SmiTagCheckOverflow(result_reg, result_reg, scratch1); | 5060 __ SmiTagCheckOverflow(result_reg, result_reg, scratch1); |
5072 DeoptimizeIf(lt, instr->environment(), scratch1, Operand(zero_reg)); | 5061 DeoptimizeIf(lt, instr->environment(), scratch1, Operand(zero_reg)); |
5073 } | 5062 } |
5074 | 5063 |
5075 | 5064 |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5912 __ li(at, scope_info); | 5901 __ li(at, scope_info); |
5913 __ Push(at, ToRegister(instr->function())); | 5902 __ Push(at, ToRegister(instr->function())); |
5914 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5903 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5915 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5904 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5916 } | 5905 } |
5917 | 5906 |
5918 | 5907 |
5919 #undef __ | 5908 #undef __ |
5920 | 5909 |
5921 } } // namespace v8::internal | 5910 } } // namespace v8::internal |
OLD | NEW |