7c55965b76
Previously, no optimized TTSes were generated for implemented types, and
so they always fell back to the default TTS, which mostly depends on
calling the runtime and cached checks in SubtypeTestCaches. Now,
optimized TTSes are generated that check for certain compatible
implementing classes before falling back on the runtime/STC.
More specifically, the optimized TTSes for implemented types checks for
the following cases:
1) The implemented type is instantiated and the checked class implements
an instantiated subtype of the implemented type. The only check
required is a class id match.
2) The instance type arguments of the checked class are compatible with
the type arguments of the checked type. That is, given the following
declarations, where Base, Impl1, and Impl2 have the same number of
parent type arguments:
```
case Impl1<K, V> implements Base<K, V>
case Impl2<V> implements Base<String, V>
```
then the generated optimized TTS for Base<S, T>, where S and T are
either type parameters or instantiated types, checks for instances of
Base and Impl1, comparing the type arguments of the instance to S and
T. The generated TTS does not currently check for Impl2, and thus
when given an instance of Impl2, it falls back to the old runtime
checking/SubtypeTestCache behavior.
This compatibility restriction allows us to perform the same checks on
the loaded instance type arguments as is done for non-implemented types,
where the checked classes are subclasses and so naturally compatible in
this manner.
Note that two implementing classes whose instance type arguments are
compatible may store their instance type arguments at different field
offsets. Thus, we also split the classes being checked into groups that
share the same instance type arguments field offset, and load the
instance type arguments differently for each checked group.
This CL also removes now-unused code in the HierarchyInfo class.
TEST=vm/cc/TTS_{Generic,}SubtypeRangeCheck
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm_x64-try
Change-Id: I4c3aa23db2e75adbad9c15727b491669b2f3a189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209540
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>