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