Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4d68474

Browse files
Load AOT compiled Dart assets only from ELF libraries (#9260)
Previously AOT compiled Dart code would be packaged as a group of assets within the APK. This has been replaced by a single ELF library containing the same data.
1 parent 3e9ffe1 commit 4d68474

File tree

3 files changed

+80
-257
lines changed

3 files changed

+80
-257
lines changed

shell/common/switches.cc

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -235,42 +235,42 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
235235
command_line.GetOptionValue(FlagForSwitch(Switch::FlutterAssetsDir),
236236
&settings.assets_path);
237237

238-
std::string aot_shared_library_path;
239-
command_line.GetOptionValue(FlagForSwitch(Switch::AotSharedLibraryPath),
240-
&aot_shared_library_path);
238+
std::string aot_shared_library_name;
239+
command_line.GetOptionValue(FlagForSwitch(Switch::AotSharedLibraryName),
240+
&aot_shared_library_name);
241241

242-
std::string aot_snapshot_path;
243-
command_line.GetOptionValue(FlagForSwitch(Switch::AotSnapshotPath),
244-
&aot_snapshot_path);
242+
std::string snapshot_asset_path;
243+
command_line.GetOptionValue(FlagForSwitch(Switch::SnapshotAssetPath),
244+
&snapshot_asset_path);
245245

246-
std::string aot_vm_snapshot_data_filename;
247-
command_line.GetOptionValue(FlagForSwitch(Switch::AotVmSnapshotData),
248-
&aot_vm_snapshot_data_filename);
246+
std::string vm_snapshot_data_filename;
247+
command_line.GetOptionValue(FlagForSwitch(Switch::VmSnapshotData),
248+
&vm_snapshot_data_filename);
249249

250-
std::string aot_vm_snapshot_instr_filename;
251-
command_line.GetOptionValue(FlagForSwitch(Switch::AotVmSnapshotInstructions),
252-
&aot_vm_snapshot_instr_filename);
250+
std::string vm_snapshot_instr_filename;
251+
command_line.GetOptionValue(FlagForSwitch(Switch::VmSnapshotInstructions),
252+
&vm_snapshot_instr_filename);
253253

254-
std::string aot_isolate_snapshot_data_filename;
255-
command_line.GetOptionValue(FlagForSwitch(Switch::AotIsolateSnapshotData),
256-
&aot_isolate_snapshot_data_filename);
254+
std::string isolate_snapshot_data_filename;
255+
command_line.GetOptionValue(FlagForSwitch(Switch::IsolateSnapshotData),
256+
&isolate_snapshot_data_filename);
257257

258-
std::string aot_isolate_snapshot_instr_filename;
258+
std::string isolate_snapshot_instr_filename;
259259
command_line.GetOptionValue(
260-
FlagForSwitch(Switch::AotIsolateSnapshotInstructions),
261-
&aot_isolate_snapshot_instr_filename);
262-
263-
if (aot_shared_library_path.size() > 0) {
264-
settings.application_library_path = aot_shared_library_path;
265-
} else if (aot_snapshot_path.size() > 0) {
266-
settings.vm_snapshot_data_path = fml::paths::JoinPaths(
267-
{aot_snapshot_path, aot_vm_snapshot_data_filename});
260+
FlagForSwitch(Switch::IsolateSnapshotInstructions),
261+
&isolate_snapshot_instr_filename);
262+
263+
if (aot_shared_library_name.size() > 0) {
264+
settings.application_library_path = aot_shared_library_name;
265+
} else if (snapshot_asset_path.size() > 0) {
266+
settings.vm_snapshot_data_path =
267+
fml::paths::JoinPaths({snapshot_asset_path, vm_snapshot_data_filename});
268268
settings.vm_snapshot_instr_path = fml::paths::JoinPaths(
269-
{aot_snapshot_path, aot_vm_snapshot_instr_filename});
269+
{snapshot_asset_path, vm_snapshot_instr_filename});
270270
settings.isolate_snapshot_data_path = fml::paths::JoinPaths(
271-
{aot_snapshot_path, aot_isolate_snapshot_data_filename});
271+
{snapshot_asset_path, isolate_snapshot_data_filename});
272272
settings.isolate_snapshot_instr_path = fml::paths::JoinPaths(
273-
{aot_snapshot_path, aot_isolate_snapshot_instr_filename});
273+
{snapshot_asset_path, isolate_snapshot_instr_filename});
274274
}
275275

276276
command_line.GetOptionValue(FlagForSwitch(Switch::CacheDirPath),

shell/common/switches.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,30 @@ namespace flutter {
2424
// clang-format on
2525

2626
DEF_SWITCHES_START
27-
DEF_SWITCH(AotSharedLibraryPath, "aot-shared-library-path", "Path to the *.so.")
28-
DEF_SWITCH(AotSnapshotPath,
29-
"aot-snapshot-path",
27+
DEF_SWITCH(AotSharedLibraryName,
28+
"aot-shared-library-name",
29+
"Name of the *.so containing AOT compiled Dart assets.")
30+
DEF_SWITCH(SnapshotAssetPath,
31+
"snapshot-asset-path",
3032
"Path to the directory containing the four files specified by "
31-
"AotVmSnapshotData, AotVmSnapshotInstructions, "
32-
"AotVmSnapshotInstructions and AotIsolateSnapshotInstructions.")
33-
DEF_SWITCH(AotVmSnapshotData,
33+
"VmSnapshotData, VmSnapshotInstructions, "
34+
"VmSnapshotInstructions and IsolateSnapshotInstructions.")
35+
DEF_SWITCH(VmSnapshotData,
3436
"vm-snapshot-data",
3537
"The VM snapshot data that will be memory mapped as read-only. "
36-
"AotSnapshotPath must be present.")
37-
DEF_SWITCH(AotVmSnapshotInstructions,
38+
"SnapshotAssetPath must be present.")
39+
DEF_SWITCH(VmSnapshotInstructions,
3840
"vm-snapshot-instr",
3941
"The VM instructions snapshot that will be memory mapped as read "
40-
"and executable. AotSnapshotPath must be present.")
41-
DEF_SWITCH(AotIsolateSnapshotData,
42+
"and executable. SnapshotAssetPath must be present.")
43+
DEF_SWITCH(IsolateSnapshotData,
4244
"isolate-snapshot-data",
4345
"The isolate snapshot data that will be memory mapped as read-only. "
44-
"AotSnapshotPath must be present.")
45-
DEF_SWITCH(AotIsolateSnapshotInstructions,
46+
"SnapshotAssetPath must be present.")
47+
DEF_SWITCH(IsolateSnapshotInstructions,
4648
"isolate-snapshot-instr",
4749
"The isolate instructions snapshot that will be memory mapped as "
48-
"read and executable. AotSnapshotPath must be present.")
50+
"read and executable. SnapshotAssetPath must be present.")
4951
DEF_SWITCH(CacheDirPath, "cache-dir-path", "Path to the cache directory.")
5052
DEF_SWITCH(ICUDataFilePath, "icu-data-file-path", "Path to the ICU data file.")
5153
DEF_SWITCH(ICUSymbolPrefix,

0 commit comments

Comments
 (0)