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

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

Issue 2531303002: Decouple WorkItem from Compiler (Closed)
Patch Set: 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.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/backend_api.dart' show Backend; 9 import '../common/backend_api.dart' show Backend;
10 import '../common/codegen.dart' show CodegenWorkItem; 10 import '../common/codegen.dart' show CodegenWorkItem;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 if (options.hasIncrementalSupport && !isProcessed(element)) { 109 if (options.hasIncrementalSupport && !isProcessed(element)) {
110 newlyEnqueuedElements.add(element); 110 newlyEnqueuedElements.add(element);
111 } 111 }
112 112
113 if (queueIsClosed) { 113 if (queueIsClosed) {
114 throw new SpannableAssertionFailure( 114 throw new SpannableAssertionFailure(
115 element, "Codegen work list is closed. Trying to add $element"); 115 element, "Codegen work list is closed. Trying to add $element");
116 } 116 }
117 queue.add(new CodegenWorkItem(_compiler, element)); 117 queue.add(new CodegenWorkItem(backend, element));
118 // TODO(sigmund): add other missing dependencies (internals, selectors 118 // TODO(sigmund): add other missing dependencies (internals, selectors
119 // enqueued after allocations). 119 // enqueued after allocations).
120 _compiler.dumpInfoTask 120 _compiler.dumpInfoTask
121 .registerDependency(_compiler.currentElement, element); 121 .registerDependency(_compiler.currentElement, element);
122 } 122 }
123 123
124 void applyImpact(WorldImpact worldImpact, {Element impactSource}) { 124 void applyImpact(WorldImpact worldImpact, {Element impactSource}) {
125 if (worldImpact.isEmpty) return; 125 if (worldImpact.isEmpty) return;
126 impactStrategy.visitImpact( 126 impactStrategy.visitImpact(
127 impactSource, worldImpact, impactVisitor, impactUse); 127 impactSource, worldImpact, impactVisitor, impactUse);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 applyImpact(backend.registerClosureWithFreeTypeVariables(element, 440 applyImpact(backend.registerClosureWithFreeTypeVariables(element,
441 forResolution: false)); 441 forResolution: false));
442 } 442 }
443 applyImpact(backend.registerBoundClosure()); 443 applyImpact(backend.registerBoundClosure());
444 } 444 }
445 445
446 void forEach(void f(WorkItem work)) { 446 void forEach(void f(WorkItem work)) {
447 do { 447 do {
448 while (queue.isNotEmpty) { 448 while (queue.isNotEmpty) {
449 // TODO(johnniwinther): Find an optimal process order. 449 // TODO(johnniwinther): Find an optimal process order.
450 strategy.processWorkItem(f, queue.removeLast()); 450 WorkItem work = queue.removeLast();
451 if (!isProcessed(work.element)) {
452 strategy.processWorkItem(f, work);
453 // TODO(johnniwinther): Register the processed element here. This
454 // is currently a side-effect of calling `work.run`.
455 }
451 } 456 }
452 List recents = recentClasses.toList(growable: false); 457 List recents = recentClasses.toList(growable: false);
453 recentClasses.clear(); 458 recentClasses.clear();
454 if (!onQueueEmpty(recents)) recentClasses.addAll(recents); 459 if (!onQueueEmpty(recents)) recentClasses.addAll(recents);
455 } while (queue.isNotEmpty || recentClasses.isNotEmpty); 460 } while (queue.isNotEmpty || recentClasses.isNotEmpty);
456 } 461 }
457 462
458 /// [onQueueEmpty] is called whenever the queue is drained. [recentClasses] 463 /// [onQueueEmpty] is called whenever the queue is drained. [recentClasses]
459 /// contains the set of all classes seen for the first time since 464 /// contains the set of all classes seen for the first time since
460 /// [onQueueEmpty] was called last. A return value of [true] indicates that 465 /// [onQueueEmpty] was called last. A return value of [true] indicates that
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 536
532 @override 537 @override
533 Iterable<ClassElement> get processedClasses => _processedClasses; 538 Iterable<ClassElement> get processedClasses => _processedClasses;
534 } 539 }
535 540
536 void removeFromSet(Map<String, Set<Element>> map, Element element) { 541 void removeFromSet(Map<String, Set<Element>> map, Element element) {
537 Set<Element> set = map[element.name]; 542 Set<Element> set = map[element.name];
538 if (set == null) return; 543 if (set == null) return;
539 set.remove(element); 544 set.remove(element);
540 } 545 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698