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

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

Issue 12374011: Fix bug 8841 by running the closure analyzer before compiling a field. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | tests/language/closure_in_field_initializer_test.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 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 * Run through the fields of [cls] and add their potential 1289 * Run through the fields of [cls] and add their potential
1290 * initializers. 1290 * initializers.
1291 * 1291 *
1292 * Invariant: [classElement] must be an implementation element. 1292 * Invariant: [classElement] must be an implementation element.
1293 */ 1293 */
1294 void buildFieldInitializers(ClassElement classElement, 1294 void buildFieldInitializers(ClassElement classElement,
1295 Map<Element, HInstruction> fieldValues) { 1295 Map<Element, HInstruction> fieldValues) {
1296 assert(invariant(classElement, classElement.isImplementation)); 1296 assert(invariant(classElement, classElement.isImplementation));
1297 classElement.forEachInstanceField( 1297 classElement.forEachInstanceField(
1298 (ClassElement enclosingClass, Element member) { 1298 (ClassElement enclosingClass, Element member) {
1299 TreeElements definitions = compiler.analyzeElement(member); 1299 compiler.withCurrentElement(member, () {
1300 Node node = member.parseNode(compiler); 1300 TreeElements definitions = compiler.analyzeElement(member);
1301 SendSet assignment = node.asSendSet(); 1301 Node node = member.parseNode(compiler);
1302 HInstruction value; 1302 SendSet assignment = node.asSendSet();
1303 if (assignment == null) { 1303 HInstruction value;
1304 value = graph.addConstantNull(constantSystem); 1304 if (assignment == null) {
1305 } else { 1305 value = graph.addConstantNull(constantSystem);
1306 Node right = assignment.arguments.head; 1306 } else {
1307 TreeElements savedElements = elements; 1307 Node right = assignment.arguments.head;
1308 elements = definitions; 1308 TreeElements savedElements = elements;
1309 right.accept(this); 1309 elements = definitions;
1310 elements = savedElements; 1310 // In case the field initializer uses closures, run the
1311 value = pop(); 1311 // closure to class mapper.
1312 } 1312 compiler.closureToClassMapper.computeClosureToClassMapping(
1313 fieldValues[member] = value; 1313 member, node, elements);
1314 right.accept(this);
1315 elements = savedElements;
1316 value = pop();
1317 }
1318 fieldValues[member] = value;
1319 });
1314 }, 1320 },
1315 includeBackendMembers: true, 1321 includeBackendMembers: true,
1316 includeSuperMembers: false); 1322 includeSuperMembers: false);
1317 } 1323 }
1318 1324
1319 1325
1320 /** 1326 /**
1321 * Build the factory function corresponding to the constructor 1327 * Build the factory function corresponding to the constructor
1322 * [functionElement]: 1328 * [functionElement]:
1323 * - Initialize fields with the values of the field initializers of the 1329 * - Initialize fields with the values of the field initializers of the
(...skipping 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after
4965 new HSubGraphBlockInformation(elseBranch.graph)); 4971 new HSubGraphBlockInformation(elseBranch.graph));
4966 4972
4967 HBasicBlock conditionStartBlock = conditionBranch.block; 4973 HBasicBlock conditionStartBlock = conditionBranch.block;
4968 conditionStartBlock.setBlockFlow(info, joinBlock); 4974 conditionStartBlock.setBlockFlow(info, joinBlock);
4969 SubGraph conditionGraph = conditionBranch.graph; 4975 SubGraph conditionGraph = conditionBranch.graph;
4970 HIf branch = conditionGraph.end.last; 4976 HIf branch = conditionGraph.end.last;
4971 assert(branch is HIf); 4977 assert(branch is HIf);
4972 branch.blockInformation = conditionStartBlock.blockFlow; 4978 branch.blockInformation = conditionStartBlock.blockFlow;
4973 } 4979 }
4974 } 4980 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/closure_in_field_initializer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698