Chromium Code Reviews| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 * We should get rid of this and ensure that all dependencies are | 247 * We should get rid of this and ensure that all dependencies are |
| 248 * associated with a particular element. | 248 * associated with a particular element. |
| 249 */ | 249 */ |
| 250 final TreeElements globalDependencies = new TreeElementMapping(null); | 250 final TreeElements globalDependencies = new TreeElementMapping(null); |
| 251 | 251 |
| 252 final bool enableMinification; | 252 final bool enableMinification; |
| 253 final bool enableTypeAssertions; | 253 final bool enableTypeAssertions; |
| 254 final bool enableUserAssertions; | 254 final bool enableUserAssertions; |
| 255 final bool trustTypeAnnotations; | 255 final bool trustTypeAnnotations; |
| 256 final bool enableConcreteTypeInference; | 256 final bool enableConcreteTypeInference; |
| 257 final bool disableTypeInference; | 257 final bool disableTypeInferenceFlag; |
| 258 | 258 |
| 259 /** | 259 /** |
| 260 * The maximum size of a concrete type before it widens to dynamic during | 260 * The maximum size of a concrete type before it widens to dynamic during |
| 261 * concrete type inference. | 261 * concrete type inference. |
| 262 */ | 262 */ |
| 263 final int maxConcreteTypeSize; | 263 final int maxConcreteTypeSize; |
| 264 final bool analyzeAll; | 264 final bool analyzeAllFlag; |
| 265 final bool analyzeOnly; | 265 final bool analyzeOnly; |
| 266 /** | 266 /** |
| 267 * If true, skip analysis of method bodies and field initializers. Implies | 267 * If true, skip analysis of method bodies and field initializers. Implies |
| 268 * [analyzeOnly]. | 268 * [analyzeOnly]. |
| 269 */ | 269 */ |
| 270 final bool analyzeSignaturesOnly; | 270 final bool analyzeSignaturesOnly; |
| 271 final bool enableNativeLiveTypeAnalysis; | 271 final bool enableNativeLiveTypeAnalysis; |
| 272 final bool rejectDeprecatedFeatures; | 272 final bool rejectDeprecatedFeatures; |
| 273 final bool checkDeprecationInSdk; | 273 final bool checkDeprecationInSdk; |
| 274 | 274 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 | 450 |
| 451 bool compilationFailed = false; | 451 bool compilationFailed = false; |
| 452 | 452 |
| 453 bool hasCrashed = false; | 453 bool hasCrashed = false; |
| 454 | 454 |
| 455 Compiler({this.tracer: const Tracer(), | 455 Compiler({this.tracer: const Tracer(), |
| 456 this.enableTypeAssertions: false, | 456 this.enableTypeAssertions: false, |
| 457 this.enableUserAssertions: false, | 457 this.enableUserAssertions: false, |
| 458 this.trustTypeAnnotations: false, | 458 this.trustTypeAnnotations: false, |
| 459 this.enableConcreteTypeInference: false, | 459 this.enableConcreteTypeInference: false, |
| 460 this.disableTypeInference: false, | 460 this.disableTypeInferenceFlag: false, |
| 461 this.maxConcreteTypeSize: 5, | 461 this.maxConcreteTypeSize: 5, |
| 462 this.enableMinification: false, | 462 this.enableMinification: false, |
| 463 this.enableNativeLiveTypeAnalysis: false, | 463 this.enableNativeLiveTypeAnalysis: false, |
| 464 bool emitJavaScript: true, | 464 bool emitJavaScript: true, |
| 465 bool generateSourceMap: true, | 465 bool generateSourceMap: true, |
| 466 bool disallowUnsafeEval: false, | 466 bool disallowUnsafeEval: false, |
| 467 this.analyzeAll: false, | 467 this.analyzeAllFlag: false, |
| 468 bool analyzeOnly: false, | 468 bool analyzeOnly: false, |
| 469 bool analyzeSignaturesOnly: false, | 469 bool analyzeSignaturesOnly: false, |
| 470 this.rejectDeprecatedFeatures: false, | 470 this.rejectDeprecatedFeatures: false, |
| 471 this.checkDeprecationInSdk: false, | 471 this.checkDeprecationInSdk: false, |
| 472 this.preserveComments: false, | 472 this.preserveComments: false, |
| 473 this.verbose: false, | 473 this.verbose: false, |
| 474 this.sourceMapUri: null, | 474 this.sourceMapUri: null, |
| 475 this.buildId: UNDETERMINED_BUILD_ID, | 475 this.buildId: UNDETERMINED_BUILD_ID, |
| 476 this.globalJsName: r'$', | 476 this.globalJsName: r'$', |
| 477 outputProvider, | 477 outputProvider, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 this, backend.constantSystem, isMetadata: true); | 518 this, backend.constantSystem, isMetadata: true); |
| 519 } | 519 } |
| 520 | 520 |
| 521 Universe get resolverWorld => enqueuer.resolution.universe; | 521 Universe get resolverWorld => enqueuer.resolution.universe; |
| 522 Universe get codegenWorld => enqueuer.codegen.universe; | 522 Universe get codegenWorld => enqueuer.codegen.universe; |
| 523 | 523 |
| 524 bool get hasBuildId => buildId != UNDETERMINED_BUILD_ID; | 524 bool get hasBuildId => buildId != UNDETERMINED_BUILD_ID; |
| 525 | 525 |
| 526 bool get mirrorsEnabled => mirrorSystemClass != null; | 526 bool get mirrorsEnabled => mirrorSystemClass != null; |
| 527 | 527 |
| 528 bool get analyzeAll => analyzeAllFlag || compileAll; | |
| 529 | |
| 530 bool get compileAll => mirrorsEnabled; | |
| 531 | |
| 532 bool get disableTypeInference => disableTypeInferenceFlag || mirrorsEnabled; | |
| 533 | |
| 528 int getNextFreeClassId() => nextFreeClassId++; | 534 int getNextFreeClassId() => nextFreeClassId++; |
| 529 | 535 |
| 530 void ensure(bool condition) { | 536 void ensure(bool condition) { |
| 531 if (!condition) cancel('failed assertion in leg'); | 537 if (!condition) cancel('failed assertion in leg'); |
| 532 } | 538 } |
| 533 | 539 |
| 534 void unimplemented(String methodName, | 540 void unimplemented(String methodName, |
| 535 {Node node, Token token, HInstruction instruction, | 541 {Node node, Token token, HInstruction instruction, |
| 536 Element element}) { | 542 Element element}) { |
| 537 internalError("$methodName not implemented", | 543 internalError("$methodName not implemented", |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 // something to the resolution queue. So we cannot wait with | 835 // something to the resolution queue. So we cannot wait with |
| 830 // this until after the resolution queue is processed. | 836 // this until after the resolution queue is processed. |
| 831 // TODO(ahe): Clean this up, for example, by not enqueueing | 837 // TODO(ahe): Clean this up, for example, by not enqueueing |
| 832 // classes only used for metadata. | 838 // classes only used for metadata. |
| 833 deferredLoadTask.findDeferredLibraries(mainApp); | 839 deferredLoadTask.findDeferredLibraries(mainApp); |
| 834 } | 840 } |
| 835 | 841 |
| 836 log('Resolving...'); | 842 log('Resolving...'); |
| 837 phase = PHASE_RESOLVING; | 843 phase = PHASE_RESOLVING; |
| 838 if (analyzeAll) { | 844 if (analyzeAll) { |
| 839 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib)); | 845 libraries.forEach( |
| 846 (_, lib) => fullyEnqueueLibrary(lib, enqueuer.resolution)); | |
| 840 } | 847 } |
| 841 // Elements required by enqueueHelpers are global dependencies | 848 // Elements required by enqueueHelpers are global dependencies |
| 842 // that are not pulled in by a particular element. | 849 // that are not pulled in by a particular element. |
| 843 backend.enqueueHelpers(enqueuer.resolution, globalDependencies); | 850 backend.enqueueHelpers(enqueuer.resolution, globalDependencies); |
| 844 resolveReflectiveDataIfNeeded(); | 851 resolveReflectiveDataIfNeeded(); |
| 845 processQueue(enqueuer.resolution, main); | 852 processQueue(enqueuer.resolution, main); |
| 846 enqueuer.resolution.logSummary(log); | 853 enqueuer.resolution.logSummary(log); |
| 847 | 854 |
| 848 if (compilationFailed) return; | 855 if (compilationFailed) return; |
| 849 if (analyzeOnly) return; | 856 if (analyzeOnly) return; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 867 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. | 874 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. |
| 868 if (hasIsolateSupport()) { | 875 if (hasIsolateSupport()) { |
| 869 enqueuer.codegen.addToWorkList( | 876 enqueuer.codegen.addToWorkList( |
| 870 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); | 877 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); |
| 871 enqueuer.codegen.registerGetOfStaticFunction(mainApp.find(MAIN)); | 878 enqueuer.codegen.registerGetOfStaticFunction(mainApp.find(MAIN)); |
| 872 } | 879 } |
| 873 if (enabledNoSuchMethod) { | 880 if (enabledNoSuchMethod) { |
| 874 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, noSuchMethodSelector); | 881 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, noSuchMethodSelector); |
| 875 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); | 882 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); |
| 876 } | 883 } |
| 884 if (compileAll) { | |
| 885 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib, enqueuer.codegen)); | |
| 886 } | |
| 877 processQueue(enqueuer.codegen, main); | 887 processQueue(enqueuer.codegen, main); |
| 878 enqueuer.codegen.logSummary(log); | 888 enqueuer.codegen.logSummary(log); |
| 879 | 889 |
| 880 if (compilationFailed) return; | 890 if (compilationFailed) return; |
| 881 | 891 |
| 882 backend.assembleProgram(); | 892 backend.assembleProgram(); |
| 883 | 893 |
| 884 checkQueues(); | 894 checkQueues(); |
| 885 } | 895 } |
| 886 | 896 |
| 887 void resolveReflectiveDataIfNeeded() { | 897 void resolveReflectiveDataIfNeeded() { |
| 888 // Only need reflective data when dart:mirrors is loaded. | 898 // Only need reflective data when dart:mirrors is loaded. |
| 889 if (!mirrorsEnabled) return; | 899 if (!mirrorsEnabled) return; |
| 890 | 900 |
| 891 for (LibraryElement library in libraries.values) { | 901 for (LibraryElement library in libraries.values) { |
| 892 for (Link link = library.metadata; !link.isEmpty; link = link.tail) { | 902 for (Link link = library.metadata; !link.isEmpty; link = link.tail) { |
| 893 link.head.ensureResolved(this); | 903 link.head.ensureResolved(this); |
| 894 } | 904 } |
| 895 } | 905 } |
| 896 } | 906 } |
| 897 | 907 |
| 898 void fullyEnqueueLibrary(LibraryElement library) { | 908 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { |
| 899 library.implementation.forEachLocalMember(fullyEnqueueTopLevelElement); | 909 // The JS backend gets confused when it tries to compile code for |
| 910 // interceptor classes. | |
|
ngeoffray
2013/06/10 19:21:00
But it is compiling methods for interceptor classe
ahe
2013/06/11 14:24:45
I've sent you some additional details in a mail.
| |
| 911 if (!world.isResolutionQueue && library.isInternalLibrary) return; | |
| 912 void enqueueAll(Element element) { | |
| 913 fullyEnqueueTopLevelElement(element, world); | |
| 914 } | |
| 915 library.implementation.forEachLocalMember(enqueueAll); | |
| 900 } | 916 } |
| 901 | 917 |
| 902 void fullyEnqueueTopLevelElement(Element element) { | 918 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { |
| 903 if (element.isClass()) { | 919 if (element.isClass()) { |
| 904 ClassElement cls = element; | 920 ClassElement cls = element; |
| 905 cls.ensureResolved(this); | 921 cls.ensureResolved(this); |
| 906 cls.forEachLocalMember(enqueuer.resolution.addToWorkList); | 922 cls.forEachLocalMember(world.addToWorkList); |
| 907 enqueuer.resolution.registerInstantiatedClass( | 923 world.registerInstantiatedClass(element, globalDependencies); |
| 908 element, globalDependencies); | |
| 909 } else { | 924 } else { |
| 910 enqueuer.resolution.addToWorkList(element); | 925 world.addToWorkList(element); |
| 911 } | 926 } |
| 912 } | 927 } |
| 913 | 928 |
| 914 void processQueue(Enqueuer world, Element main) { | 929 void processQueue(Enqueuer world, Element main) { |
| 915 world.nativeEnqueuer.processNativeClasses(libraries.values); | 930 world.nativeEnqueuer.processNativeClasses(libraries.values); |
| 916 if (main != null) { | 931 if (main != null) { |
| 917 world.addToWorkList(main); | 932 world.addToWorkList(main); |
| 918 } | 933 } |
| 919 progress.reset(); | 934 progress.reset(); |
| 920 world.forEach((WorkItem work) { | 935 world.forEach((WorkItem work) { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1370 | 1385 |
| 1371 void close() {} | 1386 void close() {} |
| 1372 | 1387 |
| 1373 toString() => name; | 1388 toString() => name; |
| 1374 | 1389 |
| 1375 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1390 /// Convenience method for getting an [api.CompilerOutputProvider]. |
| 1376 static NullSink outputProvider(String name, String extension) { | 1391 static NullSink outputProvider(String name, String extension) { |
| 1377 return new NullSink('$name.$extension'); | 1392 return new NullSink('$name.$extension'); |
| 1378 } | 1393 } |
| 1379 } | 1394 } |
| OLD | NEW |