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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 final bool enableMinification; | 705 final bool enableMinification; |
706 | 706 |
707 final bool useFrequencyNamer; | 707 final bool useFrequencyNamer; |
708 | 708 |
709 /// When `true` emits URIs in the reflection metadata. | 709 /// When `true` emits URIs in the reflection metadata. |
710 final bool preserveUris; | 710 final bool preserveUris; |
711 | 711 |
712 final bool enableTypeAssertions; | 712 final bool enableTypeAssertions; |
713 final bool enableUserAssertions; | 713 final bool enableUserAssertions; |
714 final bool trustTypeAnnotations; | 714 final bool trustTypeAnnotations; |
| 715 final bool computeAnalysisStats; |
715 final bool trustPrimitives; | 716 final bool trustPrimitives; |
716 final bool enableConcreteTypeInference; | 717 final bool enableConcreteTypeInference; |
717 final bool disableTypeInferenceFlag; | 718 final bool disableTypeInferenceFlag; |
718 final Uri deferredMapUri; | 719 final Uri deferredMapUri; |
719 final bool dumpInfo; | 720 final bool dumpInfo; |
720 final bool useContentSecurityPolicy; | 721 final bool useContentSecurityPolicy; |
721 final bool enableExperimentalMirrors; | 722 final bool enableExperimentalMirrors; |
722 | 723 |
723 /** | 724 /** |
724 * The maximum size of a concrete type before it widens to dynamic during | 725 * The maximum size of a concrete type before it widens to dynamic during |
(...skipping 10 matching lines...) Expand all Loading... |
735 * If true, skip analysis of method bodies and field initializers. Implies | 736 * If true, skip analysis of method bodies and field initializers. Implies |
736 * [analyzeOnly]. | 737 * [analyzeOnly]. |
737 */ | 738 */ |
738 final bool analyzeSignaturesOnly; | 739 final bool analyzeSignaturesOnly; |
739 final bool enableNativeLiveTypeAnalysis; | 740 final bool enableNativeLiveTypeAnalysis; |
740 | 741 |
741 /** | 742 /** |
742 * If true, stop compilation after type inference is complete. Used for | 743 * If true, stop compilation after type inference is complete. Used for |
743 * debugging and testing purposes only. | 744 * debugging and testing purposes only. |
744 */ | 745 */ |
745 bool stopAfterTypeInference = false; | 746 bool stopAfterTypeInference = |
| 747 // TODO(sigmund): remove this initializer (currently |
| 748 // compute_analysis_stats is used to retreive data and stop after |
| 749 // inference.) |
| 750 const bool.fromEnvironment('compute_analysis_stats'); |
746 | 751 |
747 /** | 752 /** |
748 * If [:true:], comment tokens are collected in [commentMap] during scanning. | 753 * If [:true:], comment tokens are collected in [commentMap] during scanning. |
749 */ | 754 */ |
750 final bool preserveComments; | 755 final bool preserveComments; |
751 | 756 |
752 /// Use the new CPS based backend end. This flag works for both the Dart and | 757 /// Use the new CPS based backend end. This flag works for both the Dart and |
753 /// JavaScript backend. | 758 /// JavaScript backend. |
754 final bool useCpsIr; | 759 final bool useCpsIr; |
755 | 760 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 GenericTask reuseLibraryTask; | 966 GenericTask reuseLibraryTask; |
962 | 967 |
963 /// The constant environment for the frontend interpretation of compile-time | 968 /// The constant environment for the frontend interpretation of compile-time |
964 /// constants. | 969 /// constants. |
965 ConstantEnvironment constants; | 970 ConstantEnvironment constants; |
966 | 971 |
967 EnqueueTask enqueuer; | 972 EnqueueTask enqueuer; |
968 DeferredLoadTask deferredLoadTask; | 973 DeferredLoadTask deferredLoadTask; |
969 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; | 974 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; |
970 DumpInfoTask dumpInfoTask; | 975 DumpInfoTask dumpInfoTask; |
| 976 StatsBuilderTask statsBuilderTask; |
971 String buildId; | 977 String buildId; |
972 | 978 |
973 /// A customizable filter that is applied to enqueued work items. | 979 /// A customizable filter that is applied to enqueued work items. |
974 QueueFilter enqueuerFilter = new QueueFilter(); | 980 QueueFilter enqueuerFilter = new QueueFilter(); |
975 | 981 |
976 static const String MAIN = 'main'; | 982 static const String MAIN = 'main'; |
977 static const String CALL_OPERATOR_NAME = 'call'; | 983 static const String CALL_OPERATOR_NAME = 'call'; |
978 static const String NO_SUCH_METHOD = 'noSuchMethod'; | 984 static const String NO_SUCH_METHOD = 'noSuchMethod'; |
979 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | 985 static const int NO_SUCH_METHOD_ARG_COUNT = 1; |
980 static const String CREATE_INVOCATION_MIRROR = | 986 static const String CREATE_INVOCATION_MIRROR = |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 } | 1032 } |
1027 | 1033 |
1028 bool hasCrashed = false; | 1034 bool hasCrashed = false; |
1029 | 1035 |
1030 /// Set by the backend if real reflection is detected in use of dart:mirrors. | 1036 /// Set by the backend if real reflection is detected in use of dart:mirrors. |
1031 bool disableTypeInferenceForMirrors = false; | 1037 bool disableTypeInferenceForMirrors = false; |
1032 | 1038 |
1033 Compiler({this.enableTypeAssertions: false, | 1039 Compiler({this.enableTypeAssertions: false, |
1034 this.enableUserAssertions: false, | 1040 this.enableUserAssertions: false, |
1035 this.trustTypeAnnotations: false, | 1041 this.trustTypeAnnotations: false, |
| 1042 // TODO(sigmund): eventually add a flag for this or merge with |
| 1043 // DumpInfo |
| 1044 this.computeAnalysisStats: |
| 1045 const bool.fromEnvironment('compute_analysis_stats'), |
1036 this.trustPrimitives: false, | 1046 this.trustPrimitives: false, |
1037 this.enableConcreteTypeInference: false, | 1047 this.enableConcreteTypeInference: false, |
1038 bool disableTypeInferenceFlag: false, | 1048 bool disableTypeInferenceFlag: false, |
1039 this.maxConcreteTypeSize: 5, | 1049 this.maxConcreteTypeSize: 5, |
1040 this.enableMinification: false, | 1050 this.enableMinification: false, |
1041 this.preserveUris: false, | 1051 this.preserveUris: false, |
1042 this.enableNativeLiveTypeAnalysis: false, | 1052 this.enableNativeLiveTypeAnalysis: false, |
1043 bool emitJavaScript: true, | 1053 bool emitJavaScript: true, |
1044 bool dart2dartMultiFile: false, | 1054 bool dart2dartMultiFile: false, |
1045 bool generateSourceMap: true, | 1055 bool generateSourceMap: true, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 resolver = new ResolverTask(this, backend.constantCompilerTask), | 1133 resolver = new ResolverTask(this, backend.constantCompilerTask), |
1124 closureToClassMapper = new closureMapping.ClosureTask(this), | 1134 closureToClassMapper = new closureMapping.ClosureTask(this), |
1125 checker = new TypeCheckerTask(this), | 1135 checker = new TypeCheckerTask(this), |
1126 irBuilder = new IrBuilderTask(this, backend.sourceInformationStrategy), | 1136 irBuilder = new IrBuilderTask(this, backend.sourceInformationStrategy), |
1127 typesTask = new ti.TypesTask(this), | 1137 typesTask = new ti.TypesTask(this), |
1128 constants = backend.constantCompilerTask, | 1138 constants = backend.constantCompilerTask, |
1129 deferredLoadTask = new DeferredLoadTask(this), | 1139 deferredLoadTask = new DeferredLoadTask(this), |
1130 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 1140 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
1131 enqueuer = new EnqueueTask(this), | 1141 enqueuer = new EnqueueTask(this), |
1132 dumpInfoTask = new DumpInfoTask(this), | 1142 dumpInfoTask = new DumpInfoTask(this), |
| 1143 statsBuilderTask = new StatsBuilderTask(this), |
1133 reuseLibraryTask = new GenericTask('Reuse library', this), | 1144 reuseLibraryTask = new GenericTask('Reuse library', this), |
1134 ]; | 1145 ]; |
1135 | 1146 |
1136 tasks.addAll(backend.tasks); | 1147 tasks.addAll(backend.tasks); |
1137 } | 1148 } |
1138 | 1149 |
1139 Universe get resolverWorld => enqueuer.resolution.universe; | 1150 Universe get resolverWorld => enqueuer.resolution.universe; |
1140 Universe get codegenWorld => enqueuer.codegen.universe; | 1151 Universe get codegenWorld => enqueuer.codegen.universe; |
1141 | 1152 |
1142 bool get hasBuildId => buildId != UNDETERMINED_BUILD_ID; | 1153 bool get hasBuildId => buildId != UNDETERMINED_BUILD_ID; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 } else { | 1522 } else { |
1512 log('Compiling $uri ($buildId)'); | 1523 log('Compiling $uri ($buildId)'); |
1513 } | 1524 } |
1514 return libraryLoader.loadLibrary(uri).then((LibraryElement library) { | 1525 return libraryLoader.loadLibrary(uri).then((LibraryElement library) { |
1515 mainApp = library; | 1526 mainApp = library; |
1516 }); | 1527 }); |
1517 } | 1528 } |
1518 }).then((_) { | 1529 }).then((_) { |
1519 compileLoadedLibraries(); | 1530 compileLoadedLibraries(); |
1520 }); | 1531 }); |
| 1532 |
1521 } | 1533 } |
1522 | 1534 |
1523 void computeMain() { | 1535 void computeMain() { |
1524 if (mainApp == null) return; | 1536 if (mainApp == null) return; |
1525 | 1537 |
1526 Element main = mainApp.findExported(MAIN); | 1538 Element main = mainApp.findExported(MAIN); |
1527 ErroneousElement errorElement = null; | 1539 ErroneousElement errorElement = null; |
1528 if (main == null) { | 1540 if (main == null) { |
1529 if (analyzeOnly) { | 1541 if (analyzeOnly) { |
1530 if (!analyzeAll) { | 1542 if (!analyzeAll) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 world.populate(); | 1662 world.populate(); |
1651 // Compute whole-program-knowledge that the backend needs. (This might | 1663 // Compute whole-program-knowledge that the backend needs. (This might |
1652 // require the information computed in [world.populate].) | 1664 // require the information computed in [world.populate].) |
1653 backend.onResolutionComplete(); | 1665 backend.onResolutionComplete(); |
1654 | 1666 |
1655 deferredLoadTask.onResolutionComplete(mainFunction); | 1667 deferredLoadTask.onResolutionComplete(mainFunction); |
1656 | 1668 |
1657 log('Inferring types...'); | 1669 log('Inferring types...'); |
1658 typesTask.onResolutionComplete(mainFunction); | 1670 typesTask.onResolutionComplete(mainFunction); |
1659 | 1671 |
| 1672 statsBuilderTask.run(); |
| 1673 |
1660 if (stopAfterTypeInference) return; | 1674 if (stopAfterTypeInference) return; |
1661 | 1675 |
1662 backend.onTypeInferenceComplete(); | 1676 backend.onTypeInferenceComplete(); |
1663 | 1677 |
1664 log('Compiling...'); | 1678 log('Compiling...'); |
1665 phase = PHASE_COMPILING; | 1679 phase = PHASE_COMPILING; |
1666 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. | 1680 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. |
1667 if (hasIsolateSupport) { | 1681 if (hasIsolateSupport) { |
1668 backend.enableIsolateSupport(enqueuer.codegen); | 1682 backend.enableIsolateSupport(enqueuer.codegen); |
1669 } | 1683 } |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2508 InterfaceType streamType([DartType elementType]) { | 2522 InterfaceType streamType([DartType elementType]) { |
2509 InterfaceType type = streamClass.computeType(compiler); | 2523 InterfaceType type = streamClass.computeType(compiler); |
2510 if (elementType == null) { | 2524 if (elementType == null) { |
2511 return streamClass.rawType; | 2525 return streamClass.rawType; |
2512 } | 2526 } |
2513 return type.createInstantiation([elementType]); | 2527 return type.createInstantiation([elementType]); |
2514 } | 2528 } |
2515 } | 2529 } |
2516 | 2530 |
2517 typedef void InternalErrorFunction(Spannable location, String message); | 2531 typedef void InternalErrorFunction(Spannable location, String message); |
OLD | NEW |