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

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

Issue 340023003: Various caches for incremental compilation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 14 matching lines...) Expand all
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 = 32 final Set<Element> functionsThatMightBePassedToApply =
33 new Set<FunctionElement>(); 33 new Set<FunctionElement>();
34 34
35 final Set<Element> alreadyPopulated = new Set<Element>.identity();
36
35 Set<ClassElement> subclassesOf(ClassElement cls) { 37 Set<ClassElement> subclassesOf(ClassElement cls) {
36 return _subclasses[cls.declaration]; 38 return _subclasses[cls.declaration];
37 } 39 }
38 40
39 Set<ClassElement> subtypesOf(ClassElement cls) { 41 Set<ClassElement> subtypesOf(ClassElement cls) {
40 return _subtypes[cls.declaration]; 42 return _subtypes[cls.declaration];
41 } 43 }
42 44
43 Set<ClassElement> supertypesOf(ClassElement cls) { 45 Set<ClassElement> supertypesOf(ClassElement cls) {
44 return _supertypes[cls.declaration]; 46 return _supertypes[cls.declaration];
45 } 47 }
46 48
47 Set<ClassElement> typesImplementedBySubclassesOf(ClassElement cls) { 49 Set<ClassElement> typesImplementedBySubclassesOf(ClassElement cls) {
48 return _typesImplementedBySubclasses[cls.declaration]; 50 return _typesImplementedBySubclasses[cls.declaration];
49 } 51 }
50 52
51 bool hasSubclasses(ClassElement cls) { 53 bool hasSubclasses(ClassElement cls) {
52 Set<ClassElement> subclasses = compiler.world.subclassesOf(cls); 54 Set<ClassElement> subclasses = compiler.world.subclassesOf(cls);
53 return subclasses != null && !subclasses.isEmpty; 55 return subclasses != null && !subclasses.isEmpty;
54 } 56 }
55 57
56 World(Compiler compiler) 58 World(Compiler compiler)
57 : allFunctions = new FunctionSet(compiler), 59 : allFunctions = new FunctionSet(compiler),
58 this.compiler = compiler; 60 this.compiler = compiler;
59 61
60 void populate() { 62 void populate() {
61 void addSubtypes(ClassElement cls) { 63 void addSubtypes(ClassElement cls) {
64 if (compiler.hasIncrementalSupport && !alreadyPopulated.add(cls)) {
65 return;
66 }
62 assert(cls.isDeclaration); 67 assert(cls.isDeclaration);
63 if (cls.resolutionState != STATE_DONE) { 68 if (cls.resolutionState != STATE_DONE) {
64 compiler.internalError(cls, 'Class "${cls.name}" is not resolved.'); 69 compiler.internalError(cls, 'Class "${cls.name}" is not resolved.');
65 } 70 }
66 71
67 for (DartType type in cls.allSupertypes) { 72 for (DartType type in cls.allSupertypes) {
68 Set<Element> supertypesOfClass = 73 Set<Element> supertypesOfClass =
69 _supertypes.putIfAbsent(cls, () => new Set<ClassElement>()); 74 _supertypes.putIfAbsent(cls, () => new Set<ClassElement>());
70 Set<Element> subtypesOfSupertype = 75 Set<Element> subtypesOfSupertype =
71 _subtypes.putIfAbsent(type.element, () => new Set<ClassElement>()); 76 _subtypes.putIfAbsent(type.element, () => new Set<ClassElement>());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // method of function classes that were generated for function 297 // method of function classes that were generated for function
293 // expressions. In such a case, we have to look at the original 298 // expressions. In such a case, we have to look at the original
294 // function expressions's element. 299 // function expressions's element.
295 // TODO(herhut): Generate classes for function expressions earlier. 300 // TODO(herhut): Generate classes for function expressions earlier.
296 if (element is closureMapping.SynthesizedCallMethodElementX) { 301 if (element is closureMapping.SynthesizedCallMethodElementX) {
297 return getMightBePassedToApply(element.expression); 302 return getMightBePassedToApply(element.expression);
298 } 303 }
299 return functionsThatMightBePassedToApply.contains(element); 304 return functionsThatMightBePassedToApply.contains(element);
300 } 305 }
301 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698