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

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

Issue 2995773002: When using SDK outline, transplant its names into the name root. (Closed)
Patch Set: Created 3 years, 4 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/test/incremental_kernel_generator_test.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/base/processed_options.dart'; 10 import 'package:front_end/src/base/processed_options.dart';
11 import 'package:front_end/src/byte_store/byte_store.dart';
11 import 'package:front_end/src/fasta/compiler_context.dart'; 12 import 'package:front_end/src/fasta/compiler_context.dart';
12 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; 13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart';
13 import 'package:front_end/src/fasta/dill/dill_target.dart'; 14 import 'package:front_end/src/fasta/dill/dill_target.dart';
14 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; 15 import 'package:front_end/src/fasta/kernel/kernel_target.dart';
15 import 'package:front_end/src/fasta/kernel/utils.dart'; 16 import 'package:front_end/src/fasta/kernel/utils.dart';
16 import 'package:front_end/src/fasta/ticker.dart'; 17 import 'package:front_end/src/fasta/ticker.dart';
17 import 'package:front_end/src/fasta/uri_translator.dart'; 18 import 'package:front_end/src/fasta/uri_translator.dart';
18 import 'package:front_end/src/byte_store/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/core_types.dart'; 21 import 'package:kernel/core_types.dart';
22 import 'package:kernel/kernel.dart' hide Source; 22 import 'package:kernel/kernel.dart' hide Source;
23 import 'package:kernel/src/incremental_class_hierarchy.dart'; 23 import 'package:kernel/src/incremental_class_hierarchy.dart';
24 import 'package:kernel/type_environment.dart'; 24 import 'package:kernel/type_environment.dart';
25 import 'package:meta/meta.dart'; 25 import 'package:meta/meta.dart';
26 26
27 /// This function is invoked for each newly discovered file, and the returned 27 /// This function is invoked for each newly discovered file, and the returned
28 /// [Future] is awaited before reading the file content. 28 /// [Future] is awaited before reading the file content.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 /// reported using [invalidate]. 124 /// reported using [invalidate].
125 /// 125 ///
126 /// If the driver has the cached result for the file with the current file 126 /// If the driver has the cached result for the file with the current file
127 /// state, it is returned. 127 /// state, it is returned.
128 /// 128 ///
129 /// Otherwise the driver will compute new kernel files and return them. 129 /// Otherwise the driver will compute new kernel files and return them.
130 Future<KernelResult> getKernel(Uri uri) async { 130 Future<KernelResult> getKernel(Uri uri) async {
131 return await runWithFrontEndContext('Compute delta', () async { 131 return await runWithFrontEndContext('Compute delta', () async {
132 await _refreshInvalidatedFiles(); 132 await _refreshInvalidatedFiles();
133 133
134 CanonicalName nameRoot = new CanonicalName.root();
135
134 // Load the SDK outline before building the graph, so that the file 136 // Load the SDK outline before building the graph, so that the file
135 // system state is configured to skip SDK libraries. 137 // system state is configured to skip SDK libraries.
136 await _loadSdkOutline(); 138 await _loadSdkOutline(nameRoot);
137 139
138 // Ensure that the graph starting at the entry point is ready. 140 // Ensure that the graph starting at the entry point is ready.
139 FileState entryLibrary = 141 FileState entryLibrary =
140 await _logger.runAsync('Build graph of files', () async { 142 await _logger.runAsync('Build graph of files', () async {
141 return await _fsState.getFile(uri); 143 return await _fsState.getFile(uri);
142 }); 144 });
143 145
144 List<LibraryCycle> cycles = _logger.run('Compute library cycles', () { 146 List<LibraryCycle> cycles = _logger.run('Compute library cycles', () {
145 List<LibraryCycle> cycles = entryLibrary.topologicalOrder; 147 List<LibraryCycle> cycles = entryLibrary.topologicalOrder;
146 _logger.writeln('Computed ${cycles.length} cycles.'); 148 _logger.writeln('Computed ${cycles.length} cycles.');
147 return cycles; 149 return cycles;
148 }); 150 });
149 151
150 CanonicalName nameRoot = new CanonicalName.root();
151 DillTarget dillTarget = new DillTarget( 152 DillTarget dillTarget = new DillTarget(
152 new Ticker(isVerbose: false), _uriTranslator, _options.target); 153 new Ticker(isVerbose: false), _uriTranslator, _options.target);
153 154
154 // If there is SDK outline, load it. 155 // If there is SDK outline, load it.
155 if (_sdkOutline != null) { 156 if (_sdkOutline != null) {
156 dillTarget.loader.appendLibraries(_sdkOutline); 157 dillTarget.loader.appendLibraries(_sdkOutline);
157 await dillTarget.buildOutlines(); 158 await dillTarget.buildOutlines();
158 } 159 }
159 160
160 List<LibraryCycleResult> results = []; 161 List<LibraryCycleResult> results = [];
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 for (var part in library.partFiles) { 353 for (var part in library.partFiles) {
353 signatureBuilder.addBytes(part.contentHash); 354 signatureBuilder.addBytes(part.contentHash);
354 } 355 }
355 } 356 }
356 357
357 return signatureBuilder.toHex(); 358 return signatureBuilder.toHex();
358 } 359 }
359 360
360 /// Load the SDK outline if its bytes are provided, and configure the file 361 /// Load the SDK outline if its bytes are provided, and configure the file
361 /// system state to skip SDK library files. 362 /// system state to skip SDK library files.
362 Future<Null> _loadSdkOutline() async { 363 Future<Null> _loadSdkOutline(CanonicalName nameRoot) async {
363 if (_sdkOutlineBytes != null) { 364 if (_sdkOutlineBytes != null) {
364 if (_sdkOutline == null) { 365 if (_sdkOutline == null) {
365 await _logger.runAsync('Load SDK outline from bytes.', () async { 366 await _logger.runAsync('Load SDK outline from bytes.', () async {
366 _sdkOutline = new Program(); 367 _sdkOutline = new Program();
Siggi Cherem (dart-lang) 2017/08/11 17:27:27 I'm not sure I follow - wouldn't it work instead i
scheglov 2017/08/11 17:29:23 We use different "nameRoot" each time. It will wo
scheglov 2017/08/11 17:32:45 Yes, that's what I was saying - we do this for eve
367 new BinaryBuilder(_sdkOutlineBytes).readProgram(_sdkOutline); 368 new BinaryBuilder(_sdkOutlineBytes).readProgram(_sdkOutline);
368 // Configure the file system state to skip the outline libraries. 369 // Configure the file system state to skip the outline libraries.
369 for (var outlineLibrary in _sdkOutline.libraries) { 370 for (var outlineLibrary in _sdkOutline.libraries) {
370 _fsState.skipSdkLibraries.add(outlineLibrary.importUri); 371 _fsState.skipSdkLibraries.add(outlineLibrary.importUri);
371 } 372 }
372 }); 373 });
373 } 374 }
375 for (var sdkLibrary in _sdkOutline.libraries) {
376 nameRoot.transplantChild(sdkLibrary.canonicalName);
377 }
374 } 378 }
375 } 379 }
376 380
377 /// Refresh all the invalidated files and update dependencies. 381 /// Refresh all the invalidated files and update dependencies.
378 Future<Null> _refreshInvalidatedFiles() async { 382 Future<Null> _refreshInvalidatedFiles() async {
379 await _logger.runAsync('Refresh invalidated files', () async { 383 await _logger.runAsync('Refresh invalidated files', () async {
380 // Create a copy to avoid concurrent modifications. 384 // Create a copy to avoid concurrent modifications.
381 var invalidatedFiles = _invalidatedFiles.toList(); 385 var invalidatedFiles = _invalidatedFiles.toList();
382 _invalidatedFiles.clear(); 386 _invalidatedFiles.clear();
383 387
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 424
421 LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); 425 LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries);
422 } 426 }
423 427
424 @visibleForTesting 428 @visibleForTesting
425 class _TestView { 429 class _TestView {
426 /// The list of [LibraryCycle]s compiled for the last delta. 430 /// The list of [LibraryCycle]s compiled for the last delta.
427 /// It does not include libraries which were read from the cache. 431 /// It does not include libraries which were read from the cache.
428 final List<LibraryCycle> compiledCycles = []; 432 final List<LibraryCycle> compiledCycles = [];
429 } 433 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/test/incremental_kernel_generator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698