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

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

Issue 223403003: Use closure tracer to identify closures that are not passed to Function.apply (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix regression in emitted meta data Created 6 years, 8 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 dart2js; 5 part of dart2js;
6 6
7 class World { 7 class World {
8 final Compiler compiler; 8 final Compiler compiler;
9 final FunctionSet allFunctions; 9 final FunctionSet allFunctions;
10 final Set<Element> functionsCalledInLoop = new Set<Element>(); 10 final Set<Element> functionsCalledInLoop = new Set<Element>();
(...skipping 11 matching lines...) Expand all
22 new Map<ClassElement, Set<ClassElement>>(); 22 new Map<ClassElement, Set<ClassElement>>();
23 final Map<ClassElement, Set<ClassElement>> _subtypes = 23 final Map<ClassElement, Set<ClassElement>> _subtypes =
24 new Map<ClassElement, Set<ClassElement>>(); 24 new Map<ClassElement, Set<ClassElement>>();
25 final Map<ClassElement, Set<ClassElement>> _supertypes = 25 final Map<ClassElement, Set<ClassElement>> _supertypes =
26 new Map<ClassElement, Set<ClassElement>>(); 26 new Map<ClassElement, Set<ClassElement>>();
27 27
28 final Set<Element> sideEffectsFreeElements = new Set<Element>(); 28 final Set<Element> sideEffectsFreeElements = new Set<Element>();
29 29
30 final Set<Element> elementsThatCannotThrow = new Set<Element>(); 30 final Set<Element> elementsThatCannotThrow = new Set<Element>();
31 31
32 final Set<Element> functionsThatMightBePassedToApply =
33 new Set<FunctionElement>();
34
32 Set<ClassElement> subclassesOf(ClassElement cls) { 35 Set<ClassElement> subclassesOf(ClassElement cls) {
33 return _subclasses[cls.declaration]; 36 return _subclasses[cls.declaration];
34 } 37 }
35 38
36 Set<ClassElement> subtypesOf(ClassElement cls) { 39 Set<ClassElement> subtypesOf(ClassElement cls) {
37 return _subtypes[cls.declaration]; 40 return _subtypes[cls.declaration];
38 } 41 }
39 42
40 Set<ClassElement> supertypesOf(ClassElement cls) { 43 Set<ClassElement> supertypesOf(ClassElement cls) {
41 return _supertypes[cls.declaration]; 44 return _supertypes[cls.declaration];
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return sideEffects; 269 return sideEffects;
267 } 270 }
268 271
269 void registerCannotThrow(Element element) { 272 void registerCannotThrow(Element element) {
270 elementsThatCannotThrow.add(element); 273 elementsThatCannotThrow.add(element);
271 } 274 }
272 275
273 bool getCannotThrow(Element element) { 276 bool getCannotThrow(Element element) {
274 return elementsThatCannotThrow.contains(element); 277 return elementsThatCannotThrow.contains(element);
275 } 278 }
279
280 void registerMightBePassedToApply(Element element) {
281 functionsThatMightBePassedToApply.add(element);
282 }
283
284 bool getMightBePassedToApply(Element element) {
285 // We have to check whether the element we look at was created after
286 // type inference ran. This is currently only the case for the call
287 // method of function classes that were generated for function
288 // expressions. In such a case, we have to look at the original
289 // function expressions's element.
290 // TODO(herhut): Generate classes for function expressions earlier.
291 if (element is SynthesizedCallMethodElementX) {
floitsch 2014/04/14 15:39:37 What if we have: === var f = () => 499; var f2 = f
herhut 2014/04/15 10:50:39 f2 would be a LocalElement, as would be f1. Only t
292 return getMightBePassedToApply(element.expression);
293 }
294 return functionsThatMightBePassedToApply.contains(element);
295 }
276 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698