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 ResolutionEnqueuer resolution; | 8 final ResolutionEnqueuer resolution; |
9 final CodegenEnqueuer codegen; | 9 final CodegenEnqueuer codegen; |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 79 |
80 /** | 80 /** |
81 * Adds [element] to the work list if it has not already been processed. | 81 * Adds [element] to the work list if it has not already been processed. |
82 * | 82 * |
83 * Returns [:true:] if the [element] should be processed. | 83 * Returns [:true:] if the [element] should be processed. |
84 */ | 84 */ |
85 // TODO(johnniwinther): Change to 'Returns true if the element was added to | 85 // TODO(johnniwinther): Change to 'Returns true if the element was added to |
86 // the work list'? | 86 // the work list'? |
87 bool addElementToWorkList(Element element, [TreeElements elements]); | 87 bool addElementToWorkList(Element element, [TreeElements elements]); |
88 | 88 |
89 void registerInstantiatedType(InterfaceType type) { | |
90 universe.instantiatedTypes.add(type); | |
91 registerInstantiatedClass(type.element); | |
92 } | |
93 | |
89 void registerInstantiatedClass(ClassElement cls) { | 94 void registerInstantiatedClass(ClassElement cls) { |
90 if (universe.instantiatedClasses.contains(cls)) return; | 95 if (universe.instantiatedClasses.contains(cls)) return; |
91 if (!cls.isAbstract(compiler)) { | 96 if (!cls.isAbstract(compiler)) { |
92 universe.instantiatedClasses.add(cls); | 97 universe.instantiatedClasses.add(cls); |
93 onRegisterInstantiatedClass(cls); | 98 onRegisterInstantiatedClass(cls); |
99 } else { | |
100 // For factories and instantiations of [List], the target is abstract. | |
101 // Since we may need the type arguments for constructing the instance, | |
102 // we register the class to be added to the classes needing rti. | |
103 compiler.world.registerInstantiatedAbstractClass(cls); | |
ngeoffray
2013/02/26 14:11:37
Instead of doing this here, it looks a bit cleaner
karlklose
2013/02/27 10:12:58
I moved the code to addToWorklist.
| |
104 compiler.backend.registerRuntimeType(); | |
ngeoffray
2013/02/26 14:11:37
You should not register this here.
karlklose
2013/02/27 10:12:58
Removed. Fixed a bug with registering getRuntimeTy
| |
94 } | 105 } |
95 compiler.backend.registerInstantiatedClass(cls, this); | 106 compiler.backend.registerInstantiatedClass(cls, this); |
96 } | 107 } |
97 | 108 |
98 bool checkNoEnqueuedInvokedInstanceMethods() { | 109 bool checkNoEnqueuedInvokedInstanceMethods() { |
99 task.measure(() { | 110 task.measure(() { |
100 // Run through the classes and see if we need to compile methods. | 111 // Run through the classes and see if we need to compile methods. |
101 for (ClassElement classElement in universe.instantiatedClasses) { | 112 for (ClassElement classElement in universe.instantiatedClasses) { |
102 for (ClassElement currentClass = classElement; | 113 for (ClassElement currentClass = classElement; |
103 currentClass != null; | 114 currentClass != null; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 while(!queue.isEmpty) { | 540 while(!queue.isEmpty) { |
530 // TODO(johnniwinther): Find an optimal process order for codegen. | 541 // TODO(johnniwinther): Find an optimal process order for codegen. |
531 f(queue.removeLast()); | 542 f(queue.removeLast()); |
532 } | 543 } |
533 } | 544 } |
534 | 545 |
535 void _logSpecificSummary(log(message)) { | 546 void _logSpecificSummary(log(message)) { |
536 log('Compiled ${generatedCode.length} methods.'); | 547 log('Compiled ${generatedCode.length} methods.'); |
537 } | 548 } |
538 } | 549 } |
OLD | NEW |