Skip to content

Commit ceba7a5

Browse files
a-sivaCommit Queue
authored andcommitted
Revert "[SDK] Reland : Switch dart2js to an AOT snapshot."
This reverts commit 9fec00a. Reason for revert: flutter tools needs an update to use the 'compile js' command instead of reaching into the dart-sdk and using snapshot names (see flutter/flutter#156654) Original change's description: > [SDK] Reland : Switch dart2js to an AOT snapshot. > > TESTS=ci > > Change-Id: I8c9f9d01cb462d1027c7a6a6521f40946fc7638b > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388071 > Reviewed-by: Ben Konyi <[email protected]> > Commit-Queue: Siva Annamalai <[email protected]> Change-Id: I72bd9ad731b2b60d154c1e6477cce913d72acec4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390020 Bot-Commit: Rubber Stamper <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent fca6949 commit ceba7a5

File tree

6 files changed

+35
-74
lines changed

6 files changed

+35
-74
lines changed

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'dart:async';
66
import 'dart:io';
7+
import 'dart:isolate';
78

89
import 'package:args/args.dart';
910
import 'package:dart2native/generate.dart';
@@ -87,41 +88,48 @@ class CompileJSCommand extends CompileSubcommandCommand {
8788

8889
@override
8990
FutureOr<int> run() async {
90-
if (!Sdk.checkArtifactExists(sdk.librariesJson)) {
91-
return genericErrorExitCode;
91+
if (!Sdk.checkArtifactExists(sdk.dart2jsSnapshot) ||
92+
!Sdk.checkArtifactExists(sdk.librariesJson)) {
93+
return 255;
9294
}
95+
9396
final args = argResults!;
94-
var snapshot = sdk.dart2jsAotSnapshot;
95-
var runtime = sdk.dartAotRuntime;
96-
if (!Sdk.checkArtifactExists(snapshot, logError: false)) {
97-
// AOT snapshots cannot be generated on IA32, so we need this fallback
98-
// branch until support for IA32 is dropped (https://dartbug.com/49969).
99-
snapshot = sdk.dart2jsSnapshot;
100-
runtime = sdk.dart;
101-
if (!Sdk.checkArtifactExists(snapshot)) {
102-
return genericErrorExitCode;
103-
}
104-
}
105-
final dart2jsCommand = [
106-
runtime,
107-
snapshot,
97+
98+
// Build arguments.
99+
final buildArgs = <String>[
108100
'--libraries-spec=${sdk.librariesJson}',
109101
'--cfe-invocation-modes=compile',
110102
'--invoker=dart_cli',
111103
// Add the remaining arguments.
112104
if (args.rest.isNotEmpty) ...args.rest.sublist(0),
113105
];
106+
107+
var retval = 0;
108+
final result = Completer<int>();
109+
final exitPort = ReceivePort()
110+
..listen((msg) {
111+
result.complete(0);
112+
});
113+
final errorPort = ReceivePort()
114+
..listen((error) {
115+
log.stderr(error.toString());
116+
result.complete(255);
117+
});
114118
try {
115-
final exitCode = await runProcessInheritStdio(dart2jsCommand);
116-
return exitCode;
119+
await Isolate.spawnUri(Uri.file(sdk.dart2jsSnapshot), buildArgs, null,
120+
onExit: exitPort.sendPort, onError: errorPort.sendPort);
121+
retval = await result.future;
117122
} catch (e, st) {
118123
log.stderr('Error: JS compilation failed');
119124
log.stderr(e.toString());
120125
if (verbose) {
121126
log.stderr(st.toString());
122127
}
123-
return compileErrorExitCode;
128+
retval = compileErrorExitCode;
124129
}
130+
errorPort.close();
131+
exitPort.close();
132+
return retval;
125133
}
126134
}
127135

pkg/dartdev/lib/src/core.dart

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,8 @@ Future<int> runProcess(
119119
}
120120

121121
log.trace(command.join(' '));
122-
final process = await Process.start(
123-
command.first,
124-
command.skip(1).toList(),
125-
workingDirectory: cwd,
126-
);
122+
final process = await Process.start(command.first, command.skip(1).toList(),
123+
workingDirectory: cwd);
127124
final (_, _, exitCode) = await (
128125
forward(process.stdout, false),
129126
forward(process.stderr, true),
@@ -132,22 +129,6 @@ Future<int> runProcess(
132129
return exitCode;
133130
}
134131

135-
Future<int> runProcessInheritStdio(
136-
List<String> command, {
137-
bool logToTrace = false,
138-
void Function(String str)? listener,
139-
String? cwd,
140-
}) async {
141-
log.trace(command.join(' '));
142-
final process = await Process.start(
143-
command.first,
144-
command.skip(1).toList(),
145-
workingDirectory: cwd,
146-
mode: ProcessStartMode.inheritStdio,
147-
);
148-
return await process.exitCode;
149-
}
150-
151132
Future _streamLineTransform(
152133
Stream<List<int>> stream,
153134
Function(String line) handler,

pkg/dartdev/lib/src/sdk.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class Sdk {
7171
'dart2js.dart.snapshot',
7272
);
7373

74-
String get dart2jsAotSnapshot => _snapshotPathFor(
75-
'dart2js_aot.dart.snapshot',
76-
);
77-
7874
String get dart2wasmSnapshot => _snapshotPathFor(
7975
'dart2wasm_product.snapshot',
8076
);

pkg/dartdev/test/sdk_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void _sdk() {
3030
});
3131

3232
test('dart2js snapshot', () {
33-
expectSnapshotExists(Sdk().dart2jsAotSnapshot, Sdk().dart2jsSnapshot);
33+
expectFileExists(Sdk().dart2jsSnapshot);
3434
});
3535
}
3636

sdk/BUILD.gn

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ declare_args() {
4343
# ......snapshots/
4444
# ........analysis_server.dart.snapshot
4545
# ........dart2bytecode.snapshot (if dart_dynamic_modules)
46-
# ........dart2js_aot.dart.snapshot (AOT snapshot, if not on ia32)
47-
# ........dart2js.dart.snapshot (JIT snapshot only on ia32)
46+
# ........dart2js.dart.snapshot
4847
# ........dart2wasm_product.snapshot (if not on ia32)
4948
# ........dartdev.dart.snapshot (app-jit snapshot or kernel dill file)
5049
# ........dartdevc.dart.snapshot
@@ -153,6 +152,10 @@ if (dart_dynamic_modules) {
153152
}
154153

155154
_full_sdk_snapshots = _platform_sdk_snapshots + [
155+
[
156+
"dart2js",
157+
"../utils/compiler:dart2js",
158+
],
156159
[
157160
"dartdevc",
158161
"../utils/ddc:dartdevc",
@@ -162,17 +165,6 @@ _full_sdk_snapshots = _platform_sdk_snapshots + [
162165
"../utils/bazel:kernel_worker",
163166
],
164167
]
165-
if (dart_target_arch != "ia32" && dart_target_arch != "x86") {
166-
_full_sdk_snapshots += [ [
167-
"dart2js_aot",
168-
"../utils/compiler:dart2js_sdk_aot",
169-
] ]
170-
} else {
171-
_full_sdk_snapshots += [ [
172-
"dart2js",
173-
"../utils/compiler:dart2js",
174-
] ]
175-
}
176168

177169
# Libraries that go under lib/
178170
_full_sdk_libraries = [

utils/compiler/BUILD.gn

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,6 @@ aot_snapshot("dart2js_aot") {
8787
name = "dart2js_aot"
8888
}
8989

90-
aot_snapshot("dart2js_sdk_aot") {
91-
deps = [ ":dart2js_create_snapshot_entry" ]
92-
93-
main_dart = "$target_gen_dir/dart2js.dart"
94-
name = "dart2js_aot.dart"
95-
output = "$root_gen_dir/dart2js_aot.dart.snapshot"
96-
97-
# dartaotruntime has dart_product_config applied to it,
98-
# so it is built in # product mode in both release and
99-
# product builds, and is only built in debug mode in debug
100-
# builds. The following line ensures that the dartaotruntime
101-
# and dartdevc_aot snapshot in an SDK build are
102-
# always compatible with each other.
103-
force_product_mode = !dart_debug
104-
}
105-
10690
compile_platform("compile_dart2js_platform_unsound") {
10791
single_root_scheme = "org-dartlang-sdk"
10892
single_root_base = rebase_path("$sdk_root/")

0 commit comments

Comments
 (0)