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

Side by Side Diff: pkg/front_end/lib/src/incremental/kernel_driver.dart

Issue 2980813002: Pass backend Target into Kernel driver. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/incremental_kernel_generator_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 import 'package:front_end/file_system.dart'; 7 import 'package:front_end/file_system.dart';
8 import 'package:front_end/src/base/api_signature.dart'; 8 import 'package:front_end/src/base/api_signature.dart';
9 import 'package:front_end/src/base/performace_logger.dart'; 9 import 'package:front_end/src/base/performace_logger.dart';
10 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; 10 import 'package:front_end/src/fasta/dill/dill_library_builder.dart';
11 import 'package:front_end/src/fasta/dill/dill_target.dart'; 11 import 'package:front_end/src/fasta/dill/dill_target.dart';
12 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; 12 import 'package:front_end/src/fasta/kernel/kernel_target.dart';
13 import 'package:front_end/src/fasta/kernel/utils.dart'; 13 import 'package:front_end/src/fasta/kernel/utils.dart';
14 import 'package:front_end/src/fasta/ticker.dart'; 14 import 'package:front_end/src/fasta/ticker.dart';
15 import 'package:front_end/src/fasta/uri_translator.dart'; 15 import 'package:front_end/src/fasta/uri_translator.dart';
16 import 'package:front_end/src/incremental/byte_store.dart'; 16 import 'package:front_end/src/incremental/byte_store.dart';
17 import 'package:front_end/src/incremental/file_state.dart'; 17 import 'package:front_end/src/incremental/file_state.dart';
18 import 'package:kernel/binary/ast_from_binary.dart'; 18 import 'package:kernel/binary/ast_from_binary.dart';
19 import 'package:kernel/kernel.dart' hide Source; 19 import 'package:kernel/kernel.dart' hide Source;
20 import 'package:kernel/target/targets.dart' show TargetFlags; 20 import 'package:kernel/target/targets.dart' show Target;
21 import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget;
22 import 'package:meta/meta.dart'; 21 import 'package:meta/meta.dart';
23 22
24 /// This function is invoked for each newly discovered file, and the returned 23 /// This function is invoked for each newly discovered file, and the returned
25 /// [Future] is awaited before reading the file content. 24 /// [Future] is awaited before reading the file content.
26 typedef Future<Null> KernelDriverFileAddedFn(Uri uri); 25 typedef Future<Null> KernelDriverFileAddedFn(Uri uri);
27 26
28 /// This class computes [KernelResult]s for Dart files. 27 /// This class computes [KernelResult]s for Dart files.
29 /// 28 ///
30 /// Let the "current file state" represent a map from file URI to the file 29 /// Let the "current file state" represent a map from file URI to the file
31 /// contents most recently read from that file. When the driver needs to 30 /// contents most recently read from that file. When the driver needs to
(...skipping 18 matching lines...) Expand all
50 49
51 /// The [FileSystem] which should be used by the front end to access files. 50 /// The [FileSystem] which should be used by the front end to access files.
52 final FileSystem _fileSystem; 51 final FileSystem _fileSystem;
53 52
54 /// The byte storage to get and put serialized data. 53 /// The byte storage to get and put serialized data.
55 final ByteStore _byteStore; 54 final ByteStore _byteStore;
56 55
57 /// The object that knows how to resolve "package:" and "dart:" URIs. 56 /// The object that knows how to resolve "package:" and "dart:" URIs.
58 final UriTranslator _uriTranslator; 57 final UriTranslator _uriTranslator;
59 58
60 /// Is `true` if strong mode analysis should be used. 59 /// The backend target to generate kernels for.
61 final bool _strongMode; 60 final Target _target;
62 61
63 /// The function that is invoked when a new file is about to be added to 62 /// The function that is invoked when a new file is about to be added to
64 /// the current file state. The [Future] that it returns is awaited before 63 /// the current file state. The [Future] that it returns is awaited before
65 /// reading the file contents. 64 /// reading the file contents.
66 final KernelDriverFileAddedFn _fileAddedFn; 65 final KernelDriverFileAddedFn _fileAddedFn;
67 66
68 /// The salt to mix into all hashes used as keys for serialized data. 67 /// The salt to mix into all hashes used as keys for serialized data.
69 List<int> _salt; 68 List<int> _salt;
70 69
71 /// The current file system state. 70 /// The current file system state.
72 FileSystemState _fsState; 71 FileSystemState _fsState;
73 72
74 /// The set of absolute file URIs that were reported through [invalidate] 73 /// The set of absolute file URIs that were reported through [invalidate]
75 /// and not checked for actual changes yet. 74 /// and not checked for actual changes yet.
76 final Set<Uri> _invalidatedFiles = new Set<Uri>(); 75 final Set<Uri> _invalidatedFiles = new Set<Uri>();
77 76
78 /// The object that provides additional information for tests. 77 /// The object that provides additional information for tests.
79 final _TestView _testView = new _TestView(); 78 final _TestView _testView = new _TestView();
80 79
81 KernelDriver(this._logger, this._fileSystem, this._byteStore, 80 KernelDriver(this._logger, this._fileSystem, this._byteStore,
82 this._uriTranslator, this._strongMode, 81 this._uriTranslator, this._target,
83 {KernelDriverFileAddedFn fileAddedFn}) 82 {KernelDriverFileAddedFn fileAddedFn})
84 : _fileAddedFn = fileAddedFn { 83 : _fileAddedFn = fileAddedFn {
85 _computeSalt(); 84 _computeSalt();
86 85
87 Future<Null> onFileAdded(Uri uri) { 86 Future<Null> onFileAdded(Uri uri) {
88 if (_fileAddedFn != null) { 87 if (_fileAddedFn != null) {
89 return _fileAddedFn(uri); 88 return _fileAddedFn(uri);
90 } 89 }
91 return new Future.value(); 90 return new Future.value();
92 } 91 }
(...skipping 30 matching lines...) Expand all
123 return await _fsState.getFile(uri); 122 return await _fsState.getFile(uri);
124 }); 123 });
125 124
126 List<LibraryCycle> cycles = _logger.run('Compute library cycles', () { 125 List<LibraryCycle> cycles = _logger.run('Compute library cycles', () {
127 List<LibraryCycle> cycles = entryLibrary.topologicalOrder; 126 List<LibraryCycle> cycles = entryLibrary.topologicalOrder;
128 _logger.writeln('Computed ${cycles.length} cycles.'); 127 _logger.writeln('Computed ${cycles.length} cycles.');
129 return cycles; 128 return cycles;
130 }); 129 });
131 130
132 CanonicalName nameRoot = new CanonicalName.root(); 131 CanonicalName nameRoot = new CanonicalName.root();
133 DillTarget dillTarget = new DillTarget( 132 DillTarget dillTarget =
134 new Ticker(isVerbose: false), 133 new DillTarget(new Ticker(isVerbose: false), _uriTranslator, _target);
135 _uriTranslator,
136 new VmFastaTarget(new TargetFlags(strongMode: _strongMode)));
137 134
138 List<LibraryCycleResult> results = []; 135 List<LibraryCycleResult> results = [];
139 _testView.compiledCycles.clear(); 136 _testView.compiledCycles.clear();
140 await _logger.runAsync('Compute results for cycles', () async { 137 await _logger.runAsync('Compute results for cycles', () async {
141 for (LibraryCycle cycle in cycles) { 138 for (LibraryCycle cycle in cycles) {
142 LibraryCycleResult result = 139 LibraryCycleResult result =
143 await _compileCycle(nameRoot, dillTarget, cycle); 140 await _compileCycle(nameRoot, dillTarget, cycle);
144 results.add(result); 141 results.add(result);
145 } 142 }
146 }); 143 });
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 273 }
277 } 274 }
278 } 275 }
279 } while (wasChanged); 276 } while (wasChanged);
280 } 277 }
281 278
282 /// Compute salt and put into [_salt]. 279 /// Compute salt and put into [_salt].
283 void _computeSalt() { 280 void _computeSalt() {
284 var saltBuilder = new ApiSignature(); 281 var saltBuilder = new ApiSignature();
285 saltBuilder.addInt(DATA_VERSION); 282 saltBuilder.addInt(DATA_VERSION);
286 saltBuilder.addBool(_strongMode); 283 saltBuilder.addBool(_target.strongMode);
287 _salt = saltBuilder.toByteList(); 284 _salt = saltBuilder.toByteList();
288 } 285 }
289 286
290 String _getCycleSignature(LibraryCycle cycle) { 287 String _getCycleSignature(LibraryCycle cycle) {
291 bool hasMixinApplication = 288 bool hasMixinApplication =
292 cycle.libraries.any((library) => library.hasMixinApplicationLibrary); 289 cycle.libraries.any((library) => library.hasMixinApplicationLibrary);
293 var signatureBuilder = new ApiSignature(); 290 var signatureBuilder = new ApiSignature();
294 signatureBuilder.addBytes(_salt); 291 signatureBuilder.addBytes(_salt);
295 Set<FileState> transitiveFiles = cycle.libraries 292 Set<FileState> transitiveFiles = cycle.libraries
296 .map((library) => library.transitiveFiles) 293 .map((library) => library.transitiveFiles)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 364
368 LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); 365 LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries);
369 } 366 }
370 367
371 @visibleForTesting 368 @visibleForTesting
372 class _TestView { 369 class _TestView {
373 /// The list of [LibraryCycle]s compiled for the last delta. 370 /// The list of [LibraryCycle]s compiled for the last delta.
374 /// It does not include libraries which were read from the cache. 371 /// It does not include libraries which were read from the cache.
375 final List<LibraryCycle> compiledCycles = []; 372 final List<LibraryCycle> compiledCycles = [];
376 } 373 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/incremental_kernel_generator_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698