| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 if (existing != null) { | 1642 if (existing != null) { |
| 1643 instruction.block.rewriteWithBetterUser(instruction, existing); | 1643 instruction.block.rewriteWithBetterUser(instruction, existing); |
| 1644 instruction.block.remove(instruction); | 1644 instruction.block.remove(instruction); |
| 1645 } else { | 1645 } else { |
| 1646 memorySet.registerKeyedValue(receiver, instruction.index, instruction); | 1646 memorySet.registerKeyedValue(receiver, instruction.index, instruction); |
| 1647 } | 1647 } |
| 1648 } | 1648 } |
| 1649 | 1649 |
| 1650 void visitIndexAssign(HIndexAssign instruction) { | 1650 void visitIndexAssign(HIndexAssign instruction) { |
| 1651 HInstruction receiver = instruction.receiver.nonCheck(); | 1651 HInstruction receiver = instruction.receiver.nonCheck(); |
| 1652 JavaScriptBackend backend = compiler.backend; | |
| 1653 // Typed arrays may narrow incoming values. | |
| 1654 if (backend.couldBeTypedArray(receiver.instructionType)) return; | |
| 1655 memorySet.registerKeyedValueUpdate( | 1652 memorySet.registerKeyedValueUpdate( |
| 1656 receiver, instruction.index, instruction.value); | 1653 receiver, instruction.index, instruction.value); |
| 1657 } | 1654 } |
| 1658 } | 1655 } |
| 1659 | 1656 |
| 1660 /** | 1657 /** |
| 1661 * Holds values of memory places. | 1658 * Holds values of memory places. |
| 1662 */ | 1659 */ |
| 1663 class MemorySet { | 1660 class MemorySet { |
| 1664 final Compiler compiler; | 1661 final Compiler compiler; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 HInstruction value) { | 1822 HInstruction value) { |
| 1826 nonEscapingReceivers.remove(value); | 1823 nonEscapingReceivers.remove(value); |
| 1827 keyedValues.forEach((key, values) { | 1824 keyedValues.forEach((key, values) { |
| 1828 if (mayAlias(receiver, key)) { | 1825 if (mayAlias(receiver, key)) { |
| 1829 values.forEach((otherIndex, otherValue) { | 1826 values.forEach((otherIndex, otherValue) { |
| 1830 if (mayAlias(index, otherIndex)) values[otherIndex] = null; | 1827 if (mayAlias(index, otherIndex)) values[otherIndex] = null; |
| 1831 }); | 1828 }); |
| 1832 } | 1829 } |
| 1833 }); | 1830 }); |
| 1834 | 1831 |
| 1832 JavaScriptBackend backend = compiler.backend; |
| 1833 // Typed arrays may narrow incoming values. |
| 1834 if (backend.couldBeTypedArray(receiver.instructionType)) return; |
| 1835 |
| 1835 Map<HInstruction, HInstruction> map = keyedValues.putIfAbsent( | 1836 Map<HInstruction, HInstruction> map = keyedValues.putIfAbsent( |
| 1836 receiver, () => <HInstruction, HInstruction> {}); | 1837 receiver, () => <HInstruction, HInstruction> {}); |
| 1837 map[index] = value; | 1838 map[index] = value; |
| 1838 } | 1839 } |
| 1839 | 1840 |
| 1840 /** | 1841 /** |
| 1841 * Returns the intersection between [this] and [other]. | 1842 * Returns the intersection between [this] and [other]. |
| 1842 */ | 1843 */ |
| 1843 MemorySet intersection(MemorySet other) { | 1844 MemorySet intersection(MemorySet other) { |
| 1844 MemorySet result = new MemorySet(compiler); | 1845 MemorySet result = new MemorySet(compiler); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 | 1884 |
| 1884 keyedValues.forEach((receiver, values) { | 1885 keyedValues.forEach((receiver, values) { |
| 1885 result.keyedValues[receiver] = | 1886 result.keyedValues[receiver] = |
| 1886 new Map<HInstruction, HInstruction>.from(values); | 1887 new Map<HInstruction, HInstruction>.from(values); |
| 1887 }); | 1888 }); |
| 1888 | 1889 |
| 1889 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 1890 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 1890 return result; | 1891 return result; |
| 1891 } | 1892 } |
| 1892 } | 1893 } |
| OLD | NEW |