Issue #55173. Exposes signed min/max on WasmI64 and f64.min/f64.max on WasmF64 in dart:_wasm, mirroring how WasmF64.sqrt is exposed today. The dart:math min/max patches in math_patch.dart dispatch to them via runtime `is`-checks, with @pragma('wasm:prefer-inline') so the inliner folds the chain to the bare instruction sequence at each call site: T min<T extends num>(T a, T b) { if (a is int && b is int) return unsafeCast<T>((a as int).minS(b)); if (a is double && b is double) return unsafeCast<T>((a as double).min(b)); return _minSlow<T>(a, b); } Wasm has no native i64 min_s/max_s, so WasmI64.minS/maxS emit the same local.tee + i64.le_s/ge_s + select sequence. WasmF64.min/max emit f64.min/f64.max directly. The NaN- and signed-zero-aware fallback ladder is preserved in `_minSlow` / `_maxSlow` (out-of-line, no pragma) and called for the mixed and num cases. tests/lib/math/min_max_test.dart requires type preservation between equal int and double arguments (e.g. min(-499, -499.0) is int at line 113; max(499, 499.0) is int at line 382), which a toDouble().max(toDouble()) fallback would not satisfy. Adds pkg/dart2wasm/test/ir_tests/math_min_max.dart covering min/max for static int/int, double/double, mixed int/double, and num/num. The .wat locks in f64.min/f64.max for the f64 paths, i64.le_s/i64.ge_s + select for the i64 paths, and `call $_minSlow` / `call $_maxSlow` for mixed and num/num. Measurements on a probe with four typed call sites (one each for min<double>, max<double>, min<int>, max<int>, all marked @pragma('wasm:never-inline')): * .wasm size: 27,112 → 25,848 bytes (-4.66%). Generic $min and $max are eliminated by DCE. * Runtime, 100M iterations per operation on d8, median of 10 runs: min<double> 543 → 213 ms (2.55x), max<double> 550 → 213 ms (2.58x), min<int> 552 → 65 ms (8.49x), max<int> 555 → 73 ms (7.61x). Checksums match between baseline and patched. tests/lib/math/min_max_test.dart passes. R=mkustermann@google.com, osa1@google.com Change-Id: If8cf0a4df976f2d7f2230308905ff68491311c97 Bug: https://github.com/dart-lang/sdk/issues/55173 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503740 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Kevin Moore <kevmoo@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
Dart
An approachable, portable, and productive language for high-quality apps on any platform
Dart is:
-
Approachable: Develop with a strongly typed programming language that is consistent, concise, and offers modern language features like null safety and patterns.
-
Portable: Compile to ARM, x64, or RISC-V machine code for mobile, desktop, and backend. Compile to JavaScript or WebAssembly for the web.
-
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app. Diagnose app issues using DevTools.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
-
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
-
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
License & patents
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Using Dart
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
Building Dart
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents in our repo at docs.
Contributing to Dart
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.
Roadmap
Future plans for Dart are included in the combined Dart and Flutter roadmap on the Flutter wiki.