Unverified Commit 73330e12 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Remove compilation trace and dynamic support code (#34529)

parent 3ebef868
......@@ -391,8 +391,7 @@ class AndroidDevice extends Device {
final TargetPlatform devicePlatform = await targetPlatform;
if (!(devicePlatform == TargetPlatform.android_arm ||
devicePlatform == TargetPlatform.android_arm64) &&
!(debuggingOptions.buildInfo.isDebug ||
debuggingOptions.buildInfo.isDynamic)) {
!debuggingOptions.buildInfo.isDebug) {
printError('Profile and release builds are only supported on ARM targets.');
return LaunchResult.failed();
}
......
......@@ -445,8 +445,6 @@ Future<void> _buildGradleProjectV2(
}
assert(buildInfo.trackWidgetCreation != null);
command.add('-Ptrack-widget-creation=${buildInfo.trackWidgetCreation}');
if (buildInfo.compilationTraceFilePath != null)
command.add('-Pcompilation-trace-file=${buildInfo.compilationTraceFilePath}');
if (buildInfo.extraFrontEndOptions != null)
command.add('-Pextra-front-end-options=${buildInfo.extraFrontEndOptions}');
if (buildInfo.extraGenSnapshotOptions != null)
......
......@@ -49,19 +49,8 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
case Artifact.flutterMacOSFramework:
return 'FlutterMacOS.framework';
case Artifact.vmSnapshotData:
// Flutter 'debug' and 'dynamic profile' modes for all target platforms use Dart
// RELEASE VM snapshot that comes from host debug build and has the metadata
// related to development tools. Flutter 'dynamic release' mode uses Dart PRODUCT
// VM snapshot from host dynamic release build that strips out the metadata
// related to development tools.
if (mode == BuildMode.dynamicRelease) {
return 'product_vm_isolate_snapshot.bin';
}
return 'vm_isolate_snapshot.bin';
case Artifact.isolateSnapshotData:
if (mode == BuildMode.dynamicRelease) {
return 'product_isolate_snapshot.bin';
}
return 'isolate_snapshot.bin';
case Artifact.platformKernelDill:
return 'platform_strong.dill';
......
......@@ -286,7 +286,7 @@ class _Asset {
@override
int get hashCode {
return baseDir.hashCode
^relativeUri.hashCode
^ relativeUri.hashCode
^ entryUri.hashCode;
}
}
......
......@@ -14,7 +14,6 @@ class BuildInfo {
this.mode,
this.flavor, {
this.trackWidgetCreation = false,
this.compilationTraceFilePath,
this.extraFrontEndOptions,
this.extraGenSnapshotOptions,
this.fileSystemRoots,
......@@ -39,9 +38,6 @@ class BuildInfo {
/// Whether the build should track widget creation locations.
final bool trackWidgetCreation;
/// Dart compilation trace file to use for JIT VM snapshot.
final String compilationTraceFilePath;
/// Extra command-line options for front-end.
final String extraFrontEndOptions;
......@@ -64,8 +60,6 @@ class BuildInfo {
static const BuildInfo debug = BuildInfo(BuildMode.debug, null);
static const BuildInfo profile = BuildInfo(BuildMode.profile, null);
static const BuildInfo release = BuildInfo(BuildMode.release, null);
static const BuildInfo dynamicProfile = BuildInfo(BuildMode.dynamicProfile, null);
static const BuildInfo dynamicRelease = BuildInfo(BuildMode.dynamicRelease, null);
/// Returns whether a debug build is requested.
///
......@@ -75,15 +69,12 @@ class BuildInfo {
/// Returns whether a profile build is requested.
///
/// Exactly one of [isDebug], [isProfile], or [isRelease] is true.
bool get isProfile => mode == BuildMode.profile || mode == BuildMode.dynamicProfile;
bool get isProfile => mode == BuildMode.profile;
/// Returns whether a release build is requested.
///
/// Exactly one of [isDebug], [isProfile], or [isRelease] is true.
bool get isRelease => mode == BuildMode.release || mode == BuildMode.dynamicRelease;
/// Returns whether a dynamic build is requested.
bool get isDynamic => mode == BuildMode.dynamicProfile || mode == BuildMode.dynamicRelease;
bool get isRelease => mode == BuildMode.release;
bool get usesAot => isAotBuildMode(mode);
bool get supportsEmulator => isEmulatorBuildMode(mode);
......@@ -122,8 +113,6 @@ enum BuildMode {
debug,
profile,
release,
dynamicProfile,
dynamicRelease
}
String validatedBuildNumberForPlatform(TargetPlatform targetPlatform, String buildNumber) {
......@@ -216,9 +205,7 @@ bool isAotBuildMode(BuildMode mode) {
// Returns true if the given build mode can be used on emulators / simulators.
bool isEmulatorBuildMode(BuildMode mode) {
return mode == BuildMode.debug ||
mode == BuildMode.dynamicRelease ||
mode == BuildMode.dynamicProfile;
return mode == BuildMode.debug;
}
enum HostPlatform {
......@@ -468,9 +455,3 @@ String getWindowsBuildDirectory() {
String getFuchsiaBuildDirectory() {
return fs.path.join(getBuildDirectory(), 'fuchsia');
}
/// 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');
}
......@@ -9,7 +9,6 @@ import 'package:pool/pool.dart';
import 'artifacts.dart';
import 'asset.dart';
import 'base/build.dart';
import 'base/common.dart';
import 'base/file_system.dart';
import 'build_info.dart';
......@@ -46,7 +45,6 @@ const String defaultPrivateKeyPath = 'privatekey.der';
const String _kKernelKey = 'kernel_blob.bin';
const String _kVMSnapshotData = 'vm_snapshot_data';
const String _kIsolateSnapshotData = 'isolate_snapshot_data';
const String _kIsolateSnapshotInstr = 'isolate_snapshot_instr';
/// Provides a `build` method that builds the bundle.
class BundleBuilder {
......@@ -67,7 +65,6 @@ class BundleBuilder {
bool precompiledSnapshot = false,
bool reportLicensedPackages = false,
bool trackWidgetCreation = false,
String compilationTraceFilePath,
List<String> extraFrontEndOptions = const <String>[],
List<String> extraGenSnapshotOptions = const <String>[],
List<String> fileSystemRoots,
......@@ -79,27 +76,6 @@ class BundleBuilder {
applicationKernelFilePath ??= getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation);
final FlutterProject flutterProject = FlutterProject.current();
if (compilationTraceFilePath != null) {
if (buildMode != BuildMode.dynamicProfile && buildMode != BuildMode.dynamicRelease) {
// Silently ignore JIT snapshotting for those builds that don't support it.
compilationTraceFilePath = null;
} else if (compilationTraceFilePath.isEmpty) {
// Disable JIT snapshotting if flag is empty.
printStatus('Code snapshot will be disabled for this build.');
compilationTraceFilePath = null;
} else if (!fs.file(compilationTraceFilePath).existsSync()) {
// Be forgiving if compilation trace file is missing.
printStatus('No compilation trace available. To optimize performance, consider using --train.');
final File tmp = fs.systemTempDirectory.childFile('flutterEmptyCompilationTrace.txt');
compilationTraceFilePath = (tmp..createSync(recursive: true)).path;
} else {
printStatus('Code snapshot will use compilation training file $compilationTraceFilePath.');
}
}
DevFSContent kernelContent;
if (!precompiledSnapshot) {
if ((extraFrontEndOptions != null) && extraFrontEndOptions.isNotEmpty)
......@@ -108,8 +84,6 @@ class BundleBuilder {
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject);
final CompilerOutput compilerOutput = await kernelCompiler.compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
incrementalCompilerByteStorePath: compilationTraceFilePath != null ? null :
fs.path.absolute(getIncrementalCompilerByteStoreDirectory()),
mainPath: fs.file(mainPath).absolute.path,
outputFilePath: applicationKernelFilePath,
depFilePath: depfilePath,
......@@ -118,7 +92,6 @@ class BundleBuilder {
fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme,
packagesPath: packagesPath,
linkPlatformKernelIn: compilationTraceFilePath != null,
);
if (compilerOutput?.outputFilename == null) {
throwToolExit('Compiler failed on $mainPath');
......@@ -127,22 +100,6 @@ class BundleBuilder {
await fs.directory(getBuildDirectory()).childFile('frontend_server.d')
.writeAsString('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n');
if (compilationTraceFilePath != null) {
final JITSnapshotter snapshotter = JITSnapshotter();
final int snapshotExitCode = await snapshotter.build(
platform: platform,
buildMode: buildMode,
mainPath: applicationKernelFilePath,
outputPath: getBuildDirectory(),
packagesPath: packagesPath,
compilationTraceFilePath: compilationTraceFilePath,
extraGenSnapshotOptions: extraGenSnapshotOptions,
);
if (snapshotExitCode != 0) {
throwToolExit('Snapshotting exited with non-zero exit code: $snapshotExitCode');
}
}
}
final AssetBundle assets = await buildAssets(
......@@ -160,7 +117,6 @@ class BundleBuilder {
kernelContent: kernelContent,
privateKeyPath: privateKeyPath,
assetDirPath: assetDirPath,
compilationTraceFilePath: compilationTraceFilePath,
);
}
}
......@@ -196,28 +152,18 @@ Future<void> assemble({
DevFSContent kernelContent,
String privateKeyPath = defaultPrivateKeyPath,
String assetDirPath,
String compilationTraceFilePath,
}) async {
assetDirPath ??= getAssetBuildDirectory();
printTrace('Building bundle');
final Map<String, DevFSContent> assetEntries = Map<String, DevFSContent>.from(assetBundle.entries);
if (kernelContent != null) {
if (compilationTraceFilePath != null) {
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode);
final String isolateSnapshotData = fs.path.join(getBuildDirectory(), _kIsolateSnapshotData);
final String isolateSnapshotInstr = fs.path.join(getBuildDirectory(), _kIsolateSnapshotInstr);
assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData));
assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData));
assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr));
} else {
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode);
assetEntries[_kKernelKey] = kernelContent;
assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData));
assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData));
}
}
printTrace('Writing asset files to $assetDirPath');
ensureDirectoryExists(assetDirPath);
......
......@@ -125,7 +125,6 @@ class BuildBundleCommand extends BuildSubCommand {
precompiledSnapshot: argResults['precompiled'],
reportLicensedPackages: argResults['report-licensed-packages'],
trackWidgetCreation: argResults['track-widget-creation'],
compilationTraceFilePath: argResults['compilation-trace-file'],
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions],
fileSystemScheme: argResults['filesystem-scheme'],
......
......@@ -43,18 +43,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
)
..addOption('route',
help: 'Which route to load when running the app.',
)
..addFlag('train',
hide: !verboseHelp,
negatable: false,
help: 'Save Dart runtime compilation trace to a file. '
'Compilation trace will be saved to a file specified by --compilation-trace-file '
'when \'flutter run --dynamic --profile --train\' exits. '
'This file contains a list of Dart symbols that were compiled by the runtime JIT '
'compiler up to that point. This file can be used in subsequent --dynamic builds '
'to precompile some code by the offline compiler. '
'This flag is only allowed when running as --dynamic --profile (recommended) or '
'--debug (may include unwanted debug symbols).',
);
usesTargetOption();
usesPortOptions();
......@@ -400,11 +388,6 @@ class RunCommand extends RunCommandBase {
}
}
if (argResults['train'] &&
getBuildMode() != BuildMode.debug && getBuildMode() != BuildMode.dynamicProfile)
throwToolExit('Error: --train is only allowed when running as --dynamic --profile '
'(recommended) or --debug (may include unwanted debug symbols).');
List<String> expFlags;
if (argParser.options.containsKey(FlutterOptions.kEnableExperiment) &&
argResults[FlutterOptions.kEnableExperiment].isNotEmpty) {
......@@ -447,7 +430,6 @@ class RunCommand extends RunCommandBase {
projectRootPath: argResults['project-root'],
packagesFilePath: globalResults['packages'],
dillOutputPath: argResults['output-dill'],
saveCompilationTrace: argResults['train'],
stayResident: stayResident,
ipv6: ipv6,
);
......@@ -469,7 +451,6 @@ class RunCommand extends RunCommandBase {
applicationBinary: applicationBinaryPath == null
? null
: fs.file(applicationBinaryPath),
saveCompilationTrace: argResults['train'],
stayResident: stayResident,
ipv6: ipv6,
);
......
......@@ -54,15 +54,15 @@ class FlutterDevice {
Device device, {
@required FlutterProject flutterProject,
@required bool trackWidgetCreation,
@required String target,
@required BuildMode buildMode,
String dillOutputPath,
List<String> fileSystemRoots,
String fileSystemScheme,
String viewFilter,
@required String target,
TargetModel targetModel = TargetModel.flutter,
List<String> experimentalFlags,
ResidentCompiler generator,
@required BuildMode buildMode,
}) async {
ResidentCompiler generator;
if (flutterProject.hasBuilders) {
......@@ -512,7 +512,6 @@ abstract class ResidentRunner {
this.usesTerminalUI = true,
String projectRootPath,
String packagesFilePath,
this.saveCompilationTrace,
this.stayResident,
this.ipv6,
}) {
......@@ -527,7 +526,6 @@ abstract class ResidentRunner {
final String target;
final DebuggingOptions debuggingOptions;
final bool usesTerminalUI;
final bool saveCompilationTrace;
final bool stayResident;
final bool ipv6;
final Completer<int> _finished = Completer<int>();
......@@ -585,8 +583,6 @@ abstract class ResidentRunner {
Future<void> exit() async {
_exited = true;
if (saveCompilationTrace)
await _debugSaveCompilationTrace();
await stopEchoingDeviceLog();
await preExit();
await exitApp();
......@@ -704,35 +700,6 @@ abstract class ResidentRunner {
}
}
Future<void> _debugSaveCompilationTrace() async {
if (!supportsServiceProtocol)
return;
for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) {
final int index = device.views.indexOf(view);
final File outputFile = fs.currentDirectory
.childFile('compilation${index == 0 ? '' : index}.txt');
printStatus('Saving compilation training data '
'for ${device.device.name}${index == 0 ? '' :'/Isolate$index'} '
'to ${fs.path.relative(outputFile.path)}...');
List<int> buffer;
try {
buffer = await view.uiIsolate.flutterDebugSaveCompilationTrace();
assert(buffer != null);
} catch (error) {
printError('Error communicating with Flutter on the device: $error');
continue;
}
outputFile.parent.createSync(recursive: true);
outputFile.writeAsBytesSync(buffer);
}
}
}
Future<void> _debugTogglePlatform() async {
await refreshViews();
final String from = await flutterDevices[0].views[0].uiIsolate.flutterPlatformOverride();
......
......@@ -39,7 +39,6 @@ class ResidentWebRunner extends ResidentRunner {
target: target,
usesTerminalUI: true,
stayResident: true,
saveCompilationTrace: false,
debuggingOptions: debuggingOptions,
ipv6: ipv6,
);
......
......@@ -23,14 +23,12 @@ class ColdRunner extends ResidentRunner {
this.traceStartup = false,
this.awaitFirstFrameWhenTracing = true,
this.applicationBinary,
bool saveCompilationTrace = false,
bool stayResident = true,
bool ipv6 = false,
}) : super(devices,
target: target,
debuggingOptions: debuggingOptions,
usesTerminalUI: usesTerminalUI,
saveCompilationTrace: saveCompilationTrace,
stayResident: stayResident,
ipv6: ipv6);
......@@ -193,9 +191,6 @@ class ColdRunner extends ResidentRunner {
? 'To detach, press "d"; to quit, press "q".'
: 'To quit, press "q".';
if (haveDetails && !details) {
if (saveCompilationTrace) {
printStatus('Compilation training data will be saved when flutter run quits...');
}
printStatus('For a more detailed help message, press "h". $quitMessage');
} else if (haveAnything) {
printStatus('To repeat this help message, press "h". $quitMessage');
......
......@@ -64,7 +64,6 @@ class HotRunner extends ResidentRunner {
String projectRootPath,
String packagesFilePath,
this.dillOutputPath,
bool saveCompilationTrace = false,
bool stayResident = true,
bool ipv6 = false,
}) : super(devices,
......@@ -73,7 +72,6 @@ class HotRunner extends ResidentRunner {
usesTerminalUI: usesTerminalUI,
projectRootPath: projectRootPath,
packagesFilePath: packagesFilePath,
saveCompilationTrace: saveCompilationTrace,
stayResident: stayResident,
ipv6: ipv6);
......
......@@ -286,27 +286,15 @@ abstract class FlutterCommand extends Command<void> {
final List<bool> modeFlags = <bool>[argResults['debug'], argResults['profile'], argResults['release']];
if (modeFlags.where((bool flag) => flag).length > 1)
throw UsageException('Only one of --debug, --profile, or --release can be specified.', null);
final bool dynamicFlag = argParser.options.containsKey('dynamic')
? argResults['dynamic']
: false;
if (argResults['debug']) {
if (dynamicFlag)
throw ToolExit('Error: --dynamic requires --release or --profile.');
return BuildMode.debug;
}
if (argResults['profile'])
return dynamicFlag ? BuildMode.dynamicProfile : BuildMode.profile;
if (argResults['release'])
return dynamicFlag ? BuildMode.dynamicRelease : BuildMode.release;
if (_defaultBuildMode == BuildMode.debug && dynamicFlag)
throw ToolExit('Error: --dynamic requires --release or --profile.');
if (_defaultBuildMode == BuildMode.release && dynamicFlag)
return BuildMode.dynamicRelease;
if (_defaultBuildMode == BuildMode.profile && dynamicFlag)
return BuildMode.dynamicProfile;
if (argResults['profile']) {
return BuildMode.profile;
}
if (argResults['release']) {
return BuildMode.release;
}
return _defaultBuildMode;
}
......@@ -349,9 +337,6 @@ abstract class FlutterCommand extends Command<void> {
? argResults['flavor']
: null,
trackWidgetCreation: trackWidgetCreation,
compilationTraceFilePath: argParser.options.containsKey('compilation-trace-file')
? argResults['compilation-trace-file']
: null,
extraFrontEndOptions: extraFrontEndOptions,
extraGenSnapshotOptions: argParser.options.containsKey(FlutterOptions.kExtraGenSnapshotOptions)
? argResults[FlutterOptions.kExtraGenSnapshotOptions]
......
......@@ -35,14 +35,6 @@ void main() {
artifacts.getArtifactPath(Artifact.flutterTester),
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
);
expect(
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.android_arm64, mode: BuildMode.dynamicRelease),
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'android-arm64-dynamic-release', 'linux-x64', 'gen_snapshot'),
);
expect(
artifacts.getArtifactPath(Artifact.vmSnapshotData, platform: TargetPlatform.darwin_x64, mode: BuildMode.dynamicRelease),
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'product_vm_isolate_snapshot.bin'),
);
}, overrides: <Type, Generator>{
Cache: () => Cache(rootOverride: tempDir),
Platform: () => FakePlatform(operatingSystem: 'linux'),
......@@ -53,10 +45,6 @@ void main() {
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
'android-arm',
);
expect(
artifacts.getEngineType(TargetPlatform.android_arm64, BuildMode.dynamicProfile),
'android-arm64-dynamic-profile',
);
expect(
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
'ios-release',
......
......@@ -38,7 +38,6 @@ void main() {
precompiledSnapshot: anyNamed('precompiledSnapshot'),
reportLicensedPackages: anyNamed('reportLicensedPackages'),
trackWidgetCreation: anyNamed('trackWidgetCreation'),
compilationTraceFilePath: anyNamed('compilationTraceFilePath'),
extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
extraGenSnapshotOptions: anyNamed('extraGenSnapshotOptions'),
fileSystemRoots: anyNamed('fileSystemRoots'),
......
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