Chromium Code Reviews| 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 return does_deopt ? AssignEnvironment(result) : result; | 827 return does_deopt ? AssignEnvironment(result) : result; |
| 828 } | 828 } |
| 829 | 829 |
| 830 | 830 |
| 831 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 831 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 832 HArithmeticBinaryOperation* instr) { | 832 HArithmeticBinaryOperation* instr) { |
| 833 ASSERT(instr->representation().IsDouble()); | 833 ASSERT(instr->representation().IsDouble()); |
| 834 ASSERT(instr->left()->representation().IsDouble()); | 834 ASSERT(instr->left()->representation().IsDouble()); |
| 835 ASSERT(instr->right()->representation().IsDouble()); | 835 ASSERT(instr->right()->representation().IsDouble()); |
| 836 ASSERT(op != Token::MOD); | 836 ASSERT(op != Token::MOD); |
| 837 LOperand* left = UseRegisterAtStart(instr->left()); | 837 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 838 LOperand* right = UseRegisterAtStart(instr->right()); | 838 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
| 839 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | 839 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
| 840 return DefineSameAsFirst(result); | 840 return DefineSameAsFirst(result); |
| 841 } | 841 } |
| 842 | 842 |
| 843 | 843 |
| 844 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 844 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
| 845 HArithmeticBinaryOperation* instr) { | 845 HArithmeticBinaryOperation* instr) { |
| 846 ASSERT(op == Token::ADD || | 846 ASSERT(op == Token::ADD || |
| 847 op == Token::DIV || | 847 op == Token::DIV || |
| 848 op == Token::MOD || | 848 op == Token::MOD || |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | 1385 LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
| 1386 return DoShift(Token::SHL, instr); | 1386 return DoShift(Token::SHL, instr); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 | 1389 |
| 1390 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1390 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
| 1391 if (instr->representation().IsInteger32()) { | 1391 if (instr->representation().IsInteger32()) { |
| 1392 ASSERT(instr->left()->representation().IsInteger32()); | 1392 ASSERT(instr->left()->representation().IsInteger32()); |
| 1393 ASSERT(instr->right()->representation().IsInteger32()); | 1393 ASSERT(instr->right()->representation().IsInteger32()); |
| 1394 | 1394 |
| 1395 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1395 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1396 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1396 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
| 1397 return DefineSameAsFirst(new(zone()) LBitI(left, right)); | 1397 return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
| 1398 } else { | 1398 } else { |
| 1399 ASSERT(instr->representation().IsTagged()); | 1399 ASSERT(instr->representation().IsTagged()); |
| 1400 ASSERT(instr->left()->representation().IsTagged()); | 1400 ASSERT(instr->left()->representation().IsTagged()); |
| 1401 ASSERT(instr->right()->representation().IsTagged()); | 1401 ASSERT(instr->right()->representation().IsTagged()); |
| 1402 | 1402 |
| 1403 LOperand* context = UseFixed(instr->context(), esi); | 1403 LOperand* context = UseFixed(instr->context(), esi); |
| 1404 LOperand* left = UseFixed(instr->left(), edx); | 1404 LOperand* left = UseFixed(instr->left(), edx); |
| 1405 LOperand* right = UseFixed(instr->right(), eax); | 1405 LOperand* right = UseFixed(instr->right(), eax); |
| 1406 LArithmeticT* result = | 1406 LArithmeticT* result = |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1553 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); | 1553 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); |
| 1554 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); | 1554 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
| 1555 } | 1555 } |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 | 1558 |
| 1559 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1559 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
| 1560 if (instr->representation().IsInteger32()) { | 1560 if (instr->representation().IsInteger32()) { |
| 1561 ASSERT(instr->left()->representation().IsInteger32()); | 1561 ASSERT(instr->left()->representation().IsInteger32()); |
| 1562 ASSERT(instr->right()->representation().IsInteger32()); | 1562 ASSERT(instr->right()->representation().IsInteger32()); |
| 1563 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1563 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1564 LOperand* right = UseOrConstant(instr->MostConstantOperand()); | 1564 LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
| 1565 LOperand* temp = NULL; | 1565 LOperand* temp = NULL; |
| 1566 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1566 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1567 temp = TempRegister(); | 1567 temp = TempRegister(); |
| 1568 } | 1568 } |
| 1569 LMulI* mul = new(zone()) LMulI(left, right, temp); | 1569 LMulI* mul = new(zone()) LMulI(left, right, temp); |
| 1570 if (instr->CheckFlag(HValue::kCanOverflow) || | 1570 if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1571 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1571 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1572 AssignEnvironment(mul); | 1572 AssignEnvironment(mul); |
| 1573 } | 1573 } |
| 1574 return DefineSameAsFirst(mul); | 1574 return DefineSameAsFirst(mul); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1597 return DoArithmeticD(Token::SUB, instr); | 1597 return DoArithmeticD(Token::SUB, instr); |
| 1598 } else { | 1598 } else { |
| 1599 ASSERT(instr->representation().IsTagged()); | 1599 ASSERT(instr->representation().IsTagged()); |
| 1600 return DoArithmeticT(Token::SUB, instr); | 1600 return DoArithmeticT(Token::SUB, instr); |
| 1601 } | 1601 } |
| 1602 } | 1602 } |
| 1603 | 1603 |
| 1604 | 1604 |
| 1605 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1605 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
| 1606 if (instr->representation().IsInteger32()) { | 1606 if (instr->representation().IsInteger32()) { |
| 1607 // Check to see if it would be advantageous to use an lea instruction rather | |
| 1608 // than an add. This is the case when no overflow check is needed and are | |
|
Jakob Kummerow
2013/05/07 11:53:58
nit: s/are/there are/
danno
2013/05/08 08:37:18
Done.
| |
| 1609 // multiple uses of the add's inputs, so using a 3-register add will | |
| 1610 // preserve all input values for later uses. | |
| 1611 bool use_lea = LAddI::UseLea(instr); | |
| 1607 ASSERT(instr->left()->representation().IsInteger32()); | 1612 ASSERT(instr->left()->representation().IsInteger32()); |
| 1608 ASSERT(instr->right()->representation().IsInteger32()); | 1613 ASSERT(instr->right()->representation().IsInteger32()); |
| 1609 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1614 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1610 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1615 HValue* right_candidate = instr->BetterRightOperand(); |
| 1616 LOperand* right = use_lea | |
| 1617 ? UseRegisterOrConstantAtStart(right_candidate) | |
| 1618 : UseOrConstantAtStart(right_candidate); | |
| 1611 LAddI* add = new(zone()) LAddI(left, right); | 1619 LAddI* add = new(zone()) LAddI(left, right); |
| 1612 LInstruction* result = DefineSameAsFirst(add); | 1620 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
| 1613 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1621 LInstruction* result = NULL; |
|
Sven Panne
2013/05/07 11:38:40
Ternary aversion? Use ?:
danno
2013/05/08 08:37:18
Done.
| |
| 1622 if (use_lea) { | |
| 1623 result = DefineAsRegister(add); | |
| 1624 } else { | |
| 1625 result = DefineSameAsFirst(add); | |
| 1626 } | |
| 1627 if (can_overflow) { | |
| 1614 result = AssignEnvironment(result); | 1628 result = AssignEnvironment(result); |
| 1615 } | 1629 } |
| 1616 return result; | 1630 return result; |
| 1617 } else if (instr->representation().IsDouble()) { | 1631 } else if (instr->representation().IsDouble()) { |
| 1618 return DoArithmeticD(Token::ADD, instr); | 1632 return DoArithmeticD(Token::ADD, instr); |
| 1619 } else { | 1633 } else { |
| 1620 ASSERT(instr->representation().IsTagged()); | 1634 ASSERT(instr->representation().IsTagged()); |
| 1621 return DoArithmeticT(Token::ADD, instr); | 1635 return DoArithmeticT(Token::ADD, instr); |
| 1622 } | 1636 } |
| 1623 } | 1637 } |
| 1624 | 1638 |
| 1625 | 1639 |
| 1626 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1640 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
| 1627 LOperand* left = NULL; | 1641 LOperand* left = NULL; |
| 1628 LOperand* right = NULL; | 1642 LOperand* right = NULL; |
| 1629 if (instr->representation().IsInteger32()) { | 1643 if (instr->representation().IsInteger32()) { |
| 1630 ASSERT(instr->left()->representation().IsInteger32()); | 1644 ASSERT(instr->left()->representation().IsInteger32()); |
| 1631 ASSERT(instr->right()->representation().IsInteger32()); | 1645 ASSERT(instr->right()->representation().IsInteger32()); |
| 1632 left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1646 left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1633 right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1647 right = UseOrConstantAtStart(instr->BetterRightOperand()); |
| 1634 } else { | 1648 } else { |
| 1635 ASSERT(instr->representation().IsDouble()); | 1649 ASSERT(instr->representation().IsDouble()); |
| 1636 ASSERT(instr->left()->representation().IsDouble()); | 1650 ASSERT(instr->left()->representation().IsDouble()); |
| 1637 ASSERT(instr->right()->representation().IsDouble()); | 1651 ASSERT(instr->right()->representation().IsDouble()); |
| 1638 left = UseRegisterAtStart(instr->left()); | 1652 left = UseRegisterAtStart(instr->left()); |
| 1639 right = UseRegisterAtStart(instr->right()); | 1653 right = UseRegisterAtStart(instr->right()); |
| 1640 } | 1654 } |
| 1641 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); | 1655 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); |
| 1642 return DefineSameAsFirst(minmax); | 1656 return DefineSameAsFirst(minmax); |
| 1643 } | 1657 } |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2765 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2779 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2766 LOperand* object = UseRegister(instr->object()); | 2780 LOperand* object = UseRegister(instr->object()); |
| 2767 LOperand* index = UseTempRegister(instr->index()); | 2781 LOperand* index = UseTempRegister(instr->index()); |
| 2768 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2782 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2769 } | 2783 } |
| 2770 | 2784 |
| 2771 | 2785 |
| 2772 } } // namespace v8::internal | 2786 } } // namespace v8::internal |
| 2773 | 2787 |
| 2774 #endif // V8_TARGET_ARCH_IA32 | 2788 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |