OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 } | 1806 } |
1807 } | 1807 } |
1808 | 1808 |
1809 | 1809 |
1810 void HGraph::InsertRepresentationChangeForUse(HValue* value, | 1810 void HGraph::InsertRepresentationChangeForUse(HValue* value, |
1811 HValue* use, | 1811 HValue* use, |
1812 Representation to, | 1812 Representation to, |
1813 bool is_truncating) { | 1813 bool is_truncating) { |
1814 // Insert the representation change right before its use. For phi-uses we | 1814 // Insert the representation change right before its use. For phi-uses we |
1815 // insert at the end of the corresponding predecessor. | 1815 // insert at the end of the corresponding predecessor. |
1816 HBasicBlock* insert_block = use->block(); | 1816 HInstruction* next = NULL; |
1817 if (use->IsPhi()) { | 1817 if (use->IsPhi()) { |
1818 int index = 0; | 1818 int index = 0; |
1819 while (use->OperandAt(index) != value) ++index; | 1819 while (use->OperandAt(index) != value) ++index; |
1820 insert_block = insert_block->predecessors()->at(index); | 1820 next = use->block()->predecessors()->at(index)->end(); |
| 1821 } else { |
| 1822 next = HInstruction::cast(use); |
1821 } | 1823 } |
1822 | 1824 |
1823 HInstruction* next = (insert_block == use->block()) | |
1824 ? HInstruction::cast(use) | |
1825 : insert_block->end(); | |
1826 | |
1827 // For constants we try to make the representation change at compile | 1825 // For constants we try to make the representation change at compile |
1828 // time. When a representation change is not possible without loss of | 1826 // time. When a representation change is not possible without loss of |
1829 // information we treat constants like normal instructions and insert the | 1827 // information we treat constants like normal instructions and insert the |
1830 // change instructions for them. | 1828 // change instructions for them. |
1831 HInstruction* new_value = NULL; | 1829 HInstruction* new_value = NULL; |
1832 if (value->IsConstant()) { | 1830 if (value->IsConstant()) { |
1833 HConstant* constant = HConstant::cast(value); | 1831 HConstant* constant = HConstant::cast(value); |
1834 // Try to create a new copy of the constant with the new representation. | 1832 // Try to create a new copy of the constant with the new representation. |
1835 new_value = is_truncating | 1833 new_value = is_truncating |
1836 ? constant->CopyToTruncatedInt32() | 1834 ? constant->CopyToTruncatedInt32() |
(...skipping 4141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5978 } | 5976 } |
5979 } | 5977 } |
5980 | 5978 |
5981 #ifdef DEBUG | 5979 #ifdef DEBUG |
5982 if (graph_ != NULL) graph_->Verify(); | 5980 if (graph_ != NULL) graph_->Verify(); |
5983 if (allocator_ != NULL) allocator_->Verify(); | 5981 if (allocator_ != NULL) allocator_->Verify(); |
5984 #endif | 5982 #endif |
5985 } | 5983 } |
5986 | 5984 |
5987 } } // namespace v8::internal | 5985 } } // namespace v8::internal |
OLD | NEW |