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

Side by Side Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 1177603002: Include all allocations in trivial dead-store elimination (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of ssa; 5 part of ssa;
6 6
7 abstract class OptimizationPhase { 7 abstract class OptimizationPhase {
8 String get name; 8 String get name;
9 void visitGraph(HGraph graph); 9 void visitGraph(HGraph graph);
10 } 10 }
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 if (use is HFieldSet) { 1135 if (use is HFieldSet) {
1136 // The use must be the receiver. Even if the use is also the argument, 1136 // The use must be the receiver. Even if the use is also the argument,
1137 // i.e. a.x = a, the store is still dead if all other uses are dead. 1137 // i.e. a.x = a, the store is still dead if all other uses are dead.
1138 if (use.getDartReceiver(compiler) == instruction) return true; 1138 if (use.getDartReceiver(compiler) == instruction) return true;
1139 } else if (use is HFieldGet) { 1139 } else if (use is HFieldGet) {
1140 assert(use.getDartReceiver(compiler) == instruction); 1140 assert(use.getDartReceiver(compiler) == instruction);
1141 if (isDeadCode(use)) return true; 1141 if (isDeadCode(use)) return true;
1142 } 1142 }
1143 return false; 1143 return false;
1144 } 1144 }
1145 return instruction is HForeignNew 1145 return instruction.isAllocation
1146 && instruction.isPure()
1146 && trivialDeadStoreReceivers.putIfAbsent(instruction, 1147 && trivialDeadStoreReceivers.putIfAbsent(instruction,
1147 () => instruction.usedBy.every(isDeadUse)); 1148 () => instruction.usedBy.every(isDeadUse));
1148 } 1149 }
1149 1150
1150 bool isTrivialDeadStore(HInstruction instruction) { 1151 bool isTrivialDeadStore(HInstruction instruction) {
1151 return instruction is HFieldSet 1152 return instruction is HFieldSet
1152 && isTrivialDeadStoreReceiver(instruction.getDartReceiver(compiler)); 1153 && isTrivialDeadStoreReceiver(instruction.getDartReceiver(compiler));
1153 } 1154 }
1154 1155
1155 bool isDeadCode(HInstruction instruction) { 1156 bool isDeadCode(HInstruction instruction) {
1156 if (!instruction.usedBy.isEmpty) return false; 1157 if (!instruction.usedBy.isEmpty) return false;
1157 if (isTrivialDeadStore(instruction)) return true; 1158 if (isTrivialDeadStore(instruction)) return true;
1158 if (instruction.sideEffects.hasSideEffects()) return false; 1159 if (instruction.sideEffects.hasSideEffects()) return false;
1159 if (instruction.canThrow() 1160 if (instruction.canThrow() &&
1160 && instruction.onlyThrowsNSM() 1161 instruction.onlyThrowsNSM() &&
1161 && hasFollowingThrowingNSM(instruction)) { 1162 hasFollowingThrowingNSM(instruction)) {
1162 return true; 1163 return true;
1163 } 1164 }
1164 return !instruction.canThrow() 1165 return !instruction.canThrow()
1165 && instruction is !HParameterValue 1166 && instruction is !HParameterValue
1166 && instruction is !HLocalSet; 1167 && instruction is !HLocalSet;
1167 } 1168 }
1168 1169
1169 void visitGraph(HGraph graph) { 1170 void visitGraph(HGraph graph) {
1170 analyzer = new SsaLiveBlockAnalyzer(graph, compiler, optimizer); 1171 analyzer = new SsaLiveBlockAnalyzer(graph, compiler, optimizer);
1171 analyzer.analyze(); 1172 analyzer.analyze();
1172 visitPostDominatorTree(graph); 1173 visitPostDominatorTree(graph);
1173 cleanPhis(graph); 1174 cleanPhis(graph);
1174 } 1175 }
1175 1176
1176 void visitBasicBlock(HBasicBlock block) { 1177 void visitBasicBlock(HBasicBlock block) {
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 2296
2296 keyedValues.forEach((receiver, values) { 2297 keyedValues.forEach((receiver, values) {
2297 result.keyedValues[receiver] = 2298 result.keyedValues[receiver] =
2298 new Map<HInstruction, HInstruction>.from(values); 2299 new Map<HInstruction, HInstruction>.from(values);
2299 }); 2300 });
2300 2301
2301 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2302 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2302 return result; 2303 return result;
2303 } 2304 }
2304 } 2305 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698