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

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

Issue 11787023: Fix dart2js by copying keys of a map that is modified under us. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files for fixed tests. 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 library closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import "elements/elements.dart"; 7 import "elements/elements.dart";
8 import "dart2jslib.dart"; 8 import "dart2jslib.dart";
9 import "scanner/scannerlib.dart" show Token; 9 import "scanner/scannerlib.dart" show Token;
10 import "tree/tree.dart"; 10 import "tree/tree.dart";
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void updateClosures() { 252 void updateClosures() {
253 for (Expression closure in closures) { 253 for (Expression closure in closures) {
254 // The captured variables that need to be stored in a field of the closure 254 // The captured variables that need to be stored in a field of the closure
255 // class. 255 // class.
256 Set<Element> fieldCaptures = new Set<Element>(); 256 Set<Element> fieldCaptures = new Set<Element>();
257 Set<Element> boxes = new Set<Element>(); 257 Set<Element> boxes = new Set<Element>();
258 ClosureClassMap data = closureMappingCache[closure]; 258 ClosureClassMap data = closureMappingCache[closure];
259 Map<Element, Element> freeVariableMapping = data.freeVariableMapping; 259 Map<Element, Element> freeVariableMapping = data.freeVariableMapping;
260 // We get a copy of the keys and iterate over it, to avoid modifications 260 // We get a copy of the keys and iterate over it, to avoid modifications
261 // to the map while iterating over it. 261 // to the map while iterating over it.
262 freeVariableMapping.keys.forEach((Element fromElement) { 262 freeVariableMapping.keys.toList().forEach((Element fromElement) {
263 assert(fromElement == freeVariableMapping[fromElement]); 263 assert(fromElement == freeVariableMapping[fromElement]);
264 Element updatedElement = capturedVariableMapping[fromElement]; 264 Element updatedElement = capturedVariableMapping[fromElement];
265 assert(updatedElement != null); 265 assert(updatedElement != null);
266 if (fromElement == updatedElement) { 266 if (fromElement == updatedElement) {
267 assert(freeVariableMapping[fromElement] == updatedElement); 267 assert(freeVariableMapping[fromElement] == updatedElement);
268 assert(Elements.isLocal(updatedElement) 268 assert(Elements.isLocal(updatedElement)
269 || updatedElement.isTypeVariable()); 269 || updatedElement.isTypeVariable());
270 // The variable has not been boxed. 270 // The variable has not been boxed.
271 fieldCaptures.add(updatedElement); 271 fieldCaptures.add(updatedElement);
272 } else { 272 } else {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } 651 }
652 652
653 visitTryStatement(TryStatement node) { 653 visitTryStatement(TryStatement node) {
654 // TODO(ngeoffray): implement finer grain state. 654 // TODO(ngeoffray): implement finer grain state.
655 bool oldInTryStatement = inTryStatement; 655 bool oldInTryStatement = inTryStatement;
656 inTryStatement = true; 656 inTryStatement = true;
657 node.visitChildren(this); 657 node.visitChildren(this);
658 inTryStatement = oldInTryStatement; 658 inTryStatement = oldInTryStatement;
659 } 659 }
660 } 660 }
OLDNEW
« no previous file with comments | « samples/tests/samples/samples.status ('k') | tests/compiler/dart2js_extra/checked_accessor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698