Skip to content

Commit 651bdae

Browse files
authored
Make FrontendServerClient start the frontend server from AOT snapshot by default (#2263)
1 parent 4d1de26 commit 651bdae

File tree

7 files changed

+71
-11
lines changed

7 files changed

+71
-11
lines changed

frontend_server_client/CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
## 3.3.0-wip
1+
## 4.0.0-wip
22

3-
- Update Dart SDK constraint to `>=3.0.0 <4.0.0`.
3+
- Update Dart SDK constraint to `^3.0.0`.
44
- Support changes in the SDK layout for Dart 3.0.
5+
- By default, start the frontend server from the AOT snapshot shipped in the
6+
Dart SDK.
7+
- Throw an `ArgumentError` when `FrontendServerClient.start` is called with the
8+
`frontendServerPath` argument omitted and the `debug` argument set to true.
9+
- Update `package:vm_service` constraint to `^14.0.0`.
510

611
## 3.2.0
712

frontend_server_client/lib/src/frontend_server_client.dart

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ class FrontendServerClient {
4040
/// The [outputDillPath] determines where the primary output should be, and
4141
/// some targets may output additional files based on that file name (by
4242
/// adding file extensions for instance).
43+
///
44+
/// When the [frontendServerPath] argument is provided, the frontend server
45+
/// will be started from the specified file. The specified file can either be
46+
/// a Dart source file or an AppJIT snapshot.
47+
///
48+
/// When the [frontendServerPath] argument is provided, setting [debug] to
49+
/// true permits debuggers to attach to the frontend server. When the
50+
/// [frontendServerPath] argument is omitted, setting [debug] to true will
51+
/// cause an [ArgumentError] to be thrown.
4352
static Future<FrontendServerClient> start(
4453
String entrypoint,
4554
String outputDillPath,
@@ -60,9 +69,7 @@ class FrontendServerClient {
6069
List<String> additionalSources = const [],
6170
String? nativeAssets,
6271
}) async {
63-
var feServer = await Process.start(Platform.resolvedExecutable, [
64-
if (debug) '--observe',
65-
frontendServerPath ?? _feServerPath,
72+
final commonArguments = <String>[
6673
'--sdk-root',
6774
sdkRoot ?? sdkDir,
6875
'--platform=$platformKernel',
@@ -90,7 +97,38 @@ class FrontendServerClient {
9097
'--native-assets',
9198
nativeAssets,
9299
],
93-
]);
100+
];
101+
late final Process feServer;
102+
if (frontendServerPath != null) {
103+
feServer = await Process.start(
104+
Platform.resolvedExecutable,
105+
<String>[
106+
if (debug) '--observe',
107+
frontendServerPath,
108+
...commonArguments,
109+
],
110+
);
111+
} else if (File(_feServerAotSnapshotPath).existsSync()) {
112+
if (debug) {
113+
throw ArgumentError('The debug argument cannot be set to true when the '
114+
'frontendServerPath argument is omitted.');
115+
}
116+
feServer = await Process.start(
117+
_dartAotRuntimePath,
118+
<String>[_feServerAotSnapshotPath, ...commonArguments],
119+
);
120+
} else {
121+
// AOT snapshots cannot be generated on IA32, so we need this fallback
122+
// branch until support for IA32 is dropped (https://dartbug.com/49969).
123+
feServer = await Process.start(
124+
Platform.resolvedExecutable,
125+
<String>[
126+
if (debug) '--observe',
127+
_feServerAppJitSnapshotPath,
128+
...commonArguments,
129+
],
130+
);
131+
}
94132
var feServerStdoutLines = StreamQueue(feServer.stdout
95133
.transform(utf8.decoder)
96134
.transform(const LineSplitter()));
@@ -407,5 +445,10 @@ enum _RejectState {
407445
done,
408446
}
409447

410-
final _feServerPath =
448+
final _dartAotRuntimePath = p.join(sdkDir, 'bin', 'dartaotruntime');
449+
450+
final _feServerAppJitSnapshotPath =
411451
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server.dart.snapshot');
452+
453+
final _feServerAotSnapshotPath =
454+
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server_aot.dart.snapshot');

frontend_server_client/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: frontend_server_client
2-
version: 3.3.0-wip
2+
version: 4.0.0-wip
33
description: >-
44
Client code to start and interact with the frontend_server compiler from the
55
Dart SDK.
@@ -20,4 +20,4 @@ dev_dependencies:
2020
test: ^1.16.0
2121
test_descriptor: ^2.0.0
2222
test_process: ^2.0.0
23-
vm_service: ^8.0.0
23+
vm_service: ^14.0.0

frontend_server_common/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.2
2+
3+
- Start the frontend server from the AOT snapshot shipped in the Dart SDK.
4+
15
## 0.2.1
26

37
- Doe not pass `-debugger-module-names` flag to the frontend server.

frontend_server_common/lib/src/frontend_server_client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class ResidentCompiler {
398398

399399
_logger.info(args.join(' '));
400400
final workingDirectory = projectDirectory.toFilePath();
401-
_server = await Process.start(sdkLayout.dartPath, args,
401+
_server = await Process.start(sdkLayout.dartAotRuntimePath, args,
402402
workingDirectory: workingDirectory);
403403

404404
var server = _server!;

test_common/lib/test_sdk_layout.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ class TestSdkLayout {
9090
'bin',
9191
Platform.isWindows ? 'dart.exe' : 'dart',
9292
),
93+
dartAotRuntimePath: p.join(
94+
sdkLayout.sdkDirectory,
95+
'bin',
96+
Platform.isWindows ? 'dartaotruntime.exe' : 'dartaotruntime',
97+
),
9398
frontendServerSnapshotPath: p.join(
9499
sdkLayout.sdkDirectory,
95100
'bin',
96101
'snapshots',
97-
'frontend_server.dart.snapshot',
102+
'frontend_server_aot.dart.snapshot',
98103
),
99104
dartdevcSnapshotPath: sdkLayout.dartdevcSnapshotPath,
100105
kernelWorkerSnapshotPath: p.join(
@@ -137,6 +142,7 @@ class TestSdkLayout {
137142
final String stackTraceMapperPath;
138143

139144
final String dartPath;
145+
final String dartAotRuntimePath;
140146
final String frontendServerSnapshotPath;
141147
final String dartdevcSnapshotPath;
142148
final String kernelWorkerSnapshotPath;
@@ -155,6 +161,7 @@ class TestSdkLayout {
155161
required this.requireJsPath,
156162
required this.stackTraceMapperPath,
157163
required this.dartPath,
164+
required this.dartAotRuntimePath,
158165
required this.frontendServerSnapshotPath,
159166
required this.dartdevcSnapshotPath,
160167
required this.kernelWorkerSnapshotPath,

test_common/test/test_sdk_configuration_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void main() {
7070
expect(sdkLayout.stackTraceMapperPath, _fileExists);
7171

7272
expect(sdkLayout.dartPath, _fileExists);
73+
expect(sdkLayout.dartAotRuntimePath, _fileExists);
7374
expect(sdkLayout.frontendServerSnapshotPath, _fileExists);
7475
expect(sdkLayout.dartdevcSnapshotPath, _fileExists);
7576
expect(sdkLayout.kernelWorkerSnapshotPath, _fileExists);

0 commit comments

Comments
 (0)