Unverified Commit a3221667 authored by Dan Field's avatar Dan Field Committed by GitHub

Kill dead code (#38652)

parent 13844aa6
...@@ -18,7 +18,6 @@ import '../reporting/reporting.dart'; ...@@ -18,7 +18,6 @@ import '../reporting/reporting.dart';
import 'context.dart'; import 'context.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'fingerprint.dart';
import 'process.dart'; import 'process.dart';
GenSnapshot get genSnapshot => context.get<GenSnapshot>(); GenSnapshot get genSnapshot => context.get<GenSnapshot>();
...@@ -349,142 +348,3 @@ class AOTSnapshotter { ...@@ -349,142 +348,3 @@ class AOTSnapshotter {
return value; return value;
} }
} }
class JITSnapshotter {
/// Builds a JIT VM snapshot of the specified kernel. This snapshot includes
/// data as well as either machine code or DBC, depending on build configuration.
Future<int> build({
@required TargetPlatform platform,
@required BuildMode buildMode,
@required String mainPath,
@required String packagesPath,
@required String outputPath,
@required String compilationTraceFilePath,
List<String> extraGenSnapshotOptions = const <String>[],
}) async {
if (!_isValidJitPlatform(platform)) {
printError('${getNameForTargetPlatform(platform)} does not support JIT snapshotting.');
return 1;
}
final Directory outputDir = fs.directory(outputPath);
outputDir.createSync(recursive: true);
final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode);
final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode);
final String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data');
final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr');
final List<String> inputPaths = <String>[
mainPath, compilationTraceFilePath, engineVmSnapshotData, engineIsolateSnapshotData,
];
final String depfilePath = fs.path.join(outputDir.path, 'snapshot.d');
final List<String> genSnapshotArgs = <String>[
'--deterministic',
];
if (buildMode == BuildMode.debug) {
genSnapshotArgs.add('--enable_asserts');
}
if (extraGenSnapshotOptions != null && extraGenSnapshotOptions.isNotEmpty) {
printTrace('Extra gen_snapshot options: $extraGenSnapshotOptions');
genSnapshotArgs.addAll(extraGenSnapshotOptions);
}
final Set<String> outputPaths = <String>{
isolateSnapshotData,
isolateSnapshotInstructions,
};
// There are a couple special cases below where we create a snapshot
// with only the data section, which only contains interpreted code.
bool supportsAppJit = true;
if (platform == TargetPlatform.android_x64 &&
getCurrentHostPlatform() == HostPlatform.windows_x64) {
supportsAppJit = false;
printStatus('Android x64 dynamic build on Windows x64 will use purely interpreted '
'code for now (see https://github.com/flutter/flutter/issues/17489).');
}
if (platform == TargetPlatform.android_x86) {
supportsAppJit = false;
printStatus('Android x86 dynamic build will use purely interpreted code for now. '
'To optimize performance, consider using --target-platform=android-x64.');
}
genSnapshotArgs.addAll(<String>[
'--snapshot_kind=${supportsAppJit ? 'app-jit' : 'app'}',
'--load_compilation_trace=$compilationTraceFilePath',
'--load_vm_snapshot_data=$engineVmSnapshotData',
'--load_isolate_snapshot_data=$engineIsolateSnapshotData',
'--isolate_snapshot_data=$isolateSnapshotData',
]);
genSnapshotArgs.add('--isolate_snapshot_instructions=$isolateSnapshotInstructions');
if (platform == TargetPlatform.android_arm) {
// Use softfp for Android armv7 devices.
// TODO(cbracken): eliminate this when we fix https://github.com/flutter/flutter/issues/17489
genSnapshotArgs.add('--no-sim-use-hardfp');
// Not supported by the Pixel in 32-bit mode.
genSnapshotArgs.add('--no-use-integer-division');
}
genSnapshotArgs.add(mainPath);
// Verify that all required inputs exist.
final Iterable<String> missingInputs = inputPaths.where((String p) => !fs.isFileSync(p));
if (missingInputs.isNotEmpty) {
printError('Missing input files: $missingInputs from $inputPaths');
return 1;
}
// If inputs and outputs have not changed since last run, skip the build.
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: '$depfilePath.fingerprint',
paths: <String>[mainPath, ...inputPaths, ...outputPaths],
properties: <String, String>{
'buildMode': buildMode.toString(),
'targetPlatform': platform.toString(),
'entryPoint': mainPath,
'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '),
},
depfilePaths: <String>[],
);
// TODO(jonahwilliams): re-enable once this can be proved correct.
// if (await fingerprinter.doesFingerprintMatch()) {
// printTrace('Skipping JIT snapshot build. Fingerprint match.');
// return 0;
// }
final SnapshotType snapshotType = SnapshotType(platform, buildMode);
final int genSnapshotExitCode = await genSnapshot.run(
snapshotType: snapshotType,
additionalArgs: genSnapshotArgs,
);
if (genSnapshotExitCode != 0) {
printError('Dart snapshot generator failed with exit code $genSnapshotExitCode');
return genSnapshotExitCode;
}
// Write path to gen_snapshot, since snapshots have to be re-generated when we roll
// the Dart SDK.
final String genSnapshotPath = GenSnapshot.getSnapshotterPath(snapshotType);
await outputDir.childFile('gen_snapshot.d').writeAsString('gen_snapshot.d: $genSnapshotPath\n');
// Compute and record build fingerprint.
await fingerprinter.writeFingerprint();
return 0;
}
bool _isValidJitPlatform(TargetPlatform platform) {
return const <TargetPlatform>[
TargetPlatform.android_arm,
TargetPlatform.android_arm64,
TargetPlatform.android_x86,
TargetPlatform.android_x64,
].contains(platform);
}
}
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