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

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: Only allocate caches when hasIncrementalCompilation is true. 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
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/native_handler.dart ('k') | no next file » | 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 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;
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,
61 alreadyPopulated = compiler.cacheStrategy.newSet();
59 62
60 void populate() { 63 void populate() {
61 void addSubtypes(ClassElement cls) { 64 void addSubtypes(ClassElement cls) {
65 if (compiler.hasIncrementalSupport && !alreadyPopulated.add(cls)) {
66 return;
67 }
62 assert(cls.isDeclaration); 68 assert(cls.isDeclaration);
63 if (cls.resolutionState != STATE_DONE) { 69 if (cls.resolutionState != STATE_DONE) {
64 compiler.internalError(cls, 'Class "${cls.name}" is not resolved.'); 70 compiler.internalError(cls, 'Class "${cls.name}" is not resolved.');
65 } 71 }
66 72
67 for (DartType type in cls.allSupertypes) { 73 for (DartType type in cls.allSupertypes) {
68 Set<Element> supertypesOfClass = 74 Set<Element> supertypesOfClass =
69 _supertypes.putIfAbsent(cls, () => new Set<ClassElement>()); 75 _supertypes.putIfAbsent(cls, () => new Set<ClassElement>());
70 Set<Element> subtypesOfSupertype = 76 Set<Element> subtypesOfSupertype =
71 _subtypes.putIfAbsent(type.element, () => new Set<ClassElement>()); 77 _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 298 // method of function classes that were generated for function
293 // expressions. In such a case, we have to look at the original 299 // expressions. In such a case, we have to look at the original
294 // function expressions's element. 300 // function expressions's element.
295 // TODO(herhut): Generate classes for function expressions earlier. 301 // TODO(herhut): Generate classes for function expressions earlier.
296 if (element is closureMapping.SynthesizedCallMethodElementX) { 302 if (element is closureMapping.SynthesizedCallMethodElementX) {
297 return getMightBePassedToApply(element.expression); 303 return getMightBePassedToApply(element.expression);
298 } 304 }
299 return functionsThatMightBePassedToApply.contains(element); 305 return functionsThatMightBePassedToApply.contains(element);
300 } 306 }
301 } 307 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/native_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698