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

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

Issue 11364212: Track the origin element of inlined arguments to super constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | dart/tests/language/inline_super_part.dart » ('j') | 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 class Interceptors { 7 class Interceptors {
8 Compiler compiler; 8 Compiler compiler;
9 Interceptors(Compiler this.compiler); 9 Interceptors(Compiler this.compiler);
10 10
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 if (!InlineWeeder.canBeInlined(functionExpression, newElements)) { 1136 if (!InlineWeeder.canBeInlined(functionExpression, newElements)) {
1137 return false; 1137 return false;
1138 } 1138 }
1139 1139
1140 InliningState state = enterInlinedMethod(function, selector, arguments); 1140 InliningState state = enterInlinedMethod(function, selector, arguments);
1141 functionExpression.body.accept(this); 1141 functionExpression.body.accept(this);
1142 leaveInlinedMethod(state); 1142 leaveInlinedMethod(state);
1143 return true; 1143 return true;
1144 } 1144 }
1145 1145
1146 inlinedFrom(Element element, f()) {
1147 return compiler.withCurrentElement(element, () {
1148 sourceElementStack.add(element);
1149 var result = f();
1150 sourceElementStack.removeLast();
1151 return result;
1152 });
1153 }
1154
1146 /** 1155 /**
1147 * Documentation wanted -- johnniwinther 1156 * Documentation wanted -- johnniwinther
1148 * 1157 *
1149 * Invariant: [constructor] and [constructors] must all be implementation 1158 * Invariant: [constructor] and [constructors] must all be implementation
1150 * elements. 1159 * elements.
1151 */ 1160 */
1152 void inlineSuperOrRedirect(FunctionElement constructor, 1161 void inlineSuperOrRedirect(FunctionElement constructor,
1153 Selector selector, 1162 Selector selector,
1154 Link<Node> arguments, 1163 Link<Node> arguments,
1155 List<FunctionElement> constructors, 1164 List<FunctionElement> constructors,
1156 Map<Element, HInstruction> fieldValues) { 1165 Map<Element, HInstruction> fieldValues,
1166 FunctionElement inlinedFromElement) {
1157 compiler.withCurrentElement(constructor, () { 1167 compiler.withCurrentElement(constructor, () {
1158 assert(invariant(constructor, constructor.isImplementation)); 1168 assert(invariant(constructor, constructor.isImplementation));
1159 constructors.addLast(constructor); 1169 constructors.addLast(constructor);
1160 1170
1161 List<HInstruction> compiledArguments = new List<HInstruction>(); 1171 List<HInstruction> compiledArguments = new List<HInstruction>();
1162 bool succeeded = addStaticSendArgumentsToList(selector, 1172 bool succeeded =
1163 arguments, 1173 inlinedFrom(inlinedFromElement,
1164 constructor, 1174 () => addStaticSendArgumentsToList(selector,
1165 compiledArguments); 1175 arguments,
1176 constructor,
1177 compiledArguments));
1166 if (!succeeded) { 1178 if (!succeeded) {
1167 // Non-matching super and redirects are compile-time errors and thus 1179 // Non-matching super and redirects are compile-time errors and thus
1168 // checked by the resolver. 1180 // checked by the resolver.
1169 compiler.internalError( 1181 compiler.internalError(
1170 "Parameters and arguments didn't match for super/redirect call", 1182 "Parameters and arguments didn't match for super/redirect call",
1171 element: constructor); 1183 element: constructor);
1172 } 1184 }
1173 1185
1174 sourceElementStack.add(constructor.enclosingElement); 1186 sourceElementStack.add(constructor.enclosingElement);
1175 buildFieldInitializers(constructor.enclosingElement.implementation, 1187 buildFieldInitializers(constructor.enclosingElement.implementation,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 assert(link.head is Send); 1252 assert(link.head is Send);
1241 if (link.head is !SendSet) { 1253 if (link.head is !SendSet) {
1242 // A super initializer or constructor redirection. 1254 // A super initializer or constructor redirection.
1243 Send call = link.head; 1255 Send call = link.head;
1244 assert(Initializers.isSuperConstructorCall(call) || 1256 assert(Initializers.isSuperConstructorCall(call) ||
1245 Initializers.isConstructorRedirect(call)); 1257 Initializers.isConstructorRedirect(call));
1246 FunctionElement target = elements[call]; 1258 FunctionElement target = elements[call];
1247 Selector selector = elements.getSelector(call); 1259 Selector selector = elements.getSelector(call);
1248 Link<Node> arguments = call.arguments; 1260 Link<Node> arguments = call.arguments;
1249 inlineSuperOrRedirect(target, selector, arguments, constructors, 1261 inlineSuperOrRedirect(target, selector, arguments, constructors,
1250 fieldValues); 1262 fieldValues, constructor);
1251 foundSuperOrRedirect = true; 1263 foundSuperOrRedirect = true;
1252 } else { 1264 } else {
1253 // A field initializer. 1265 // A field initializer.
1254 SendSet init = link.head; 1266 SendSet init = link.head;
1255 Link<Node> arguments = init.arguments; 1267 Link<Node> arguments = init.arguments;
1256 assert(!arguments.isEmpty && arguments.tail.isEmpty); 1268 assert(!arguments.isEmpty && arguments.tail.isEmpty);
1257 sourceElementStack.add(constructor); 1269 sourceElementStack.add(constructor);
1258 visit(arguments.head); 1270 visit(arguments.head);
1259 sourceElementStack.removeLast(); 1271 sourceElementStack.removeLast();
1260 fieldValues[elements[init]] = pop(); 1272 fieldValues[elements[init]] = pop();
(...skipping 13 matching lines...) Expand all
1274 new Selector.callDefaultConstructor(enclosingClass.getLibrary()); 1286 new Selector.callDefaultConstructor(enclosingClass.getLibrary());
1275 // TODO(johnniwinther): Should we find injected constructors as well? 1287 // TODO(johnniwinther): Should we find injected constructors as well?
1276 FunctionElement target = superClass.lookupConstructor(selector); 1288 FunctionElement target = superClass.lookupConstructor(selector);
1277 if (target == null) { 1289 if (target == null) {
1278 compiler.internalError("no default constructor available"); 1290 compiler.internalError("no default constructor available");
1279 } 1291 }
1280 inlineSuperOrRedirect(target.implementation, 1292 inlineSuperOrRedirect(target.implementation,
1281 selector, 1293 selector,
1282 const Link<Node>(), 1294 const Link<Node>(),
1283 constructors, 1295 constructors,
1284 fieldValues); 1296 fieldValues,
1297 constructor);
1285 } 1298 }
1286 } 1299 }
1287 } 1300 }
1288 1301
1289 /** 1302 /**
1290 * Run through the fields of [cls] and add their potential 1303 * Run through the fields of [cls] and add their potential
1291 * initializers. 1304 * initializers.
1292 * 1305 *
1293 * Invariant: [classElement] must be an implementation element. 1306 * Invariant: [classElement] must be an implementation element.
1294 */ 1307 */
(...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after
4760 new HSubGraphBlockInformation(elseBranch.graph)); 4773 new HSubGraphBlockInformation(elseBranch.graph));
4761 4774
4762 HBasicBlock conditionStartBlock = conditionBranch.block; 4775 HBasicBlock conditionStartBlock = conditionBranch.block;
4763 conditionStartBlock.setBlockFlow(info, joinBlock); 4776 conditionStartBlock.setBlockFlow(info, joinBlock);
4764 SubGraph conditionGraph = conditionBranch.graph; 4777 SubGraph conditionGraph = conditionBranch.graph;
4765 HIf branch = conditionGraph.end.last; 4778 HIf branch = conditionGraph.end.last;
4766 assert(branch is HIf); 4779 assert(branch is HIf);
4767 branch.blockInformation = conditionStartBlock.blockFlow; 4780 branch.blockInformation = conditionStartBlock.blockFlow;
4768 } 4781 }
4769 } 4782 }
OLDNEW
« no previous file with comments | « no previous file | dart/tests/language/inline_super_part.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698