| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:front_end/file_system.dart'; | 8 import 'package:front_end/file_system.dart'; |
| 9 import 'package:front_end/incremental_kernel_generator.dart'; | 9 import 'package:front_end/incremental_kernel_generator.dart'; |
| 10 import 'package:front_end/src/base/api_signature.dart'; | 10 import 'package:front_end/src/base/api_signature.dart'; |
| 11 import 'package:front_end/src/base/performace_logger.dart'; | 11 import 'package:front_end/src/base/performace_logger.dart'; |
| 12 import 'package:front_end/src/base/processed_options.dart'; | 12 import 'package:front_end/src/base/processed_options.dart'; |
| 13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; | 13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; |
| 14 import 'package:front_end/src/fasta/dill/dill_target.dart'; | 14 import 'package:front_end/src/fasta/dill/dill_target.dart'; |
| 15 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; | 15 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; |
| 16 import 'package:front_end/src/fasta/ticker.dart'; | 16 import 'package:front_end/src/fasta/ticker.dart'; |
| 17 import 'package:front_end/src/fasta/translate_uri.dart'; | 17 import 'package:front_end/src/fasta/translate_uri.dart'; |
| 18 import 'package:front_end/src/incremental/byte_store.dart'; | 18 import 'package:front_end/src/incremental/byte_store.dart'; |
| 19 import 'package:front_end/src/incremental/file_state.dart'; | 19 import 'package:front_end/src/incremental/file_state.dart'; |
| 20 import 'package:kernel/binary/ast_from_binary.dart'; | 20 import 'package:kernel/binary/ast_from_binary.dart'; |
| 21 import 'package:kernel/binary/limited_ast_to_binary.dart'; | 21 import 'package:kernel/binary/limited_ast_to_binary.dart'; |
| 22 import 'package:kernel/kernel.dart' hide Source; | 22 import 'package:kernel/kernel.dart' hide Source; |
| 23 import 'package:kernel/target/targets.dart' show TargetFlags; |
| 23 | 24 |
| 24 dynamic unimplemented() { | 25 dynamic unimplemented() { |
| 25 // TODO(paulberry): get rid of this. | 26 // TODO(paulberry): get rid of this. |
| 26 throw new UnimplementedError(); | 27 throw new UnimplementedError(); |
| 27 } | 28 } |
| 28 | 29 |
| 29 class ByteSink implements Sink<List<int>> { | 30 class ByteSink implements Sink<List<int>> { |
| 30 final BytesBuilder builder = new BytesBuilder(); | 31 final BytesBuilder builder = new BytesBuilder(); |
| 31 | 32 |
| 32 void add(List<int> data) { | 33 void add(List<int> data) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // Ensure that the graph starting at the entry point is ready. | 94 // Ensure that the graph starting at the entry point is ready. |
| 94 FileState entryLibrary = await _fsState.getFile(_entryPoint); | 95 FileState entryLibrary = await _fsState.getFile(_entryPoint); |
| 95 | 96 |
| 96 List<LibraryCycle> cycles = _logger.run('Compute library cycles', () { | 97 List<LibraryCycle> cycles = _logger.run('Compute library cycles', () { |
| 97 List<LibraryCycle> cycles = entryLibrary.topologicalOrder; | 98 List<LibraryCycle> cycles = entryLibrary.topologicalOrder; |
| 98 _logger.writeln('Computed ${cycles.length} cycles.'); | 99 _logger.writeln('Computed ${cycles.length} cycles.'); |
| 99 return cycles; | 100 return cycles; |
| 100 }); | 101 }); |
| 101 | 102 |
| 102 CanonicalName nameRoot = new CanonicalName.root(); | 103 CanonicalName nameRoot = new CanonicalName.root(); |
| 103 DillTarget dillTarget = | 104 DillTarget dillTarget = new DillTarget( |
| 104 new DillTarget(new Ticker(isVerbose: false), _uriTranslator, "vm"); | 105 new Ticker(isVerbose: false), _uriTranslator, "vm_fasta", |
| 106 flags: new TargetFlags(strongMode: _options.strongMode)); |
| 105 | 107 |
| 106 List<_LibraryCycleResult> results = []; | 108 List<_LibraryCycleResult> results = []; |
| 107 await _logger.runAsync('Compute results for cycles', () async { | 109 await _logger.runAsync('Compute results for cycles', () async { |
| 108 for (LibraryCycle cycle in cycles) { | 110 for (LibraryCycle cycle in cycles) { |
| 109 _LibraryCycleResult result = | 111 _LibraryCycleResult result = |
| 110 await _compileCycle(nameRoot, dillTarget, cycle); | 112 await _compileCycle(nameRoot, dillTarget, cycle); |
| 111 results.add(result); | 113 results.add(result); |
| 112 } | 114 } |
| 113 }); | 115 }); |
| 114 | 116 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 var reader = new BinaryBuilder(bytes); | 199 var reader = new BinaryBuilder(bytes); |
| 198 reader.readProgram(program); | 200 reader.readProgram(program); |
| 199 | 201 |
| 200 await appendNewDillLibraries(program); | 202 await appendNewDillLibraries(program); |
| 201 | 203 |
| 202 return new _LibraryCycleResult(cycle, signature, program.libraries); | 204 return new _LibraryCycleResult(cycle, signature, program.libraries); |
| 203 }); | 205 }); |
| 204 } | 206 } |
| 205 | 207 |
| 206 // Create KernelTarget and configure it for compiling the cycle URIs. | 208 // Create KernelTarget and configure it for compiling the cycle URIs. |
| 207 KernelTarget kernelTarget = new KernelTarget(_fsState.fileSystemView, | 209 KernelTarget kernelTarget = |
| 208 dillTarget, _uriTranslator, _options.strongMode); | 210 new KernelTarget(_fsState.fileSystemView, dillTarget, _uriTranslator); |
| 209 for (FileState library in cycle.libraries) { | 211 for (FileState library in cycle.libraries) { |
| 210 kernelTarget.read(library.uri); | 212 kernelTarget.read(library.uri); |
| 211 } | 213 } |
| 212 | 214 |
| 213 // Compile the cycle libraries into a new full program. | 215 // Compile the cycle libraries into a new full program. |
| 214 Program program = await _logger | 216 Program program = await _logger |
| 215 .runAsync('Compile ${cycle.libraries.length} libraries', () async { | 217 .runAsync('Compile ${cycle.libraries.length} libraries', () async { |
| 216 await kernelTarget.buildOutlines(nameRoot: nameRoot); | 218 await kernelTarget.buildOutlines(nameRoot: nameRoot); |
| 217 return await kernelTarget.buildProgram(); | 219 return await kernelTarget.buildProgram(); |
| 218 }); | 220 }); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 /// TODO(scheglov) Use API signatures. | 308 /// TODO(scheglov) Use API signatures. |
| 307 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. | 309 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. |
| 308 final String signature; | 310 final String signature; |
| 309 | 311 |
| 310 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies | 312 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies |
| 311 /// are not included, but but references to those dependencies are included. | 313 /// are not included, but but references to those dependencies are included. |
| 312 final List<Library> kernelLibraries; | 314 final List<Library> kernelLibraries; |
| 313 | 315 |
| 314 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 316 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); |
| 315 } | 317 } |
| OLD | NEW |