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

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: Correctly parse metadata 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 final Map<String, LibraryElement> libraries; 96 final Map<String, LibraryElement> libraries;
97 int nextFreeClassId = 0; 97 int nextFreeClassId = 0;
98 World world; 98 World world;
99 String assembledCode; 99 String assembledCode;
100 Types types; 100 Types types;
101 101
102 final bool enableMinification; 102 final bool enableMinification;
103 final bool enableTypeAssertions; 103 final bool enableTypeAssertions;
104 final bool enableUserAssertions; 104 final bool enableUserAssertions;
105 final bool enableConcreteTypeInference; 105 final bool enableConcreteTypeInference;
106 final bool analyzeAll;
106 107
107 bool disableInlining = false; 108 bool disableInlining = false;
108 109
109 final Tracer tracer; 110 final Tracer tracer;
110 111
111 CompilerTask measuredTask; 112 CompilerTask measuredTask;
112 Element _currentElement; 113 Element _currentElement;
113 LibraryElement coreLibrary; 114 LibraryElement coreLibrary;
114 LibraryElement isolateLibrary; 115 LibraryElement isolateLibrary;
115 LibraryElement jsHelperLibrary; 116 LibraryElement jsHelperLibrary;
(...skipping 90 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (!main.isFunction()) reportFatalError('main is not a function', main); 512 if (!main.isFunction()) reportFatalError('main is not a function', main);
511 FunctionElement mainMethod = main; 513 FunctionElement mainMethod = main;
512 FunctionSignature parameters = mainMethod.computeSignature(this); 514 FunctionSignature parameters = mainMethod.computeSignature(this);
513 parameters.forEachParameter((Element parameter) { 515 parameters.forEachParameter((Element parameter) {
514 reportFatalError('main cannot have parameters', parameter); 516 reportFatalError('main cannot have parameters', parameter);
515 }); 517 });
516 } 518 }
517 519
518 log('Resolving...'); 520 log('Resolving...');
519 phase = PHASE_RESOLVING; 521 phase = PHASE_RESOLVING;
522 if (analyzeAll) libraries.forEach((_, lib) => fullyEnqueueLibrary(lib));
520 backend.enqueueHelpers(enqueuer.resolution); 523 backend.enqueueHelpers(enqueuer.resolution);
521 processQueue(enqueuer.resolution, main); 524 processQueue(enqueuer.resolution, main);
522 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); 525 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.');
523 526
524 if (compilationFailed) return; 527 if (compilationFailed) return;
525 528
526 log('Inferring types...'); 529 log('Inferring types...');
527 typesTask.onResolutionComplete(main); 530 typesTask.onResolutionComplete(main);
528 531
529 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution 532 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution
530 // should know this. 533 // should know this.
531 world.populate(); 534 world.populate();
532 535
533 log('Compiling...'); 536 log('Compiling...');
534 phase = PHASE_COMPILING; 537 phase = PHASE_COMPILING;
535 processQueue(enqueuer.codegen, main); 538 processQueue(enqueuer.codegen, main);
536 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 539 log('Compiled ${codegenWorld.generatedCode.length} methods.');
537 540
538 if (compilationFailed) return; 541 if (compilationFailed) return;
539 542
540 backend.assembleProgram(); 543 backend.assembleProgram();
541 544
542 checkQueues(); 545 checkQueues();
543 } 546 }
544 547
548 void fullyEnqueueLibrary(LibraryElement library) {
549 library.forEachLocalMember(fullyEnqueueTopLevelElement);
550 }
551
552 void fullyEnqueueTopLevelElement(Element element) {
553 if (element.isClass()) {
554 ClassElement cls = element;
555 cls.ensureResolved(this);
556 for (Element member in cls.localMembers) {
557 enqueuer.resolution.addToWorkList(member);
558 }
559 } else {
560 enqueuer.resolution.addToWorkList(element);
561 }
562 }
563
545 void processQueue(Enqueuer world, Element main) { 564 void processQueue(Enqueuer world, Element main) {
546 backend.processNativeClasses(world, libraries.values); 565 backend.processNativeClasses(world, libraries.values);
547 world.addToWorkList(main); 566 world.addToWorkList(main);
548 progress.reset(); 567 progress.reset();
549 world.forEach((WorkItem work) { 568 world.forEach((WorkItem work) {
550 withCurrentElement(work.element, () => work.run(this, world)); 569 withCurrentElement(work.element, () => work.run(this, world));
551 }); 570 });
552 world.queueIsClosed = true; 571 world.queueIsClosed = true;
553 if (compilationFailed) return; 572 if (compilationFailed) return;
554 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 573 assert(world.checkNoEnqueuedInvokedInstanceMethods());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 SourceSpan span = spanFromElement(e); 621 SourceSpan span = spanFromElement(e);
603 reportDiagnostic(span, 'Warning: $e resolved but not compiled.', 622 reportDiagnostic(span, 'Warning: $e resolved but not compiled.',
604 api.Diagnostic.WARNING); 623 api.Diagnostic.WARNING);
605 } 624 }
606 } 625 }
607 626
608 TreeElements analyzeElement(Element element) { 627 TreeElements analyzeElement(Element element) {
609 assert(invariant(element, element.isDeclaration)); 628 assert(invariant(element, element.isDeclaration));
610 TreeElements elements = enqueuer.resolution.getCachedElements(element); 629 TreeElements elements = enqueuer.resolution.getCachedElements(element);
611 if (elements != null) return elements; 630 if (elements != null) return elements;
612 final int allowed = ElementCategory.VARIABLE | ElementCategory.FUNCTION
613 | ElementCategory.FACTORY;
614 ElementKind kind = element.kind;
615 if (!element.isAccessor() &&
616 ((identical(kind, ElementKind.ABSTRACT_FIELD)) ||
617 (kind.category & allowed) == 0)) {
618 return null;
619 }
620 assert(parser != null); 631 assert(parser != null);
621 Node tree = parser.parse(element); 632 Node tree = parser.parse(element);
622 validator.validate(tree); 633 validator.validate(tree);
623 elements = resolver.resolve(element); 634 elements = resolver.resolve(element);
624 checker.check(tree, elements); 635 checker.check(tree, elements);
625 typesTask.analyze(tree, elements); 636 typesTask.analyze(tree, elements);
626 return elements; 637 return elements;
627 } 638 }
628 639
629 TreeElements analyze(WorkItem work, Enqueuer world) { 640 TreeElements analyze(WorkItem work, Enqueuer world) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 // TODO(johnniwinther): Use [spannable] and [message] to provide better 914 // TODO(johnniwinther): Use [spannable] and [message] to provide better
904 // information on assertion errors. 915 // information on assertion errors.
905 if (condition is Function){ 916 if (condition is Function){
906 condition = condition(); 917 condition = condition();
907 } 918 }
908 if (spannable == null || !condition) { 919 if (spannable == null || !condition) {
909 throw new SpannableAssertionFailure(spannable, message); 920 throw new SpannableAssertionFailure(spannable, message);
910 } 921 }
911 return true; 922 return true;
912 } 923 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698