dart-sdk/sdk
Martin Kustermann e7239ff03c [dart2wasm] Specialize is/as checks for interface types
Currently if we have a `<obj> is/as Iterable<T>` check we will

  * allocate a `WasmArray<_Type>` array and put value for `T` in it
  * allocate a `_InterfaceType` object with the array as type arguments
  * call to RTT which is looping over the type arguments array

With this CL we recognize in the compiler if we generate tests against
interface types and specialize the most common cases (0, 1 or 2 type
arguments). This in return will make us

  * call to 0/1/2 specialized RTT isInterfaceSubtype implementation
    which will use unrolled loops to do the checking.

=> We avoid allocation of `_InterfaceType` always
=> We avoid allocation of `WasmArray<_Type>` for length=0/1/2
=> We have faster checking due to unrolled loops.

(It is very unlikely binaryen can achieve the same, as it would
need to do very aggressive inlining & loop unrolling to get to the
same result. If we'd force it to inline then every is/as check
would be very large).

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

Change-Id: Ia99548d514683f678178ea30d07aeb742ae914ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370260
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-10 11:27:51 +00:00
..
bin [dart2wasm] Remove sdk/bin/dart2wasm{,_developer} scripts 2024-01-19 16:05:27 +00:00
lib [dart2wasm] Specialize is/as checks for interface types 2024-06-10 11:27:51 +00:00
.gitignore
api_readme.md [docs/api] Minor adjustments and fixes to api.dart.dev homepage 2024-02-01 21:41:38 +00:00
BUILD.gn Reland "[SDK] - Ensure we only build an AOT snapshot for the frontend-server" 2024-04-17 20:42:51 +00:00
OWNERS