| 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 755 } |
| 756 | 756 |
| 757 | 757 |
| 758 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | 758 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
| 759 return AssignEnvironment(new(zone()) LDeoptimize); | 759 return AssignEnvironment(new(zone()) LDeoptimize); |
| 760 } | 760 } |
| 761 | 761 |
| 762 | 762 |
| 763 LInstruction* LChunkBuilder::DoShift(Token::Value op, | 763 LInstruction* LChunkBuilder::DoShift(Token::Value op, |
| 764 HBitwiseBinaryOperation* instr) { | 764 HBitwiseBinaryOperation* instr) { |
| 765 if (instr->representation().IsTagged()) { | 765 if (instr->representation().IsSmiOrInteger32()) { |
| 766 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 766 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 767 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 767 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 768 LOperand* left = UseRegisterAtStart(instr->left()); |
| 768 | 769 |
| 769 LOperand* context = UseFixed(instr->context(), esi); | 770 HValue* right_value = instr->right(); |
| 770 LOperand* left = UseFixed(instr->left(), edx); | 771 LOperand* right = NULL; |
| 771 LOperand* right = UseFixed(instr->right(), eax); | 772 int constant_value = 0; |
| 772 LArithmeticT* result = new(zone()) LArithmeticT(op, context, left, right); | 773 bool does_deopt = false; |
| 773 return MarkAsCall(DefineFixed(result, eax), instr); | 774 if (right_value->IsConstant()) { |
| 775 HConstant* constant = HConstant::cast(right_value); |
| 776 right = chunk_->DefineConstantOperand(constant); |
| 777 constant_value = constant->Integer32Value() & 0x1f; |
| 778 // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| 779 // truncated to smi. |
| 780 if (instr->representation().IsSmi() && constant_value > 0) { |
| 781 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); |
| 782 } |
| 783 } else { |
| 784 right = UseFixed(right_value, ecx); |
| 785 } |
| 786 |
| 787 // Shift operations can only deoptimize if we do a logical shift by 0 and |
| 788 // the result cannot be truncated to int32. |
| 789 if (op == Token::SHR && constant_value == 0) { |
| 790 if (FLAG_opt_safe_uint32_operations) { |
| 791 does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
| 792 } else { |
| 793 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32); |
| 794 } |
| 795 } |
| 796 |
| 797 LInstruction* result = |
| 798 DefineSameAsFirst(new(zone()) LShiftI(op, left, right, does_deopt)); |
| 799 return does_deopt ? AssignEnvironment(result) : result; |
| 800 } else { |
| 801 return DoArithmeticT(op, instr); |
| 774 } | 802 } |
| 775 | |
| 776 ASSERT(instr->representation().IsSmiOrInteger32()); | |
| 777 ASSERT(instr->left()->representation().Equals(instr->representation())); | |
| 778 ASSERT(instr->right()->representation().Equals(instr->representation())); | |
| 779 LOperand* left = UseRegisterAtStart(instr->left()); | |
| 780 | |
| 781 HValue* right_value = instr->right(); | |
| 782 LOperand* right = NULL; | |
| 783 int constant_value = 0; | |
| 784 bool does_deopt = false; | |
| 785 if (right_value->IsConstant()) { | |
| 786 HConstant* constant = HConstant::cast(right_value); | |
| 787 right = chunk_->DefineConstantOperand(constant); | |
| 788 constant_value = constant->Integer32Value() & 0x1f; | |
| 789 // Left shifts can deoptimize if we shift by > 0 and the result cannot be | |
| 790 // truncated to smi. | |
| 791 if (instr->representation().IsSmi() && constant_value > 0) { | |
| 792 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); | |
| 793 } | |
| 794 } else { | |
| 795 right = UseFixed(right_value, ecx); | |
| 796 } | |
| 797 | |
| 798 // Shift operations can only deoptimize if we do a logical shift by 0 and | |
| 799 // the result cannot be truncated to int32. | |
| 800 if (op == Token::SHR && constant_value == 0) { | |
| 801 if (FLAG_opt_safe_uint32_operations) { | |
| 802 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | |
| 803 } else { | |
| 804 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32); | |
| 805 } | |
| 806 } | |
| 807 | |
| 808 LInstruction* result = | |
| 809 DefineSameAsFirst(new(zone()) LShiftI(op, left, right, does_deopt)); | |
| 810 return does_deopt ? AssignEnvironment(result) : result; | |
| 811 } | 803 } |
| 812 | 804 |
| 813 | 805 |
| 814 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 806 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 815 HArithmeticBinaryOperation* instr) { | 807 HArithmeticBinaryOperation* instr) { |
| 816 ASSERT(instr->representation().IsDouble()); | 808 ASSERT(instr->representation().IsDouble()); |
| 817 ASSERT(instr->left()->representation().IsDouble()); | 809 ASSERT(instr->left()->representation().IsDouble()); |
| 818 ASSERT(instr->right()->representation().IsDouble()); | 810 ASSERT(instr->right()->representation().IsDouble()); |
| 819 ASSERT(op != Token::MOD); | 811 if (op == Token::MOD) { |
| 820 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 812 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 821 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); | 813 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
| 822 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | 814 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
| 823 return DefineSameAsFirst(result); | 815 return MarkAsCall(DefineSameAsFirst(result), instr); |
| 816 } else { |
| 817 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 818 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
| 819 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
| 820 return DefineSameAsFirst(result); |
| 821 } |
| 824 } | 822 } |
| 825 | 823 |
| 826 | 824 |
| 827 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 825 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
| 828 HArithmeticBinaryOperation* instr) { | 826 HBinaryOperation* instr) { |
| 829 ASSERT(op == Token::ADD || | |
| 830 op == Token::DIV || | |
| 831 op == Token::MOD || | |
| 832 op == Token::MUL || | |
| 833 op == Token::SUB); | |
| 834 HValue* left = instr->left(); | 827 HValue* left = instr->left(); |
| 835 HValue* right = instr->right(); | 828 HValue* right = instr->right(); |
| 836 ASSERT(left->representation().IsTagged()); | 829 ASSERT(left->representation().IsTagged()); |
| 837 ASSERT(right->representation().IsTagged()); | 830 ASSERT(right->representation().IsTagged()); |
| 838 LOperand* context = UseFixed(instr->context(), esi); | 831 LOperand* context = UseFixed(instr->context(), esi); |
| 839 LOperand* left_operand = UseFixed(left, edx); | 832 LOperand* left_operand = UseFixed(left, edx); |
| 840 LOperand* right_operand = UseFixed(right, eax); | 833 LOperand* right_operand = UseFixed(right, eax); |
| 841 LArithmeticT* result = | 834 LArithmeticT* result = |
| 842 new(zone()) LArithmeticT(op, context, left_operand, right_operand); | 835 new(zone()) LArithmeticT(op, context, left_operand, right_operand); |
| 843 return MarkAsCall(DefineFixed(result, eax), instr); | 836 return MarkAsCall(DefineFixed(result, eax), instr); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 | 1428 |
| 1436 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | 1429 LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
| 1437 return DoShift(Token::SHL, instr); | 1430 return DoShift(Token::SHL, instr); |
| 1438 } | 1431 } |
| 1439 | 1432 |
| 1440 | 1433 |
| 1441 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1434 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
| 1442 if (instr->representation().IsSmiOrInteger32()) { | 1435 if (instr->representation().IsSmiOrInteger32()) { |
| 1443 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1436 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1444 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1437 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1438 ASSERT(instr->CheckFlag(HValue::kTruncatingToInt32)); |
| 1445 | 1439 |
| 1446 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1440 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1447 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); | 1441 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
| 1448 return DefineSameAsFirst(new(zone()) LBitI(left, right)); | 1442 return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
| 1449 } else { | 1443 } else { |
| 1450 ASSERT(instr->representation().IsSmiOrTagged()); | 1444 return DoArithmeticT(instr->op(), instr); |
| 1451 ASSERT(instr->left()->representation().IsSmiOrTagged()); | |
| 1452 ASSERT(instr->right()->representation().IsSmiOrTagged()); | |
| 1453 | |
| 1454 LOperand* context = UseFixed(instr->context(), esi); | |
| 1455 LOperand* left = UseFixed(instr->left(), edx); | |
| 1456 LOperand* right = UseFixed(instr->right(), eax); | |
| 1457 LArithmeticT* result = | |
| 1458 new(zone()) LArithmeticT(instr->op(), context, left, right); | |
| 1459 return MarkAsCall(DefineFixed(result, eax), instr); | |
| 1460 } | 1445 } |
| 1461 } | 1446 } |
| 1462 | 1447 |
| 1463 | 1448 |
| 1464 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1449 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
| 1465 if (instr->representation().IsDouble()) { | 1450 if (instr->representation().IsSmiOrInteger32()) { |
| 1466 return DoArithmeticD(Token::DIV, instr); | |
| 1467 } else if (instr->representation().IsSmiOrInteger32()) { | |
| 1468 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1451 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1469 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1452 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1470 if (instr->HasPowerOf2Divisor()) { | 1453 if (instr->HasPowerOf2Divisor()) { |
| 1471 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1454 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
| 1472 LOperand* value = UseRegisterAtStart(instr->left()); | 1455 LOperand* value = UseRegisterAtStart(instr->left()); |
| 1473 LDivI* div = | 1456 LDivI* div = |
| 1474 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); | 1457 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); |
| 1475 return AssignEnvironment(DefineSameAsFirst(div)); | 1458 return AssignEnvironment(DefineSameAsFirst(div)); |
| 1476 } | 1459 } |
| 1477 // The temporary operand is necessary to ensure that right is not allocated | 1460 // The temporary operand is necessary to ensure that right is not allocated |
| 1478 // into edx. | 1461 // into edx. |
| 1479 LOperand* temp = FixedTemp(edx); | 1462 LOperand* temp = FixedTemp(edx); |
| 1480 LOperand* dividend = UseFixed(instr->left(), eax); | 1463 LOperand* dividend = UseFixed(instr->left(), eax); |
| 1481 LOperand* divisor = UseRegister(instr->right()); | 1464 LOperand* divisor = UseRegister(instr->right()); |
| 1482 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1465 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
| 1483 return AssignEnvironment(DefineFixed(result, eax)); | 1466 return AssignEnvironment(DefineFixed(result, eax)); |
| 1467 } else if (instr->representation().IsDouble()) { |
| 1468 return DoArithmeticD(Token::DIV, instr); |
| 1484 } else { | 1469 } else { |
| 1485 ASSERT(instr->representation().IsTagged()); | |
| 1486 return DoArithmeticT(Token::DIV, instr); | 1470 return DoArithmeticT(Token::DIV, instr); |
| 1487 } | 1471 } |
| 1488 } | 1472 } |
| 1489 | 1473 |
| 1490 | 1474 |
| 1491 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1475 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1492 if (divisor->IsConstant() && | 1476 if (divisor->IsConstant() && |
| 1493 HConstant::cast(divisor)->HasInteger32Value()) { | 1477 HConstant::cast(divisor)->HasInteger32Value()) { |
| 1494 HConstant* constant_val = HConstant::cast(divisor); | 1478 HConstant* constant_val = HConstant::cast(divisor); |
| 1495 return constant_val->CopyToRepresentation(Representation::Integer32(), | 1479 return constant_val->CopyToRepresentation(Representation::Integer32(), |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 return (right->CanBeZero() || | 1561 return (right->CanBeZero() || |
| 1578 (left->RangeCanInclude(kMinInt) && | 1562 (left->RangeCanInclude(kMinInt) && |
| 1579 right->RangeCanInclude(-1) && | 1563 right->RangeCanInclude(-1) && |
| 1580 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || | 1564 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || |
| 1581 (left->CanBeNegative() && | 1565 (left->CanBeNegative() && |
| 1582 instr->CanBeZero() && | 1566 instr->CanBeZero() && |
| 1583 instr->CheckFlag(HValue::kBailoutOnMinusZero))) | 1567 instr->CheckFlag(HValue::kBailoutOnMinusZero))) |
| 1584 ? AssignEnvironment(result) | 1568 ? AssignEnvironment(result) |
| 1585 : result; | 1569 : result; |
| 1586 } | 1570 } |
| 1587 } else if (instr->representation().IsSmiOrTagged()) { | 1571 } else if (instr->representation().IsDouble()) { |
| 1572 return DoArithmeticD(Token::MOD, instr); |
| 1573 } else { |
| 1588 return DoArithmeticT(Token::MOD, instr); | 1574 return DoArithmeticT(Token::MOD, instr); |
| 1589 } else { | |
| 1590 ASSERT(instr->representation().IsDouble()); | |
| 1591 // We call a C function for double modulo. It can't trigger a GC. We need | |
| 1592 // to use fixed result register for the call. | |
| 1593 // TODO(fschneider): Allow any register as input registers. | |
| 1594 LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD, | |
| 1595 UseFixedDouble(left, xmm2), | |
| 1596 UseFixedDouble(right, xmm1)); | |
| 1597 return MarkAsCall(DefineFixedDouble(mod, xmm1), instr); | |
| 1598 } | 1575 } |
| 1599 } | 1576 } |
| 1600 | 1577 |
| 1601 | 1578 |
| 1602 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1579 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
| 1603 if (instr->representation().IsSmiOrInteger32()) { | 1580 if (instr->representation().IsSmiOrInteger32()) { |
| 1604 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1581 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1605 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1582 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1606 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1583 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1607 LOperand* right = UseOrConstant(instr->BetterRightOperand()); | 1584 LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
| 1608 LOperand* temp = NULL; | 1585 LOperand* temp = NULL; |
| 1609 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1586 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1610 temp = TempRegister(); | 1587 temp = TempRegister(); |
| 1611 } | 1588 } |
| 1612 LMulI* mul = new(zone()) LMulI(left, right, temp); | 1589 LMulI* mul = new(zone()) LMulI(left, right, temp); |
| 1613 if (instr->CheckFlag(HValue::kCanOverflow) || | 1590 if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1614 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1591 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1615 AssignEnvironment(mul); | 1592 AssignEnvironment(mul); |
| 1616 } | 1593 } |
| 1617 return DefineSameAsFirst(mul); | 1594 return DefineSameAsFirst(mul); |
| 1618 } else if (instr->representation().IsDouble()) { | 1595 } else if (instr->representation().IsDouble()) { |
| 1619 return DoArithmeticD(Token::MUL, instr); | 1596 return DoArithmeticD(Token::MUL, instr); |
| 1620 } else { | 1597 } else { |
| 1621 ASSERT(instr->representation().IsTagged()); | |
| 1622 return DoArithmeticT(Token::MUL, instr); | 1598 return DoArithmeticT(Token::MUL, instr); |
| 1623 } | 1599 } |
| 1624 } | 1600 } |
| 1625 | 1601 |
| 1626 | 1602 |
| 1627 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1603 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| 1628 if (instr->representation().IsSmiOrInteger32()) { | 1604 if (instr->representation().IsSmiOrInteger32()) { |
| 1629 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1605 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1630 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1606 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1631 LOperand* left = UseRegisterAtStart(instr->left()); | 1607 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1632 LOperand* right = UseOrConstantAtStart(instr->right()); | 1608 LOperand* right = UseOrConstantAtStart(instr->right()); |
| 1633 LSubI* sub = new(zone()) LSubI(left, right); | 1609 LSubI* sub = new(zone()) LSubI(left, right); |
| 1634 LInstruction* result = DefineSameAsFirst(sub); | 1610 LInstruction* result = DefineSameAsFirst(sub); |
| 1635 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1611 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1636 result = AssignEnvironment(result); | 1612 result = AssignEnvironment(result); |
| 1637 } | 1613 } |
| 1638 return result; | 1614 return result; |
| 1639 } else if (instr->representation().IsDouble()) { | 1615 } else if (instr->representation().IsDouble()) { |
| 1640 return DoArithmeticD(Token::SUB, instr); | 1616 return DoArithmeticD(Token::SUB, instr); |
| 1641 } else { | 1617 } else { |
| 1642 ASSERT(instr->representation().IsSmiOrTagged()); | |
| 1643 return DoArithmeticT(Token::SUB, instr); | 1618 return DoArithmeticT(Token::SUB, instr); |
| 1644 } | 1619 } |
| 1645 } | 1620 } |
| 1646 | 1621 |
| 1647 | 1622 |
| 1648 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1623 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
| 1649 if (instr->representation().IsSmiOrInteger32()) { | 1624 if (instr->representation().IsSmiOrInteger32()) { |
| 1650 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1625 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1651 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1626 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1652 // 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1664 LInstruction* result = use_lea | 1639 LInstruction* result = use_lea |
| 1665 ? DefineAsRegister(add) | 1640 ? DefineAsRegister(add) |
| 1666 : DefineSameAsFirst(add); | 1641 : DefineSameAsFirst(add); |
| 1667 if (can_overflow) { | 1642 if (can_overflow) { |
| 1668 result = AssignEnvironment(result); | 1643 result = AssignEnvironment(result); |
| 1669 } | 1644 } |
| 1670 return result; | 1645 return result; |
| 1671 } else if (instr->representation().IsDouble()) { | 1646 } else if (instr->representation().IsDouble()) { |
| 1672 return DoArithmeticD(Token::ADD, instr); | 1647 return DoArithmeticD(Token::ADD, instr); |
| 1673 } else { | 1648 } else { |
| 1674 ASSERT(instr->representation().IsSmiOrTagged()); | |
| 1675 return DoArithmeticT(Token::ADD, instr); | 1649 return DoArithmeticT(Token::ADD, instr); |
| 1676 } | 1650 } |
| 1677 } | 1651 } |
| 1678 | 1652 |
| 1679 | 1653 |
| 1680 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1654 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
| 1681 LOperand* left = NULL; | 1655 LOperand* left = NULL; |
| 1682 LOperand* right = NULL; | 1656 LOperand* right = NULL; |
| 1683 if (instr->representation().IsSmiOrInteger32()) { | 1657 if (instr->representation().IsSmiOrInteger32()) { |
| 1684 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1658 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1708 UseFixedDouble(instr->right(), xmm1) : | 1682 UseFixedDouble(instr->right(), xmm1) : |
| 1709 UseFixed(instr->right(), eax); | 1683 UseFixed(instr->right(), eax); |
| 1710 LPower* result = new(zone()) LPower(left, right); | 1684 LPower* result = new(zone()) LPower(left, right); |
| 1711 return MarkAsCall(DefineFixedDouble(result, xmm3), instr, | 1685 return MarkAsCall(DefineFixedDouble(result, xmm3), instr, |
| 1712 CAN_DEOPTIMIZE_EAGERLY); | 1686 CAN_DEOPTIMIZE_EAGERLY); |
| 1713 } | 1687 } |
| 1714 | 1688 |
| 1715 | 1689 |
| 1716 LInstruction* LChunkBuilder::DoRandom(HRandom* instr) { | 1690 LInstruction* LChunkBuilder::DoRandom(HRandom* instr) { |
| 1717 ASSERT(instr->representation().IsDouble()); | 1691 ASSERT(instr->representation().IsDouble()); |
| 1718 ASSERT(instr->global_object()->representation().IsSmiOrTagged()); | 1692 ASSERT(instr->global_object()->representation().IsTagged()); |
| 1719 LOperand* global_object = UseFixed(instr->global_object(), eax); | 1693 LOperand* global_object = UseTempRegister(instr->global_object()); |
| 1720 LRandom* result = new(zone()) LRandom(global_object); | 1694 LOperand* scratch = TempRegister(); |
| 1721 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); | 1695 LOperand* scratch2 = TempRegister(); |
| 1696 LOperand* scratch3 = TempRegister(); |
| 1697 LRandom* result = new(zone()) LRandom( |
| 1698 global_object, scratch, scratch2, scratch3); |
| 1699 return DefineFixedDouble(result, xmm1); |
| 1722 } | 1700 } |
| 1723 | 1701 |
| 1724 | 1702 |
| 1725 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { | 1703 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { |
| 1726 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 1704 ASSERT(instr->left()->representation().IsSmiOrTagged()); |
| 1727 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 1705 ASSERT(instr->right()->representation().IsSmiOrTagged()); |
| 1728 LOperand* context = UseFixed(instr->context(), esi); | 1706 LOperand* context = UseFixed(instr->context(), esi); |
| 1729 LOperand* left = UseFixed(instr->left(), edx); | 1707 LOperand* left = UseFixed(instr->left(), edx); |
| 1730 LOperand* right = UseFixed(instr->right(), eax); | 1708 LOperand* right = UseFixed(instr->right(), eax); |
| 1731 LCmpT* result = new(zone()) LCmpT(context, left, right); | 1709 LCmpT* result = new(zone()) LCmpT(context, left, right); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 from = Representation::Tagged(); | 1914 from = Representation::Tagged(); |
| 1937 } | 1915 } |
| 1938 // Only mark conversions that might need to allocate as calling rather than | 1916 // Only mark conversions that might need to allocate as calling rather than |
| 1939 // all changes. This makes simple, non-allocating conversion not have to force | 1917 // all changes. This makes simple, non-allocating conversion not have to force |
| 1940 // building a stack frame. | 1918 // building a stack frame. |
| 1941 if (from.IsTagged()) { | 1919 if (from.IsTagged()) { |
| 1942 if (to.IsDouble()) { | 1920 if (to.IsDouble()) { |
| 1943 info()->MarkAsDeferredCalling(); | 1921 info()->MarkAsDeferredCalling(); |
| 1944 LOperand* value = UseRegister(instr->value()); | 1922 LOperand* value = UseRegister(instr->value()); |
| 1945 // Temp register only necessary for minus zero check. | 1923 // Temp register only necessary for minus zero check. |
| 1946 LOperand* temp = instr->deoptimize_on_minus_zero() | 1924 LOperand* temp = TempRegister(); |
| 1947 ? TempRegister() | |
| 1948 : NULL; | |
| 1949 LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); | 1925 LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); |
| 1950 return AssignEnvironment(DefineAsRegister(res)); | 1926 return AssignEnvironment(DefineAsRegister(res)); |
| 1951 } else if (to.IsSmi()) { | 1927 } else if (to.IsSmi()) { |
| 1952 HValue* val = instr->value(); | 1928 HValue* val = instr->value(); |
| 1953 LOperand* value = UseRegister(val); | 1929 LOperand* value = UseRegister(val); |
| 1954 if (val->type().IsSmi()) { | 1930 if (val->type().IsSmi()) { |
| 1955 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1931 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1956 } | 1932 } |
| 1957 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); | 1933 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); |
| 1958 } else { | 1934 } else { |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2744 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2720 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2745 LOperand* object = UseRegister(instr->object()); | 2721 LOperand* object = UseRegister(instr->object()); |
| 2746 LOperand* index = UseTempRegister(instr->index()); | 2722 LOperand* index = UseTempRegister(instr->index()); |
| 2747 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2723 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2748 } | 2724 } |
| 2749 | 2725 |
| 2750 | 2726 |
| 2751 } } // namespace v8::internal | 2727 } } // namespace v8::internal |
| 2752 | 2728 |
| 2753 #endif // V8_TARGET_ARCH_IA32 | 2729 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |