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

Side by Side Diff: lib/compiler/implementation/ssa/optimize.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 OptimizationPhase { 5 interface OptimizationPhase {
6 String get name(); 6 String get name();
7 void visitGraph(HGraph graph); 7 void visitGraph(HGraph graph);
8 } 8 }
9 9
10 class SsaOptimizerTask extends CompilerTask { 10 class SsaOptimizerTask extends CompilerTask {
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 node.block.addBefore(node, length); 675 node.block.addBefore(node, length);
676 676
677 HBoundsCheck check = new HBoundsCheck(index, length); 677 HBoundsCheck check = new HBoundsCheck(index, length);
678 node.block.addBefore(node, check); 678 node.block.addBefore(node, check);
679 return check; 679 return check;
680 } 680 }
681 681
682 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { 682 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) {
683 HIntegerCheck check = new HIntegerCheck(value); 683 HIntegerCheck check = new HIntegerCheck(value);
684 node.block.addBefore(node, check); 684 node.block.addBefore(node, check);
685 Set<HInstruction> dominatedUsers = value.dominatedUsers(check); 685 Set<HInstruction> dominatedUsers = value.dominatedUsers(node);
686 for (HInstruction user in dominatedUsers) { 686 for (HInstruction user in dominatedUsers) {
687 user.changeUse(value, check); 687 user.changeUse(value, check);
688 } 688 }
689 return check; 689 return check;
690 } 690 }
691 691
692 void visitIndex(HIndex node) { 692 void visitIndex(HIndex node) {
693 if (!node.receiver.isIndexablePrimitive(types)) return; 693 if (!node.receiver.isIndexablePrimitive(types)) return;
694 HInstruction index = node.index; 694 HInstruction index = node.index;
695 if (index is HBoundsCheck) return; 695 if (index is HBoundsCheck) return;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 void visitGraph(HGraph graph) { 1128 void visitGraph(HGraph graph) {
1129 visitDominatorTree(graph); 1129 visitDominatorTree(graph);
1130 } 1130 }
1131 1131
1132 1132
1133 // Update users of [input] that are dominated by [:dominator.first:] 1133 // Update users of [input] that are dominated by [:dominator.first:]
1134 // to use [newInput] instead. 1134 // to use [newInput] instead.
1135 void changeUsesDominatedBy(HBasicBlock dominator, 1135 void changeUsesDominatedBy(HBasicBlock dominator,
1136 HInstruction input, 1136 HInstruction input,
1137 HType convertedType) { 1137 HType convertedType) {
1138 HTypeConversion newInput;
1139 Set<HInstruction> dominatedUsers = input.dominatedUsers(dominator.first); 1138 Set<HInstruction> dominatedUsers = input.dominatedUsers(dominator.first);
1140 for (HInstruction user in dominatedUsers) { 1139 if (dominatedUsers.isEmpty()) return;
1141 if (newInput === null) { 1140
1142 newInput = new HTypeConversion(convertedType, input); 1141 HTypeConversion newInput = new HTypeConversion(convertedType, input);
1143 dominator.addBefore(dominator.first, newInput); 1142 dominator.addBefore(dominator.first, newInput);
1144 } 1143 dominatedUsers.forEach((HInstruction user) {
1145 user.changeUse(input, newInput); 1144 user.changeUse(input, newInput);
1146 } 1145 });
1147 } 1146 }
1148 1147
1149 void visitIs(HIs instruction) { 1148 void visitIs(HIs instruction) {
1150 HInstruction input = instruction.expression; 1149 HInstruction input = instruction.expression;
1151 HType convertedType = 1150 HType convertedType =
1152 new HType.fromBoundedType(instruction.typeExpression, compiler); 1151 new HType.fromBoundedType(instruction.typeExpression, compiler);
1153 1152
1154 List<HInstruction> ifUsers = <HInstruction>[]; 1153 List<HInstruction> ifUsers = <HInstruction>[];
1155 List<HInstruction> notIfUsers = <HInstruction>[]; 1154 List<HInstruction> notIfUsers = <HInstruction>[];
1156 1155
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 // this type for the field is still a strong signal 1329 // this type for the field is still a strong signal
1331 // indicating the expected type of the field. 1330 // indicating the expected type of the field.
1332 types[field] = type; 1331 types[field] = type;
1333 } else { 1332 } else {
1334 // If there are no invoked setters we know the type of 1333 // If there are no invoked setters we know the type of
1335 // this field for sure. 1334 // this field for sure.
1336 field.guaranteedType = type; 1335 field.guaranteedType = type;
1337 } 1336 }
1338 } 1337 }
1339 } 1338 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/nodes.dart ('k') | lib/compiler/implementation/ssa/types_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698