Unverified Commit 9ae893bd authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Use IKG for restarts, use IKG with ProtectedFileByteStore. (#12953)

* Use IKG for restarts, use IKG with ProtectedFileByteStore.

* Fix comment, add end of file newline.

* Remove unused import
parent 3c4e7fe3
...@@ -205,3 +205,9 @@ String getAssetBuildDirectory() { ...@@ -205,3 +205,9 @@ String getAssetBuildDirectory() {
String getIosBuildDirectory() { String getIosBuildDirectory() {
return fs.path.join(getBuildDirectory(), 'ios'); return fs.path.join(getBuildDirectory(), 'ios');
} }
/// Returns directory used by incremental compiler (IKG - incremental kernel
/// generator) to store cached intermediate state.
String getIncrementalCompilerByteStoreDirectory() {
return fs.path.join(getBuildDirectory(), 'ikg_byte_store');
}
...@@ -60,7 +60,8 @@ Future<String> compile( ...@@ -60,7 +60,8 @@ Future<String> compile(
{String sdkRoot, {String sdkRoot,
String mainPath, String mainPath,
bool linkPlatformKernelIn : false, bool linkPlatformKernelIn : false,
List<String> extraFrontEndOptions}) async { List<String> extraFrontEndOptions,
String incrementalCompilerByteStorePath}) async {
final String frontendServer = artifacts.getArtifactPath( final String frontendServer = artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk Artifact.frontendServerSnapshotForEngineDartSdk
); );
...@@ -76,6 +77,13 @@ Future<String> compile( ...@@ -76,6 +77,13 @@ Future<String> compile(
]; ];
if (!linkPlatformKernelIn) if (!linkPlatformKernelIn)
command.add('--no-link-platform'); command.add('--no-link-platform');
if (incrementalCompilerByteStorePath != null) {
command.addAll(<String>[
'--incremental',
'--byte-store',
incrementalCompilerByteStorePath]);
fs.directory(incrementalCompilerByteStorePath).createSync(recursive: true);
}
if (extraFrontEndOptions != null) if (extraFrontEndOptions != null)
command.addAll(extraFrontEndOptions); command.addAll(extraFrontEndOptions);
command.add(mainPath); command.add(mainPath);
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show BASE64, UTF8; import 'dart:convert' show BASE64, UTF8;
import 'package:flutter_tools/src/artifacts.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc; import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'asset.dart'; import 'asset.dart';
...@@ -446,11 +445,6 @@ class DevFS { ...@@ -446,11 +445,6 @@ class DevFS {
// that isModified does not reset last check timestamp because we // that isModified does not reset last check timestamp because we
// want to report all modified files to incremental compiler next time // want to report all modified files to incremental compiler next time
// user does hot reload. // user does hot reload.
// TODO(aam): Remove this logic once we switch to using incremental
// compiler for full application compilation when doing full restart.
if (fullRestart && generator != null && content is DevFSFileContent) {
content = DevFSFileContent.clone(content);
}
if (content.isModified || (bundleDirty && archivePath != null)) { if (content.isModified || (bundleDirty && archivePath != null)) {
dirtyEntries[deviceUri] = content; dirtyEntries[deviceUri] = content;
numBytes += content.size; numBytes += content.size;
...@@ -480,11 +474,11 @@ class DevFS { ...@@ -480,11 +474,11 @@ class DevFS {
// host and result of compilation is single kernel file. // host and result of compilation is single kernel file.
filesUris.forEach(dirtyEntries.remove); filesUris.forEach(dirtyEntries.remove);
printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files'); printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
final String compiledBinary = fullRestart if (fullRestart) {
? await compile( generator.reset();
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), }
mainPath: mainPath) final String compiledBinary =
: await generator.recompile(mainPath, invalidatedFiles); await generator.recompile(mainPath, invalidatedFiles);
if (compiledBinary != null && compiledBinary.isNotEmpty) if (compiledBinary != null && compiledBinary.isNotEmpty)
dirtyEntries.putIfAbsent( dirtyEntries.putIfAbsent(
Uri.parse(target + '.dill'), Uri.parse(target + '.dill'),
......
...@@ -71,6 +71,7 @@ Future<Null> build({ ...@@ -71,6 +71,7 @@ Future<Null> build({
if (!precompiledSnapshot && previewDart2) { if (!precompiledSnapshot && previewDart2) {
final String kernelBinaryFilename = await compile( final String kernelBinaryFilename = await compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()),
mainPath: fs.file(mainPath).absolute.path mainPath: fs.file(mainPath).absolute.path
); );
kernelContent = new DevFSFileContent(fs.file(kernelBinaryFilename)); kernelContent = new DevFSFileContent(fs.file(kernelBinaryFilename));
......
...@@ -353,9 +353,20 @@ class HotRunner extends ResidentRunner { ...@@ -353,9 +353,20 @@ class HotRunner extends ResidentRunner {
// TODO(aam): Add generator reset logic once we switch to using incremental // TODO(aam): Add generator reset logic once we switch to using incremental
// compiler for full application recompilation on restart. // compiler for full application recompilation on restart.
final bool updatedDevFS = await _updateDevFS(fullRestart: true); final bool updatedDevFS = await _updateDevFS(fullRestart: true);
_resetDirtyAssets(); if (!updatedDevFS) {
if (!updatedDevFS) for (FlutterDevice device in flutterDevices) {
if (device.generator != null)
device.generator.reject();
}
return new OperationResult(1, 'DevFS synchronization failed'); return new OperationResult(1, 'DevFS synchronization failed');
}
_resetDirtyAssets();
for (FlutterDevice device in flutterDevices) {
// VM must have accepted the kernel binary, there will be no reload
// report, so we let incremental compiler know that source code was accepted.
if (device.generator != null)
device.generator.accept();
}
// Check if the isolate is paused and resume it. // Check if the isolate is paused and resume it.
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) { for (FlutterView view in device.views) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment