| 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 import '../compiler.dart' show Compiler; | 5 import '../compiler.dart' show Compiler; |
| 6 import '../constants/values.dart'; | 6 import '../constants/values.dart'; |
| 7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
| 8 import '../js_backend/js_backend.dart'; | 8 import '../js_backend/js_backend.dart'; |
| 9 import '../types/types.dart'; | 9 import '../types/types.dart'; |
| 10 import '../universe/selector.dart' show Selector; | 10 import '../universe/selector.dart' show Selector; |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 for (HInstruction temp = block.first; | 663 for (HInstruction temp = block.first; |
| 664 !identical(temp, instruction); | 664 !identical(temp, instruction); |
| 665 temp = temp.next) { | 665 temp = temp.next) { |
| 666 if (!generateAtUseSite.contains(temp)) return true; | 666 if (!generateAtUseSite.contains(temp)) return true; |
| 667 } | 667 } |
| 668 | 668 |
| 669 return false; | 669 return false; |
| 670 } | 670 } |
| 671 | 671 |
| 672 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { | 672 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { |
| 673 // HForeignNew evaluates arguments in order and passes them to a | 673 // HCreate evaluates arguments in order and passes them to a constructor. |
| 674 // constructor. | 674 if (user is HCreate) return true; |
| 675 if (user is HForeignNew) return true; | 675 // A [HForeign] instruction uses operators and if we generate [input] at use |
| 676 // A [HForeign] instruction uses operators and if we generate | 676 // site, the precedence or evaluation order might be wrong. |
| 677 // [input] at use site, the precedence might be wrong. | |
| 678 if (user is HForeign) return false; | 677 if (user is HForeign) return false; |
| 679 // A [HCheck] instruction with control flow uses its input | 678 // A [HCheck] instruction with control flow uses its input |
| 680 // multiple times, so we avoid generating it at use site. | 679 // multiple times, so we avoid generating it at use site. |
| 681 if (user is HCheck && user.isControlFlow()) return false; | 680 if (user is HCheck && user.isControlFlow()) return false; |
| 682 // A [HIs] instruction uses its input multiple times, so we | 681 // A [HIs] instruction uses its input multiple times, so we |
| 683 // avoid generating it at use site. | 682 // avoid generating it at use site. |
| 684 if (user is HIs) return false; | 683 if (user is HIs) return false; |
| 685 return true; | 684 return true; |
| 686 } | 685 } |
| 687 | 686 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 } | 787 } |
| 789 | 788 |
| 790 // If [thenInput] is defined in the first predecessor, then it is only used | 789 // If [thenInput] is defined in the first predecessor, then it is only used |
| 791 // by [phi] and can be generated at use site. | 790 // by [phi] and can be generated at use site. |
| 792 if (identical(thenInput.block, end.predecessors[0])) { | 791 if (identical(thenInput.block, end.predecessors[0])) { |
| 793 assert(thenInput.usedBy.length == 1); | 792 assert(thenInput.usedBy.length == 1); |
| 794 markAsGenerateAtUseSite(thenInput); | 793 markAsGenerateAtUseSite(thenInput); |
| 795 } | 794 } |
| 796 } | 795 } |
| 797 } | 796 } |
| OLD | NEW |