| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 void registerGetOfStaticFunction(FunctionElement element) { | 312 void registerGetOfStaticFunction(FunctionElement element) { |
| 313 registerStaticUse(element); | 313 registerStaticUse(element); |
| 314 universe.staticFunctionsNeedingGetter.add(element); | 314 universe.staticFunctionsNeedingGetter.add(element); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void registerDynamicInvocation(SourceString methodName, Selector selector) { | 317 void registerDynamicInvocation(SourceString methodName, Selector selector) { |
| 318 assert(selector != null); | 318 assert(selector != null); |
| 319 registerInvocation(methodName, selector); | 319 registerInvocation(methodName, selector); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void registerDynamicInvocationOf(Element element) { | 322 void registerDynamicInvocationOf(Element element, Selector selector) { |
| 323 addToWorkList(element); | 323 assert(selector.isCall() |
| 324 || selector.isOperator() |
| 325 || selector.isIndex() |
| 326 || selector.isIndexSet()); |
| 327 if (element.isFunction()) { |
| 328 addToWorkList(element); |
| 329 } else if (element.isAbstractField()) { |
| 330 AbstractFieldElement field = element; |
| 331 // Since the invocation is a dynamic call on a getter, we only |
| 332 // need to schedule the getter on the work list. |
| 333 addToWorkList(field.getter); |
| 334 } else { |
| 335 assert(element.isField()); |
| 336 } |
| 337 // We also need to add the selector to the invoked names map, |
| 338 // because the emitter uses that map to generate parameter stubs. |
| 339 Set<Selector> selectors = universe.invokedNames.putIfAbsent( |
| 340 element.name, () => new Set<Selector>()); |
| 341 selectors.add(selector); |
| 324 } | 342 } |
| 325 | 343 |
| 326 void registerDynamicGetter(SourceString methodName, Selector selector) { | 344 void registerDynamicGetter(SourceString methodName, Selector selector) { |
| 327 registerInvokedGetter(methodName, selector); | 345 registerInvokedGetter(methodName, selector); |
| 328 } | 346 } |
| 329 | 347 |
| 330 void registerDynamicSetter(SourceString methodName, Selector selector) { | 348 void registerDynamicSetter(SourceString methodName, Selector selector) { |
| 331 registerInvokedSetter(methodName, selector); | 349 registerInvokedSetter(methodName, selector); |
| 332 } | 350 } |
| 333 | 351 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 addToWorkList( | 456 addToWorkList( |
| 439 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); | 457 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); |
| 440 addToWorkList(compiler.isolateHelperLibrary.find( | 458 addToWorkList(compiler.isolateHelperLibrary.find( |
| 441 const SourceString('_currentIsolate'))); | 459 const SourceString('_currentIsolate'))); |
| 442 addToWorkList(compiler.isolateHelperLibrary.find( | 460 addToWorkList(compiler.isolateHelperLibrary.find( |
| 443 const SourceString('_callInIsolate'))); | 461 const SourceString('_callInIsolate'))); |
| 444 } | 462 } |
| 445 | 463 |
| 446 void enableNoSuchMethod(Element element) { | 464 void enableNoSuchMethod(Element element) { |
| 447 if (compiler.enabledNoSuchMethod) return; | 465 if (compiler.enabledNoSuchMethod) return; |
| 466 Selector selector = new Selector.noSuchMethod(); |
| 448 if (identical(element.getEnclosingClass(), compiler.objectClass)) { | 467 if (identical(element.getEnclosingClass(), compiler.objectClass)) { |
| 449 registerDynamicInvocationOf(element); | 468 registerDynamicInvocationOf(element, selector); |
| 450 return; | 469 return; |
| 451 } | 470 } |
| 452 compiler.enabledNoSuchMethod = true; | 471 compiler.enabledNoSuchMethod = true; |
| 453 Selector selector = new Selector.noSuchMethod(); | |
| 454 registerInvocation(Compiler.NO_SUCH_METHOD, selector); | 472 registerInvocation(Compiler.NO_SUCH_METHOD, selector); |
| 455 | 473 |
| 456 compiler.createInvocationMirrorElement = | 474 compiler.createInvocationMirrorElement = |
| 457 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR); | 475 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR); |
| 458 addToWorkList(compiler.createInvocationMirrorElement); | 476 addToWorkList(compiler.createInvocationMirrorElement); |
| 459 } | 477 } |
| 460 | 478 |
| 461 void forEach(f(WorkItem work)) { | 479 void forEach(f(WorkItem work)) { |
| 462 while (!queue.isEmpty) { | 480 while (!queue.isEmpty) { |
| 463 // TODO(johnniwinther): Find an optimal process order for resolution. | 481 // TODO(johnniwinther): Find an optimal process order for resolution. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 while(!queue.isEmpty) { | 570 while(!queue.isEmpty) { |
| 553 // TODO(johnniwinther): Find an optimal process order for codegen. | 571 // TODO(johnniwinther): Find an optimal process order for codegen. |
| 554 f(queue.removeLast()); | 572 f(queue.removeLast()); |
| 555 } | 573 } |
| 556 } | 574 } |
| 557 | 575 |
| 558 void _logSpecificSummary(log(message)) { | 576 void _logSpecificSummary(log(message)) { |
| 559 log('Compiled ${universe.generatedCode.length} methods.'); | 577 log('Compiled ${universe.generatedCode.length} methods.'); |
| 560 } | 578 } |
| 561 } | 579 } |
| OLD | NEW |