| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // enclosing class, since the metadata has not been parsed yet. | 202 // enclosing class, since the metadata has not been parsed yet. |
| 203 if (!member.enclosingElement.isNative()) return; | 203 if (!member.enclosingElement.isNative()) return; |
| 204 } | 204 } |
| 205 | 205 |
| 206 String memberName = member.name.slowToString(); | 206 String memberName = member.name.slowToString(); |
| 207 | 207 |
| 208 if (member.kind == ElementKind.FUNCTION) { | 208 if (member.kind == ElementKind.FUNCTION) { |
| 209 if (member.name == Compiler.NO_SUCH_METHOD) { | 209 if (member.name == Compiler.NO_SUCH_METHOD) { |
| 210 enableNoSuchMethod(member); | 210 enableNoSuchMethod(member); |
| 211 } | 211 } |
| 212 if (universe.hasInvocation(member, compiler)) { | |
| 213 return addToWorkList(member); | |
| 214 } | |
| 215 // If there is a property access with the same name as a method we | 212 // If there is a property access with the same name as a method we |
| 216 // need to emit the method. | 213 // need to emit the method. |
| 217 if (universe.hasInvokedGetter(member, compiler)) { | 214 if (universe.hasInvokedGetter(member, compiler)) { |
| 218 // We will emit a closure, so make sure the closure class is | 215 // We will emit a closure, so make sure the bound closure class is |
| 219 // generated. | 216 // generated. |
| 220 compiler.closureClass.ensureResolved(compiler); | 217 registerInstantiatedClass(compiler.boundClosureClass, |
| 221 registerInstantiatedClass(compiler.closureClass, | |
| 222 // Precise dependency is not important here. | 218 // Precise dependency is not important here. |
| 223 compiler.globalDependencies); | 219 compiler.globalDependencies); |
| 224 return addToWorkList(member); | 220 return addToWorkList(member); |
| 225 } | 221 } |
| 222 if (universe.hasInvocation(member, compiler)) { |
| 223 return addToWorkList(member); |
| 224 } |
| 226 } else if (member.kind == ElementKind.GETTER) { | 225 } else if (member.kind == ElementKind.GETTER) { |
| 227 if (universe.hasInvokedGetter(member, compiler)) { | 226 if (universe.hasInvokedGetter(member, compiler)) { |
| 228 return addToWorkList(member); | 227 return addToWorkList(member); |
| 229 } | 228 } |
| 230 // We don't know what selectors the returned closure accepts. If | 229 // We don't know what selectors the returned closure accepts. If |
| 231 // the set contains any selector we have to assume that it matches. | 230 // the set contains any selector we have to assume that it matches. |
| 232 if (universe.hasInvocation(member, compiler)) { | 231 if (universe.hasInvocation(member, compiler)) { |
| 233 return addToWorkList(member); | 232 return addToWorkList(member); |
| 234 } | 233 } |
| 235 } else if (member.kind == ElementKind.SETTER) { | 234 } else if (member.kind == ElementKind.SETTER) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 nativeEnqueuer.registerFieldStore(member); | 412 nativeEnqueuer.registerFieldStore(member); |
| 414 // We have to also handle loading from the field because we only get | 413 // We have to also handle loading from the field because we only get |
| 415 // one look at each member and there might be a load we have not | 414 // one look at each member and there might be a load we have not |
| 416 // seen yet. | 415 // seen yet. |
| 417 // TODO(sra): Process fields for storing separately. | 416 // TODO(sra): Process fields for storing separately. |
| 418 nativeEnqueuer.registerFieldLoad(member); | 417 nativeEnqueuer.registerFieldLoad(member); |
| 419 } | 418 } |
| 420 } else { | 419 } else { |
| 421 addToWorkList(member); | 420 addToWorkList(member); |
| 422 } | 421 } |
| 422 if (selector.isGetter() && member.isFunction()) { |
| 423 registerInstantiatedClass(compiler.boundClosureClass, |
| 424 compiler.globalDependencies); |
| 425 } |
| 423 return true; | 426 return true; |
| 424 } | 427 } |
| 425 return false; | 428 return false; |
| 426 }); | 429 }); |
| 427 } | 430 } |
| 428 | 431 |
| 429 /** | 432 /** |
| 430 * Documentation wanted -- johnniwinther | 433 * Documentation wanted -- johnniwinther |
| 431 * | 434 * |
| 432 * Invariant: [element] must be a declaration element. | 435 * Invariant: [element] must be a declaration element. |
| 433 */ | 436 */ |
| 434 void registerStaticUse(Element element) { | 437 void registerStaticUse(Element element) { |
| 435 if (element == null) return; | 438 if (element == null) return; |
| 436 assert(invariant(element, element.isDeclaration)); | 439 assert(invariant(element, element.isDeclaration)); |
| 437 addToWorkList(element); | 440 addToWorkList(element); |
| 438 } | 441 } |
| 439 | 442 |
| 440 void registerGetOfStaticFunction(FunctionElement element) { | 443 void registerGetOfStaticFunction(FunctionElement element) { |
| 441 registerStaticUse(element); | 444 registerStaticUse(element); |
| 445 registerInstantiatedClass(compiler.closureClass, |
| 446 compiler.globalDependencies); |
| 442 universe.staticFunctionsNeedingGetter.add(element); | 447 universe.staticFunctionsNeedingGetter.add(element); |
| 443 } | 448 } |
| 444 | 449 |
| 445 void registerDynamicInvocation(SourceString methodName, Selector selector) { | 450 void registerDynamicInvocation(SourceString methodName, Selector selector) { |
| 446 assert(selector != null); | 451 assert(selector != null); |
| 447 registerInvocation(methodName, selector); | 452 registerInvocation(methodName, selector); |
| 448 } | 453 } |
| 449 | 454 |
| 450 void registerDynamicInvocationOf(Element element, Selector selector) { | 455 void registerDynamicInvocationOf(Element element, Selector selector) { |
| 451 assert(selector.isCall() | 456 assert(selector.isCall() |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 while(!queue.isEmpty) { | 726 while(!queue.isEmpty) { |
| 722 // TODO(johnniwinther): Find an optimal process order for codegen. | 727 // TODO(johnniwinther): Find an optimal process order for codegen. |
| 723 f(queue.removeLast()); | 728 f(queue.removeLast()); |
| 724 } | 729 } |
| 725 } | 730 } |
| 726 | 731 |
| 727 void _logSpecificSummary(log(message)) { | 732 void _logSpecificSummary(log(message)) { |
| 728 log('Compiled ${generatedCode.length} methods.'); | 733 log('Compiled ${generatedCode.length} methods.'); |
| 729 } | 734 } |
| 730 } | 735 } |
| OLD | NEW |