Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 11304021: Add NativeEnqueuer to work with the Enqueuer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : this.constantSystem = constantSystem; 67 : this.constantSystem = constantSystem;
68 68
69 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { 69 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) {
70 lib.forEachExport((Element e) { 70 lib.forEachExport((Element e) {
71 if (e.isFunction()) world.addToWorkList(e); 71 if (e.isFunction()) world.addToWorkList(e);
72 }); 72 });
73 } 73 }
74 74
75 void enqueueHelpers(Enqueuer world); 75 void enqueueHelpers(Enqueuer world);
76 void codegen(WorkItem work); 76 void codegen(WorkItem work);
77 void processNativeClasses(Enqueuer world, 77
78 Collection<LibraryElement> libraries); 78 // The backend determines the native resolution enqueuer so tools like
79 // dart2dart can ignore the native classes.
80 NativeEnqueuer nativeResolutionEnqueuer(world);
81 NativeEnqueuer nativeCodegenEnqueuer(world);
82
79 void assembleProgram(); 83 void assembleProgram();
80 List<CompilerTask> get tasks; 84 List<CompilerTask> get tasks;
81 85
82 // TODO(ahe,karlklose): rename this? 86 // TODO(ahe,karlklose): rename this?
83 void dumpInferredTypes() {} 87 void dumpInferredTypes() {}
84 88
85 ItemCompilationContext createItemCompilationContext() { 89 ItemCompilationContext createItemCompilationContext() {
86 return new ItemCompilationContext(); 90 return new ItemCompilationContext();
87 } 91 }
88 92
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 reportFatalError('Could not find $MAIN', mainApp); 518 reportFatalError('Could not find $MAIN', mainApp);
515 } else { 519 } else {
516 if (!main.isFunction()) reportFatalError('main is not a function', main); 520 if (!main.isFunction()) reportFatalError('main is not a function', main);
517 FunctionElement mainMethod = main; 521 FunctionElement mainMethod = main;
518 FunctionSignature parameters = mainMethod.computeSignature(this); 522 FunctionSignature parameters = mainMethod.computeSignature(this);
519 parameters.forEachParameter((Element parameter) { 523 parameters.forEachParameter((Element parameter) {
520 reportFatalError('main cannot have parameters', parameter); 524 reportFatalError('main cannot have parameters', parameter);
521 }); 525 });
522 } 526 }
523 527
528 enqueuer.resolution.nativeEnqueuer =
529 backend.nativeResolutionEnqueuer(enqueuer.resolution);
530 enqueuer.codegen.nativeEnqueuer =
531 backend.nativeCodegenEnqueuer(enqueuer.codegen);
532
524 log('Resolving...'); 533 log('Resolving...');
525 phase = PHASE_RESOLVING; 534 phase = PHASE_RESOLVING;
526 backend.enqueueHelpers(enqueuer.resolution); 535 backend.enqueueHelpers(enqueuer.resolution);
527 processQueue(enqueuer.resolution, main); 536 processQueue(enqueuer.resolution, main);
528 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); 537 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.');
538 log('Resolved ${enqueuer.resolution.nativeEnqueuer.registeredClasses.length} native elements used, '
539 '${enqueuer.resolution.nativeEnqueuer.unusedClasses.length} native eleme nts dead.');
529 540
530 if (compilationFailed) return; 541 if (compilationFailed) return;
531 542
532 log('Inferring types...'); 543 log('Inferring types...');
533 typesTask.onResolutionComplete(main); 544 typesTask.onResolutionComplete(main);
534 545
535 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution 546 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution
536 // should know this. 547 // should know this.
537 world.populate(); 548 world.populate();
538 549
539 log('Compiling...'); 550 log('Compiling...');
540 phase = PHASE_COMPILING; 551 phase = PHASE_COMPILING;
541 processQueue(enqueuer.codegen, main); 552 processQueue(enqueuer.codegen, main);
542 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 553 log('Compiled ${codegenWorld.generatedCode.length} methods.');
554 log('Compiled ${enqueuer.codegen.nativeEnqueuer.registeredClasses.length} na tive classes, '
555 '${enqueuer.codegen.nativeEnqueuer.unusedClasses.length} native classes omitted.');
543 556
544 if (compilationFailed) return; 557 if (compilationFailed) return;
545 558
546 backend.assembleProgram(); 559 backend.assembleProgram();
547 560
548 checkQueues(); 561 checkQueues();
549 } 562 }
550 563
551 void processQueue(Enqueuer world, Element main) { 564 void processQueue(Enqueuer world, Element main) {
552 backend.processNativeClasses(world, libraries.values); 565 world.nativeEnqueuer.processNativeClasses(libraries.values);
553 world.addToWorkList(main); 566 world.addToWorkList(main);
554 progress.reset(); 567 progress.reset();
555 world.forEach((WorkItem work) { 568 world.forEach((WorkItem work) {
556 withCurrentElement(work.element, () => work.run(this, world)); 569 withCurrentElement(work.element, () => work.run(this, world));
557 }); 570 });
558 world.queueIsClosed = true; 571 world.queueIsClosed = true;
559 if (compilationFailed) return; 572 if (compilationFailed) return;
560 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 573 assert(world.checkNoEnqueuedInvokedInstanceMethods());
561 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) { 574 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) {
562 backend.dumpInferredTypes(); 575 backend.dumpInferredTypes();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 if (phase == PHASE_RESOLVING) { 658 if (phase == PHASE_RESOLVING) {
646 log('Resolved ${enqueuer.resolution.resolvedElements.length} ' 659 log('Resolved ${enqueuer.resolution.resolvedElements.length} '
647 'elements.'); 660 'elements.');
648 progress.reset(); 661 progress.reset();
649 } 662 }
650 } 663 }
651 Element element = work.element; 664 Element element = work.element;
652 TreeElements result = world.getCachedElements(element); 665 TreeElements result = world.getCachedElements(element);
653 if (result != null) return result; 666 if (result != null) return result;
654 if (!identical(world, enqueuer.resolution)) { 667 if (!identical(world, enqueuer.resolution)) {
668 throw 'Internal error: unresolved element: $element.';
655 internalErrorOnElement(element, 669 internalErrorOnElement(element,
656 'Internal error: unresolved element: $element.'); 670 'Internal error: unresolved element: $element.');
657 } 671 }
658 result = analyzeElement(element); 672 result = analyzeElement(element);
659 assert(invariant(element, element.isDeclaration)); 673 assert(invariant(element, element.isDeclaration));
660 enqueuer.resolution.resolvedElements[element] = result; 674 enqueuer.resolution.resolvedElements[element] = result;
661 return result; 675 return result;
662 } 676 }
663 677
664 void codegen(WorkItem work, Enqueuer world) { 678 void codegen(WorkItem work, Enqueuer world) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 // TODO(johnniwinther): Use [spannable] and [message] to provide better 923 // TODO(johnniwinther): Use [spannable] and [message] to provide better
910 // information on assertion errors. 924 // information on assertion errors.
911 if (condition is Function){ 925 if (condition is Function){
912 condition = condition(); 926 condition = condition();
913 } 927 }
914 if (spannable == null || !condition) { 928 if (spannable == null || !condition) {
915 throw new SpannableAssertionFailure(spannable, message); 929 throw new SpannableAssertionFailure(spannable, message);
916 } 930 }
917 return true; 931 return true;
918 } 932 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698