Skip to content

Commit ab44b20

Browse files
a-sivaCommit Queue
authored andcommitted
Reapply "[VM/dartdev] Switch dartdev to use an AOT runtime." and
Add the fixes that were done after original CL landed. This reverts commit 97bc401. TEST=ci Change-Id: I26373aecc325e4c0c379c92e779aa301e3a58c5a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441700 Reviewed-by: Brian Quinlan <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent a1699ec commit ab44b20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2674
-1696
lines changed

BUILD.gn

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ group("runtime") {
4242

4343
deps = [
4444
"runtime/bin:dart",
45+
"runtime/bin:dartvm",
4546
"runtime/bin:ffi_test_dynamic_library",
4647
"runtime/bin:ffi_test_functions",
4748
"runtime/bin:process_test",
@@ -60,12 +61,15 @@ group("runtime") {
6061
deps += [
6162
"runtime/bin:dartaotruntime",
6263
"runtime/bin:dartaotruntime_product",
64+
"utils/dartdev:dartdev_aot_snapshot",
6365
"utils/dds:dds_aot",
66+
"utils/dtd:dtd_aot",
6467
"utils/kernel-service:frontend_server_aot_product",
6568
]
6669
} else {
6770
deps += [
6871
"utils/dds:dds",
72+
"utils/dtd:dtd",
6973
"utils/kernel-service:frontend_server",
7074
]
7175
}
@@ -420,7 +424,7 @@ if (is_fuchsia) {
420424
}
421425

422426
test_binaries = [
423-
"dart",
427+
"dartvm",
424428
"dartaotruntime",
425429
"run_vm_tests",
426430
]

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ when the target OS is Linux.
8686

8787
[cross-compilation]: https://dart.dev/tools/dart-compile#cross-compilation-exe
8888

89+
#### Dart CLI and Dart VM
90+
91+
- The Dart CLI and Dart VM have been split into two seperate executables.
92+
93+
The Dart CLI tool has been split out of the VM into it's own embedder which
94+
runs in AOT mode. The pure Dart VM executable is called `dartvm` and
95+
has no Dart CLI functionality in it
96+
97+
The Dart CLI executable parses the CLI commands and invokes the rest
98+
of the AOT tools in the same process, for the 'run' and 'test'
99+
commands it execs a process which runs `dartvm`
100+
101+
`dart hello.dart` execs the `dartvm` process and runs 'hello.dart'
102+
103+
The Dart CLI is not generated for ia32 as we are not shipping a
104+
Dart SDK for ia32 anymore (support to execute the `dartvm` for ia32
105+
architecture is retained)
106+
107+
89108
#### Pub
90109

91110
- [Git dependencies][] can now be version-solved based on git tags.

build/dart/dart_action.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ template("_built_tool_action") {
353353
template("dart_action") {
354354
assert(defined(invoker.script), "script must be defined for $target_name")
355355
_built_tool_action(target_name) {
356-
tool = "$_dart_root/runtime/bin:dart"
356+
tool = "$_dart_root/runtime/bin:dartvm"
357357
forward_variables_from(invoker,
358358
[
359359
"args",

build/rbe/rewrapper_dart.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def parse_rewrapper(self):
269269
elif arg.endswith('/dart'):
270270
self.dart_subdir = os.path.dirname(arg)
271271
return self.parse_dart()
272+
elif arg.endswith('/dartvm'):
273+
self.dart_subdir = os.path.dirname(arg)
274+
return self.parse_dart()
272275
elif arg.endswith('/dartaotruntime'):
273276
self.dart_subdir = os.path.dirname(arg)
274277
return self.parse_dartaotruntime()

pkg/analysis_server/integration_test/analysis/get_errors_non_standard_sdk_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class AnalysisDomainGetErrorsTest
2727
return path.join(sdkPath, 'bin', name);
2828
}
2929

30+
String executableVmFilePathIn(String sdkPath) {
31+
var name = Platform.isWindows ? 'dartvm.exe' : 'dartvm';
32+
return path.join(sdkPath, 'bin', name);
33+
}
34+
3035
String serverSnapshotPathIn(String sdkPath) {
3136
return path.join(
3237
sdkPath,
@@ -50,6 +55,10 @@ class AnalysisDomainGetErrorsTest
5055
executableFilePathIn(standardSdkPath),
5156
).copySync(executableFilePathIn(sdkPath));
5257

58+
File(
59+
executableVmFilePathIn(standardSdkPath),
60+
).copySync(executableVmFilePathIn(sdkPath));
61+
5362
File(
5463
serverSnapshotPathIn(standardSdkPath),
5564
).copySync(serverSnapshotPathIn(sdkPath));

pkg/dartdev/lib/src/commands/compile.dart

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,12 @@ class CompileJSCommand extends CompileSubcommandCommand {
9999
}
100100
final args = argResults!;
101101
var snapshot = sdk.dart2jsAotSnapshot;
102-
var script = sdk.dartAotRuntime;
103-
var useExecProcess = true;
104102
if (!Sdk.checkArtifactExists(snapshot, logError: false)) {
105-
// AOT snapshots cannot be generated on IA32, so we need this fallback
106-
// branch until support for IA32 is dropped (https://dartbug.com/49969).
107-
script = sdk.dart2jsSnapshot;
108-
if (!Sdk.checkArtifactExists(script)) {
109-
return genericErrorExitCode;
110-
}
111-
useExecProcess = false;
103+
log.stderr('Error: JS compilation failed');
104+
log.stderr('Unable to find $snapshot');
105+
return compileErrorExitCode;
112106
}
113107
final dart2jsCommand = [
114-
if (useExecProcess) snapshot,
115108
'--libraries-spec=${sdk.librariesJson}',
116109
'--cfe-invocation-modes=compile',
117110
'--invoker=dart_cli',
@@ -120,10 +113,10 @@ class CompileJSCommand extends CompileSubcommandCommand {
120113
];
121114
try {
122115
VmInteropHandler.run(
123-
script,
116+
snapshot,
124117
dart2jsCommand,
125118
packageConfigOverride: null,
126-
useExecProcess: useExecProcess,
119+
useExecProcess: false,
127120
);
128121
return 0;
129122
} catch (e, st) {
@@ -164,28 +157,21 @@ class CompileDDCCommand extends CompileSubcommandCommand {
164157
}
165158
final args = argResults!;
166159
var snapshot = sdk.ddcAotSnapshot;
167-
var script = sdk.dartAotRuntime;
168-
var useExecProcess = true;
169160
if (!Sdk.checkArtifactExists(snapshot, logError: false)) {
170-
// AOT snapshots cannot be generated on IA32, so we need this fallback
171-
// branch until support for IA32 is dropped (https://dartbug.com/49969).
172-
script = sdk.ddcSnapshot;
173-
if (!Sdk.checkArtifactExists(script)) {
174-
return genericErrorExitCode;
175-
}
176-
useExecProcess = false;
161+
log.stderr('Error: JS compilation failed');
162+
log.stderr('Unable to find $snapshot');
163+
return compileErrorExitCode;
177164
}
178165
final ddcCommand = <String>[
179-
if (useExecProcess) snapshot,
180166
// Add the remaining arguments.
181167
if (args.rest.isNotEmpty) ...args.rest.sublist(0),
182168
];
183169
try {
184170
VmInteropHandler.run(
185-
script,
171+
snapshot,
186172
ddcCommand,
187173
packageConfigOverride: null,
188-
useExecProcess: useExecProcess,
174+
useExecProcess: false,
189175
);
190176
return 0;
191177
} catch (e, st) {
@@ -460,7 +446,7 @@ class CompileJitSnapshotCommand extends CompileSubcommandCommand {
460446

461447
log.stdout('Compiling $sourcePath to jit-snapshot file $outputFile.');
462448
// TODO(bkonyi): perform compilation in same process.
463-
return await runProcess([sdk.dart, ...buildArgs]);
449+
return await runProcess([sdk.dartvm, ...buildArgs]);
464450
}
465451
}
466452

pkg/dartdev/lib/src/commands/dart_mcp_server.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ A stdio based Model Context Protocol (MCP) server to aid in Dart and Flutter dev
5151
}
5252
try {
5353
VmInteropHandler.run(
54-
sdk.dartAotRuntime,
54+
sdk.dartMCPServerAotSnapshot,
5555
[
56-
sdk.dartMCPServerAotSnapshot,
5756
...forwardedArgs,
5857
],
59-
useExecProcess: true,
58+
useExecProcess: false,
6059
);
6160
return 0;
6261
} catch (e, st) {

pkg/dartdev/lib/src/commands/development_service.dart

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:io';
76

87
import 'package:dds/src/arg_parser.dart';
98
import 'package:path/path.dart';
@@ -37,38 +36,22 @@ class DevelopmentServiceCommand extends DartdevCommand {
3736
Future<int> run() async {
3837
final sdkDir = dirname(sdk.dart);
3938
final fullSdk = sdkDir.endsWith('bin');
40-
var script = fullSdk
41-
? sdk.dartAotRuntime
42-
: absolute(sdkDir, 'dartaotruntime${Platform.isWindows ? '.exe' : ''}');
4339
var snapshot = fullSdk
4440
? sdk.ddsAotSnapshot
4541
: absolute(sdkDir, 'dds_aot.dart.snapshot');
46-
var useExecProcess = true;
4742
final args = argResults!.arguments;
4843

4944
if (!Sdk.checkArtifactExists(snapshot, logError: false)) {
50-
// On ia32 platforms we do not have an AOT snapshot and so we need
51-
// to run the JIT snapshot.
52-
useExecProcess = false;
53-
script =
54-
fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot');
55-
if (!Sdk.checkArtifactExists(script, logError: false)) {
56-
log.stderr('Error: launching development server failed : '
57-
'Unable to find snapshot for the development server');
58-
return 255;
59-
}
45+
log.stderr('Error: launching development server failed : '
46+
'Unable to find snapshot for the development server');
47+
return 255;
6048
}
61-
final ddsCommand = [
62-
if (useExecProcess) snapshot,
63-
// Add the remaining args.
64-
if (args.isNotEmpty) ...args,
65-
];
6649
try {
6750
VmInteropHandler.run(
68-
script,
69-
ddsCommand,
51+
snapshot,
52+
args,
7053
packageConfigOverride: null,
71-
useExecProcess: useExecProcess,
54+
useExecProcess: false,
7255
);
7356
return 0;
7457
} catch (e, st) {

pkg/dartdev/lib/src/commands/language_server.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,35 @@ For more information about the server's capabilities and configuration, see:
5454
args = [...args, '--$protocol=$lsp'];
5555
}
5656
try {
57+
var script = sdk.analysisServerAotSnapshot;
58+
var useExec = false;
5759
if (argResults!.flag(useAotSnapshotFlag)) {
58-
if (!Sdk.checkArtifactExists(sdk.dartAotRuntime)) {
60+
if (!Sdk.checkArtifactExists(sdk.analysisServerAotSnapshot)) {
61+
log.stderr('Error: launching language analysis server failed');
62+
log.stderr('${sdk.analysisServerAotSnapshot} not found');
5963
return _genericErrorExitCode;
6064
}
6165
args = [...args];
6266
args.remove('--$useAotSnapshotFlag');
63-
VmInteropHandler.run(
64-
sdk.dartAotRuntime,
65-
[sdk.analysisServerAotSnapshot, ...args],
66-
useExecProcess: true,
67-
);
6867
} else {
6968
args = [...args];
7069
args.remove('--no-$useAotSnapshotFlag');
71-
VmInteropHandler.run(
72-
sdk.analysisServerSnapshot,
73-
args,
74-
useExecProcess: false,
75-
);
70+
script = sdk.analysisServerSnapshot;
71+
useExec = true;
7672
}
73+
VmInteropHandler.run(
74+
script,
75+
args,
76+
useExecProcess: useExec,
77+
);
7778
return 0;
7879
} catch (e, st) {
7980
log.stderr('Error: launching language analysis server failed');
8081
log.stderr(e.toString());
8182
if (verbose) {
8283
log.stderr(st.toString());
8384
}
84-
return 255;
85+
return _genericErrorExitCode;
8586
}
8687
}
8788

0 commit comments

Comments
 (0)