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

Unified Diff: pkg/front_end/lib/src/incremental_kernel_generator_impl.dart

Issue 2893453005: Mix salt into result signatures. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/incremental_kernel_generator_impl.dart
diff --git a/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart b/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart
index 43c016a0cae0bad16cfeb8a40d1e64bded16e650..c81a6f8bec89fc787f6bb9df4332214e4eeb2c18 100644
--- a/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart
+++ b/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart
@@ -4,6 +4,7 @@
import 'dart:async';
import 'dart:io';
+import 'dart:typed_data';
import 'package:front_end/file_system.dart';
import 'package:front_end/incremental_kernel_generator.dart';
@@ -45,6 +46,9 @@ class ByteSink implements Sink<List<int>> {
/// used to obtain resolved ASTs, and these are fed into kernel code generation
/// logic.
class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator {
+ /// The version of data format, should be incremented on every format change.
+ static const int DATA_VERSION = 1;
+
/// The compiler options, such as the [FileSystem], the SDK dill location,
/// etc.
final ProcessedOptions _options;
@@ -64,8 +68,11 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator {
/// The URI of the program entry point.
final Uri _entryPoint;
+ /// The salt to mix into all hashes used as keys for serialized data.
+ final Uint8List _salt = new Uint8List(16);
+
/// Latest compilation signatures produced by [computeDelta] for libraries.
- final Map<Uri, String> _uriToLatestSignature = {};
+ final Map<Uri, String> _latestSignature = {};
/// The set of absolute file URIs that were reported through [invalidate]
/// and not checked for actual changes yet.
@@ -75,7 +82,9 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator {
this._options, this._uriTranslator, this._entryPoint)
: _logger = _options.logger,
_fsState = new FileSystemState(_options.fileSystem, _uriTranslator),
- _byteStore = _options.byteStore;
+ _byteStore = _options.byteStore {
+ _fillSalt();
+ }
@override
Future<DeltaProgram> computeDelta(
@@ -111,8 +120,8 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator {
for (_LibraryCycleResult result in results) {
for (Library library in result.kernelLibraries) {
Uri uri = library.importUri;
- if (_uriToLatestSignature[uri] != result.signature) {
- _uriToLatestSignature[uri] = result.signature;
+ if (_latestSignature[uri] != result.signature) {
+ _latestSignature[uri] = result.signature;
program.libraries.add(library);
}
}
@@ -141,8 +150,7 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator {
String signature;
{
var signatureBuilder = new ApiSignature();
- // TODO(scheglov) add salt
- // signature.addUint32List(_fsState._salt);
+ signatureBuilder.addBytes(_salt);
Set<FileState> transitiveFiles = cycle.libraries
.map((library) => library.transitiveFiles)
.expand((files) => files)
@@ -253,6 +261,15 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator {
} while (wasChanged);
}
+ /// Fill [_salt] with data.
+ void _fillSalt() {
+ var saltBuilder = new ApiSignature();
+ saltBuilder.addInt(DATA_VERSION);
+ saltBuilder.addBool(_options.strongMode);
+ var saltBytes = saltBuilder.toByteList();
+ _salt.setRange(0, 16, saltBytes);
Paul Berry 2017/05/17 22:25:06 This doesn't seem safe. If saltBytes has fewer th
scheglov 2017/05/17 22:38:09 Hm... I think toByteList() returns exactly 16 byte
Paul Berry 2017/05/18 02:57:15 Oops, you're right. I forgot about that.
+ }
+
/// Refresh all the invalidated files and update dependencies.
Future<Null> _refreshInvalidatedFiles() async {
await _logger.runAsync('Refresh invalidated files', () async {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698