Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FrontendServerClient start the frontend server from AOT snapshot by default #2263

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions frontend_server_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 3.3.0-wip
## 4.0.0-wip

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

## 3.2.0

Expand Down
53 changes: 48 additions & 5 deletions frontend_server_client/lib/src/frontend_server_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class FrontendServerClient {
/// The [outputDillPath] determines where the primary output should be, and
/// some targets may output additional files based on that file name (by
/// adding file extensions for instance).
///
/// When the [frontendServerPath] argument is provided, the frontend server
/// will be started from the specified file. The specified file can either be
/// a Dart source file or an AppJIT snapshot.
///
/// When the [frontendServerPath] argument is provided, setting [debug] to
derekxu16 marked this conversation as resolved.
Show resolved Hide resolved
/// true permits debuggers to attach to the frontend server. When the
/// [frontendServerPath] argument is omitted, setting [debug] to true will
/// cause an [ArgumentError] to be thrown.
static Future<FrontendServerClient> start(
String entrypoint,
String outputDillPath,
Expand All @@ -60,9 +69,7 @@ class FrontendServerClient {
List<String> additionalSources = const [],
String? nativeAssets,
}) async {
var feServer = await Process.start(Platform.resolvedExecutable, [
if (debug) '--observe',
frontendServerPath ?? _feServerPath,
final commonArguments = <String>[
'--sdk-root',
sdkRoot ?? sdkDir,
'--platform=$platformKernel',
Expand Down Expand Up @@ -90,7 +97,38 @@ class FrontendServerClient {
'--native-assets',
nativeAssets,
],
]);
];
late final Process feServer;
if (frontendServerPath != null) {
feServer = await Process.start(
Platform.resolvedExecutable,
<String>[
if (debug) '--observe',
frontendServerPath,
...commonArguments,
],
);
} else if (File(_feServerAotSnapshotPath).existsSync()) {
derekxu16 marked this conversation as resolved.
Show resolved Hide resolved
if (debug) {
throw ArgumentError('The debug argument cannot be set to true when the '
'frontendServerPath argument is omitted.');
}
feServer = await Process.start(
_dartAotRuntimePath,
<String>[_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,
<String>[
if (debug) '--observe',
_feServerAppJitSnapshotPath,
...commonArguments,
],
);
}
var feServerStdoutLines = StreamQueue(feServer.stdout
.transform(utf8.decoder)
.transform(const LineSplitter()));
Expand Down Expand Up @@ -407,5 +445,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');
4 changes: 2 additions & 2 deletions frontend_server_client/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: frontend_server_client
version: 3.3.0-wip
version: 4.0.0-wip
description: >-
Client code to start and interact with the frontend_server compiler from the
Dart SDK.
Expand All @@ -20,4 +20,4 @@ dev_dependencies:
test: ^1.16.0
test_descriptor: ^2.0.0
test_process: ^2.0.0
vm_service: ^8.0.0
vm_service: ^14.0.0
4 changes: 4 additions & 0 deletions frontend_server_common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.2

- Start the frontend server from the AOT snapshot shipped in the Dart SDK.

## 0.2.1

- Doe not pass `-debugger-module-names` flag to the frontend server.
Expand Down
2 changes: 1 addition & 1 deletion frontend_server_common/lib/src/frontend_server_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class ResidentCompiler {

_logger.info(args.join(' '));
final workingDirectory = projectDirectory.toFilePath();
_server = await Process.start(sdkLayout.dartPath, args,
_server = await Process.start(sdkLayout.dartAotRuntimePath, args,
workingDirectory: workingDirectory);

var server = _server!;
Expand Down
9 changes: 8 additions & 1 deletion test_common/lib/test_sdk_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ class TestSdkLayout {
'bin',
Platform.isWindows ? 'dart.exe' : 'dart',
),
dartAotRuntimePath: p.join(
sdkLayout.sdkDirectory,
'bin',
Platform.isWindows ? 'dartaotruntime.exe' : 'dartaotruntime',
),
frontendServerSnapshotPath: p.join(
sdkLayout.sdkDirectory,
'bin',
'snapshots',
'frontend_server.dart.snapshot',
'frontend_server_aot.dart.snapshot',
),
dartdevcSnapshotPath: sdkLayout.dartdevcSnapshotPath,
kernelWorkerSnapshotPath: p.join(
Expand Down Expand Up @@ -137,6 +142,7 @@ class TestSdkLayout {
final String stackTraceMapperPath;

final String dartPath;
final String dartAotRuntimePath;
final String frontendServerSnapshotPath;
final String dartdevcSnapshotPath;
final String kernelWorkerSnapshotPath;
Expand All @@ -155,6 +161,7 @@ class TestSdkLayout {
required this.requireJsPath,
required this.stackTraceMapperPath,
required this.dartPath,
required this.dartAotRuntimePath,
required this.frontendServerSnapshotPath,
required this.dartdevcSnapshotPath,
required this.kernelWorkerSnapshotPath,
Expand Down
1 change: 1 addition & 0 deletions test_common/test/test_sdk_configuration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void main() {
expect(sdkLayout.stackTraceMapperPath, _fileExists);

expect(sdkLayout.dartPath, _fileExists);
expect(sdkLayout.dartAotRuntimePath, _fileExists);
expect(sdkLayout.frontendServerSnapshotPath, _fileExists);
expect(sdkLayout.dartdevcSnapshotPath, _fileExists);
expect(sdkLayout.kernelWorkerSnapshotPath, _fileExists);
Expand Down