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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 836 |
837 void HNumericConstraint::PrintDataTo(StringStream* stream) { | 837 void HNumericConstraint::PrintDataTo(StringStream* stream) { |
838 stream->Add("("); | 838 stream->Add("("); |
839 constrained_value()->PrintNameTo(stream); | 839 constrained_value()->PrintNameTo(stream); |
840 stream->Add(" %s ", relation().Mnemonic()); | 840 stream->Add(" %s ", relation().Mnemonic()); |
841 related_value()->PrintNameTo(stream); | 841 related_value()->PrintNameTo(stream); |
842 stream->Add(")"); | 842 stream->Add(")"); |
843 } | 843 } |
844 | 844 |
845 | 845 |
| 846 HInductionVariable* HInductionVariable::AddToGraph(HPhi* phi, |
| 847 NumericRelation relation, |
| 848 int operand_index) { |
| 849 HInductionVariable* result = new(phi->block()->zone()) HInductionVariable( |
| 850 phi, relation, operand_index); |
| 851 result->InsertAfter(phi->block()->first()); |
| 852 return result; |
| 853 } |
| 854 |
| 855 |
| 856 void HInductionVariable::PrintDataTo(StringStream* stream) { |
| 857 stream->Add("("); |
| 858 RedefinedOperand()->PrintNameTo(stream); |
| 859 stream->Add(" %s ", relation().Mnemonic()); |
| 860 induction_base()->PrintNameTo(stream); |
| 861 stream->Add(")"); |
| 862 } |
| 863 |
| 864 |
846 void HDummyUse::PrintDataTo(StringStream* stream) { | 865 void HDummyUse::PrintDataTo(StringStream* stream) { |
847 value()->PrintNameTo(stream); | 866 value()->PrintNameTo(stream); |
848 } | 867 } |
849 | 868 |
850 | 869 |
851 void HUnaryCall::PrintDataTo(StringStream* stream) { | 870 void HUnaryCall::PrintDataTo(StringStream* stream) { |
852 value()->PrintNameTo(stream); | 871 value()->PrintNameTo(stream); |
853 stream->Add(" "); | 872 stream->Add(" "); |
854 stream->Add("#%d", argument_count()); | 873 stream->Add("#%d", argument_count()); |
855 } | 874 } |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 } | 1566 } |
1548 return result; | 1567 return result; |
1549 } else { | 1568 } else { |
1550 return HValue::InferRange(zone); | 1569 return HValue::InferRange(zone); |
1551 } | 1570 } |
1552 } | 1571 } |
1553 | 1572 |
1554 | 1573 |
1555 void HPhi::AddInformativeDefinitions() { | 1574 void HPhi::AddInformativeDefinitions() { |
1556 if (OperandCount() == 2) { | 1575 if (OperandCount() == 2) { |
| 1576 // If one of the operands is an OSR block give up (this cannot be an |
| 1577 // induction variable). |
| 1578 if (OperandAt(0)->block()->is_osr_entry() || |
| 1579 OperandAt(1)->block()->is_osr_entry()) return; |
| 1580 |
1557 for (int operand_index = 0; operand_index < 2; operand_index++) { | 1581 for (int operand_index = 0; operand_index < 2; operand_index++) { |
1558 int other_operand_index = (operand_index + 1) % 2; | 1582 int other_operand_index = (operand_index + 1) % 2; |
1559 | 1583 |
1560 // Add an idef that "discards" the OSR entry block branch. | |
1561 if (OperandAt(operand_index)->block()->is_osr_entry()) { | |
1562 HNumericConstraint::AddToGraph( | |
1563 this, NumericRelation::Eq(), OperandAt(other_operand_index)); | |
1564 } | |
1565 | |
1566 static NumericRelation relations[] = { | 1584 static NumericRelation relations[] = { |
1567 NumericRelation::Ge(), | 1585 NumericRelation::Ge(), |
1568 NumericRelation::Le() | 1586 NumericRelation::Le() |
1569 }; | 1587 }; |
1570 | 1588 |
1571 // Check if this phi is an induction variable. If, e.g., we know that | 1589 // Check if this phi is an induction variable. If, e.g., we know that |
1572 // its first input is greater than the phi itself, then that must be | 1590 // its first input is greater than the phi itself, then that must be |
1573 // the back edge, and the phi is always greater than its second input. | 1591 // the back edge, and the phi is always greater than its second input. |
1574 for (int relation_index = 0; relation_index < 2; relation_index++) { | 1592 for (int relation_index = 0; relation_index < 2; relation_index++) { |
1575 if (OperandAt(operand_index)->IsRelationTrue(relations[relation_index], | 1593 if (OperandAt(operand_index)->IsRelationTrue(relations[relation_index], |
1576 this)) { | 1594 this)) { |
1577 HNumericConstraint::AddToGraph(this, | 1595 HInductionVariable::AddToGraph(this, |
1578 relations[relation_index], | 1596 relations[relation_index], |
1579 OperandAt(other_operand_index)); | 1597 other_operand_index); |
1580 } | 1598 } |
1581 } | 1599 } |
1582 } | 1600 } |
1583 } | 1601 } |
1584 } | 1602 } |
1585 | 1603 |
1586 | 1604 |
| 1605 bool HPhi::IsRelationTrueInternal(NumericRelation relation, HValue* other) { |
| 1606 if (CheckFlag(kNumericConstraintEvaluationInProgress)) return false; |
| 1607 |
| 1608 SetFlag(kNumericConstraintEvaluationInProgress); |
| 1609 bool result = true; |
| 1610 for (int i = 0; i < OperandCount(); i++) { |
| 1611 // Skip OSR entry blocks |
| 1612 if (OperandAt(i)->block()->is_osr_entry()) continue; |
| 1613 |
| 1614 if (!OperandAt(i)->IsRelationTrue(relation, other)) { |
| 1615 result = false; |
| 1616 break; |
| 1617 } |
| 1618 } |
| 1619 ClearFlag(kNumericConstraintEvaluationInProgress); |
| 1620 |
| 1621 return result; |
| 1622 } |
| 1623 |
| 1624 |
1587 Range* HMathMinMax::InferRange(Zone* zone) { | 1625 Range* HMathMinMax::InferRange(Zone* zone) { |
1588 if (representation().IsInteger32()) { | 1626 if (representation().IsInteger32()) { |
1589 Range* a = left()->range(); | 1627 Range* a = left()->range(); |
1590 Range* b = right()->range(); | 1628 Range* b = right()->range(); |
1591 Range* res = a->Copy(zone); | 1629 Range* res = a->Copy(zone); |
1592 if (operation_ == kMathMax) { | 1630 if (operation_ == kMathMax) { |
1593 res->CombinedMax(b); | 1631 res->CombinedMax(b); |
1594 } else { | 1632 } else { |
1595 ASSERT(operation_ == kMathMin); | 1633 ASSERT(operation_ == kMathMin); |
1596 res->CombinedMin(b); | 1634 res->CombinedMin(b); |
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3060 | 3098 |
3061 | 3099 |
3062 void HCheckFunction::Verify() { | 3100 void HCheckFunction::Verify() { |
3063 HInstruction::Verify(); | 3101 HInstruction::Verify(); |
3064 ASSERT(HasNoUses()); | 3102 ASSERT(HasNoUses()); |
3065 } | 3103 } |
3066 | 3104 |
3067 #endif | 3105 #endif |
3068 | 3106 |
3069 } } // namespace v8::internal | 3107 } } // namespace v8::internal |
OLD | NEW |