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

Side by Side Diff: pkg/compiler/lib/src/js_backend/enqueuer.dart

Issue 2732633002: Remove Enqueuer.nativeEnqueuer (Closed)
Patch Set: Updated cf. comment Created 3 years, 9 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
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 dart2js.js.enqueue; 5 library dart2js.js.enqueue;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import '../common/codegen.dart' show CodegenWorkItem; 9 import '../common/codegen.dart' show CodegenWorkItem;
10 import '../common/tasks.dart' show CompilerTask; 10 import '../common/tasks.dart' show CompilerTask;
11 import '../common/work.dart' show WorkItem; 11 import '../common/work.dart' show WorkItem;
12 import '../common.dart'; 12 import '../common.dart';
13 import '../elements/resolution_types.dart' 13 import '../elements/resolution_types.dart'
14 show ResolutionDartType, ResolutionInterfaceType; 14 show ResolutionDartType, ResolutionInterfaceType;
15 import '../elements/elements.dart' show MemberElement, TypedElement; 15 import '../elements/elements.dart' show MemberElement;
16 import '../elements/entities.dart'; 16 import '../elements/entities.dart';
17 import '../enqueue.dart'; 17 import '../enqueue.dart';
18 import '../js_backend/backend.dart' show JavaScriptBackend; 18 import '../js_backend/backend.dart' show JavaScriptBackend;
19 import '../native/native.dart' as native;
20 import '../options.dart'; 19 import '../options.dart';
21 import '../types/types.dart' show TypeMaskStrategy; 20 import '../types/types.dart' show TypeMaskStrategy;
22 import '../universe/world_builder.dart'; 21 import '../universe/world_builder.dart';
23 import '../universe/use.dart' 22 import '../universe/use.dart'
24 show DynamicUse, StaticUse, StaticUseKind, TypeUse, TypeUseKind; 23 show DynamicUse, StaticUse, StaticUseKind, TypeUse, TypeUseKind;
25 import '../universe/world_impact.dart' 24 import '../universe/world_impact.dart'
26 show ImpactUseCase, WorldImpact, WorldImpactVisitor; 25 show ImpactUseCase, WorldImpact, WorldImpactVisitor;
27 import '../util/enumset.dart'; 26 import '../util/enumset.dart';
28 import '../util/util.dart' show Setlet; 27 import '../util/util.dart' show Setlet;
29 28
30 /// [Enqueuer] which is specific to code generation. 29 /// [Enqueuer] which is specific to code generation.
31 class CodegenEnqueuer extends EnqueuerImpl { 30 class CodegenEnqueuer extends EnqueuerImpl {
32 final String name; 31 final String name;
33 final EnqueuerStrategy strategy; 32 final EnqueuerStrategy strategy;
34 33
35 Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>(); 34 Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>();
36 final CodegenWorldBuilderImpl _universe; 35 final CodegenWorldBuilderImpl _universe;
37 final WorkItemBuilder _workItemBuilder; 36 final WorkItemBuilder _workItemBuilder;
38 37
39 bool queueIsClosed = false; 38 bool queueIsClosed = false;
40 final CompilerTask task; 39 final CompilerTask task;
41 final native.NativeEnqueuer nativeEnqueuer;
42 final EnqueuerListener listener; 40 final EnqueuerListener listener;
43 final CompilerOptions _options; 41 final CompilerOptions _options;
44 42
45 WorldImpactVisitor _impactVisitor; 43 WorldImpactVisitor _impactVisitor;
46 44
47 final Queue<WorkItem> _queue = new Queue<WorkItem>(); 45 final Queue<WorkItem> _queue = new Queue<WorkItem>();
48 46
49 /// All declaration elements that have been processed by codegen. 47 /// All declaration elements that have been processed by codegen.
50 final Set<Entity> _processedEntities = new Set<Entity>(); 48 final Set<Entity> _processedEntities = new Set<Entity>();
51 49
52 static const ImpactUseCase IMPACT_USE = 50 static const ImpactUseCase IMPACT_USE =
53 const ImpactUseCase('CodegenEnqueuer'); 51 const ImpactUseCase('CodegenEnqueuer');
54 52
55 CodegenEnqueuer(this.task, JavaScriptBackend backend, CompilerOptions options, 53 CodegenEnqueuer(this.task, JavaScriptBackend backend, CompilerOptions options,
56 this.strategy) 54 this.strategy)
57 : _universe = 55 : _universe =
58 new CodegenWorldBuilderImpl(backend, const TypeMaskStrategy()), 56 new CodegenWorldBuilderImpl(backend, const TypeMaskStrategy()),
59 _workItemBuilder = new CodegenWorkItemBuilder(backend, options), 57 _workItemBuilder = new CodegenWorkItemBuilder(backend, options),
60 nativeEnqueuer = backend.nativeCodegenEnqueuer(),
61 this.listener = backend.codegenEnqueuerListener, 58 this.listener = backend.codegenEnqueuerListener,
62 this._options = options, 59 this._options = options,
63 this.name = 'codegen enqueuer' { 60 this.name = 'codegen enqueuer' {
64 _impactVisitor = new EnqueuerImplImpactVisitor(this); 61 _impactVisitor = new EnqueuerImplImpactVisitor(this);
65 } 62 }
66 63
67 CodegenWorldBuilder get worldBuilder => _universe; 64 CodegenWorldBuilder get worldBuilder => _universe;
68 65
69 bool get queueIsEmpty => _queue.isEmpty; 66 bool get queueIsEmpty => _queue.isEmpty;
70 67
(...skipping 29 matching lines...) Expand all
100 if (worldImpact.isEmpty) return; 97 if (worldImpact.isEmpty) return;
101 impactStrategy.visitImpact( 98 impactStrategy.visitImpact(
102 impactSource, worldImpact, _impactVisitor, impactUse); 99 impactSource, worldImpact, _impactVisitor, impactUse);
103 } 100 }
104 101
105 void _registerInstantiatedType(ResolutionInterfaceType type, 102 void _registerInstantiatedType(ResolutionInterfaceType type,
106 {bool mirrorUsage: false, bool nativeUsage: false}) { 103 {bool mirrorUsage: false, bool nativeUsage: false}) {
107 task.measure(() { 104 task.measure(() {
108 _universe.registerTypeInstantiation(type, _applyClassUse, 105 _universe.registerTypeInstantiation(type, _applyClassUse,
109 byMirrors: mirrorUsage); 106 byMirrors: mirrorUsage);
110 if (nativeUsage) { 107 listener.registerInstantiatedType(type, nativeUsage: nativeUsage);
111 nativeEnqueuer.onInstantiatedType(type);
112 }
113 listener.registerInstantiatedType(type);
114 }); 108 });
115 } 109 }
116 110
117 bool checkNoEnqueuedInvokedInstanceMethods() { 111 bool checkNoEnqueuedInvokedInstanceMethods() {
118 return strategy.checkEnqueuerConsistency(this); 112 return strategy.checkEnqueuerConsistency(this);
119 } 113 }
120 114
121 void checkClass(ClassEntity cls) { 115 void checkClass(ClassEntity cls) {
122 _universe.processClassMembers(cls, (MemberEntity member, useSet) { 116 _universe.processClassMembers(cls, (MemberEntity member, useSet) {
123 if (useSet.isNotEmpty) { 117 if (useSet.isNotEmpty) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 /// [_onQueueEmpty] was called last. A return value of [true] indicates that 227 /// [_onQueueEmpty] was called last. A return value of [true] indicates that
234 /// the [recentClasses] have been processed and may be cleared. If [false] is 228 /// the [recentClasses] have been processed and may be cleared. If [false] is
235 /// returned, [_onQueueEmpty] will be called once the queue is empty again (or 229 /// returned, [_onQueueEmpty] will be called once the queue is empty again (or
236 /// still empty) and [recentClasses] will be a superset of the current value. 230 /// still empty) and [recentClasses] will be a superset of the current value.
237 bool _onQueueEmpty(Iterable<ClassEntity> recentClasses) { 231 bool _onQueueEmpty(Iterable<ClassEntity> recentClasses) {
238 return listener.onQueueEmpty(this, recentClasses); 232 return listener.onQueueEmpty(this, recentClasses);
239 } 233 }
240 234
241 void logSummary(log(message)) { 235 void logSummary(log(message)) {
242 log('Compiled ${_processedEntities.length} methods.'); 236 log('Compiled ${_processedEntities.length} methods.');
243 nativeEnqueuer.logSummary(log); 237 listener.logSummary(log);
244 } 238 }
245 239
246 String toString() => 'Enqueuer($name)'; 240 String toString() => 'Enqueuer($name)';
247 241
248 ImpactUseCase get impactUse => IMPACT_USE; 242 ImpactUseCase get impactUse => IMPACT_USE;
249 243
250 @override 244 @override
251 Iterable<Entity> get processedEntities => _processedEntities; 245 Iterable<Entity> get processedEntities => _processedEntities;
252 246
253 @override 247 @override
(...skipping 19 matching lines...) Expand all
273 // code for checked setters. 267 // code for checked setters.
274 if (element.isField && element.isInstanceMember) { 268 if (element.isField && element.isInstanceMember) {
275 if (!_options.enableTypeAssertions || 269 if (!_options.enableTypeAssertions ||
276 element.enclosingElement.isClosure) { 270 element.enclosingElement.isClosure) {
277 return null; 271 return null;
278 } 272 }
279 } 273 }
280 return new CodegenWorkItem(_backend, element); 274 return new CodegenWorkItem(_backend, element);
281 } 275 }
282 } 276 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen_listener.dart ('k') | pkg/compiler/lib/src/js_backend/impact_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698