[dart2wasm] Run an additional -Os in open world compilation

This reduces e main module size by ~ 0.5-1%

When compiling with deferred loading, we optimize each module
individually with open world assumptions.

Currently we run only one -Os pass which leaves code behind that can be
optimized by another -Os. See e.g. discussion at [0].

The additional -Os pass is much faster than the first, so it doesn't add
meaningful compile-time.

[0] https://github.com/WebAssembly/binaryen/issues/8077

Change-Id: Id8c5e49d97439e28b2f7d9c5a0c206eec0893cad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490101
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann
2026-03-24 13:07:26 -07:00
committed by Commit Queue
parent 9f2bb62d83
commit f32057642b
4 changed files with 27 additions and 31 deletions
@@ -13,13 +13,14 @@ void main() {
const List<(String?, int?, int?, String?)?> frameDetails = [
('source_map_simple_lib.dart', 18, 3, 'g'),
('source_map_simple_lib.dart', 14, 3, 'f'),
('source_map_simple_lib.dart', 43, 5, 'testMain'),
// The wasm runtime will produce stack frames including `_invokeMain`. But
// `wasm-opt` will inline `f` into `_invokeMain` which will make the source
// maps map `_invokeMain+<offset>` to be `f`.
];
/*
at $.Error._throwWithCurrentStackTrace (wasm://wasm/$-0009ed7a:wasm-function[57]:0xb2bb)
at $.g (wasm://wasm/$-0009ed7a:wasm-function[194]:0xe340)
at $.f (wasm://wasm/$-0009ed7a:wasm-function[193]:0xe334)
at $._invokeMain (wasm://wasm/$-0009ed7a:wasm-function[52]:0xa82c)
at InstantiatedApp.invokeMain (.../source_map_simple_optimized_deferred_test.mjs:413:37)
at main (.../run_wasm.js:428:21)