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 library dart2js.compiler_base; | 5 library dart2js.compiler_base; |
6 | 6 |
7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
8 | 8 |
9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 /// Override this to mock resolution for testing. | 298 /// Override this to mock resolution for testing. |
299 Resolution createResolution() => new CompilerResolution(this); | 299 Resolution createResolution() => new CompilerResolution(this); |
300 | 300 |
301 /// Creates the resolver task. | 301 /// Creates the resolver task. |
302 /// | 302 /// |
303 /// Override this to mock the resolver for testing. | 303 /// Override this to mock the resolver for testing. |
304 ResolverTask createResolverTask() { | 304 ResolverTask createResolverTask() { |
305 return new ResolverTask(resolution, backend.constantCompilerTask, measurer); | 305 return new ResolverTask(resolution, backend.constantCompilerTask, measurer); |
306 } | 306 } |
307 | 307 |
308 // TODO(johnniwinther): Rename these appropriately when unification of worlds/ | 308 ResolutionWorldBuilder get resolutionWorldBuilder => |
309 // universes is complete. | 309 enqueuer.resolution.worldBuilder; |
310 ResolutionWorldBuilder get resolverWorld => enqueuer.resolution.universe; | 310 CodegenWorldBuilder get codegenWorldBuilder => enqueuer.codegen.worldBuilder; |
311 CodegenWorldBuilder get codegenWorld => enqueuer.codegen.universe; | |
312 | 311 |
313 bool get analyzeAll => options.analyzeAll || compileAll; | 312 bool get analyzeAll => options.analyzeAll || compileAll; |
314 | 313 |
315 bool get compileAll => false; | 314 bool get compileAll => false; |
316 | 315 |
317 bool get disableTypeInference => | 316 bool get disableTypeInference => |
318 options.disableTypeInference || compilationFailed; | 317 options.disableTypeInference || compilationFailed; |
319 | 318 |
320 // TODO(het): remove this from here. Either inline at all use sites or add it | 319 // TODO(het): remove this from here. Either inline at all use sites or add it |
321 // to Reporter. | 320 // to Reporter. |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 globalInference.runGlobalTypeInference( | 701 globalInference.runGlobalTypeInference( |
703 mainFunction, closedWorld, closedWorldRefiner); | 702 mainFunction, closedWorld, closedWorldRefiner); |
704 | 703 |
705 if (stopAfterTypeInference) return; | 704 if (stopAfterTypeInference) return; |
706 | 705 |
707 backend.onTypeInferenceComplete(); | 706 backend.onTypeInferenceComplete(); |
708 | 707 |
709 reporter.log('Compiling...'); | 708 reporter.log('Compiling...'); |
710 phase = PHASE_COMPILING; | 709 phase = PHASE_COMPILING; |
711 | 710 |
712 codegenWorld.open(closedWorld); | 711 codegenWorldBuilder.open(closedWorld); |
713 enqueuer.codegen.applyImpact(backend.onCodegenStart(closedWorld)); | 712 enqueuer.codegen.applyImpact(backend.onCodegenStart(closedWorld)); |
714 if (compileAll) { | 713 if (compileAll) { |
715 libraryLoader.libraries.forEach((LibraryElement library) { | 714 libraryLoader.libraries.forEach((LibraryElement library) { |
716 enqueuer.codegen.applyImpact(computeImpactForLibrary(library)); | 715 enqueuer.codegen.applyImpact(computeImpactForLibrary(library)); |
717 }); | 716 }); |
718 } | 717 } |
719 processQueue(enqueuer.codegen, mainFunction, | 718 processQueue(enqueuer.codegen, mainFunction, |
720 onProgress: showCodegenProgress); | 719 onProgress: showCodegenProgress); |
721 enqueuer.codegen.logSummary(reporter.log); | 720 enqueuer.codegen.logSummary(reporter.log); |
722 | 721 |
723 int programSize = backend.assembleProgram(closedWorld); | 722 int programSize = backend.assembleProgram(closedWorld); |
724 | 723 |
725 if (options.dumpInfo) { | 724 if (options.dumpInfo) { |
726 dumpInfoTask.reportSize(programSize); | 725 dumpInfoTask.reportSize(programSize); |
727 dumpInfoTask.dumpInfo(closedWorld); | 726 dumpInfoTask.dumpInfo(closedWorld); |
728 } | 727 } |
729 | 728 |
730 backend.onCodegenEnd(); | 729 backend.onCodegenEnd(); |
731 | 730 |
732 checkQueues(); | 731 checkQueues(); |
733 }); | 732 }); |
734 | 733 |
735 /// Perform the steps needed to fully end the resolution phase. | 734 /// Perform the steps needed to fully end the resolution phase. |
736 ClosedWorldRefiner closeResolution() { | 735 ClosedWorldRefiner closeResolution() { |
737 phase = PHASE_DONE_RESOLVING; | 736 phase = PHASE_DONE_RESOLVING; |
738 | 737 |
739 ClosedWorldImpl world = resolverWorld.closeWorld(reporter); | 738 ClosedWorldImpl world = resolutionWorldBuilder.closeWorld(reporter); |
740 // Compute whole-program-knowledge that the backend needs. (This might | 739 // Compute whole-program-knowledge that the backend needs. (This might |
741 // require the information computed in [world.closeWorld].) | 740 // require the information computed in [world.closeWorld].) |
742 backend.onResolutionComplete(world, world); | 741 backend.onResolutionComplete(world, world); |
743 | 742 |
744 deferredLoadTask.onResolutionComplete(mainFunction); | 743 deferredLoadTask.onResolutionComplete(mainFunction); |
745 | 744 |
746 // TODO(johnniwinther): Move this after rti computation but before | 745 // TODO(johnniwinther): Move this after rti computation but before |
747 // reflection members computation, and (re-)close the world afterwards. | 746 // reflection members computation, and (re-)close the world afterwards. |
748 closureToClassMapper.createClosureClasses(world); | 747 closureToClassMapper.createClosureClasses(world); |
749 return world; | 748 return world; |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 _compiler.mirrorUsageAnalyzerTask; | 1959 _compiler.mirrorUsageAnalyzerTask; |
1961 | 1960 |
1962 @override | 1961 @override |
1963 LibraryElement get coreLibrary => _compiler._commonElements.coreLibrary; | 1962 LibraryElement get coreLibrary => _compiler._commonElements.coreLibrary; |
1964 | 1963 |
1965 @override | 1964 @override |
1966 bool get wasProxyConstantComputedTestingOnly => _proxyConstant != null; | 1965 bool get wasProxyConstantComputedTestingOnly => _proxyConstant != null; |
1967 | 1966 |
1968 @override | 1967 @override |
1969 void registerClass(ClassElement cls) { | 1968 void registerClass(ClassElement cls) { |
1970 enqueuer.universe.registerClass(cls); | 1969 enqueuer.worldBuilder.registerClass(cls); |
1971 } | 1970 } |
1972 | 1971 |
1973 @override | 1972 @override |
1974 void resolveClass(ClassElement cls) { | 1973 void resolveClass(ClassElement cls) { |
1975 _compiler.resolver.resolveClass(cls); | 1974 _compiler.resolver.resolveClass(cls); |
1976 } | 1975 } |
1977 | 1976 |
1978 @override | 1977 @override |
1979 void resolveTypedef(TypedefElement typdef) { | 1978 void resolveTypedef(TypedefElement typdef) { |
1980 _compiler.resolver.resolve(typdef); | 1979 _compiler.resolver.resolve(typdef); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 _ElementScanner(this.scanner); | 2232 _ElementScanner(this.scanner); |
2234 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2233 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
2235 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2234 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
2236 } | 2235 } |
2237 | 2236 |
2238 class _EmptyEnvironment implements Environment { | 2237 class _EmptyEnvironment implements Environment { |
2239 const _EmptyEnvironment(); | 2238 const _EmptyEnvironment(); |
2240 | 2239 |
2241 String valueOf(String key) => null; | 2240 String valueOf(String key) => null; |
2242 } | 2241 } |
OLD | NEW |