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 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 } | 1408 } |
1409 | 1409 |
1410 | 1410 |
1411 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | 1411 LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
1412 return DoShift(Token::SHL, instr); | 1412 return DoShift(Token::SHL, instr); |
1413 } | 1413 } |
1414 | 1414 |
1415 | 1415 |
1416 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1416 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
1417 if (instr->representation().IsSmiOrInteger32()) { | 1417 if (instr->representation().IsSmiOrInteger32()) { |
1418 ASSERT(instr->left()->representation().IsSmiOrInteger32()); | 1418 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1419 ASSERT(instr->right()->representation().Equals( | 1419 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1420 instr->left()->representation())); | |
1421 | 1420 |
1422 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1421 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1423 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); | 1422 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1424 return DefineSameAsFirst(new(zone()) LBitI(left, right)); | 1423 return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
1425 } else { | 1424 } else { |
1426 ASSERT(instr->representation().IsSmiOrTagged()); | 1425 ASSERT(instr->representation().IsSmiOrTagged()); |
1427 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 1426 ASSERT(instr->left()->representation().IsSmiOrTagged()); |
1428 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 1427 ASSERT(instr->right()->representation().IsSmiOrTagged()); |
1429 | 1428 |
1430 LOperand* context = UseFixed(instr->context(), esi); | 1429 LOperand* context = UseFixed(instr->context(), esi); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 new(zone()) LMathFloorOfDiv(dividend, divisor, temp), edx); | 1517 new(zone()) LMathFloorOfDiv(dividend, divisor, temp), edx); |
1519 return divisor_si < 0 ? AssignEnvironment(result) : result; | 1518 return divisor_si < 0 ? AssignEnvironment(result) : result; |
1520 } | 1519 } |
1521 } | 1520 } |
1522 | 1521 |
1523 | 1522 |
1524 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1523 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1525 HValue* left = instr->left(); | 1524 HValue* left = instr->left(); |
1526 HValue* right = instr->right(); | 1525 HValue* right = instr->right(); |
1527 if (instr->representation().IsSmiOrInteger32()) { | 1526 if (instr->representation().IsSmiOrInteger32()) { |
1528 ASSERT(left->representation().IsSmiOrInteger32()); | 1527 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1529 ASSERT(right->representation().Equals(left->representation())); | 1528 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1530 | 1529 |
1531 if (instr->HasPowerOf2Divisor()) { | 1530 if (instr->HasPowerOf2Divisor()) { |
1532 ASSERT(!right->CanBeZero()); | 1531 ASSERT(!right->CanBeZero()); |
1533 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1532 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
1534 UseOrConstant(right), | 1533 UseOrConstant(right), |
1535 NULL); | 1534 NULL); |
1536 LInstruction* result = DefineSameAsFirst(mod); | 1535 LInstruction* result = DefineSameAsFirst(mod); |
1537 return (left->CanBeNegative() && | 1536 return (left->CanBeNegative() && |
1538 instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 1537 instr->CheckFlag(HValue::kBailoutOnMinusZero)) |
1539 ? AssignEnvironment(result) | 1538 ? AssignEnvironment(result) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 return DoArithmeticD(Token::MUL, instr); | 1594 return DoArithmeticD(Token::MUL, instr); |
1596 } else { | 1595 } else { |
1597 ASSERT(instr->representation().IsTagged()); | 1596 ASSERT(instr->representation().IsTagged()); |
1598 return DoArithmeticT(Token::MUL, instr); | 1597 return DoArithmeticT(Token::MUL, instr); |
1599 } | 1598 } |
1600 } | 1599 } |
1601 | 1600 |
1602 | 1601 |
1603 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1602 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
1604 if (instr->representation().IsSmiOrInteger32()) { | 1603 if (instr->representation().IsSmiOrInteger32()) { |
1605 ASSERT(instr->left()->representation().IsSmiOrInteger32()); | 1604 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1606 ASSERT(instr->right()->representation().Equals( | 1605 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1607 instr->left()->representation())); | |
1608 LOperand* left = UseRegisterAtStart(instr->left()); | 1606 LOperand* left = UseRegisterAtStart(instr->left()); |
1609 LOperand* right = UseOrConstantAtStart(instr->right()); | 1607 LOperand* right = UseOrConstantAtStart(instr->right()); |
1610 LSubI* sub = new(zone()) LSubI(left, right); | 1608 LSubI* sub = new(zone()) LSubI(left, right); |
1611 LInstruction* result = DefineSameAsFirst(sub); | 1609 LInstruction* result = DefineSameAsFirst(sub); |
1612 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1610 if (instr->CheckFlag(HValue::kCanOverflow)) { |
1613 result = AssignEnvironment(result); | 1611 result = AssignEnvironment(result); |
1614 } | 1612 } |
1615 return result; | 1613 return result; |
1616 } else if (instr->representation().IsDouble()) { | 1614 } else if (instr->representation().IsDouble()) { |
1617 return DoArithmeticD(Token::SUB, instr); | 1615 return DoArithmeticD(Token::SUB, instr); |
1618 } else { | 1616 } else { |
1619 ASSERT(instr->representation().IsSmiOrTagged()); | 1617 ASSERT(instr->representation().IsSmiOrTagged()); |
1620 return DoArithmeticT(Token::SUB, instr); | 1618 return DoArithmeticT(Token::SUB, instr); |
1621 } | 1619 } |
1622 } | 1620 } |
1623 | 1621 |
1624 | 1622 |
1625 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1623 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
1626 if (instr->representation().IsSmiOrInteger32()) { | 1624 if (instr->representation().IsSmiOrInteger32()) { |
1627 ASSERT(instr->left()->representation().IsSmiOrInteger32()); | 1625 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1628 ASSERT(instr->right()->representation().Equals( | 1626 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1629 instr->left()->representation())); | |
1630 // Check to see if it would be advantageous to use an lea instruction rather | 1627 // Check to see if it would be advantageous to use an lea instruction rather |
1631 // than an add. This is the case when no overflow check is needed and there | 1628 // than an add. This is the case when no overflow check is needed and there |
1632 // are multiple uses of the add's inputs, so using a 3-register add will | 1629 // are multiple uses of the add's inputs, so using a 3-register add will |
1633 // preserve all input values for later uses. | 1630 // preserve all input values for later uses. |
1634 bool use_lea = LAddI::UseLea(instr); | 1631 bool use_lea = LAddI::UseLea(instr); |
1635 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1632 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1636 HValue* right_candidate = instr->BetterRightOperand(); | 1633 HValue* right_candidate = instr->BetterRightOperand(); |
1637 LOperand* right = use_lea | 1634 LOperand* right = use_lea |
1638 ? UseRegisterOrConstantAtStart(right_candidate) | 1635 ? UseRegisterOrConstantAtStart(right_candidate) |
1639 : UseOrConstantAtStart(right_candidate); | 1636 : UseOrConstantAtStart(right_candidate); |
(...skipping 12 matching lines...) Expand all Loading... |
1652 ASSERT(instr->representation().IsSmiOrTagged()); | 1649 ASSERT(instr->representation().IsSmiOrTagged()); |
1653 return DoArithmeticT(Token::ADD, instr); | 1650 return DoArithmeticT(Token::ADD, instr); |
1654 } | 1651 } |
1655 } | 1652 } |
1656 | 1653 |
1657 | 1654 |
1658 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1655 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
1659 LOperand* left = NULL; | 1656 LOperand* left = NULL; |
1660 LOperand* right = NULL; | 1657 LOperand* right = NULL; |
1661 if (instr->representation().IsSmiOrInteger32()) { | 1658 if (instr->representation().IsSmiOrInteger32()) { |
1662 ASSERT(instr->left()->representation().IsSmiOrInteger32()); | 1659 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1663 ASSERT(instr->right()->representation().Equals( | 1660 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1664 instr->left()->representation())); | |
1665 left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1661 left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1666 right = UseOrConstantAtStart(instr->BetterRightOperand()); | 1662 right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1667 } else { | 1663 } else { |
1668 ASSERT(instr->representation().IsDouble()); | 1664 ASSERT(instr->representation().IsDouble()); |
1669 ASSERT(instr->left()->representation().IsDouble()); | 1665 ASSERT(instr->left()->representation().IsDouble()); |
1670 ASSERT(instr->right()->representation().IsDouble()); | 1666 ASSERT(instr->right()->representation().IsDouble()); |
1671 left = UseRegisterAtStart(instr->left()); | 1667 left = UseRegisterAtStart(instr->left()); |
1672 right = UseRegisterAtStart(instr->right()); | 1668 right = UseRegisterAtStart(instr->right()); |
1673 } | 1669 } |
1674 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); | 1670 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 LOperand* right = UseFixed(instr->right(), eax); | 1705 LOperand* right = UseFixed(instr->right(), eax); |
1710 LCmpT* result = new(zone()) LCmpT(context, left, right); | 1706 LCmpT* result = new(zone()) LCmpT(context, left, right); |
1711 return MarkAsCall(DefineFixed(result, eax), instr); | 1707 return MarkAsCall(DefineFixed(result, eax), instr); |
1712 } | 1708 } |
1713 | 1709 |
1714 | 1710 |
1715 LInstruction* LChunkBuilder::DoCompareNumericAndBranch( | 1711 LInstruction* LChunkBuilder::DoCompareNumericAndBranch( |
1716 HCompareNumericAndBranch* instr) { | 1712 HCompareNumericAndBranch* instr) { |
1717 Representation r = instr->representation(); | 1713 Representation r = instr->representation(); |
1718 if (r.IsSmiOrInteger32()) { | 1714 if (r.IsSmiOrInteger32()) { |
1719 ASSERT(instr->left()->representation().IsSmiOrInteger32()); | 1715 ASSERT(instr->left()->representation().Equals(r)); |
1720 ASSERT(instr->left()->representation().Equals( | 1716 ASSERT(instr->right()->representation().Equals(r)); |
1721 instr->right()->representation())); | |
1722 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); | 1717 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); |
1723 LOperand* right = UseOrConstantAtStart(instr->right()); | 1718 LOperand* right = UseOrConstantAtStart(instr->right()); |
1724 return new(zone()) LCompareNumericAndBranch(left, right); | 1719 return new(zone()) LCompareNumericAndBranch(left, right); |
1725 } else { | 1720 } else { |
1726 ASSERT(r.IsDouble()); | 1721 ASSERT(r.IsDouble()); |
1727 ASSERT(instr->left()->representation().IsDouble()); | 1722 ASSERT(instr->left()->representation().IsDouble()); |
1728 ASSERT(instr->right()->representation().IsDouble()); | 1723 ASSERT(instr->right()->representation().IsDouble()); |
1729 LOperand* left; | 1724 LOperand* left; |
1730 LOperand* right; | 1725 LOperand* right; |
1731 if (instr->left()->IsConstant() && instr->right()->IsConstant()) { | 1726 if (instr->left()->IsConstant() && instr->right()->IsConstant()) { |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2726 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2732 LOperand* object = UseRegister(instr->object()); | 2727 LOperand* object = UseRegister(instr->object()); |
2733 LOperand* index = UseTempRegister(instr->index()); | 2728 LOperand* index = UseTempRegister(instr->index()); |
2734 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2729 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2735 } | 2730 } |
2736 | 2731 |
2737 | 2732 |
2738 } } // namespace v8::internal | 2733 } } // namespace v8::internal |
2739 | 2734 |
2740 #endif // V8_TARGET_ARCH_IA32 | 2735 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |