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 HVisitor<R> { | 7 abstract class HVisitor<R> { |
8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
9 R visitBailoutTarget(HBailoutTarget node); | 9 R visitBailoutTarget(HBailoutTarget node); |
10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 to.usedBy.addAll(from.usedBy); | 613 to.usedBy.addAll(from.usedBy); |
614 from.usedBy.clear(); | 614 from.usedBy.clear(); |
615 } | 615 } |
616 | 616 |
617 /** | 617 /** |
618 * Rewrites all uses of the [from] instruction to using either the | 618 * Rewrites all uses of the [from] instruction to using either the |
619 * [to] instruction, or a [HCheck] instruction that has better type | 619 * [to] instruction, or a [HCheck] instruction that has better type |
620 * information on [to], and that dominates the user. | 620 * information on [to], and that dominates the user. |
621 */ | 621 */ |
622 void rewriteWithBetterUser(HInstruction from, HInstruction to) { | 622 void rewriteWithBetterUser(HInstruction from, HInstruction to) { |
| 623 // BUG(11841): Turn this method into a phase to be run after GVN phases. |
623 Link<HCheck> better = const Link<HCheck>(); | 624 Link<HCheck> better = const Link<HCheck>(); |
624 for (HInstruction user in to.usedBy) { | 625 for (HInstruction user in to.usedBy) { |
625 if (user == from || user is! HCheck) continue; | 626 if (user == from || user is! HCheck) continue; |
626 HCheck check = user; | 627 HCheck check = user; |
627 if (check.checkedInput == to) { | 628 if (check.checkedInput == to) { |
628 better = better.prepend(user); | 629 better = better.prepend(user); |
629 } | 630 } |
630 } | 631 } |
631 | 632 |
632 if (better.isEmpty) return rewrite(from, to); | 633 if (better.isEmpty) return rewrite(from, to); |
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 HBasicBlock get start => expression.start; | 2713 HBasicBlock get start => expression.start; |
2713 HBasicBlock get end { | 2714 HBasicBlock get end { |
2714 // We don't create a switch block if there are no cases. | 2715 // We don't create a switch block if there are no cases. |
2715 assert(!statements.isEmpty); | 2716 assert(!statements.isEmpty); |
2716 return statements.last.end; | 2717 return statements.last.end; |
2717 } | 2718 } |
2718 | 2719 |
2719 bool accept(HStatementInformationVisitor visitor) => | 2720 bool accept(HStatementInformationVisitor visitor) => |
2720 visitor.visitSwitchInfo(this); | 2721 visitor.visitSwitchInfo(this); |
2721 } | 2722 } |
OLD | NEW |