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

Side by Side Diff: lib/compiler/implementation/enqueue.dart

Issue 10532158: Some cleanup of recompilation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed "Closure" Created 8 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 class EnqueueTask extends CompilerTask { 5 class EnqueueTask extends CompilerTask {
6 final Enqueuer codegen; 6 final Enqueuer codegen;
7 final Enqueuer resolution; 7 final Enqueuer resolution;
8 8
9 String get name() => 'Enqueue'; 9 String get name() => 'Enqueue';
10 10
11 EnqueueTask(Compiler compiler) 11 EnqueueTask(Compiler compiler)
12 : codegen = new Enqueuer(compiler), 12 : codegen = new Enqueuer(compiler),
13 resolution = new Enqueuer(compiler), 13 resolution = new Enqueuer(compiler),
14 super(compiler) { 14 super(compiler) {
15 codegen.task = this; 15 codegen.task = this;
16 resolution.task = this; 16 resolution.task = this;
17 } 17 }
18 } 18 }
19 19
20 class RecompilationQueue { 20 class RecompilationQueue {
21 final Queue<WorkItem> queue; 21 final Queue<WorkItem> queue;
22 final Set<Element> queueElements; 22 final Set<Element> queueElements;
23 int processed = 0;
23 24
24 RecompilationQueue() 25 RecompilationQueue()
25 : queue = new Queue<WorkItem>(), 26 : queue = new Queue<WorkItem>(),
26 queueElements = new Set<Element>(); 27 queueElements = new Set<Element>();
27 28
28 void add(Element element, TreeElements elements) { 29 void add(Element element, TreeElements elements) {
29 if (queueElements.contains(element)) return; 30 if (queueElements.contains(element)) return;
30 // TODO(sgjesse): Make this handle constructor bodies as well. 31 // TODO(sgjesse): Make this handle constructor bodies as well.
31 if (element.kind !== ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { 32 if (element.kind !== ElementKind.GENERATIVE_CONSTRUCTOR_BODY) {
32 queueElements.add(element); 33 queueElements.add(element);
33 queue.add(new WorkItem(element, elements)); 34 queue.add(new WorkItem(element, elements));
34 } 35 }
35 } 36 }
36 37
37 int get length() => queue.length; 38 int get length() => queue.length;
38 39
39 bool isEmpty() => queue.isEmpty(); 40 bool isEmpty() => queue.isEmpty();
40 41
41 WorkItem next() { 42 WorkItem next() {
42 WorkItem item = queue.removeLast(); 43 WorkItem item = queue.removeLast();
43 queueElements.remove(item.element); 44 queueElements.remove(item.element);
45 processed++;
44 return item; 46 return item;
45 } 47 }
46 } 48 }
47 49
48 class Enqueuer { 50 class Enqueuer {
49 final Compiler compiler; // TODO(ahe): Remove this dependency. 51 final Compiler compiler; // TODO(ahe): Remove this dependency.
50 final Map<String, Link<Element>> instanceMembersByName; 52 final Map<String, Link<Element>> instanceMembersByName;
51 final Set<ClassElement> seenClasses; 53 final Set<ClassElement> seenClasses;
52 final Universe universe; 54 final Universe universe;
53 final Queue<WorkItem> queue; 55 final Queue<WorkItem> queue;
(...skipping 13 matching lines...) Expand all
67 69
68 bool get isResolutionQueue() => compiler.enqueuer.resolution === this; 70 bool get isResolutionQueue() => compiler.enqueuer.resolution === this;
69 71
70 TreeElements getCachedElements(Element element) { 72 TreeElements getCachedElements(Element element) {
71 Element owner = element.getOutermostEnclosingMemberOrTopLevel(); 73 Element owner = element.getOutermostEnclosingMemberOrTopLevel();
72 return compiler.enqueuer.resolution.resolvedElements[owner]; 74 return compiler.enqueuer.resolution.resolvedElements[owner];
73 } 75 }
74 76
75 void addToWorkList(Element element, [TreeElements elements]) { 77 void addToWorkList(Element element, [TreeElements elements]) {
76 if (element.isForeign()) return; 78 if (element.isForeign()) return;
77 if (compiler.pass == 2) return; 79 if (compiler.phase == Compiler.PHASE_RECOMPILING) return;
78 if (queueIsClosed) { 80 if (queueIsClosed) {
79 if (isResolutionQueue && getCachedElements(element) !== null) return; 81 if (isResolutionQueue && getCachedElements(element) !== null) return;
80 compiler.internalErrorOnElement(element, "Work list is closed."); 82 compiler.internalErrorOnElement(element, "Work list is closed.");
81 } 83 }
82 if (!isResolutionQueue && 84 if (!isResolutionQueue &&
83 element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) { 85 element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) {
84 registerInstantiatedClass(element.enclosingElement); 86 registerInstantiatedClass(element.enclosingElement);
85 } 87 }
86 if (elements === null) { 88 if (elements === null) {
87 elements = getCachedElements(element); 89 elements = getCachedElements(element);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void registerIsCheck(Element element) { 317 void registerIsCheck(Element element) {
316 universe.isChecks.add(element); 318 universe.isChecks.add(element);
317 } 319 }
318 320
319 void forEach(f(WorkItem work)) { 321 void forEach(f(WorkItem work)) {
320 while (!queue.isEmpty()) { 322 while (!queue.isEmpty()) {
321 f(queue.removeLast()); 323 f(queue.removeLast());
322 } 324 }
323 } 325 }
324 } 326 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698