diff --git a/frontend_server_client/lib/src/frontend_server_client.dart b/frontend_server_client/lib/src/frontend_server_client.dart index cd91511d5..20fa2ea09 100644 --- a/frontend_server_client/lib/src/frontend_server_client.dart +++ b/frontend_server_client/lib/src/frontend_server_client.dart @@ -60,9 +60,7 @@ class FrontendServerClient { List additionalSources = const [], String? nativeAssets, }) async { - var feServer = await Process.start(Platform.resolvedExecutable, [ - if (debug) '--observe', - frontendServerPath ?? _feServerPath, + final commonArguments = [ '--sdk-root', sdkRoot ?? sdkDir, '--platform=$platformKernel', @@ -90,7 +88,34 @@ class FrontendServerClient { '--native-assets', nativeAssets, ], - ]); + ]; + late final Process feServer; + if (frontendServerPath != null) { + feServer = await Process.start( + Platform.resolvedExecutable, + [ + if (debug) '--observe', + frontendServerPath, + ] + + commonArguments, + ); + } else if (File(_feServerAotSnapshotPath).existsSync()) { + feServer = await Process.start( + _dartAotRuntimePath, + [_feServerAotSnapshotPath] + commonArguments, + ); + } else { + // AOT snapshots cannot be generated on IA32, so we need this fallback + // branch until support for IA32 is dropped (https://dartbug.com/49969). + feServer = await Process.start( + Platform.resolvedExecutable, + [ + if (debug) '--observe', + _feServerAppJitSnapshotPath, + ] + + commonArguments, + ); + } var feServerStdoutLines = StreamQueue(feServer.stdout .transform(utf8.decoder) .transform(const LineSplitter())); @@ -407,5 +432,10 @@ enum _RejectState { done, } -final _feServerPath = +final _dartAotRuntimePath = p.join(sdkDir, 'bin', 'dartaotruntime'); + +final _feServerAppJitSnapshotPath = p.join(sdkDir, 'bin', 'snapshots', 'frontend_server.dart.snapshot'); + +final _feServerAotSnapshotPath = + p.join(sdkDir, 'bin', 'snapshots', 'frontend_server_aot.dart.snapshot');