Skip to content

Commit 19c0821

Browse files
committed
Make FrontendServerClient start the frontend server from AOT snapshot by default
1 parent 2d8e9c2 commit 19c0821

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

frontend_server_client/lib/src/frontend_server_client.dart

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ class FrontendServerClient {
6060
List<String> additionalSources = const [],
6161
String? nativeAssets,
6262
}) async {
63-
var feServer = await Process.start(Platform.resolvedExecutable, [
64-
if (debug) '--observe',
65-
frontendServerPath ?? _feServerPath,
63+
final commonArguments = <String>[
6664
'--sdk-root',
6765
sdkRoot ?? sdkDir,
6866
'--platform=$platformKernel',
@@ -90,7 +88,34 @@ class FrontendServerClient {
9088
'--native-assets',
9189
nativeAssets,
9290
],
93-
]);
91+
];
92+
late final Process feServer;
93+
if (frontendServerPath != null) {
94+
feServer = await Process.start(
95+
Platform.resolvedExecutable,
96+
<String>[
97+
if (debug) '--observe',
98+
frontendServerPath,
99+
] +
100+
commonArguments,
101+
);
102+
} else if (File(_feServerAotSnapshotPath).existsSync()) {
103+
feServer = await Process.start(
104+
_dartAotRuntimePath,
105+
<String>[_feServerAotSnapshotPath] + commonArguments,
106+
);
107+
} else {
108+
// AOT snapshots cannot be generated on IA32, so we need this fallback
109+
// branch until support for IA32 is dropped (https://dartbug.com/49969).
110+
feServer = await Process.start(
111+
Platform.resolvedExecutable,
112+
<String>[
113+
if (debug) '--observe',
114+
_feServerAppJitSnapshotPath,
115+
] +
116+
commonArguments,
117+
);
118+
}
94119
var feServerStdoutLines = StreamQueue(feServer.stdout
95120
.transform(utf8.decoder)
96121
.transform(const LineSplitter()));
@@ -407,5 +432,10 @@ enum _RejectState {
407432
done,
408433
}
409434

410-
final _feServerPath =
435+
final _dartAotRuntimePath = p.join(sdkDir, 'bin', 'dartaotruntime');
436+
437+
final _feServerAppJitSnapshotPath =
411438
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server.dart.snapshot');
439+
440+
final _feServerAotSnapshotPath =
441+
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server_aot.dart.snapshot');

0 commit comments

Comments
 (0)