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

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

Issue 11882017: Add --analyze-only flag to dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years, 11 months 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/apiimpl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 final bool enableMinification; 186 final bool enableMinification;
187 final bool enableTypeAssertions; 187 final bool enableTypeAssertions;
188 final bool enableUserAssertions; 188 final bool enableUserAssertions;
189 final bool enableConcreteTypeInference; 189 final bool enableConcreteTypeInference;
190 /** 190 /**
191 * The maximum size of a concrete type before it widens to dynamic during 191 * The maximum size of a concrete type before it widens to dynamic during
192 * concrete type inference. 192 * concrete type inference.
193 */ 193 */
194 final int maxConcreteTypeSize; 194 final int maxConcreteTypeSize;
195 final bool analyzeAll; 195 final bool analyzeAll;
196 final bool analyzeOnly;
196 final bool enableNativeLiveTypeAnalysis; 197 final bool enableNativeLiveTypeAnalysis;
197 final bool rejectDeprecatedFeatures; 198 final bool rejectDeprecatedFeatures;
198 final bool checkDeprecationInSdk; 199 final bool checkDeprecationInSdk;
199 200
200 /** 201 /**
201 * If [:true:], comment tokens are collected in [commentMap] during scanning. 202 * If [:true:], comment tokens are collected in [commentMap] during scanning.
202 */ 203 */
203 final bool preserveComments; 204 final bool preserveComments;
204 205
205 bool disableInlining = false; 206 bool disableInlining = false;
206 207
208 List<Uri> librariesToAnalyzeWhenRun;
209
207 final Tracer tracer; 210 final Tracer tracer;
208 211
209 CompilerTask measuredTask; 212 CompilerTask measuredTask;
210 Element _currentElement; 213 Element _currentElement;
211 LibraryElement coreLibrary; 214 LibraryElement coreLibrary;
212 LibraryElement isolateLibrary; 215 LibraryElement isolateLibrary;
213 LibraryElement isolateHelperLibrary; 216 LibraryElement isolateHelperLibrary;
214 LibraryElement jsHelperLibrary; 217 LibraryElement jsHelperLibrary;
215 LibraryElement interceptorsLibrary; 218 LibraryElement interceptorsLibrary;
216 LibraryElement foreignLibrary; 219 LibraryElement foreignLibrary;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 this.enableTypeAssertions: false, 320 this.enableTypeAssertions: false,
318 this.enableUserAssertions: false, 321 this.enableUserAssertions: false,
319 this.enableConcreteTypeInference: false, 322 this.enableConcreteTypeInference: false,
320 this.maxConcreteTypeSize: 5, 323 this.maxConcreteTypeSize: 5,
321 this.enableMinification: false, 324 this.enableMinification: false,
322 this.enableNativeLiveTypeAnalysis: false, 325 this.enableNativeLiveTypeAnalysis: false,
323 bool emitJavaScript: true, 326 bool emitJavaScript: true,
324 bool generateSourceMap: true, 327 bool generateSourceMap: true,
325 bool disallowUnsafeEval: false, 328 bool disallowUnsafeEval: false,
326 this.analyzeAll: false, 329 this.analyzeAll: false,
330 this.analyzeOnly: false,
327 this.rejectDeprecatedFeatures: false, 331 this.rejectDeprecatedFeatures: false,
328 this.checkDeprecationInSdk: false, 332 this.checkDeprecationInSdk: false,
329 this.preserveComments: false, 333 this.preserveComments: false,
330 List<String> strips: const []}) 334 List<String> strips: const []})
331 : libraries = new Map<String, LibraryElement>(), 335 : libraries = new Map<String, LibraryElement>(),
332 progress = new Stopwatch() { 336 progress = new Stopwatch() {
333 progress.start(); 337 progress.start();
334 world = new World(this); 338 world = new World(this);
335 339
336 closureMapping.ClosureNamer closureNamer; 340 closureMapping.ClosureNamer closureNamer;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if (libraryName == 'dart:isolate' 630 if (libraryName == 'dart:isolate'
627 || libraryName == 'dart:html' 631 || libraryName == 'dart:html'
628 // TODO(floitsch): create a separate async-helper library instead of 632 // TODO(floitsch): create a separate async-helper library instead of
629 // importing the isolate-library just for TimerImpl. 633 // importing the isolate-library just for TimerImpl.
630 || libraryName == 'dart:async') { 634 || libraryName == 'dart:async') {
631 importIsolateHelperLibrary(library); 635 importIsolateHelperLibrary(library);
632 } 636 }
633 } 637 }
634 638
635 void runCompiler(Uri uri) { 639 void runCompiler(Uri uri) {
636 log('compiling $uri ($BUILD_ID)'); 640 assert(uri != null || analyzeOnly);
637 scanBuiltinLibraries(); 641 scanBuiltinLibraries();
638 mainApp = libraryLoader.loadLibrary(uri, null, uri); 642 if (librariesToAnalyzeWhenRun != null) {
643 for (Uri libraryUri in librariesToAnalyzeWhenRun) {
644 log('analyzing $libraryUri ($BUILD_ID)');
645 libraryLoader.loadLibrary(libraryUri, null, libraryUri);
646 }
647 }
648 if (uri != null) {
649 log('compiling $uri ($BUILD_ID)');
650 mainApp = libraryLoader.loadLibrary(uri, null, uri);
651 }
639 libraries.forEach((_, library) { 652 libraries.forEach((_, library) {
640 maybeEnableJSHelper(library); 653 maybeEnableJSHelper(library);
641 maybeEnableIsolateHelper(library); 654 maybeEnableIsolateHelper(library);
642 }); 655 });
643 final Element main = mainApp.find(MAIN); 656 Element main = null;
644 if (main == null) { 657 if (!analyzeOnly) {
ahe 2013/01/21 12:23:21 I think this should be: if (mainApp != null) {
645 reportFatalError('Could not find $MAIN', mainApp); 658 main = mainApp.find(MAIN);
646 } else { 659 if (main == null) {
647 if (!main.isFunction()) reportFatalError('main is not a function', main); 660 reportFatalError('Could not find $MAIN', mainApp);
648 FunctionElement mainMethod = main; 661 } else {
649 FunctionSignature parameters = mainMethod.computeSignature(this); 662 if (!main.isFunction()) reportFatalError('main is not a function', main) ;
ahe 2013/01/21 12:23:21 Long line.
Johnni Winther 2013/01/22 16:06:55 Done.
650 parameters.forEachParameter((Element parameter) { 663 FunctionElement mainMethod = main;
651 reportFatalError('main cannot have parameters', parameter); 664 FunctionSignature parameters = mainMethod.computeSignature(this);
652 }); 665 parameters.forEachParameter((Element parameter) {
666 reportFatalError('main cannot have parameters', parameter);
667 });
668 }
653 } 669 }
654 670
655 log('Resolving...'); 671 log('Resolving...');
656 phase = PHASE_RESOLVING; 672 phase = PHASE_RESOLVING;
657 if (analyzeAll) libraries.forEach((_, lib) => fullyEnqueueLibrary(lib)); 673 if (analyzeAll || analyzeOnly) {
ahe 2013/01/21 12:23:21 I don't think analyzeOnly should imply analyzeAll.
Johnni Winther 2013/01/22 16:06:55 Done.
674 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib));
675 }
658 backend.enqueueHelpers(enqueuer.resolution); 676 backend.enqueueHelpers(enqueuer.resolution);
659 processQueue(enqueuer.resolution, main); 677 processQueue(enqueuer.resolution, main);
660 enqueuer.resolution.logSummary(log); 678 enqueuer.resolution.logSummary(log);
661 679
662 if (compilationFailed) return; 680 if (compilationFailed) return;
681 if (analyzeOnly) return;
682 assert(main != null);
663 683
664 log('Inferring types...'); 684 log('Inferring types...');
665 typesTask.onResolutionComplete(main); 685 typesTask.onResolutionComplete(main);
666 686
667 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution 687 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution
668 // should know this. 688 // should know this.
669 world.populate(); 689 world.populate();
670 690
671 log('Compiling...'); 691 log('Compiling...');
672 phase = PHASE_COMPILING; 692 phase = PHASE_COMPILING;
(...skipping 19 matching lines...) Expand all
692 712
693 void fullyEnqueueLibrary(LibraryElement library) { 713 void fullyEnqueueLibrary(LibraryElement library) {
694 library.forEachLocalMember(fullyEnqueueTopLevelElement); 714 library.forEachLocalMember(fullyEnqueueTopLevelElement);
695 } 715 }
696 716
697 void fullyEnqueueTopLevelElement(Element element) { 717 void fullyEnqueueTopLevelElement(Element element) {
698 if (element.isClass()) { 718 if (element.isClass()) {
699 ClassElement cls = element; 719 ClassElement cls = element;
700 cls.ensureResolved(this); 720 cls.ensureResolved(this);
701 cls.forEachLocalMember(enqueuer.resolution.addToWorkList); 721 cls.forEachLocalMember(enqueuer.resolution.addToWorkList);
722 } else if (element.isTypedef()) {
723 TypedefElement typdef = element;
724 typdef.computeType(this);
702 } else { 725 } else {
703 enqueuer.resolution.addToWorkList(element); 726 enqueuer.resolution.addToWorkList(element);
704 } 727 }
705 } 728 }
706 729
707 void processQueue(Enqueuer world, Element main) { 730 void processQueue(Enqueuer world, Element main) {
708 world.nativeEnqueuer.processNativeClasses(libraries.values); 731 world.nativeEnqueuer.processNativeClasses(libraries.values);
709 world.addToWorkList(main); 732 if (main != null) {
733 world.addToWorkList(main);
734 }
710 progress.reset(); 735 progress.reset();
711 world.forEach((WorkItem work) { 736 world.forEach((WorkItem work) {
712 withCurrentElement(work.element, () => work.run(this, world)); 737 withCurrentElement(work.element, () => work.run(this, world));
713 }); 738 });
714 world.queueIsClosed = true; 739 world.queueIsClosed = true;
715 if (compilationFailed) return; 740 if (compilationFailed) return;
716 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 741 assert(world.checkNoEnqueuedInvokedInstanceMethods());
717 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) { 742 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) {
718 backend.dumpInferredTypes(); 743 backend.dumpInferredTypes();
719 } 744 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 // TODO(johnniwinther): Use [spannable] and [message] to provide better 1103 // TODO(johnniwinther): Use [spannable] and [message] to provide better
1079 // information on assertion errors. 1104 // information on assertion errors.
1080 if (condition is Function){ 1105 if (condition is Function){
1081 condition = condition(); 1106 condition = condition();
1082 } 1107 }
1083 if (spannable == null || !condition) { 1108 if (spannable == null || !condition) {
1084 throw new SpannableAssertionFailure(spannable, message); 1109 throw new SpannableAssertionFailure(spannable, message);
1085 } 1110 }
1086 return true; 1111 return true;
1087 } 1112 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/apiimpl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698