| 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 interface HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBailoutTarget(HBailoutTarget node); | 7 R visitBailoutTarget(HBailoutTarget node); |
| 8 R visitBitAnd(HBitAnd node); | 8 R visitBitAnd(HBitAnd node); |
| 9 R visitBitNot(HBitNot node); | 9 R visitBitNot(HBitNot node); |
| 10 R visitBitOr(HBitOr node); | 10 R visitBitOr(HBitOr node); |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 if (oldInputUsers[i] == this) { | 925 if (oldInputUsers[i] == this) { |
| 926 oldInputUsers[i] = oldInputUsers[oldInput.usedBy.length - 1]; | 926 oldInputUsers[i] = oldInputUsers[oldInput.usedBy.length - 1]; |
| 927 oldInputUsers.length--; | 927 oldInputUsers.length--; |
| 928 } else { | 928 } else { |
| 929 i++; | 929 i++; |
| 930 } | 930 } |
| 931 } | 931 } |
| 932 } | 932 } |
| 933 | 933 |
| 934 // Compute the set of users of this instruction that is dominated by | 934 // Compute the set of users of this instruction that is dominated by |
| 935 // [other]. | 935 // [other]. If [other] is a user of [this], it is included in the |
| 936 // returned set. |
| 936 Set<HInstruction> dominatedUsers(HInstruction other) { | 937 Set<HInstruction> dominatedUsers(HInstruction other) { |
| 937 // Keep track of all instructions that we have to deal with later | 938 // Keep track of all instructions that we have to deal with later |
| 938 // and count the number of them that are in the current block. | 939 // and count the number of them that are in the current block. |
| 939 Set<HInstruction> users = new Set<HInstruction>(); | 940 Set<HInstruction> users = new Set<HInstruction>(); |
| 940 int usersInCurrentBlock = 0; | 941 int usersInCurrentBlock = 0; |
| 941 | 942 |
| 942 // Run through all the users and see if they are dominated or | 943 // Run through all the users and see if they are dominated or |
| 943 // potentially dominated by [other]. | 944 // potentially dominated by [other]. |
| 944 HBasicBlock otherBlock = other.block; | 945 HBasicBlock otherBlock = other.block; |
| 945 for (int i = 0, length = usedBy.length; i < length; i++) { | 946 for (int i = 0, length = usedBy.length; i < length; i++) { |
| 946 HInstruction current = usedBy[i]; | 947 HInstruction current = usedBy[i]; |
| 947 if (current !== other && otherBlock.dominates(current.block)) { | 948 if (otherBlock.dominates(current.block)) { |
| 948 if (current.block === otherBlock) usersInCurrentBlock++; | 949 if (current.block === otherBlock) usersInCurrentBlock++; |
| 949 users.add(current); | 950 users.add(current); |
| 950 } | 951 } |
| 951 } | 952 } |
| 952 | 953 |
| 953 // Run through all the phis in the same block as [other] and remove them | 954 // Run through all the phis in the same block as [other] and remove them |
| 954 // from the users set. | 955 // from the users set. |
| 955 if (usersInCurrentBlock > 0) { | 956 if (usersInCurrentBlock > 0) { |
| 956 for (HPhi phi = otherBlock.phis.first; phi !== null; phi = phi.next) { | 957 for (HPhi phi = otherBlock.phis.first; phi !== null; phi = phi.next) { |
| 957 if (users.contains(phi)) { | 958 if (users.contains(phi)) { |
| (...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 HBasicBlock get start() => expression.start; | 2743 HBasicBlock get start() => expression.start; |
| 2743 HBasicBlock get end() { | 2744 HBasicBlock get end() { |
| 2744 // We don't create a switch block if there are no cases. | 2745 // We don't create a switch block if there are no cases. |
| 2745 assert(!statements.isEmpty()); | 2746 assert(!statements.isEmpty()); |
| 2746 return statements.last().end; | 2747 return statements.last().end; |
| 2747 } | 2748 } |
| 2748 | 2749 |
| 2749 bool accept(HStatementInformationVisitor visitor) => | 2750 bool accept(HStatementInformationVisitor visitor) => |
| 2750 visitor.visitSwitchInfo(this); | 2751 visitor.visitSwitchInfo(this); |
| 2751 } | 2752 } |
| OLD | NEW |