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

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

Issue 11293244: Implement --analyze-all option. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 final Map<String, LibraryElement> libraries; 95 final Map<String, LibraryElement> libraries;
96 int nextFreeClassId = 0; 96 int nextFreeClassId = 0;
97 World world; 97 World world;
98 String assembledCode; 98 String assembledCode;
99 Types types; 99 Types types;
100 100
101 final bool enableMinification; 101 final bool enableMinification;
102 final bool enableTypeAssertions; 102 final bool enableTypeAssertions;
103 final bool enableUserAssertions; 103 final bool enableUserAssertions;
104 final bool enableConcreteTypeInference; 104 final bool enableConcreteTypeInference;
105 final bool analyzeAll;
105 106
106 bool disableInlining = false; 107 bool disableInlining = false;
107 108
108 final Tracer tracer; 109 final Tracer tracer;
109 110
110 CompilerTask measuredTask; 111 CompilerTask measuredTask;
111 Element _currentElement; 112 Element _currentElement;
112 LibraryElement coreLibrary; 113 LibraryElement coreLibrary;
113 LibraryElement coreImplLibrary; 114 LibraryElement coreImplLibrary;
114 LibraryElement isolateLibrary; 115 LibraryElement isolateLibrary;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool hasCrashed = false; 207 bool hasCrashed = false;
207 208
208 Compiler({this.tracer: const Tracer(), 209 Compiler({this.tracer: const Tracer(),
209 this.enableTypeAssertions: false, 210 this.enableTypeAssertions: false,
210 this.enableUserAssertions: false, 211 this.enableUserAssertions: false,
211 this.enableConcreteTypeInference: false, 212 this.enableConcreteTypeInference: false,
212 this.enableMinification: false, 213 this.enableMinification: false,
213 bool emitJavaScript: true, 214 bool emitJavaScript: true,
214 bool generateSourceMap: true, 215 bool generateSourceMap: true,
215 bool disallowUnsafeEval: false, 216 bool disallowUnsafeEval: false,
217 this.analyzeAll: false,
216 List<String> strips: const []}) 218 List<String> strips: const []})
217 : libraries = new Map<String, LibraryElement>(), 219 : libraries = new Map<String, LibraryElement>(),
218 progress = new Stopwatch() { 220 progress = new Stopwatch() {
219 progress.start(); 221 progress.start();
220 world = new World(this); 222 world = new World(this);
221 scanner = new ScannerTask(this); 223 scanner = new ScannerTask(this);
222 dietParser = new DietParserTask(this); 224 dietParser = new DietParserTask(this);
223 parser = new ParserTask(this); 225 parser = new ParserTask(this);
224 patchParser = new PatchParserTask(this); 226 patchParser = new PatchParserTask(this);
225 libraryLoader = new LibraryLoaderTask(this); 227 libraryLoader = new LibraryLoaderTask(this);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 if (!main.isFunction()) reportFatalError('main is not a function', main); 519 if (!main.isFunction()) reportFatalError('main is not a function', main);
518 FunctionElement mainMethod = main; 520 FunctionElement mainMethod = main;
519 FunctionSignature parameters = mainMethod.computeSignature(this); 521 FunctionSignature parameters = mainMethod.computeSignature(this);
520 parameters.forEachParameter((Element parameter) { 522 parameters.forEachParameter((Element parameter) {
521 reportFatalError('main cannot have parameters', parameter); 523 reportFatalError('main cannot have parameters', parameter);
522 }); 524 });
523 } 525 }
524 526
525 log('Resolving...'); 527 log('Resolving...');
526 phase = PHASE_RESOLVING; 528 phase = PHASE_RESOLVING;
529 if (analyzeAll) libraries.forEach(fullyEnqueueLibrary);
527 backend.enqueueHelpers(enqueuer.resolution); 530 backend.enqueueHelpers(enqueuer.resolution);
528 processQueue(enqueuer.resolution, main); 531 processQueue(enqueuer.resolution, main);
529 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); 532 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.');
530 533
531 if (compilationFailed) return; 534 if (compilationFailed) return;
532 535
533 log('Inferring types...'); 536 log('Inferring types...');
534 typesTask.onResolutionComplete(main); 537 typesTask.onResolutionComplete(main);
535 538
536 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution 539 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution
537 // should know this. 540 // should know this.
538 world.populate(); 541 world.populate();
539 542
540 log('Compiling...'); 543 log('Compiling...');
541 phase = PHASE_COMPILING; 544 phase = PHASE_COMPILING;
542 processQueue(enqueuer.codegen, main); 545 processQueue(enqueuer.codegen, main);
543 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 546 log('Compiled ${codegenWorld.generatedCode.length} methods.');
544 547
545 if (compilationFailed) return; 548 if (compilationFailed) return;
546 549
547 backend.assembleProgram(); 550 backend.assembleProgram();
548 551
549 checkQueues(); 552 checkQueues();
550 } 553 }
551 554
555 void fullyEnqueueLibrary(_, LibraryElement library) {
karlklose 2012/11/13 08:33:47 The ignored first argument looks a bit strange. Yo
ahe 2012/11/13 13:13:43 Done.
556 library.forEachLocalMember(fullyEnqueueTopLevelElement);
557 }
558
559 void fullyEnqueueTopLevelElement(Element element) {
560 element.computeType(this);
karlklose 2012/11/13 08:33:47 Move this computation to ensureResolved?
ahe 2012/11/13 13:13:43 Well, that wouldn't work. But making sure that al
561 if (element.isClass()) {
562 resolver.resolve(element);
karlklose 2012/11/13 08:33:47 Why do you not use ensureResolved here? Is it to m
ahe 2012/11/13 13:13:43 Done.
563 ClassElement cls = element;
564 for (Element member in cls.localMembers) {
565 enqueuer.resolution.addToWorkList(member);
566 }
567 } else {
568 enqueuer.resolution.addToWorkList(element);
569 }
570 }
571
552 void processQueue(Enqueuer world, Element main) { 572 void processQueue(Enqueuer world, Element main) {
553 backend.processNativeClasses(world, libraries.values); 573 backend.processNativeClasses(world, libraries.values);
554 world.addToWorkList(main); 574 world.addToWorkList(main);
555 progress.reset(); 575 progress.reset();
556 world.forEach((WorkItem work) { 576 world.forEach((WorkItem work) {
557 withCurrentElement(work.element, () => work.run(this, world)); 577 withCurrentElement(work.element, () => work.run(this, world));
558 }); 578 });
559 world.queueIsClosed = true; 579 world.queueIsClosed = true;
560 if (compilationFailed) return; 580 if (compilationFailed) return;
561 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 581 assert(world.checkNoEnqueuedInvokedInstanceMethods());
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 // TODO(johnniwinther): Use [spannable] and [message] to provide better 930 // TODO(johnniwinther): Use [spannable] and [message] to provide better
911 // information on assertion errors. 931 // information on assertion errors.
912 if (condition is Function){ 932 if (condition is Function){
913 condition = condition(); 933 condition = condition();
914 } 934 }
915 if (spannable == null || !condition) { 935 if (spannable == null || !condition) {
916 throw new SpannableAssertionFailure(spannable, message); 936 throw new SpannableAssertionFailure(spannable, message);
917 } 937 }
918 return true; 938 return true;
919 } 939 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698