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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 bool contains(T x) => map.containsKey(x); 122 bool contains(T x) => map.containsKey(x);
123 123
124 bool remove(T x) => map.remove(x) != null; 124 bool remove(T x) => map.remove(x) != null;
125 125
126 bool get isEmpty => map.isEmpty; 126 bool get isEmpty => map.isEmpty;
127 127
128 void forEach(f) => map.keys.forEach(f); 128 void forEach(f) => map.keys.forEach(f);
129 129
130 T get first => map.keys.iterator().next(); 130 T get first {
131 var iterator = map.keys.iterator;
132 if (!iterator.moveNext()) throw new StateError("No elements");
133 return iterator.current;
134 }
131 135
132 get length => map.length; 136 get length => map.length;
133 } 137 }
134 138
135 typedef void ElementAction(Element element); 139 typedef void ElementAction(Element element);
136 140
137 abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { 141 abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
138 /** 142 /**
139 * Returned by [expressionType] to tell how code can be generated for 143 * Returned by [expressionType] to tell how code can be generated for
140 * a subgraph. 144 * a subgraph.
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 } 1140 }
1137 1141
1138 void emitAssignment(String destination, String source) { 1142 void emitAssignment(String destination, String source) {
1139 assignVariable(destination, new js.VariableUse(source)); 1143 assignVariable(destination, new js.VariableUse(source));
1140 } 1144 }
1141 1145
1142 /** 1146 /**
1143 * Sequentialize a list of conceptually parallel copies. Parallel 1147 * Sequentialize a list of conceptually parallel copies. Parallel
1144 * copies may contain cycles, that this method breaks. 1148 * copies may contain cycles, that this method breaks.
1145 */ 1149 */
1146 void sequentializeCopies(List<Copy> copies, 1150 void sequentializeCopies(Iterable<Copy> copies,
1147 String tempName, 1151 String tempName,
1148 void doAssignment(String target, String source)) { 1152 void doAssignment(String target, String source)) {
1149 // Map to keep track of the current location (ie the variable that 1153 // Map to keep track of the current location (ie the variable that
1150 // holds the initial value) of a variable. 1154 // holds the initial value) of a variable.
1151 Map<String, String> currentLocation = new Map<String, String>(); 1155 Map<String, String> currentLocation = new Map<String, String>();
1152 1156
1153 // Map to keep track of the initial value of a variable. 1157 // Map to keep track of the initial value of a variable.
1154 Map<String, String> initialValue = new Map<String, String>(); 1158 Map<String, String> initialValue = new Map<String, String>();
1155 1159
1156 // List of variables to assign a value. 1160 // List of variables to assign a value.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 ready.add(current); 1223 ready.add(current);
1220 } 1224 }
1221 } 1225 }
1222 } 1226 }
1223 1227
1224 void assignPhisOfSuccessors(HBasicBlock node) { 1228 void assignPhisOfSuccessors(HBasicBlock node) {
1225 CopyHandler handler = variableNames.getCopyHandler(node); 1229 CopyHandler handler = variableNames.getCopyHandler(node);
1226 if (handler == null) return; 1230 if (handler == null) return;
1227 1231
1228 // Map the instructions to strings. 1232 // Map the instructions to strings.
1229 List<Copy> copies = handler.copies.map((Copy copy) { 1233 Iterable<Copy> copies = handler.copies.mappedBy((Copy copy) {
1230 return new Copy(variableNames.getName(copy.source), 1234 return new Copy(variableNames.getName(copy.source),
1231 variableNames.getName(copy.destination)); 1235 variableNames.getName(copy.destination));
1232 }); 1236 });
1233 1237
1234 sequentializeCopies(copies, variableNames.getSwapTemp(), emitAssignment); 1238 sequentializeCopies(copies, variableNames.getSwapTemp(), emitAssignment);
1235 1239
1236 for (Copy copy in handler.assignments) { 1240 for (Copy copy in handler.assignments) {
1237 String name = variableNames.getName(copy.destination); 1241 String name = variableNames.getName(copy.destination);
1238 use(copy.source); 1242 use(copy.source);
1239 assignVariable(name, pop()); 1243 assignVariable(name, pop());
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
3040 if (leftType.canBeNull() && rightType.canBeNull()) { 3044 if (leftType.canBeNull() && rightType.canBeNull()) {
3041 if (left.isConstantNull() || right.isConstantNull() || 3045 if (left.isConstantNull() || right.isConstantNull() ||
3042 (leftType.isPrimitive() && leftType == rightType)) { 3046 (leftType.isPrimitive() && leftType == rightType)) {
3043 return '=='; 3047 return '==';
3044 } 3048 }
3045 return null; 3049 return null;
3046 } else { 3050 } else {
3047 return '==='; 3051 return '===';
3048 } 3052 }
3049 } 3053 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698