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

Side by Side Diff: pkg/compiler/lib/src/enqueue.dart

Issue 2589183002: Move CodegenEnqueuer.generatedCode to JavaScriptBackend. (Closed)
Patch Set: dartfmt Created 4 years 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.enqueue; 5 library dart2js.enqueue;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import 'cache_strategy.dart'; 9 import 'cache_strategy.dart';
10 import 'common/backend_api.dart' show Backend; 10 import 'common/backend_api.dart' show Backend;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 final EnqueuerStrategy strategy; 137 final EnqueuerStrategy strategy;
138 final Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>(); 138 final Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>();
139 final ResolutionWorldBuilderImpl _universe; 139 final ResolutionWorldBuilderImpl _universe;
140 140
141 bool queueIsClosed = false; 141 bool queueIsClosed = false;
142 142
143 WorldImpactVisitor _impactVisitor; 143 WorldImpactVisitor _impactVisitor;
144 144
145 /// All declaration elements that have been processed by the resolver. 145 /// All declaration elements that have been processed by the resolver.
146 final Set<Entity> _processedElements = new Set<Entity>(); 146 final Set<Entity> _processedEntities = new Set<Entity>();
147 147
148 final Queue<WorkItem> _queue = new Queue<WorkItem>(); 148 final Queue<WorkItem> _queue = new Queue<WorkItem>();
149 149
150 /// Queue of deferred resolution actions to execute when the resolution queue 150 /// Queue of deferred resolution actions to execute when the resolution queue
151 /// has been emptied. 151 /// has been emptied.
152 final Queue<_DeferredAction> _deferredQueue = new Queue<_DeferredAction>(); 152 final Queue<_DeferredAction> _deferredQueue = new Queue<_DeferredAction>();
153 153
154 ResolutionEnqueuer( 154 ResolutionEnqueuer(
155 this.task, 155 this.task,
156 this._options, 156 this._options,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 applyImpact(backend.registerBoundClosure()); 324 applyImpact(backend.registerBoundClosure());
325 _universe.closurizedMembers.add(element); 325 _universe.closurizedMembers.add(element);
326 } 326 }
327 327
328 void forEach(void f(WorkItem work)) { 328 void forEach(void f(WorkItem work)) {
329 do { 329 do {
330 while (_queue.isNotEmpty) { 330 while (_queue.isNotEmpty) {
331 // TODO(johnniwinther): Find an optimal process order. 331 // TODO(johnniwinther): Find an optimal process order.
332 WorkItem work = _queue.removeLast(); 332 WorkItem work = _queue.removeLast();
333 if (!_processedElements.contains(work.element)) { 333 if (!_processedEntities.contains(work.element)) {
334 strategy.processWorkItem(f, work); 334 strategy.processWorkItem(f, work);
335 _processedElements.add(work.element); 335 _processedEntities.add(work.element);
336 } 336 }
337 } 337 }
338 List recents = _recentClasses.toList(growable: false); 338 List recents = _recentClasses.toList(growable: false);
339 _recentClasses.clear(); 339 _recentClasses.clear();
340 if (!_onQueueEmpty(recents)) { 340 if (!_onQueueEmpty(recents)) {
341 _recentClasses.addAll(recents); 341 _recentClasses.addAll(recents);
342 } 342 }
343 } while (_queue.isNotEmpty || _recentClasses.isNotEmpty); 343 } while (_queue.isNotEmpty || _recentClasses.isNotEmpty);
344 } 344 }
345 345
346 void logSummary(log(message)) { 346 void logSummary(log(message)) {
347 log('Resolved ${_processedElements.length} elements.'); 347 log('Resolved ${_processedEntities.length} elements.');
348 nativeEnqueuer.logSummary(log); 348 nativeEnqueuer.logSummary(log);
349 } 349 }
350 350
351 String toString() => 'Enqueuer($name)'; 351 String toString() => 'Enqueuer($name)';
352 352
353 Iterable<Entity> get processedEntities => _processedElements; 353 Iterable<Entity> get processedEntities => _processedEntities;
354 354
355 ImpactUseCase get impactUse => IMPACT_USE; 355 ImpactUseCase get impactUse => IMPACT_USE;
356 356
357 bool get isResolutionQueue => true; 357 bool get isResolutionQueue => true;
358 358
359 /// Returns `true` if [element] has been processed by the resolution enqueuer. 359 /// Returns `true` if [element] has been processed by the resolution enqueuer.
360 // TODO(johnniwinther): Move this to the [OpenWorld]/[ResolutionWorldBuilder]. 360 // TODO(johnniwinther): Move this to the [OpenWorld]/[ResolutionWorldBuilder].
361 bool hasBeenProcessed(Element element) { 361 bool hasBeenProcessed(Element element) {
362 assert(invariant(element, element == element.analyzableElement.declaration, 362 assert(invariant(element, element == element.analyzableElement.declaration,
363 message: "Unexpected element $element")); 363 message: "Unexpected element $element"));
364 return _processedElements.contains(element); 364 return _processedEntities.contains(element);
365 } 365 }
366 366
367 /// Registers [element] as processed by the resolution enqueuer. Used only for 367 /// Registers [element] as processed by the resolution enqueuer. Used only for
368 /// testing. 368 /// testing.
369 void registerProcessedElementInternal(AstElement element) { 369 void registerProcessedElementInternal(Entity entity) {
370 _processedElements.add(element); 370 _processedEntities.add(entity);
371 } 371 }
372 372
373 /// Adds [element] to the work list if it has not already been processed. 373 /// Adds [element] to the work list if it has not already been processed.
374 /// 374 ///
375 /// Invariant: [element] must be a declaration element. 375 /// Invariant: [element] must be a declaration element.
376 void _addToWorkList(Element element) { 376 void _addToWorkList(Element element) {
377 assert(invariant(element, element.isDeclaration)); 377 assert(invariant(element, element.isDeclaration));
378 if (element.isMalformed) return; 378 if (element.isMalformed) return;
379 379
380 assert(invariant(element, element is AnalyzableElement, 380 assert(invariant(element, element is AnalyzableElement,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 void _emptyDeferredQueue() { 424 void _emptyDeferredQueue() {
425 while (!_deferredQueue.isEmpty) { 425 while (!_deferredQueue.isEmpty) {
426 _DeferredAction task = _deferredQueue.removeFirst(); 426 _DeferredAction task = _deferredQueue.removeFirst();
427 _reporter.withCurrentElement(task.element, task.action); 427 _reporter.withCurrentElement(task.element, task.action);
428 } 428 }
429 } 429 }
430 430
431 void forgetEntity(Entity entity, Compiler compiler) { 431 void forgetEntity(Entity entity, Compiler compiler) {
432 _universe.forgetEntity(entity, compiler); 432 _universe.forgetEntity(entity, compiler);
433 _processedElements.remove(entity); 433 _processedEntities.remove(entity);
434 } 434 }
435 } 435 }
436 436
437 /// Strategy used by the enqueuer to populate the world. 437 /// Strategy used by the enqueuer to populate the world.
438 class EnqueuerStrategy { 438 class EnqueuerStrategy {
439 const EnqueuerStrategy(); 439 const EnqueuerStrategy();
440 440
441 /// Process a static use of and element in live code. 441 /// Process a static use of and element in live code.
442 void processStaticUse(EnqueuerImpl enqueuer, StaticUse staticUse) {} 442 void processStaticUse(EnqueuerImpl enqueuer, StaticUse staticUse) {}
443 443
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 524 }
525 525
526 typedef void _DeferredActionFunction(); 526 typedef void _DeferredActionFunction();
527 527
528 class _DeferredAction { 528 class _DeferredAction {
529 final Element element; 529 final Element element;
530 final _DeferredActionFunction action; 530 final _DeferredActionFunction action;
531 531
532 _DeferredAction(this.element, this.action); 532 _DeferredAction(this.element, this.action);
533 } 533 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698