Skip to content

Commit

Permalink
Revert "[SDK] Switch dart2js to an AOT snapshot."
Browse files Browse the repository at this point in the history
This reverts commit ff2d1a2.

Reason for revert: golem benachmark build needs some tweaking, webdev dart2js build tests

Original change's description:
> [SDK] Switch dart2js to an AOT snapshot.
>
> TESTS=ci
>
> Change-Id: I1e4fa050652786367e6410fedbceca4e32121aa5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386660
> Reviewed-by: Ben Konyi <[email protected]>
> Commit-Queue: Siva Annamalai <[email protected]>

Change-Id: I221a81274725bd562c4cafcf0db413cef1ac9d75
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388261
Reviewed-by: Siva Annamalai <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Commit-Queue: Siva Annamalai <[email protected]>
Reviewed-by: Liam Appelbe <[email protected]>
  • Loading branch information
a-siva authored and Commit Queue committed Oct 4, 2024
1 parent 6b845ec commit 947639d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 67 deletions.
46 changes: 27 additions & 19 deletions pkg/dartdev/lib/src/commands/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:async';
import 'dart:io';
import 'dart:isolate';

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

@override
FutureOr<int> run() async {
if (!Sdk.checkArtifactExists(sdk.librariesJson)) {
return genericErrorExitCode;
if (!Sdk.checkArtifactExists(sdk.dart2jsSnapshot) ||
!Sdk.checkArtifactExists(sdk.librariesJson)) {
return 255;
}

final args = argResults!;
var snapshot = sdk.dart2jsAotSnapshot;
var runtime = sdk.dartAotRuntime;
if (!Sdk.checkArtifactExists(snapshot, logError: false)) {
// AOT snapshots cannot be generated on IA32, so we need this fallback
// branch until support for IA32 is dropped (https://dartbug.com/49969).
snapshot = sdk.dart2jsSnapshot;
runtime = sdk.dart;
if (!Sdk.checkArtifactExists(snapshot)) {
return genericErrorExitCode;
}
}
final dart2jsCommand = [
runtime,
snapshot,

// Build arguments.
final buildArgs = <String>[
'--libraries-spec=${sdk.librariesJson}',
'--cfe-invocation-modes=compile',
'--invoker=dart_cli',
// Add the remaining arguments.
if (args.rest.isNotEmpty) ...args.rest.sublist(0),
];

var retval = 0;
final result = Completer<int>();
final exitPort = ReceivePort()
..listen((msg) {
result.complete(0);
});
final errorPort = ReceivePort()
..listen((error) {
log.stderr(error.toString());
result.complete(255);
});
try {
final exitCode = await runProcessInheritStdio(dart2jsCommand);
return exitCode;
await Isolate.spawnUri(Uri.file(sdk.dart2jsSnapshot), buildArgs, null,
onExit: exitPort.sendPort, onError: errorPort.sendPort);
retval = await result.future;
} catch (e, st) {
log.stderr('Error: JS compilation failed');
log.stderr(e.toString());
if (verbose) {
log.stderr(st.toString());
}
return compileErrorExitCode;
retval = compileErrorExitCode;
}
errorPort.close();
exitPort.close();
return retval;
}
}

Expand Down
23 changes: 2 additions & 21 deletions pkg/dartdev/lib/src/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,8 @@ Future<int> runProcess(
}

log.trace(command.join(' '));
final process = await Process.start(
command.first,
command.skip(1).toList(),
workingDirectory: cwd,
);
final process = await Process.start(command.first, command.skip(1).toList(),
workingDirectory: cwd);
final (_, _, exitCode) = await (
forward(process.stdout, false),
forward(process.stderr, true),
Expand All @@ -132,22 +129,6 @@ Future<int> runProcess(
return exitCode;
}

Future<int> runProcessInheritStdio(
List<String> command, {
bool logToTrace = false,
void Function(String str)? listener,
String? cwd,
}) async {
log.trace(command.join(' '));
final process = await Process.start(
command.first,
command.skip(1).toList(),
workingDirectory: cwd,
mode: ProcessStartMode.inheritStdio,
);
return await process.exitCode;
}

Future _streamLineTransform(
Stream<List<int>> stream,
Function(String line) handler,
Expand Down
4 changes: 0 additions & 4 deletions pkg/dartdev/lib/src/sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ class Sdk {
'dart2js.dart.snapshot',
);

String get dart2jsAotSnapshot => _snapshotPathFor(
'dart2js_aot.dart.snapshot',
);

String get dart2wasmSnapshot => _snapshotPathFor(
'dart2wasm_product.snapshot',
);
Expand Down
2 changes: 1 addition & 1 deletion pkg/dartdev/test/sdk_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void _sdk() {
});

test('dart2js snapshot', () {
expectSnapshotExists(Sdk().dart2jsAotSnapshot, Sdk().dart2jsSnapshot);
expectFileExists(Sdk().dart2jsSnapshot);
});
}

Expand Down
18 changes: 5 additions & 13 deletions sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ declare_args() {
# ......snapshots/
# ........analysis_server.dart.snapshot
# ........dart2bytecode.snapshot (if dart_dynamic_modules)
# ........dart2js_aot.dart.snapshot (AOT snapshot, if not on ia32)
# ........dart2js.dart.snapshot (JIT snapshot only on ia32)
# ........dart2js.dart.snapshot
# ........dart2wasm_product.snapshot (if not on ia32)
# ........dartdev.dart.snapshot (app-jit snapshot or kernel dill file)
# ........dartdevc.dart.snapshot
Expand Down Expand Up @@ -153,6 +152,10 @@ if (dart_dynamic_modules) {
}

_full_sdk_snapshots = _platform_sdk_snapshots + [
[
"dart2js",
"../utils/compiler:dart2js",
],
[
"dartdevc",
"../utils/ddc:dartdevc",
Expand All @@ -162,17 +165,6 @@ _full_sdk_snapshots = _platform_sdk_snapshots + [
"../utils/bazel:kernel_worker",
],
]
if (dart_target_arch != "ia32" && dart_target_arch != "x86") {
_full_sdk_snapshots += [ [
"dart2js_aot",
"../utils/compiler:dart2js_aot",
] ]
} else {
_full_sdk_snapshots += [ [
"dart2js",
"../utils/compiler:dart2js",
] ]
}

# Libraries that go under lib/
_full_sdk_libraries = [
Expand Down
9 changes: 0 additions & 9 deletions utils/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ aot_snapshot("dart2js_aot") {

main_dart = "$target_gen_dir/dart2js.dart"
name = "dart2js_aot"
output = "$root_gen_dir/dart2js_aot.dart.snapshot"

# dartaotruntime has dart_product_config applied to it,
# so it is built in # product mode in both release and
# product builds, and is only built in debug mode in debug
# builds. The following line ensures that the dartaotruntime
# and dartdevc_aot snapshot in an SDK build are
# always compatible with each other.
force_product_mode = !dart_debug
}

compile_platform("compile_dart2js_platform_unsound") {
Expand Down

0 comments on commit 947639d

Please sign in to comment.