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

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

Issue 12525007: Record dependency information to implement first version of dependency (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years, 9 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
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 lib.forEachExport((Element e) { 104 lib.forEachExport((Element e) {
105 if (e.isFunction()) world.addToWorkList(e); 105 if (e.isFunction()) world.addToWorkList(e);
106 }); 106 });
107 } 107 }
108 108
109 // TODO(karlklose): get rid of this and add a factory constructor to [List] 109 // TODO(karlklose): get rid of this and add a factory constructor to [List]
110 // that creates an instance of JSArray to make the dependency visible in from 110 // that creates an instance of JSArray to make the dependency visible in from
111 // the source code. 111 // the source code.
112 void addBackendRtiDependencies(World world); 112 void addBackendRtiDependencies(World world);
113 113
114 void enqueueHelpers(ResolutionEnqueuer world); 114 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements);
115 void codegen(CodegenWorkItem work); 115 void codegen(CodegenWorkItem work);
116 116
117 // The backend determines the native resolution enqueuer, with a no-op 117 // The backend determines the native resolution enqueuer, with a no-op
118 // default, so tools like dart2dart can ignore the native classes. 118 // default, so tools like dart2dart can ignore the native classes.
119 native.NativeEnqueuer nativeResolutionEnqueuer(world) { 119 native.NativeEnqueuer nativeResolutionEnqueuer(world) {
120 return new native.NativeEnqueuer(); 120 return new native.NativeEnqueuer();
121 } 121 }
122 native.NativeEnqueuer nativeCodegenEnqueuer(world) { 122 native.NativeEnqueuer nativeCodegenEnqueuer(world) {
123 return new native.NativeEnqueuer(); 123 return new native.NativeEnqueuer();
124 } 124 }
125 125
126 void assembleProgram(); 126 void assembleProgram();
127 List<CompilerTask> get tasks; 127 List<CompilerTask> get tasks;
128 128
129 // TODO(ahe,karlklose): rename this? 129 // TODO(ahe,karlklose): rename this?
130 void dumpInferredTypes() {} 130 void dumpInferredTypes() {}
131 131
132 ItemCompilationContext createItemCompilationContext() { 132 ItemCompilationContext createItemCompilationContext() {
133 return new ItemCompilationContext(); 133 return new ItemCompilationContext();
134 } 134 }
135 135
136 // The following methods are hooks for the backend to register its 136 // The following methods are hooks for the backend to register its
137 // helper methods. 137 // helper methods.
138 void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) {} 138 void registerInstantiatedClass(ClassElement cls,
139 void registerStringInterpolation() {} 139 Enqueuer enqueuer,
140 void registerCatchStatement() {} 140 TreeElements elements) {}
141 void registerThrow() {} 141 void registerStringInterpolation(TreeElements elements) {}
142 void registerLazyField() {} 142 void registerCatchStatement(TreeElements elements) {}
143 void registerTypeLiteral() {} 143 void registerThrow(TreeElements elements) {}
144 void registerStackTraceInCatch() {} 144 void registerLazyField(TreeElements elements) {}
145 void registerIsCheck(DartType type, Enqueuer enqueuer) {} 145 void registerTypeLiteral(TreeElements elements) {}
146 void registerAsCheck(DartType type) {} 146 void registerStackTraceInCatch(TreeElements elements) {}
147 void registerThrowNoSuchMethod() {} 147 void registerIsCheck(DartType type,
148 void registerThrowRuntimeError() {} 148 Enqueuer enqueuer,
149 void registerAbstractClassInstantiation() {} 149 TreeElements elements) {}
150 void registerFallThroughError() {} 150 void registerAsCheck(DartType type, TreeElements elements) {}
151 void registerSuperNoSuchMethod() {} 151 void registerThrowNoSuchMethod(TreeElements elements) {}
152 void registerConstantMap() {} 152 void registerThrowRuntimeError(TreeElements elements) {}
153 void registerRuntimeType() {} 153 void registerAbstractClassInstantiation(TreeElements elements) {}
154 void registerFallThroughError(TreeElements elements) {}
155 void registerSuperNoSuchMethod(TreeElements elements) {}
156 void registerConstantMap(TreeElements elements) {}
157 void registerRuntimeType(TreeElements elements) {}
154 158
155 bool isNullImplementation(ClassElement cls) { 159 bool isNullImplementation(ClassElement cls) {
156 return cls == compiler.nullClass; 160 return cls == compiler.nullClass;
157 } 161 }
158 ClassElement get intImplementation => compiler.intClass; 162 ClassElement get intImplementation => compiler.intClass;
159 ClassElement get doubleImplementation => compiler.doubleClass; 163 ClassElement get doubleImplementation => compiler.doubleClass;
160 ClassElement get numImplementation => compiler.numClass; 164 ClassElement get numImplementation => compiler.numClass;
161 ClassElement get stringImplementation => compiler.stringClass; 165 ClassElement get stringImplementation => compiler.stringClass;
162 ClassElement get listImplementation => compiler.listClass; 166 ClassElement get listImplementation => compiler.listClass;
163 ClassElement get growableListImplementation => compiler.listClass; 167 ClassElement get growableListImplementation => compiler.listClass;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 int nextFreeClassId = 0; 220 int nextFreeClassId = 0;
217 World world; 221 World world;
218 String assembledCode; 222 String assembledCode;
219 Types types; 223 Types types;
220 224
221 /** 225 /**
222 * Map from token to the first preceeding comment token. 226 * Map from token to the first preceeding comment token.
223 */ 227 */
224 final TokenMap commentMap = new TokenMap(); 228 final TokenMap commentMap = new TokenMap();
225 229
230 /**
231 * Records global dependencies, that is, dependencies that don't
232 * correspond to a particular element.
233 *
234 * We should get rid of this and ensure that all dependencies are
235 * associated with a particular element.
236 */
237 final TreeElements globalDependencies = new TreeElementMapping(null);
238
226 final bool enableMinification; 239 final bool enableMinification;
227 final bool enableTypeAssertions; 240 final bool enableTypeAssertions;
228 final bool enableUserAssertions; 241 final bool enableUserAssertions;
229 final bool enableConcreteTypeInference; 242 final bool enableConcreteTypeInference;
230 /** 243 /**
231 * The maximum size of a concrete type before it widens to dynamic during 244 * The maximum size of a concrete type before it widens to dynamic during
232 * concrete type inference. 245 * concrete type inference.
233 */ 246 */
234 final int maxConcreteTypeSize; 247 final int maxConcreteTypeSize;
235 final bool analyzeAll; 248 final bool analyzeAll;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 dynamicClass = lookupHelperClass('Dynamic_'); 606 dynamicClass = lookupHelperClass('Dynamic_');
594 nullClass = lookupHelperClass('Null'); 607 nullClass = lookupHelperClass('Null');
595 if (!missingHelperClasses.isEmpty) { 608 if (!missingHelperClasses.isEmpty) {
596 internalErrorOnElement(jsHelperLibrary, 609 internalErrorOnElement(jsHelperLibrary,
597 'dart:_js_helper library does not contain required classes: ' 610 'dart:_js_helper library does not contain required classes: '
598 '$missingHelperClasses'); 611 '$missingHelperClasses');
599 } 612 }
600 613
601 types = new Types(this, dynamicClass); 614 types = new Types(this, dynamicClass);
602 backend.initializeHelperClasses(); 615 backend.initializeHelperClasses();
616
617 dynamicClass.ensureResolved(this);
603 } 618 }
604 619
605 Element _unnamedListConstructor; 620 Element _unnamedListConstructor;
606 Element get unnamedListConstructor { 621 Element get unnamedListConstructor {
607 if (_unnamedListConstructor != null) return _unnamedListConstructor; 622 if (_unnamedListConstructor != null) return _unnamedListConstructor;
608 Selector callConstructor = new Selector.callConstructor( 623 Selector callConstructor = new Selector.callConstructor(
609 const SourceString(""), listClass.getLibrary()); 624 const SourceString(""), listClass.getLibrary());
610 return _unnamedListConstructor = 625 return _unnamedListConstructor =
611 listClass.lookupConstructor(callConstructor); 626 listClass.lookupConstructor(callConstructor);
612 } 627 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 reportFatalError('main is not a function', main); 706 reportFatalError('main is not a function', main);
692 } 707 }
693 FunctionElement mainMethod = main; 708 FunctionElement mainMethod = main;
694 FunctionSignature parameters = mainMethod.computeSignature(this); 709 FunctionSignature parameters = mainMethod.computeSignature(this);
695 parameters.forEachParameter((Element parameter) { 710 parameters.forEachParameter((Element parameter) {
696 reportFatalError('main cannot have parameters', parameter); 711 reportFatalError('main cannot have parameters', parameter);
697 }); 712 });
698 } 713 }
699 } 714 }
700 715
701 deferredLoadTask.registerMainApp(mainApp);
702
703 log('Resolving...'); 716 log('Resolving...');
704 phase = PHASE_RESOLVING; 717 phase = PHASE_RESOLVING;
705 if (analyzeAll) { 718 if (analyzeAll) {
706 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib)); 719 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib));
707 } 720 }
708 backend.enqueueHelpers(enqueuer.resolution); 721 // Elements required by enqueueHelpers are global dependencies
722 // that are not pulled in by a particular element.
723 backend.enqueueHelpers(enqueuer.resolution, globalDependencies);
709 processQueue(enqueuer.resolution, main); 724 processQueue(enqueuer.resolution, main);
710 enqueuer.resolution.logSummary(log); 725 enqueuer.resolution.logSummary(log);
711 726
712 if (compilationFailed) return; 727 if (compilationFailed) return;
713 if (analyzeOnly) return; 728 if (analyzeOnly) return;
714 assert(main != null); 729 assert(main != null);
715 phase = PHASE_DONE_RESOLVING; 730 phase = PHASE_DONE_RESOLVING;
716 731
717 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution 732 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution
718 // should know this. 733 // should know this.
719 world.populate(); 734 world.populate();
720 735
736 deferredLoadTask.onResolutionComplete(main);
737
721 log('Inferring types...'); 738 log('Inferring types...');
722 typesTask.onResolutionComplete(main); 739 typesTask.onResolutionComplete(main);
723 740
724 log('Compiling...'); 741 log('Compiling...');
725 phase = PHASE_COMPILING; 742 phase = PHASE_COMPILING;
726 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. 743 // TODO(johnniwinther): Move these to [CodegenEnqueuer].
727 if (hasIsolateSupport()) { 744 if (hasIsolateSupport()) {
728 enqueuer.codegen.addToWorkList( 745 enqueuer.codegen.addToWorkList(
729 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); 746 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE));
730 } 747 }
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 1210
1194 void close() {} 1211 void close() {}
1195 1212
1196 toString() => name; 1213 toString() => name;
1197 1214
1198 /// Convenience method for getting an [api.CompilerOutputProvider]. 1215 /// Convenience method for getting an [api.CompilerOutputProvider].
1199 static NullSink outputProvider(String name, String extension) { 1216 static NullSink outputProvider(String name, String extension) {
1200 return new NullSink('$name.$extension'); 1217 return new NullSink('$name.$extension');
1201 } 1218 }
1202 } 1219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698