62835950d1
The following issue can happen:
When we performa a type-test against a type parameter the TTS stub for
the type parameter will call the TTS stub for the type argument of the
parameter (by loading it from the instantiator type arguments).
The (instantiated) type argument does not yet have a specialized TTS but
rather the lazy TTS stub, which will got to the runtime.
The runtime will instantiate the type parameter using the instantiator tav,
which will give it a non-nullable 'String!'. Though the NNBD mode used
for instnatiation is kLegacy, which means the instantiation will
actually return 'String*'.
Now we generate a specialized TTS and install it on 'String*'.
=> The original 'String!' will still have the lazy TTS installed and we
will therefore always go to runtime.
Example:
This code is massively slowed down after 61b4bbcb6b "[vm] Set non_nullable_flag() to true"
main(List<String> args) {
args = args.toList();
while (args.isNotEmpty) {
args.removeAt(0);
}
}
The embedder creates the List<String> when calling main. The embedder
API uses effectively `ObjectStore::string_type`, which is initialized,
after 61b4bbcb6b to 'String!' (which might be a bug because we do
have a specific `ObjectStore::non_nullablestring_type`).
=> For now we disable lazy specialization of non-nullable types - which
makes us fall back to subtype test cache searches in this case (which is
significantly slower).
See b/148528639
Issue https://github.com/dart-lang/sdk/issues/39755
Change-Id: I715fe2a9ee22932ae2d949b5cef93d6afb3176d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133981
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>