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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/native_handler.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
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 native; 5 library native;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 import 'dart2jslib.dart'; 8 import 'dart2jslib.dart';
9 import 'dart_types.dart'; 9 import 'dart_types.dart';
10 import 'elements/elements.dart'; 10 import 'elements/elements.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 /** 83 /**
84 * The set of all native classes. Each native class is in [nativeClasses] and 84 * The set of all native classes. Each native class is in [nativeClasses] and
85 * exactly one of [unusedClasses], [pendingClasses] and [registeredClasses]. 85 * exactly one of [unusedClasses], [pendingClasses] and [registeredClasses].
86 */ 86 */
87 final Set<ClassElement> nativeClasses = new Set<ClassElement>(); 87 final Set<ClassElement> nativeClasses = new Set<ClassElement>();
88 88
89 final Set<ClassElement> registeredClasses = new Set<ClassElement>(); 89 final Set<ClassElement> registeredClasses = new Set<ClassElement>();
90 final Set<ClassElement> pendingClasses = new Set<ClassElement>(); 90 final Set<ClassElement> pendingClasses = new Set<ClassElement>();
91 final Set<ClassElement> unusedClasses = new Set<ClassElement>(); 91 final Set<ClassElement> unusedClasses = new Set<ClassElement>();
92 92
93 final Set<LibraryElement> processedLibraries;
94
93 bool hasInstantiatedNativeClasses() => !registeredClasses.isEmpty; 95 bool hasInstantiatedNativeClasses() => !registeredClasses.isEmpty;
94 96
95 final Set<ClassElement> nativeClassesAndSubclasses = new Set<ClassElement>(); 97 final Set<ClassElement> nativeClassesAndSubclasses = new Set<ClassElement>();
96 98
97 final Map<ClassElement, Set<ClassElement>> nonNativeSubclasses = 99 final Map<ClassElement, Set<ClassElement>> nonNativeSubclasses =
98 new Map<ClassElement, Set<ClassElement>>(); 100 new Map<ClassElement, Set<ClassElement>>();
99 101
100 /** 102 /**
101 * Records matched constraints ([SpecialType] or [DartType]). Once a type 103 * Records matched constraints ([SpecialType] or [DartType]). Once a type
102 * constraint has been matched, there is no need to match it again. 104 * constraint has been matched, there is no need to match it again.
(...skipping 11 matching lines...) Expand all
114 116
115 final Enqueuer world; 117 final Enqueuer world;
116 final Compiler compiler; 118 final Compiler compiler;
117 final bool enableLiveTypeAnalysis; 119 final bool enableLiveTypeAnalysis;
118 120
119 ClassElement _annotationCreatesClass; 121 ClassElement _annotationCreatesClass;
120 ClassElement _annotationReturnsClass; 122 ClassElement _annotationReturnsClass;
121 ClassElement _annotationJsNameClass; 123 ClassElement _annotationJsNameClass;
122 124
123 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. 125 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend.
124 NativeEnqueuerBase(this.world, this.compiler, this.enableLiveTypeAnalysis); 126 NativeEnqueuerBase(this.world, Compiler compiler, this.enableLiveTypeAnalysis)
127 : this.compiler = compiler,
128 processedLibraries = compiler.cacheStrategy.newSet();
125 129
126 void processNativeClasses(Iterable<LibraryElement> libraries) { 130 void processNativeClasses(Iterable<LibraryElement> libraries) {
131 if (compiler.hasIncrementalSupport) {
132 // Since [Set.add] returns bool if an element was added, this restricts
133 // [libraries] to ones that haven't already been processed. This saves
134 // time during incremental compiles.
135 libraries = libraries.where(processedLibraries.add);
136 }
127 libraries.forEach(processNativeClassesInLibrary); 137 libraries.forEach(processNativeClassesInLibrary);
128 if (compiler.isolateHelperLibrary != null) { 138 if (compiler.isolateHelperLibrary != null) {
129 processNativeClassesInLibrary(compiler.isolateHelperLibrary); 139 processNativeClassesInLibrary(compiler.isolateHelperLibrary);
130 } 140 }
131 processSubclassesOfNativeClasses(libraries); 141 processSubclassesOfNativeClasses(libraries);
132 if (!enableLiveTypeAnalysis) { 142 if (!enableLiveTypeAnalysis) {
133 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); 143 nativeClasses.forEach((c) => enqueueClass(c, 'forced'));
134 flushQueue(); 144 flushQueue();
135 } 145 }
136 } 146 }
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 LiteralString jsCode = nativeBody.asLiteralString(); 1192 LiteralString jsCode = nativeBody.asLiteralString();
1183 builder.push(new HForeign.statement( 1193 builder.push(new HForeign.statement(
1184 js.js.statementTemplateYielding( 1194 js.js.statementTemplateYielding(
1185 new js.LiteralStatement(jsCode.dartString.slowToString())), 1195 new js.LiteralStatement(jsCode.dartString.slowToString())),
1186 <HInstruction>[], 1196 <HInstruction>[],
1187 new SideEffects(), 1197 new SideEffects(),
1188 null, 1198 null,
1189 backend.dynamicType)); 1199 backend.dynamicType));
1190 } 1200 }
1191 } 1201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698