[dart2wasm] Align semantics of -O3 with dart2js semantics

* Golem is now using -O3
   => remove `--omit-checks` from pkg/dart2wasm/tool/compile_benchmark.

* Dart CI is using -O1/-O2
  => remove `--optimize`/`--no-optimize` from
     pkg/dart2wasm/tool/compile_benchmark and `dart compile wasm`

* Align semantics of -3 with dartjs (enable `--minify`, enable
  `--omit-implicit-checks` disable  `--omit-explicit-checks`).
  => This will make us see changes in benchmarks.

What remains is

* Expose remaining flags in `dart compile wasm` that are needed for
  flutter (or add a generic `--extra-compiler-args` that forwards flags)

* Migrate flutter to use `dart compile wasm`.

* Remove `--omit-type-checks` from pkg/dart2wasm/lib/dart2wasm.dart

Issue https://github.com/dart-lang/sdk/issues/54675

Change-Id: I80654a3ae81bdc5f4c57e3fadccdf5612236102a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348500
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2024-01-26 13:26:40 +00:00 committed by Commit Queue
parent 5db4f9bbd0
commit b562998c14
2 changed files with 4 additions and 41 deletions

View file

@ -115,25 +115,6 @@ while [ $# -gt 0 ]; do
shift
;;
# TODO: Remove this deprecated flag
--optimize)
RUN_BINARYEN=1
shift
;;
# TODO: Remove this deprecated flag
--no-optimize)
RUN_BINARYEN=0
shift
;;
--omit-checks)
# Golem uses --omit-checks but pkg/dart2wasm/bin/dart2wasm accepts
# --omit-type-checks.
DART2WASM_ARGS+=("--omit-type-checks")
shift
;;
--* | -*)
DART2WASM_ARGS+=("$1")
shift

View file

@ -447,8 +447,8 @@ class CompileWasmCommand extends CompileSubcommandCommand {
final List<String> optimizationLevel3Flags = _flagList('''
--inlining
--minify
--omit-implicit-checks
--omit-explicit-checks
'''); // end of optimizationLevel3Flags
final List<String> optimizationLevel4Flags = _flagList('''
@ -479,20 +479,6 @@ class CompileWasmCommand extends CompileSubcommandCommand {
help: 'Generate minified output.',
hide: !verbose,
)
// TODO: Deprecate this flag.
..addFlag(
'optimize',
defaultsTo: true,
negatable: true,
help: 'Optimize wasm output using Binaryen wasm-opt.',
)
..addFlag(
'omit-type-checks',
defaultsTo: false,
negatable: false,
help: 'Omit runtime type checks, such as covariance and downcasts.',
hide: !verbose,
)
..addFlag(
'name-section',
defaultsTo: false,
@ -536,7 +522,7 @@ class CompileWasmCommand extends CompileSubcommandCommand {
help: 'Controls optimizations that can help reduce code-size and '
'improve performance of the generated code.',
allowed: ['0', '1', '2', '3', '4'],
defaultsTo: null, // TODO: Set this to '1'
defaultsTo: '1',
valueHelp: 'level',
hide: !verbose,
)
@ -566,12 +552,11 @@ class CompileWasmCommand extends CompileSubcommandCommand {
final args = argResults!;
final verbose = this.verbose || args['verbose'];
final optimize = args['optimize'];
if (!Sdk.checkArtifactExists(sdk.librariesJson) ||
!Sdk.checkArtifactExists(sdk.dartAotRuntime) ||
!Sdk.checkArtifactExists(sdk.dart2wasmSnapshot) ||
(optimize && !Sdk.checkArtifactExists(sdk.wasmOpt))) {
!Sdk.checkArtifactExists(sdk.wasmOpt)) {
return 255;
}
@ -615,9 +600,7 @@ class CompileWasmCommand extends CompileSubcommandCommand {
}
}
final defaultOptimizationLevel = args['optimize'] ? '1' : '0';
final optimizationLevel =
int.parse(args['optimization-level'] ?? defaultOptimizationLevel);
final optimizationLevel = int.parse(args['optimization-level']);
final runWasmOpt = optimizationLevel >= 1;
final dart2wasmCommand = [
@ -647,7 +630,6 @@ class CompileWasmCommand extends CompileSubcommandCommand {
_ => throw 'unreachable',
},
// Then we pass flags that were opted into explicitly.
if (args['omit-type-checks']) '--omit-type-checks',
if (args['name-section']) '--name-section',
if (args['minify']) '--minify',