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 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 } | 1320 } |
1321 } | 1321 } |
1322 | 1322 |
1323 | 1323 |
1324 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { | 1324 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { |
1325 ASSERT(instr->representation().IsSmiOrInteger32()); | 1325 ASSERT(instr->representation().IsSmiOrInteger32()); |
1326 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1326 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1327 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1327 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1328 LOperand* dividend = UseRegister(instr->left()); | 1328 LOperand* dividend = UseRegister(instr->left()); |
1329 int32_t divisor = instr->right()->GetInteger32Constant(); | 1329 int32_t divisor = instr->right()->GetInteger32Constant(); |
1330 LInstruction* result = | 1330 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I( |
1331 DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor)); | 1331 dividend, divisor)); |
1332 bool can_deopt = | 1332 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || |
1333 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1333 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) || |
1334 instr->left()->RangeCanInclude(0) && divisor < 0) || | |
1335 (instr->CheckFlag(HValue::kCanOverflow) && | |
1336 instr->left()->RangeCanInclude(kMinInt) && divisor == -1) || | |
1337 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && | 1334 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && |
1338 divisor != 1 && divisor != -1); | 1335 divisor != 1 && divisor != -1)) { |
1339 return can_deopt ? AssignEnvironment(result) : result; | 1336 result = AssignEnvironment(result); |
| 1337 } |
| 1338 return result; |
1340 } | 1339 } |
1341 | 1340 |
1342 | 1341 |
1343 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { | 1342 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { |
1344 ASSERT(instr->representation().IsInteger32()); | 1343 ASSERT(instr->representation().IsInteger32()); |
1345 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1344 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1346 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1345 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1347 LOperand* dividend = UseRegister(instr->left()); | 1346 LOperand* dividend = UseRegister(instr->left()); |
1348 int32_t divisor = instr->right()->GetInteger32Constant(); | 1347 int32_t divisor = instr->right()->GetInteger32Constant(); |
1349 LOperand* temp1 = FixedTemp(eax); | 1348 LOperand* temp1 = FixedTemp(eax); |
1350 LOperand* temp2 = FixedTemp(edx); | 1349 LOperand* temp2 = FixedTemp(edx); |
1351 LInstruction* result = | 1350 LInstruction* result = DefineFixed(new(zone()) LDivByConstI( |
1352 DefineFixed( | 1351 dividend, divisor, temp1, temp2), edx); |
1353 new(zone()) LDivByConstI(dividend, divisor, temp1, temp2), edx); | 1352 if (divisor == 0 || |
1354 bool can_deopt = | 1353 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || |
1355 divisor == 0 || | 1354 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { |
1356 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1355 result = AssignEnvironment(result); |
1357 instr->left()->RangeCanInclude(0) && divisor < 0) || | 1356 } |
1358 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32); | 1357 return result; |
1359 return can_deopt ? AssignEnvironment(result) : result; | |
1360 } | 1358 } |
1361 | 1359 |
1362 | 1360 |
1363 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { | 1361 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { |
1364 ASSERT(instr->representation().IsSmiOrInteger32()); | 1362 ASSERT(instr->representation().IsSmiOrInteger32()); |
1365 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1363 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1366 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1364 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1367 LOperand* dividend = UseFixed(instr->left(), eax); | 1365 LOperand* dividend = UseFixed(instr->left(), eax); |
1368 LOperand* divisor = UseRegister(instr->right()); | 1366 LOperand* divisor = UseRegister(instr->right()); |
1369 LOperand* temp = FixedTemp(edx); | 1367 LOperand* temp = FixedTemp(edx); |
1370 LInstruction* result = | 1368 LInstruction* result = DefineFixed(new(zone()) LDivI( |
1371 DefineFixed(new(zone()) LDivI(dividend, divisor, temp), eax); | 1369 dividend, divisor, temp), eax); |
1372 return AssignEnvironment(result); | 1370 if (instr->CheckFlag(HValue::kCanBeDivByZero) || |
| 1371 instr->CheckFlag(HValue::kBailoutOnMinusZero) || |
| 1372 instr->CheckFlag(HValue::kCanOverflow) || |
| 1373 (!instr->IsMathFloorOfDiv() && |
| 1374 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) { |
| 1375 result = AssignEnvironment(result); |
| 1376 } |
| 1377 return result; |
1373 } | 1378 } |
1374 | 1379 |
1375 | 1380 |
1376 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1381 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
1377 if (instr->representation().IsSmiOrInteger32()) { | 1382 if (instr->representation().IsSmiOrInteger32()) { |
1378 if (instr->RightIsPowerOf2()) { | 1383 if (instr->RightIsPowerOf2()) { |
1379 return DoDivByPowerOf2I(instr); | 1384 return DoDivByPowerOf2I(instr); |
1380 } else if (instr->right()->IsConstant()) { | 1385 } else if (instr->right()->IsConstant()) { |
1381 return DoDivByConstI(instr); | 1386 return DoDivByConstI(instr); |
1382 } else { | 1387 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
1411 LOperand* temp1 = FixedTemp(eax); | 1416 LOperand* temp1 = FixedTemp(eax); |
1412 LOperand* temp2 = FixedTemp(edx); | 1417 LOperand* temp2 = FixedTemp(edx); |
1413 LInstruction* result = | 1418 LInstruction* result = |
1414 DefineFixed(new(zone()) LFlooringDivByConstI(dividend, | 1419 DefineFixed(new(zone()) LFlooringDivByConstI(dividend, |
1415 divisor, | 1420 divisor, |
1416 temp1, | 1421 temp1, |
1417 temp2), | 1422 temp2), |
1418 edx); | 1423 edx); |
1419 bool can_deopt = | 1424 bool can_deopt = |
1420 divisor == 0 || | 1425 divisor == 0 || |
1421 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1426 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0); |
1422 instr->left()->RangeCanInclude(0) && divisor < 0); | |
1423 return can_deopt ? AssignEnvironment(result) : result; | 1427 return can_deopt ? AssignEnvironment(result) : result; |
1424 } | 1428 } |
1425 | 1429 |
1426 | 1430 |
1427 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1431 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1428 if (instr->RightIsPowerOf2()) { | 1432 if (instr->RightIsPowerOf2()) { |
1429 return DoFlooringDivByPowerOf2I(instr); | 1433 return DoFlooringDivByPowerOf2I(instr); |
1430 } else if (instr->right()->IsConstant()) { | 1434 } else if (instr->right()->IsConstant()) { |
1431 return DoFlooringDivByConstI(instr); | 1435 return DoFlooringDivByConstI(instr); |
1432 } else { | 1436 } else { |
1433 return DoDivI(instr); | 1437 return DoDivI(instr); |
1434 } | 1438 } |
1435 } | 1439 } |
1436 | 1440 |
1437 | 1441 |
1438 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { | 1442 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { |
1439 ASSERT(instr->representation().IsSmiOrInteger32()); | 1443 ASSERT(instr->representation().IsSmiOrInteger32()); |
1440 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1444 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1441 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1445 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1442 LOperand* dividend = UseRegisterAtStart(instr->left()); | 1446 LOperand* dividend = UseRegisterAtStart(instr->left()); |
1443 int32_t divisor = instr->right()->GetInteger32Constant(); | 1447 int32_t divisor = instr->right()->GetInteger32Constant(); |
1444 LInstruction* result = | 1448 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I( |
1445 DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor)); | 1449 dividend, divisor)); |
1446 bool can_deopt = | 1450 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1447 instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1451 result = AssignEnvironment(result); |
1448 instr->left()->CanBeNegative(); | 1452 } |
1449 return can_deopt ? AssignEnvironment(result) : result; | 1453 return result; |
1450 } | 1454 } |
1451 | 1455 |
1452 | 1456 |
1453 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { | 1457 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { |
1454 ASSERT(instr->representation().IsSmiOrInteger32()); | 1458 ASSERT(instr->representation().IsSmiOrInteger32()); |
1455 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1459 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1456 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1460 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1457 LOperand* dividend = UseRegister(instr->left()); | 1461 LOperand* dividend = UseRegister(instr->left()); |
1458 int32_t divisor = instr->right()->GetInteger32Constant(); | 1462 int32_t divisor = instr->right()->GetInteger32Constant(); |
1459 LOperand* temp1 = FixedTemp(eax); | 1463 LOperand* temp1 = FixedTemp(eax); |
1460 LOperand* temp2 = FixedTemp(edx); | 1464 LOperand* temp2 = FixedTemp(edx); |
1461 LInstruction* result = | 1465 LInstruction* result = DefineFixed(new(zone()) LModByConstI( |
1462 DefineFixed( | 1466 dividend, divisor, temp1, temp2), eax); |
1463 new(zone()) LModByConstI(dividend, divisor, temp1, temp2), eax); | 1467 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1464 bool can_deopt = | 1468 result = AssignEnvironment(result); |
1465 divisor == 0 || | 1469 } |
1466 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1470 return result; |
1467 instr->left()->CanBeNegative()); | |
1468 return can_deopt ? AssignEnvironment(result) : result; | |
1469 } | 1471 } |
1470 | 1472 |
1471 | 1473 |
1472 LInstruction* LChunkBuilder::DoModI(HMod* instr) { | 1474 LInstruction* LChunkBuilder::DoModI(HMod* instr) { |
1473 ASSERT(instr->representation().IsSmiOrInteger32()); | 1475 ASSERT(instr->representation().IsSmiOrInteger32()); |
1474 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1476 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1475 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1477 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1476 LOperand* dividend = UseFixed(instr->left(), eax); | 1478 LOperand* dividend = UseFixed(instr->left(), eax); |
1477 LOperand* divisor = UseRegister(instr->right()); | 1479 LOperand* divisor = UseRegister(instr->right()); |
1478 LOperand* temp = FixedTemp(edx); | 1480 LOperand* temp = FixedTemp(edx); |
1479 LInstruction* result = | 1481 LInstruction* result = DefineFixed(new(zone()) LModI( |
1480 DefineFixed(new(zone()) LModI(dividend, divisor, temp), edx); | 1482 dividend, divisor, temp), edx); |
1481 bool can_deopt = (instr->right()->CanBeZero() || | 1483 if (instr->CheckFlag(HValue::kCanBeDivByZero) || |
1482 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1484 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1483 instr->left()->RangeCanInclude(kMinInt) && | 1485 result = AssignEnvironment(result); |
1484 instr->right()->RangeCanInclude(-1)) || | 1486 } |
1485 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1487 return result; |
1486 instr->left()->CanBeNegative() && | |
1487 instr->CanBeZero())); | |
1488 return can_deopt ? AssignEnvironment(result) : result; | |
1489 } | 1488 } |
1490 | 1489 |
1491 | 1490 |
1492 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1491 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1493 if (instr->representation().IsSmiOrInteger32()) { | 1492 if (instr->representation().IsSmiOrInteger32()) { |
1494 if (instr->RightIsPowerOf2()) { | 1493 if (instr->RightIsPowerOf2()) { |
1495 return DoModByPowerOf2I(instr); | 1494 return DoModByPowerOf2I(instr); |
1496 } else if (instr->right()->IsConstant()) { | 1495 } else if (instr->right()->IsConstant()) { |
1497 return DoModByConstI(instr); | 1496 return DoModByConstI(instr); |
1498 } else { | 1497 } else { |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2682 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2681 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2683 LOperand* object = UseRegister(instr->object()); | 2682 LOperand* object = UseRegister(instr->object()); |
2684 LOperand* index = UseTempRegister(instr->index()); | 2683 LOperand* index = UseTempRegister(instr->index()); |
2685 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2684 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2686 } | 2685 } |
2687 | 2686 |
2688 | 2687 |
2689 } } // namespace v8::internal | 2688 } } // namespace v8::internal |
2690 | 2689 |
2691 #endif // V8_TARGET_ARCH_IA32 | 2690 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |