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

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

Issue 10537025: Prototype re-compiling methods in dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 Enqueuer { 20 class Enqueuer {
21 final Compiler compiler; // TODO(ahe): Remove this dependency. 21 final Compiler compiler; // TODO(ahe): Remove this dependency.
22 final Map<String, Link<Element>> instanceMembersByName; 22 final Map<String, Link<Element>> instanceMembersByName;
23 final Set<ClassElement> seenClasses; 23 final Set<ClassElement> seenClasses;
24 final Universe universe; 24 final Universe universe;
25 final Queue<WorkItem> queue; 25 final Queue<WorkItem> queue;
26 final Queue<WorkItem> queue2;
ricow1 2012/06/07 06:35:49 I would probably call this recompilationCandidates
Søren Gjesse 2012/06/07 08:06:12 Done.
27 final Set<Element> inQueue2;
26 bool queueIsClosed = false; 28 bool queueIsClosed = false;
27 EnqueueTask task; 29 EnqueueTask task;
28 30
29 Enqueuer(this.compiler) 31 Enqueuer(this.compiler)
30 : instanceMembersByName = new Map<String, Link<Element>>(), 32 : instanceMembersByName = new Map<String, Link<Element>>(),
31 seenClasses = new Set<ClassElement>(), 33 seenClasses = new Set<ClassElement>(),
32 universe = new Universe(), 34 universe = new Universe(),
33 queue = new Queue<WorkItem>(); 35 queue = new Queue<WorkItem>(),
36 queue2 = new Queue<WorkItem>(),
37 inQueue2 = new Set<Element>();
34 38
35 void addToWorkList(Element element, [TreeElements elements]) { 39 void addToWorkList(Element element, [TreeElements elements]) {
40 if (compiler.pass == 2) return;
36 if (queueIsClosed) { 41 if (queueIsClosed) {
37 compiler.internalErrorOnElement(element, "Work list is closed."); 42 compiler.internalErrorOnElement(element, "Work list is closed.");
38 } 43 }
39 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) { 44 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) {
40 registerInstantiatedClass(element.enclosingElement); 45 registerInstantiatedClass(element.enclosingElement);
41 } 46 }
42 queue.add(new WorkItem(element, elements)); 47 queue.add(new WorkItem(element, elements));
43 } 48 }
44 49
50 void addToWorkList2(Element element, [TreeElements elements]) {
51 if (queueIsClosed) {
52 compiler.internalErrorOnElement(element, "Work list is closed.");
53 }
54 if (inQueue2.contains(element)) return;
55 if (element.kind !== ElementKind.GENERATIVE_CONSTRUCTOR_BODY &&
56 element.kind !== ElementKind.GENERATIVE_CONSTRUCTOR) {
57 inQueue2.add(element);
58 queue2.add(new WorkItem(element, elements));
59 }
60 }
61
45 void registerInstantiatedClass(ClassElement cls) { 62 void registerInstantiatedClass(ClassElement cls) {
46 universe.instantiatedClasses.add(cls); 63 universe.instantiatedClasses.add(cls);
47 onRegisterInstantiatedClass(cls); 64 onRegisterInstantiatedClass(cls);
48 } 65 }
49 66
50 bool checkNoEnqueuedInvokedInstanceMethods() { 67 bool checkNoEnqueuedInvokedInstanceMethods() {
51 task.measure(() { 68 task.measure(() {
52 // Run through the classes and see if we need to compile methods. 69 // Run through the classes and see if we need to compile methods.
53 for (ClassElement classElement in universe.instantiatedClasses) { 70 for (ClassElement classElement in universe.instantiatedClasses) {
54 for (ClassElement currentClass = classElement; 71 for (ClassElement currentClass = classElement;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 238
222 void registerDynamicSetter(SourceString methodName, Selector selector) { 239 void registerDynamicSetter(SourceString methodName, Selector selector) {
223 registerSetter(methodName, selector); 240 registerSetter(methodName, selector);
224 } 241 }
225 242
226 // TODO(ngeoffray): This should get a type. 243 // TODO(ngeoffray): This should get a type.
227 void registerIsCheck(Element element) { 244 void registerIsCheck(Element element) {
228 universe.isChecks.add(element); 245 universe.isChecks.add(element);
229 } 246 }
230 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698