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 Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
10 import 'backend_strategy.dart'; | 10 import 'backend_strategy.dart'; |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 globalInference.runGlobalTypeInference( | 603 globalInference.runGlobalTypeInference( |
604 mainFunction, closedWorld, closedWorldRefiner); | 604 mainFunction, closedWorld, closedWorldRefiner); |
605 | 605 |
606 if (stopAfterTypeInference) return; | 606 if (stopAfterTypeInference) return; |
607 | 607 |
608 backend.onTypeInferenceComplete(globalInference.results); | 608 backend.onTypeInferenceComplete(globalInference.results); |
609 | 609 |
610 reporter.log('Compiling...'); | 610 reporter.log('Compiling...'); |
611 phase = PHASE_COMPILING; | 611 phase = PHASE_COMPILING; |
612 | 612 |
613 Enqueuer codegenEnqueuer = enqueuer.createCodegenEnqueuer(closedWorld); | 613 Enqueuer codegenEnqueuer = startCodegen(closedWorld); |
614 _codegenWorldBuilder = codegenEnqueuer.worldBuilder; | |
615 codegenEnqueuer.applyImpact( | |
616 backend.onCodegenStart(closedWorld, _codegenWorldBuilder)); | |
617 if (compileAll) { | 614 if (compileAll) { |
618 libraryLoader.libraries.forEach((LibraryEntity library) { | 615 libraryLoader.libraries.forEach((LibraryEntity library) { |
619 codegenEnqueuer.applyImpact(computeImpactForLibrary(library)); | 616 codegenEnqueuer.applyImpact(computeImpactForLibrary(library)); |
620 }); | 617 }); |
621 } | 618 } |
622 processQueue(closedWorld.elementEnvironment, codegenEnqueuer, | 619 processQueue(closedWorld.elementEnvironment, codegenEnqueuer, |
623 mainFunction, libraryLoader.libraries, | 620 mainFunction, libraryLoader.libraries, |
624 onProgress: showCodegenProgress); | 621 onProgress: showCodegenProgress); |
625 codegenEnqueuer.logSummary(reporter.log); | 622 codegenEnqueuer.logSummary(reporter.log); |
626 | 623 |
627 int programSize = backend.assembleProgram(closedWorld); | 624 int programSize = backend.assembleProgram(closedWorld); |
628 | 625 |
629 if (options.dumpInfo) { | 626 if (options.dumpInfo) { |
630 dumpInfoTask.reportSize(programSize); | 627 dumpInfoTask.reportSize(programSize); |
631 dumpInfoTask.dumpInfo(closedWorld); | 628 dumpInfoTask.dumpInfo(closedWorld); |
632 } | 629 } |
633 | 630 |
634 backend.onCodegenEnd(); | 631 backend.onCodegenEnd(); |
635 | 632 |
636 checkQueues(resolutionEnqueuer, codegenEnqueuer); | 633 checkQueues(resolutionEnqueuer, codegenEnqueuer); |
637 }); | 634 }); |
638 | 635 |
| 636 Enqueuer startCodegen(ClosedWorld closedWorld) { |
| 637 Enqueuer codegenEnqueuer = enqueuer.createCodegenEnqueuer(closedWorld); |
| 638 _codegenWorldBuilder = codegenEnqueuer.worldBuilder; |
| 639 codegenEnqueuer |
| 640 .applyImpact(backend.onCodegenStart(closedWorld, _codegenWorldBuilder)); |
| 641 return codegenEnqueuer; |
| 642 } |
| 643 |
639 /// Perform the steps needed to fully end the resolution phase. | 644 /// Perform the steps needed to fully end the resolution phase. |
640 ClosedWorldRefiner closeResolution() { | 645 ClosedWorldRefiner closeResolution() { |
641 phase = PHASE_DONE_RESOLVING; | 646 phase = PHASE_DONE_RESOLVING; |
642 | 647 |
643 ClosedWorld closedWorld = resolutionWorldBuilder.closeWorld(); | 648 ClosedWorld closedWorld = resolutionWorldBuilder.closeWorld(); |
644 ClosedWorldRefiner closedWorldRefiner = | 649 ClosedWorldRefiner closedWorldRefiner = |
645 backendStrategy.createClosedWorldRefiner(closedWorld); | 650 backendStrategy.createClosedWorldRefiner(closedWorld); |
646 // Compute whole-program-knowledge that the backend needs. (This might | 651 // Compute whole-program-knowledge that the backend needs. (This might |
647 // require the information computed in [world.closeWorld].) | 652 // require the information computed in [world.closeWorld].) |
648 backend.onResolutionClosedWorld(closedWorld, closedWorldRefiner); | 653 backend.onResolutionClosedWorld(closedWorld, closedWorldRefiner); |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 _ElementScanner(this.scanner); | 1590 _ElementScanner(this.scanner); |
1586 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 1591 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
1587 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 1592 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
1588 } | 1593 } |
1589 | 1594 |
1590 class _EmptyEnvironment implements Environment { | 1595 class _EmptyEnvironment implements Environment { |
1591 const _EmptyEnvironment(); | 1596 const _EmptyEnvironment(); |
1592 | 1597 |
1593 String valueOf(String key) => null; | 1598 String valueOf(String key) => null; |
1594 } | 1599 } |
OLD | NEW |