Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: lib/compiler/implementation/ssa/nodes.dart

Issue 10824371: Add an optional parameter to the dominatedUsers function in case we want to analyze the whole block, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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] or [otherBlock].
936 Set<HInstruction> dominatedUsers(HInstruction other) { 936 Set<HInstruction> dominatedUsers(HInstruction other,
kasperl 2012/08/20 11:37:22 I'd prefer two different entry points for this:
937 [HBasicBlock otherBlock = null]) {
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;
942 if (otherBlock == null) otherBlock = other.block;
941 943
942 // Run through all the users and see if they are dominated or 944 // Run through all the users and see if they are dominated or
943 // potentially dominated by [other]. 945 // potentially dominated by [otherBlock].
kasperl 2012/08/20 11:37:22 Here you're adding all the users that are dominate
944 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 (current !== other && 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 otherBlock 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)) {
958 users.remove(phi); 959 users.remove(phi);
959 if (--usersInCurrentBlock == 0) break; 960 if (--usersInCurrentBlock == 0) break;
960 } 961 }
961 } 962 }
962 } 963 }
963 964
964 // Run through all the instructions before [other] and remove them 965 // Run through all the instructions before otherBlock and remove them
kasperl 2012/08/20 11:37:22 This should still be all instructions before [othe
965 // from the users set. 966 // from the users set.
966 if (usersInCurrentBlock > 0) { 967 if (other != null && usersInCurrentBlock > 0) {
967 HInstruction current = otherBlock.first; 968 HInstruction current = otherBlock.first;
968 while (current !== other) { 969 while (current !== other) {
969 if (users.contains(current)) { 970 if (users.contains(current)) {
970 users.remove(current); 971 users.remove(current);
971 if (--usersInCurrentBlock == 0) break; 972 if (--usersInCurrentBlock == 0) break;
972 } 973 }
973 current = current.next; 974 current = current.next;
974 } 975 }
975 } 976 }
976 977
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/optimize.dart » ('j') | lib/compiler/implementation/ssa/optimize.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698