| 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 /** | 7 /** |
| 8 * Replaces some instructions with specialized versions to make codegen easier. | 8 * Replaces some instructions with specialized versions to make codegen easier. |
| 9 * Caches codegen information on nodes. | 9 * Caches codegen information on nodes. |
| 10 */ | 10 */ |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 for (HInstruction temp = block.first; | 630 for (HInstruction temp = block.first; |
| 631 !identical(temp, instruction); | 631 !identical(temp, instruction); |
| 632 temp = temp.next) { | 632 temp = temp.next) { |
| 633 if (!generateAtUseSite.contains(temp)) return true; | 633 if (!generateAtUseSite.contains(temp)) return true; |
| 634 } | 634 } |
| 635 | 635 |
| 636 return false; | 636 return false; |
| 637 } | 637 } |
| 638 | 638 |
| 639 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { | 639 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { |
| 640 // HForeignNew evaluates arguments in order and passes them to a |
| 641 // constructor. |
| 642 if (user is HForeignNew) return true; |
| 640 // A [HForeign] instruction uses operators and if we generate | 643 // A [HForeign] instruction uses operators and if we generate |
| 641 // [input] at use site, the precedence might be wrong. | 644 // [input] at use site, the precedence might be wrong. |
| 642 if (user is HForeign) return false; | 645 if (user is HForeign) return false; |
| 643 // A [HCheck] instruction with control flow uses its input | 646 // A [HCheck] instruction with control flow uses its input |
| 644 // multiple times, so we avoid generating it at use site. | 647 // multiple times, so we avoid generating it at use site. |
| 645 if (user is HCheck && user.isControlFlow()) return false; | 648 if (user is HCheck && user.isControlFlow()) return false; |
| 646 // A [HIs] instruction uses its input multiple times, so we | 649 // A [HIs] instruction uses its input multiple times, so we |
| 647 // avoid generating it at use site. | 650 // avoid generating it at use site. |
| 648 if (user is HIs) return false; | 651 if (user is HIs) return false; |
| 649 return true; | 652 return true; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 } | 755 } |
| 753 | 756 |
| 754 // If [thenInput] is defined in the first predecessor, then it is only used | 757 // If [thenInput] is defined in the first predecessor, then it is only used |
| 755 // by [phi] and can be generated at use site. | 758 // by [phi] and can be generated at use site. |
| 756 if (identical(thenInput.block, end.predecessors[0])) { | 759 if (identical(thenInput.block, end.predecessors[0])) { |
| 757 assert(thenInput.usedBy.length == 1); | 760 assert(thenInput.usedBy.length == 1); |
| 758 markAsGenerateAtUseSite(thenInput); | 761 markAsGenerateAtUseSite(thenInput); |
| 759 } | 762 } |
| 760 } | 763 } |
| 761 } | 764 } |
| OLD | NEW |