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 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 // This method tries to specialize the representation type of the value | 1759 // This method tries to specialize the representation type of the value |
1760 // given as a parameter. The value is asked to infer its representation type | 1760 // given as a parameter. The value is asked to infer its representation type |
1761 // based on its inputs. If the inferred type is more specialized, then this | 1761 // based on its inputs. If the inferred type is more specialized, then this |
1762 // becomes the new representation type of the node. | 1762 // becomes the new representation type of the node. |
1763 void HInferRepresentation::InferBasedOnInputs(HValue* current) { | 1763 void HInferRepresentation::InferBasedOnInputs(HValue* current) { |
1764 Representation r = current->representation(); | 1764 Representation r = current->representation(); |
1765 if (r.IsSpecialization()) return; | 1765 if (r.IsSpecialization()) return; |
1766 ASSERT(current->CheckFlag(HValue::kFlexibleRepresentation)); | 1766 ASSERT(current->CheckFlag(HValue::kFlexibleRepresentation)); |
1767 Representation inferred = current->InferredRepresentation(); | 1767 Representation inferred = current->InferredRepresentation(); |
1768 if (inferred.IsSpecialization()) { | 1768 if (inferred.IsSpecialization()) { |
| 1769 if (FLAG_trace_representation) { |
| 1770 PrintF("Changing #%d representation %s -> %s based on inputs\n", |
| 1771 current->id(), |
| 1772 r.Mnemonic(), |
| 1773 inferred.Mnemonic()); |
| 1774 } |
1769 current->ChangeRepresentation(inferred); | 1775 current->ChangeRepresentation(inferred); |
1770 AddDependantsToWorklist(current); | 1776 AddDependantsToWorklist(current); |
1771 } | 1777 } |
1772 } | 1778 } |
1773 | 1779 |
1774 | 1780 |
1775 void HInferRepresentation::AddDependantsToWorklist(HValue* value) { | 1781 void HInferRepresentation::AddDependantsToWorklist(HValue* value) { |
1776 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) { | 1782 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) { |
1777 AddToWorklist(it.value()); | 1783 AddToWorklist(it.value()); |
1778 } | 1784 } |
1779 for (int i = 0; i < value->OperandCount(); ++i) { | 1785 for (int i = 0; i < value->OperandCount(); ++i) { |
1780 AddToWorklist(value->OperandAt(i)); | 1786 AddToWorklist(value->OperandAt(i)); |
1781 } | 1787 } |
1782 } | 1788 } |
1783 | 1789 |
1784 | 1790 |
1785 // This method calculates whether specializing the representation of the value | 1791 // This method calculates whether specializing the representation of the value |
1786 // given as the parameter has a benefit in terms of less necessary type | 1792 // given as the parameter has a benefit in terms of less necessary type |
1787 // conversions. If there is a benefit, then the representation of the value is | 1793 // conversions. If there is a benefit, then the representation of the value is |
1788 // specialized. | 1794 // specialized. |
1789 void HInferRepresentation::InferBasedOnUses(HValue* value) { | 1795 void HInferRepresentation::InferBasedOnUses(HValue* value) { |
1790 Representation r = value->representation(); | 1796 Representation r = value->representation(); |
1791 if (r.IsSpecialization() || value->HasNoUses()) return; | 1797 if (r.IsSpecialization() || value->HasNoUses()) return; |
1792 ASSERT(value->CheckFlag(HValue::kFlexibleRepresentation)); | 1798 ASSERT(value->CheckFlag(HValue::kFlexibleRepresentation)); |
1793 Representation new_rep = TryChange(value); | 1799 Representation new_rep = TryChange(value); |
1794 if (!new_rep.IsNone()) { | 1800 if (!new_rep.IsNone()) { |
1795 if (!value->representation().Equals(new_rep)) { | 1801 if (!value->representation().Equals(new_rep)) { |
| 1802 if (FLAG_trace_representation) { |
| 1803 PrintF("Changing #%d representation %s -> %s based on uses\n", |
| 1804 value->id(), |
| 1805 r.Mnemonic(), |
| 1806 new_rep.Mnemonic()); |
| 1807 } |
1796 value->ChangeRepresentation(new_rep); | 1808 value->ChangeRepresentation(new_rep); |
1797 AddDependantsToWorklist(value); | 1809 AddDependantsToWorklist(value); |
1798 } | 1810 } |
1799 } | 1811 } |
1800 } | 1812 } |
1801 | 1813 |
1802 | 1814 |
1803 Representation HInferRepresentation::TryChange(HValue* value) { | 1815 Representation HInferRepresentation::TryChange(HValue* value) { |
1804 // Array of use counts for each representation. | 1816 // Array of use counts for each representation. |
1805 int use_count[Representation::kNumRepresentations] = { 0 }; | 1817 int use_count[Representation::kNumRepresentations] = { 0 }; |
(...skipping 6300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8106 } | 8118 } |
8107 } | 8119 } |
8108 | 8120 |
8109 #ifdef DEBUG | 8121 #ifdef DEBUG |
8110 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 8122 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
8111 if (allocator_ != NULL) allocator_->Verify(); | 8123 if (allocator_ != NULL) allocator_->Verify(); |
8112 #endif | 8124 #endif |
8113 } | 8125 } |
8114 | 8126 |
8115 } } // namespace v8::internal | 8127 } } // namespace v8::internal |
OLD | NEW |