b4cfeb1093
When compiled to WebAssembly, the Dart SDK needs access to external host functions to implement regular expressions, stack traces, timers and more. Currently, `dart2wasm` relies on `js_interop` definition to implement these functions in JavaScript. As discussed in https://github.com/dart-lang/sdk/issues/53884, an alternative is to use `wasm:import` annotations to let an arbitrary embedder that doesn't necessarily run in a JavaScript context inject implementations for these host functions. This would allow running `dart2wasm` apps by e.g. - using a runtime like wasmtime and defining host functions in Rust. - defining a wrapper module implementing required functions by delegating to WASI definitions, and then using say `wasm-merge` to run the app in any WASI-compatible runtime. This prepares the `--standalone` flag on `dart2wasm` to do just that. When enabled, the compiler uses a different SDK platform to use imports instead of JS interop. For now, these platforms are almost identical: I've ported the timer logic to use wasm imports as a demo, but the rest is still based on existing patch files. We can revisit in subsequent CLs to incrementally reduce `js_interop` dependencies before removing that library from the `dart2wasm_standalone` target entirely. Change-Id: I3f406afbf2dab65506094de5c3f4067f4db66f3e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486380 Reviewed-by: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>