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