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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 return does_deopt ? AssignEnvironment(result) : result; | 775 return does_deopt ? AssignEnvironment(result) : result; |
776 } | 776 } |
777 | 777 |
778 | 778 |
779 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 779 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
780 HArithmeticBinaryOperation* instr) { | 780 HArithmeticBinaryOperation* instr) { |
781 ASSERT(instr->representation().IsDouble()); | 781 ASSERT(instr->representation().IsDouble()); |
782 ASSERT(instr->left()->representation().IsDouble()); | 782 ASSERT(instr->left()->representation().IsDouble()); |
783 ASSERT(instr->right()->representation().IsDouble()); | 783 ASSERT(instr->right()->representation().IsDouble()); |
784 ASSERT(op != Token::MOD); | 784 ASSERT(op != Token::MOD); |
785 LOperand* left = UseRegisterAtStart(instr->left()); | 785 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
786 LOperand* right = UseRegisterAtStart(instr->right()); | 786 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
787 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | 787 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
788 return DefineSameAsFirst(result); | 788 return DefineSameAsFirst(result); |
789 } | 789 } |
790 | 790 |
791 | 791 |
792 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 792 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
793 HArithmeticBinaryOperation* instr) { | 793 HArithmeticBinaryOperation* instr) { |
794 ASSERT(op == Token::ADD || | 794 ASSERT(op == Token::ADD || |
795 op == Token::DIV || | 795 op == Token::DIV || |
796 op == Token::MOD || | 796 op == Token::MOD || |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | 1302 LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
1303 return DoShift(Token::SHL, instr); | 1303 return DoShift(Token::SHL, instr); |
1304 } | 1304 } |
1305 | 1305 |
1306 | 1306 |
1307 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1307 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
1308 if (instr->representation().IsInteger32()) { | 1308 if (instr->representation().IsInteger32()) { |
1309 ASSERT(instr->left()->representation().IsInteger32()); | 1309 ASSERT(instr->left()->representation().IsInteger32()); |
1310 ASSERT(instr->right()->representation().IsInteger32()); | 1310 ASSERT(instr->right()->representation().IsInteger32()); |
1311 | 1311 |
1312 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1312 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1313 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1313 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1314 return DefineSameAsFirst(new(zone()) LBitI(left, right)); | 1314 return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
1315 } else { | 1315 } else { |
1316 ASSERT(instr->representation().IsTagged()); | 1316 ASSERT(instr->representation().IsTagged()); |
1317 ASSERT(instr->left()->representation().IsTagged()); | 1317 ASSERT(instr->left()->representation().IsTagged()); |
1318 ASSERT(instr->right()->representation().IsTagged()); | 1318 ASSERT(instr->right()->representation().IsTagged()); |
1319 | 1319 |
1320 LOperand* left = UseFixed(instr->left(), rdx); | 1320 LOperand* left = UseFixed(instr->left(), rdx); |
1321 LOperand* right = UseFixed(instr->right(), rax); | 1321 LOperand* right = UseFixed(instr->right(), rax); |
1322 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1322 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
1323 return MarkAsCall(DefineFixed(result, rax), instr); | 1323 return MarkAsCall(DefineFixed(result, rax), instr); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); | 1466 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); |
1467 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); | 1467 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
1468 } | 1468 } |
1469 } | 1469 } |
1470 | 1470 |
1471 | 1471 |
1472 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1472 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
1473 if (instr->representation().IsInteger32()) { | 1473 if (instr->representation().IsInteger32()) { |
1474 ASSERT(instr->left()->representation().IsInteger32()); | 1474 ASSERT(instr->left()->representation().IsInteger32()); |
1475 ASSERT(instr->right()->representation().IsInteger32()); | 1475 ASSERT(instr->right()->representation().IsInteger32()); |
1476 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1476 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1477 LOperand* right = UseOrConstant(instr->MostConstantOperand()); | 1477 LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
1478 LMulI* mul = new(zone()) LMulI(left, right); | 1478 LMulI* mul = new(zone()) LMulI(left, right); |
1479 if (instr->CheckFlag(HValue::kCanOverflow) || | 1479 if (instr->CheckFlag(HValue::kCanOverflow) || |
1480 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1480 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1481 AssignEnvironment(mul); | 1481 AssignEnvironment(mul); |
1482 } | 1482 } |
1483 return DefineSameAsFirst(mul); | 1483 return DefineSameAsFirst(mul); |
1484 } else if (instr->representation().IsDouble()) { | 1484 } else if (instr->representation().IsDouble()) { |
1485 return DoArithmeticD(Token::MUL, instr); | 1485 return DoArithmeticD(Token::MUL, instr); |
1486 } else { | 1486 } else { |
1487 ASSERT(instr->representation().IsTagged()); | 1487 ASSERT(instr->representation().IsTagged()); |
(...skipping 18 matching lines...) Expand all Loading... |
1506 return DoArithmeticD(Token::SUB, instr); | 1506 return DoArithmeticD(Token::SUB, instr); |
1507 } else { | 1507 } else { |
1508 ASSERT(instr->representation().IsTagged()); | 1508 ASSERT(instr->representation().IsTagged()); |
1509 return DoArithmeticT(Token::SUB, instr); | 1509 return DoArithmeticT(Token::SUB, instr); |
1510 } | 1510 } |
1511 } | 1511 } |
1512 | 1512 |
1513 | 1513 |
1514 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1514 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
1515 if (instr->representation().IsInteger32()) { | 1515 if (instr->representation().IsInteger32()) { |
| 1516 // Check to see if it would be advantageous to use an lea instruction rather |
| 1517 // than an add. This is the case when no overflow check is needed and there |
| 1518 // are multiple uses of the add's inputs, so using a 3-register add will |
| 1519 // preserve all input values for later uses. |
| 1520 bool use_lea = LAddI::UseLea(instr); |
1516 ASSERT(instr->left()->representation().IsInteger32()); | 1521 ASSERT(instr->left()->representation().IsInteger32()); |
1517 ASSERT(instr->right()->representation().IsInteger32()); | 1522 ASSERT(instr->right()->representation().IsInteger32()); |
1518 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1523 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1519 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1524 HValue* right_candidate = instr->BetterRightOperand(); |
| 1525 LOperand* right = use_lea |
| 1526 ? UseRegisterOrConstantAtStart(right_candidate) |
| 1527 : UseOrConstantAtStart(right_candidate); |
1520 LAddI* add = new(zone()) LAddI(left, right); | 1528 LAddI* add = new(zone()) LAddI(left, right); |
1521 LInstruction* result = DefineSameAsFirst(add); | 1529 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
1522 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1530 LInstruction* result = use_lea |
| 1531 ? DefineAsRegister(add) |
| 1532 : DefineSameAsFirst(add); |
| 1533 if (can_overflow) { |
1523 result = AssignEnvironment(result); | 1534 result = AssignEnvironment(result); |
1524 } | 1535 } |
1525 return result; | 1536 return result; |
1526 } else if (instr->representation().IsDouble()) { | 1537 } else if (instr->representation().IsDouble()) { |
1527 return DoArithmeticD(Token::ADD, instr); | 1538 return DoArithmeticD(Token::ADD, instr); |
1528 } else { | 1539 } else { |
1529 ASSERT(instr->representation().IsTagged()); | 1540 ASSERT(instr->representation().IsTagged()); |
1530 return DoArithmeticT(Token::ADD, instr); | 1541 return DoArithmeticT(Token::ADD, instr); |
1531 } | 1542 } |
1532 return NULL; | 1543 return NULL; |
1533 } | 1544 } |
1534 | 1545 |
1535 | 1546 |
1536 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1547 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
1537 LOperand* left = NULL; | 1548 LOperand* left = NULL; |
1538 LOperand* right = NULL; | 1549 LOperand* right = NULL; |
1539 if (instr->representation().IsInteger32()) { | 1550 if (instr->representation().IsInteger32()) { |
1540 ASSERT(instr->left()->representation().IsInteger32()); | 1551 ASSERT(instr->left()->representation().IsInteger32()); |
1541 ASSERT(instr->right()->representation().IsInteger32()); | 1552 ASSERT(instr->right()->representation().IsInteger32()); |
1542 left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1553 left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1543 right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1554 right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1544 } else { | 1555 } else { |
1545 ASSERT(instr->representation().IsDouble()); | 1556 ASSERT(instr->representation().IsDouble()); |
1546 ASSERT(instr->left()->representation().IsDouble()); | 1557 ASSERT(instr->left()->representation().IsDouble()); |
1547 ASSERT(instr->right()->representation().IsDouble()); | 1558 ASSERT(instr->right()->representation().IsDouble()); |
1548 left = UseRegisterAtStart(instr->left()); | 1559 left = UseRegisterAtStart(instr->left()); |
1549 right = UseRegisterAtStart(instr->right()); | 1560 right = UseRegisterAtStart(instr->right()); |
1550 } | 1561 } |
1551 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); | 1562 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); |
1552 return DefineSameAsFirst(minmax); | 1563 return DefineSameAsFirst(minmax); |
1553 } | 1564 } |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2567 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2557 LOperand* object = UseRegister(instr->object()); | 2568 LOperand* object = UseRegister(instr->object()); |
2558 LOperand* index = UseTempRegister(instr->index()); | 2569 LOperand* index = UseTempRegister(instr->index()); |
2559 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2570 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2560 } | 2571 } |
2561 | 2572 |
2562 | 2573 |
2563 } } // namespace v8::internal | 2574 } } // namespace v8::internal |
2564 | 2575 |
2565 #endif // V8_TARGET_ARCH_X64 | 2576 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |