dart-sdk/sdk
Tess Strickland 6672353e0f [vm] Fix instantiation of default type args in closure functions.
Previously, the default type arguments for closure functions were
instantiated in the same way as other types of functions, where the
instantiator and function type arguments of the call were used. However,
the defaults for closure functions should be instantiated with the
instantiator and parent function type arguments stored within the
closure itself.

Since the instantiation of the default type arguments only depends on
the instantiator and parent function type arguments, which are shared
between partial instantiations of the same generic closure, the VM
performs this instantiation once at closure creation and caches it in
the closure object, so it can be retrieved when the default type
arguments are needed and copied to new partial instantiations of the
same closure without need for recalculation.

As a side effect, this should speed up dynamic invocation of generic
closures, since the invoke field dispatcher that implements them
previously performed this instantiation when needed on every invocation,
but now it just retrieves the cached version instead.

TEST=language/closure/type_arguments vm/dart/regress_54426

Fixes: https://github.com/dart-lang/sdk/issues/54426
Change-Id: I9baad807befa0323f3c5b66196b9664e4d78af0a
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-reload-linux-release-x64-try,vm-reload-rollback-linux-release-x64-try,vm-tsan-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-aot-linux-release-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-mac-product-arm64-try,vm-aot-obfuscate-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344700
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-01-08 13:07:16 +00:00
..
bin [dart2wasm] Start using WebAssembly.String imports 2023-12-08 10:04:41 +00:00
lib [vm] Fix instantiation of default type args in closure functions. 2024-01-08 13:07:16 +00:00
.gitignore [sdk] Generate a version file for the unpatched SDK 2022-05-05 10:36:05 +00:00
api_readme.md [docs] fix a grammar issue in the sdk readme 2023-04-26 18:25:55 +00:00
BUILD.gn [build] Omit SDK and Git hashes on RBE. 2023-12-20 12:23:56 +00:00
OWNERS [infra] Add OWNERS to the Dart SDK 2022-02-14 14:06:34 +00:00