| 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 typedef ItemCompilationContext ItemCompilationContextCreator(); | 7 typedef ItemCompilationContext ItemCompilationContextCreator(); |
| 8 | 8 |
| 9 class EnqueueTask extends CompilerTask { | 9 class EnqueueTask extends CompilerTask { |
| 10 final ResolutionEnqueuer resolution; | 10 final ResolutionEnqueuer resolution; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 = new Map<String, Link<Element>>(); | 78 = new Map<String, Link<Element>>(); |
| 79 final Map<String, Link<Element>> instanceFunctionsByName | 79 final Map<String, Link<Element>> instanceFunctionsByName |
| 80 = new Map<String, Link<Element>>(); | 80 = new Map<String, Link<Element>>(); |
| 81 final Set<ClassElement> seenClasses = new Set<ClassElement>(); | 81 final Set<ClassElement> seenClasses = new Set<ClassElement>(); |
| 82 final Universe universe = new Universe(); | 82 final Universe universe = new Universe(); |
| 83 | 83 |
| 84 bool queueIsClosed = false; | 84 bool queueIsClosed = false; |
| 85 EnqueueTask task; | 85 EnqueueTask task; |
| 86 native.NativeEnqueuer nativeEnqueuer; // Set by EnqueueTask | 86 native.NativeEnqueuer nativeEnqueuer; // Set by EnqueueTask |
| 87 | 87 |
| 88 bool hasEnqueuedReflectiveElements = false; | 88 bool hasEnqueuedEverything = false; |
| 89 bool hasEnqueuedReflectiveStaticFields = false; |
| 89 | 90 |
| 90 Enqueuer(this.name, this.compiler, this.itemCompilationContextCreator); | 91 Enqueuer(this.name, this.compiler, this.itemCompilationContextCreator); |
| 91 | 92 |
| 92 Queue<WorkItem> get queue; | 93 Queue<WorkItem> get queue; |
| 93 | 94 |
| 94 /// Returns [:true:] if this enqueuer is the resolution enqueuer. | 95 /// Returns [:true:] if this enqueuer is the resolution enqueuer. |
| 95 bool get isResolutionQueue => false; | 96 bool get isResolutionQueue => false; |
| 96 | 97 |
| 97 /// Returns [:true:] if [member] has been processed by this enqueuer. | 98 /// Returns [:true:] if [member] has been processed by this enqueuer. |
| 98 bool isProcessed(Element member); | 99 bool isProcessed(Element member); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 } | 355 } |
| 355 | 356 |
| 356 /// Called when [:new Symbol(...):] is seen. | 357 /// Called when [:new Symbol(...):] is seen. |
| 357 void registerNewSymbol(TreeElements elements) { | 358 void registerNewSymbol(TreeElements elements) { |
| 358 compiler.backend.registerNewSymbol(elements); | 359 compiler.backend.registerNewSymbol(elements); |
| 359 } | 360 } |
| 360 | 361 |
| 361 void enqueueEverything() { | 362 void enqueueEverything() { |
| 362 if (hasEnqueuedReflectiveElements) return; | 363 if (hasEnqueuedEverything) return; |
| 363 compiler.log('Enqueuing everything'); | 364 compiler.log('Enqueuing everything'); |
| 364 task.ensureAllElementsByName(); | 365 task.ensureAllElementsByName(); |
| 365 for (Link link in task.allElementsByName.values) { | 366 for (Link link in task.allElementsByName.values) { |
| 366 for (Element element in link) { | 367 for (Element element in link) { |
| 367 pretendElementWasUsed(element, compiler.globalDependencies); | 368 pretendElementWasUsed(element, compiler.globalDependencies); |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 hasEnqueuedReflectiveElements = true; | 371 hasEnqueuedEverything = true; |
| 372 hasEnqueuedReflectiveStaticFields = true; |
| 371 } | 373 } |
| 372 | 374 |
| 373 /// Enqueue the static fields that have been marked as used by reflective | 375 /// Enqueue the static fields that have been marked as used by reflective |
| 374 /// usage through `MirrorsUsed`. | 376 /// usage through `MirrorsUsed`. |
| 375 void enqueueReflectiveStaticFields(Iterable<Element> elements) { | 377 void enqueueReflectiveStaticFields(Iterable<Element> elements) { |
| 376 if (hasEnqueuedReflectiveElements) return; | 378 if (hasEnqueuedReflectiveStaticFields) return; |
| 377 hasEnqueuedReflectiveElements = true; | 379 hasEnqueuedReflectiveStaticFields = true; |
| 378 for (Element element in elements) { | 380 for (Element element in elements) { |
| 379 pretendElementWasUsed(element, compiler.globalDependencies); | 381 pretendElementWasUsed(element, compiler.globalDependencies); |
| 380 } | 382 } |
| 381 } | 383 } |
| 382 | 384 |
| 383 processLink(Map<String, Link<Element>> map, | 385 processLink(Map<String, Link<Element>> map, |
| 384 String memberName, | 386 String memberName, |
| 385 bool f(Element e)) { | 387 bool f(Element e)) { |
| 386 Link<Element> members = map[memberName]; | 388 Link<Element> members = map[memberName]; |
| 387 if (members != null) { | 389 if (members != null) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 } | 772 } |
| 771 CodegenWorkItem workItem = new CodegenWorkItem( | 773 CodegenWorkItem workItem = new CodegenWorkItem( |
| 772 element, itemCompilationContextCreator()); | 774 element, itemCompilationContextCreator()); |
| 773 queue.add(workItem); | 775 queue.add(workItem); |
| 774 } | 776 } |
| 775 | 777 |
| 776 void _logSpecificSummary(log(message)) { | 778 void _logSpecificSummary(log(message)) { |
| 777 log('Compiled ${generatedCode.length} methods.'); | 779 log('Compiled ${generatedCode.length} methods.'); |
| 778 } | 780 } |
| 779 } | 781 } |
| OLD | NEW |