OLD | NEW |
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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 class EnqueueTask extends CompilerTask { | 7 class EnqueueTask extends CompilerTask { |
8 final Enqueuer codegen; | 8 final Enqueuer codegen; |
9 final Enqueuer resolution; | 9 final Enqueuer resolution; |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 * | 82 * |
83 * Invariant: [element] must be a declaration element. | 83 * Invariant: [element] must be a declaration element. |
84 */ | 84 */ |
85 void addToWorkList(Element element, [TreeElements elements]) { | 85 void addToWorkList(Element element, [TreeElements elements]) { |
86 assert(invariant(element, element.isDeclaration)); | 86 assert(invariant(element, element.isDeclaration)); |
87 if (element.isForeign()) return; | 87 if (element.isForeign()) return; |
88 if (queueIsClosed) { | 88 if (queueIsClosed) { |
89 if (isResolutionQueue && getCachedElements(element) != null) return; | 89 if (isResolutionQueue && getCachedElements(element) != null) return; |
90 compiler.internalErrorOnElement(element, "Work list is closed."); | 90 compiler.internalErrorOnElement(element, "Work list is closed."); |
91 } | 91 } |
92 if (!isResolutionQueue && | |
93 identical(element.kind, ElementKind.GENERATIVE_CONSTRUCTOR)) { | |
94 registerInstantiatedClass(element.getEnclosingClass()); | |
95 } | |
96 if (elements == null) { | 92 if (elements == null) { |
97 elements = getCachedElements(element); | 93 elements = getCachedElements(element); |
98 } | 94 } |
99 if (isResolutionQueue) { | 95 if (isResolutionQueue) { |
100 compiler.world.registerUsedElement(element); | 96 compiler.world.registerUsedElement(element); |
101 } | 97 } |
102 | 98 |
103 queue.add(new WorkItem(element, elements, itemCompilationContextCreator())); | 99 queue.add(new WorkItem(element, elements, itemCompilationContextCreator())); |
104 | 100 |
105 // Enable runtime type support if we discover a getter called runtimeType. | 101 // Enable runtime type support if we discover a getter called runtimeType. |
(...skipping 26 matching lines...) Expand all Loading... |
132 */ | 128 */ |
133 void eagerRecompile(Element element) { | 129 void eagerRecompile(Element element) { |
134 assert(invariant(element, element.isDeclaration)); | 130 assert(invariant(element, element.isDeclaration)); |
135 universe.generatedCode.remove(element); | 131 universe.generatedCode.remove(element); |
136 universe.generatedBailoutCode.remove(element); | 132 universe.generatedBailoutCode.remove(element); |
137 addToWorkList(element); | 133 addToWorkList(element); |
138 } | 134 } |
139 | 135 |
140 void registerInstantiatedClass(ClassElement cls) { | 136 void registerInstantiatedClass(ClassElement cls) { |
141 if (universe.instantiatedClasses.contains(cls)) return; | 137 if (universe.instantiatedClasses.contains(cls)) return; |
142 universe.instantiatedClasses.add(cls); | 138 if (!cls.isAbstract(compiler)) { |
143 onRegisterInstantiatedClass(cls); | 139 universe.instantiatedClasses.add(cls); |
| 140 onRegisterInstantiatedClass(cls); |
| 141 } |
144 compiler.backend.registerInstantiatedClass(cls, this); | 142 compiler.backend.registerInstantiatedClass(cls, this); |
145 } | 143 } |
146 | 144 |
147 bool checkNoEnqueuedInvokedInstanceMethods() { | 145 bool checkNoEnqueuedInvokedInstanceMethods() { |
148 task.measure(() { | 146 task.measure(() { |
149 // Run through the classes and see if we need to compile methods. | 147 // Run through the classes and see if we need to compile methods. |
150 for (ClassElement classElement in universe.instantiatedClasses) { | 148 for (ClassElement classElement in universe.instantiatedClasses) { |
151 for (ClassElement currentClass = classElement; | 149 for (ClassElement currentClass = classElement; |
152 currentClass != null; | 150 currentClass != null; |
153 currentClass = currentClass.superclass) { | 151 currentClass = currentClass.superclass) { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 396 |
399 String toString() => 'Enqueuer($name)'; | 397 String toString() => 'Enqueuer($name)'; |
400 | 398 |
401 void logSummary(log(message)) { | 399 void logSummary(log(message)) { |
402 log(isResolutionQueue | 400 log(isResolutionQueue |
403 ? 'Resolved ${resolvedElements.length} elements.' | 401 ? 'Resolved ${resolvedElements.length} elements.' |
404 : 'Compiled ${universe.generatedCode.length} methods.'); | 402 : 'Compiled ${universe.generatedCode.length} methods.'); |
405 nativeEnqueuer.logSummary(log); | 403 nativeEnqueuer.logSummary(log); |
406 } | 404 } |
407 } | 405 } |
OLD | NEW |