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 /** | 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 return elements; | 595 return elements; |
596 } | 596 } |
597 | 597 |
598 TreeElements analyze(WorkItem work, Enqueuer world) { | 598 TreeElements analyze(WorkItem work, Enqueuer world) { |
599 if (work.isAnalyzed()) { | 599 if (work.isAnalyzed()) { |
600 // TODO(ahe): Clean this up and find a better way for adding all resolved | 600 // TODO(ahe): Clean this up and find a better way for adding all resolved |
601 // elements. | 601 // elements. |
602 enqueuer.resolution.resolvedElements[work.element] = work.resolutionTree; | 602 enqueuer.resolution.resolvedElements[work.element] = work.resolutionTree; |
603 return work.resolutionTree; | 603 return work.resolutionTree; |
604 } | 604 } |
605 if (progress.elapsedInMs() > 500) { | 605 if (progress.elapsedMilliseconds > 500) { |
606 // TODO(ahe): Add structured diagnostics to the compiler API and | 606 // TODO(ahe): Add structured diagnostics to the compiler API and |
607 // use it to separate this from the --verbose option. | 607 // use it to separate this from the --verbose option. |
608 if (phase == PHASE_RESOLVING) { | 608 if (phase == PHASE_RESOLVING) { |
609 log('Resolved ${enqueuer.resolution.resolvedElements.length} ' | 609 log('Resolved ${enqueuer.resolution.resolvedElements.length} ' |
610 'elements.'); | 610 'elements.'); |
611 progress.reset(); | 611 progress.reset(); |
612 } | 612 } |
613 } | 613 } |
614 Element element = work.element; | 614 Element element = work.element; |
615 TreeElements result = world.getCachedElements(element); | 615 TreeElements result = world.getCachedElements(element); |
616 if (result != null) return result; | 616 if (result != null) return result; |
617 if (!identical(world, enqueuer.resolution)) { | 617 if (!identical(world, enqueuer.resolution)) { |
618 internalErrorOnElement(element, | 618 internalErrorOnElement(element, |
619 'Internal error: unresolved element: $element.'); | 619 'Internal error: unresolved element: $element.'); |
620 } | 620 } |
621 result = analyzeElement(element); | 621 result = analyzeElement(element); |
622 assert(invariant(element, element.isDeclaration)); | 622 assert(invariant(element, element.isDeclaration)); |
623 enqueuer.resolution.resolvedElements[element] = result; | 623 enqueuer.resolution.resolvedElements[element] = result; |
624 return result; | 624 return result; |
625 } | 625 } |
626 | 626 |
627 void codegen(WorkItem work, Enqueuer world) { | 627 void codegen(WorkItem work, Enqueuer world) { |
628 if (!identical(world, enqueuer.codegen)) return null; | 628 if (!identical(world, enqueuer.codegen)) return null; |
629 if (progress.elapsedInMs() > 500) { | 629 if (progress.elapsedMilliseconds > 500) { |
630 // TODO(ahe): Add structured diagnostics to the compiler API and | 630 // TODO(ahe): Add structured diagnostics to the compiler API and |
631 // use it to separate this from the --verbose option. | 631 // use it to separate this from the --verbose option. |
632 log('Compiled ${codegenWorld.generatedCode.length} methods.'); | 632 log('Compiled ${codegenWorld.generatedCode.length} methods.'); |
633 progress.reset(); | 633 progress.reset(); |
634 } | 634 } |
635 backend.codegen(work); | 635 backend.codegen(work); |
636 } | 636 } |
637 | 637 |
638 DartType resolveTypeAnnotation(Element element, | 638 DartType resolveTypeAnnotation(Element element, |
639 TypeAnnotation annotation) { | 639 TypeAnnotation annotation) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 bool get isMockCompilation => false; | 777 bool get isMockCompilation => false; |
778 } | 778 } |
779 | 779 |
780 class CompilerTask { | 780 class CompilerTask { |
781 final Compiler compiler; | 781 final Compiler compiler; |
782 final Stopwatch watch; | 782 final Stopwatch watch; |
783 | 783 |
784 CompilerTask(this.compiler) : watch = new Stopwatch(); | 784 CompilerTask(this.compiler) : watch = new Stopwatch(); |
785 | 785 |
786 String get name => 'Unknown task'; | 786 String get name => 'Unknown task'; |
787 int get timing => watch.elapsedInMs(); | 787 int get timing => watch.elapsedMilliseconds; |
788 | 788 |
789 measure(Function action) { | 789 measure(Function action) { |
790 // TODO(kasperl): Do we have to worry about exceptions here? | 790 // TODO(kasperl): Do we have to worry about exceptions here? |
791 CompilerTask previous = compiler.measuredTask; | 791 CompilerTask previous = compiler.measuredTask; |
792 compiler.measuredTask = this; | 792 compiler.measuredTask = this; |
793 if (previous != null) previous.watch.stop(); | 793 if (previous != null) previous.watch.stop(); |
794 watch.start(); | 794 watch.start(); |
795 var result = action(); | 795 var result = action(); |
796 watch.stop(); | 796 watch.stop(); |
797 if (previous != null) previous.watch.start(); | 797 if (previous != null) previous.watch.start(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 862 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
863 // information on assertion errors. | 863 // information on assertion errors. |
864 if (condition is Function){ | 864 if (condition is Function){ |
865 condition = condition(); | 865 condition = condition(); |
866 } | 866 } |
867 if (!condition && message != null) { | 867 if (!condition && message != null) { |
868 print('assertion failed: $message'); | 868 print('assertion failed: $message'); |
869 } | 869 } |
870 return spannable != null && condition; | 870 return spannable != null && condition; |
871 } | 871 } |
OLD | NEW |