Implement build flow for hot updates on Android (#22391)
This also involves switching from Core JIT to App JIT snapshot, and replacing per-isolate VM snapshot with the shared VM snapshot. For now there is no separate update bundle file, as the generated update gets packaged directly into the APK for testing purposes.
This commit is contained in:
committed by
GitHub
parent
b65d3bceaa
commit
54c10f44b2
@@ -545,23 +545,29 @@ void main() {
|
||||
|
||||
});
|
||||
|
||||
group('Snapshotter - Core JIT', () {
|
||||
group('Snapshotter - JIT', () {
|
||||
const String kTrace = 'trace.txt';
|
||||
const String kEngineVmSnapshotData = 'engine_vm_snapshot_data';
|
||||
const String kEngineIsolateSnapshotData = 'engine_isolate_snapshot_data';
|
||||
|
||||
_FakeGenSnapshot genSnapshot;
|
||||
MemoryFileSystem fs;
|
||||
CoreJITSnapshotter snapshotter;
|
||||
JITSnapshotter snapshotter;
|
||||
MockAndroidSdk mockAndroidSdk;
|
||||
MockArtifacts mockArtifacts;
|
||||
|
||||
setUp(() async {
|
||||
fs = MemoryFileSystem();
|
||||
fs.file(kTrace).createSync();
|
||||
fs.file(kEngineVmSnapshotData).createSync();
|
||||
fs.file(kEngineIsolateSnapshotData).createSync();
|
||||
|
||||
genSnapshot = _FakeGenSnapshot();
|
||||
snapshotter = CoreJITSnapshotter();
|
||||
snapshotter = JITSnapshotter();
|
||||
mockAndroidSdk = MockAndroidSdk();
|
||||
mockArtifacts = MockArtifacts();
|
||||
when(mockArtifacts.getArtifactPath(Artifact.vmSnapshotData)).thenReturn(kEngineVmSnapshotData);
|
||||
when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData)).thenReturn(kEngineIsolateSnapshotData);
|
||||
});
|
||||
|
||||
final Map<Type, Generator> contextOverrides = <Type, Generator>{
|
||||
@@ -571,7 +577,7 @@ void main() {
|
||||
GenSnapshot: () => genSnapshot,
|
||||
};
|
||||
|
||||
testUsingContext('iOS debug Core JIT snapshot is invalid', () async {
|
||||
testUsingContext('iOS debug JIT snapshot is invalid', () async {
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
expect(await snapshotter.build(
|
||||
platform: TargetPlatform.ios,
|
||||
@@ -580,19 +586,18 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
), isNot(equals(0)));
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm debug Core JIT snapshot', () async {
|
||||
testUsingContext('builds Android arm debug JIT snapshot', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'vm_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
@@ -604,6 +609,7 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
@@ -616,28 +622,26 @@ void main() {
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--enable_asserts',
|
||||
'--snapshot_kind=core-jit',
|
||||
'--vm_snapshot_data=build/foo/vm_snapshot_data',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--vm_snapshot_instructions=build/foo/vm_snapshot_instr',
|
||||
'--isolate_snapshot_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--load_compilation_trace=trace.txt',
|
||||
'--no-sim-use-hardfp',
|
||||
'--no-use-integer-division',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm64 debug Core JIT snapshot', () async {
|
||||
testUsingContext('builds Android arm64 debug JIT snapshot', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'vm_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
@@ -649,6 +653,7 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
@@ -661,17 +666,17 @@ void main() {
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--enable_asserts',
|
||||
'--snapshot_kind=core-jit',
|
||||
'--vm_snapshot_data=build/foo/vm_snapshot_data',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--vm_snapshot_instructions=build/foo/vm_snapshot_instr',
|
||||
'--isolate_snapshot_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--load_compilation_trace=trace.txt',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('iOS release Core JIT snapshot is invalid', () async {
|
||||
testUsingContext('iOS release JIT snapshot is invalid', () async {
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
expect(await snapshotter.build(
|
||||
platform: TargetPlatform.ios,
|
||||
@@ -680,19 +685,18 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
), isNot(equals(0)));
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm profile Core JIT snapshot', () async {
|
||||
testUsingContext('builds Android arm profile JIT snapshot', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'vm_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
@@ -704,6 +708,7 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
@@ -715,28 +720,26 @@ void main() {
|
||||
'--reify-generic-functions',
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--snapshot_kind=core-jit',
|
||||
'--vm_snapshot_data=build/foo/vm_snapshot_data',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--vm_snapshot_instructions=build/foo/vm_snapshot_instr',
|
||||
'--isolate_snapshot_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--load_compilation_trace=trace.txt',
|
||||
'--no-sim-use-hardfp',
|
||||
'--no-use-integer-division',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm64 profile Core JIT snapshot', () async {
|
||||
testUsingContext('builds Android arm64 profile JIT snapshot', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'vm_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
@@ -748,6 +751,7 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
@@ -759,17 +763,17 @@ void main() {
|
||||
'--reify-generic-functions',
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--snapshot_kind=core-jit',
|
||||
'--vm_snapshot_data=build/foo/vm_snapshot_data',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--vm_snapshot_instructions=build/foo/vm_snapshot_instr',
|
||||
'--isolate_snapshot_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--load_compilation_trace=trace.txt',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('iOS release Core JIT snapshot is invalid', () async {
|
||||
testUsingContext('iOS release JIT snapshot is invalid', () async {
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
expect(await snapshotter.build(
|
||||
platform: TargetPlatform.ios,
|
||||
@@ -778,19 +782,18 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
), isNot(equals(0)));
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm release Core JIT snapshot', () async {
|
||||
testUsingContext('builds Android arm release JIT snapshot', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'vm_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
@@ -802,6 +805,7 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
@@ -813,28 +817,26 @@ void main() {
|
||||
'--reify-generic-functions',
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--snapshot_kind=core-jit',
|
||||
'--vm_snapshot_data=build/foo/vm_snapshot_data',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--vm_snapshot_instructions=build/foo/vm_snapshot_instr',
|
||||
'--isolate_snapshot_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--load_compilation_trace=trace.txt',
|
||||
'--no-sim-use-hardfp',
|
||||
'--no-use-integer-division',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm64 release Core JIT snapshot', () async {
|
||||
testUsingContext('builds Android arm64 release JIT snapshot', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'vm_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'isolate_snapshot_instr'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
@@ -846,6 +848,7 @@ void main() {
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: false,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
@@ -857,12 +860,55 @@ void main() {
|
||||
'--reify-generic-functions',
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--snapshot_kind=core-jit',
|
||||
'--vm_snapshot_data=build/foo/vm_snapshot_data',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--vm_snapshot_instructions=build/foo/vm_snapshot_instr',
|
||||
'--isolate_snapshot_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--load_compilation_trace=trace.txt',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
testUsingContext('builds Android arm release JIT snapshot for hot update', () async {
|
||||
fs.file('main.dill').writeAsStringSync('binary magic');
|
||||
|
||||
final String outputPath = fs.path.join('build', 'foo');
|
||||
fs.directory(outputPath).createSync(recursive: true);
|
||||
fs.file(fs.path.join(outputPath, 'isolate_snapshot_instr')).createSync();
|
||||
|
||||
genSnapshot.outputs = <String, String>{
|
||||
fs.path.join(outputPath, 'isolate_snapshot_data'): '',
|
||||
fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ',
|
||||
};
|
||||
|
||||
final int genSnapshotExitCode = await snapshotter.build(
|
||||
platform: TargetPlatform.android_arm,
|
||||
buildMode: BuildMode.release,
|
||||
mainPath: 'main.dill',
|
||||
packagesPath: '.packages',
|
||||
outputPath: outputPath,
|
||||
compilationTraceFilePath: kTrace,
|
||||
buildHotUpdate: true,
|
||||
);
|
||||
|
||||
expect(genSnapshotExitCode, 0);
|
||||
expect(genSnapshot.callCount, 1);
|
||||
expect(genSnapshot.snapshotType.platform, TargetPlatform.android_arm);
|
||||
expect(genSnapshot.snapshotType.mode, BuildMode.release);
|
||||
expect(genSnapshot.packagesPath, '.packages');
|
||||
expect(genSnapshot.additionalArgs, <String>[
|
||||
'--reify-generic-functions',
|
||||
'--strong',
|
||||
'--sync-async',
|
||||
'--snapshot_kind=app-jit',
|
||||
'--load_compilation_trace=$kTrace',
|
||||
'--load_vm_snapshot_data=$kEngineVmSnapshotData',
|
||||
'--load_isolate_snapshot_data=$kEngineIsolateSnapshotData',
|
||||
'--isolate_snapshot_data=build/foo/isolate_snapshot_data',
|
||||
'--reused_instructions=build/foo/isolate_snapshot_instr',
|
||||
'--no-sim-use-hardfp',
|
||||
'--no-use-integer-division',
|
||||
'main.dill',
|
||||
]);
|
||||
}, overrides: contextOverrides);
|
||||
|
||||
Reference in New Issue
Block a user