dart-sdk/runtime
Martin Kustermann b85679eaf3 [vm] Avoid runtime call in common type literal "T" case
Right now all type literal usages will perform a runtime call which is
rather slow.

Flutter happens to use type literals such as `return T;` in hot code
which causes this to show up in the profile.

This CL adds fast paths for type parameter type literals if
the type parameter value (i.e. entry of TAV corresponding to T):

    * is `null`: return `dynamic`
    * is a non-FutureOr [Type] with compatible nullability: return value
    * is [FunctionType] with compatible nullability: return value

otherwise fall back to runtime call.

It makes simple type literal uses 10x+ faster - the kinds that Flutter
is using.

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

TEST=vm/dart{,_2}/instantiate_type_literal_test

Change-Id: I1139d6689aedbc68321f47ee6c9946a3323fbf6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241968
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-27 10:26:25 +00:00
..
bin [format] Remove multiline comment that gcc errors on. 2022-04-21 22:30:59 +00:00
docs [vm] Expose whether extension stream has listeners, guard postEvent 2022-04-26 07:53:43 +00:00
include [dart:io] Publish implementations of the VM file callbacks. 2022-04-19 23:27:17 +00:00
lib [vm] Finalizer / NativeFinalizer fixes 2022-04-07 07:05:27 +00:00
observatory [vm] Expose whether extension stream has listeners, guard postEvent 2022-04-26 07:53:43 +00:00
observatory_2 [vm] Expose whether extension stream has listeners, guard postEvent 2022-04-26 07:53:43 +00:00
platform Revert "[build] Fix Android build for ARM64 Mac." 2022-04-20 23:13:29 +00:00
tests [vm] Avoid runtime call in common type literal "T" case 2022-04-27 10:26:25 +00:00
third_party [vm] More pieces of Windows ARM support. 2022-04-07 23:15:48 +00:00
tools move runtime/tools/wiki/xref_extractor to package:lints 2022-04-19 15:39:57 +00:00
vm [vm] Avoid runtime call in common type literal "T" case 2022-04-27 10:26:25 +00:00
.clang-tidy
.gitignore
BUILD.gn [build] -fno-strict-vtable-pointers is a Clang-only flag. 2022-03-30 17:34:20 +00:00
codereview.settings
configs.gni
CPPLINT.cfg
OWNERS [infra] Add OWNERS to the Dart SDK 2022-02-14 14:06:34 +00:00
PRESUBMIT.py
runtime_args.gni [VM] error: ‘mallinfo mallinfo()’ is deprecated 2021-12-08 00:25:10 +00:00