diff options
author | Andy Ayers <andya@microsoft.com> | 2017-09-27 07:15:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 07:15:04 -0700 |
commit | ccc5e17738a4b2f652059f31e8146513163dbee7 (patch) | |
tree | eb7fe9d6b30b01d02a6b8bbe454333607899d507 /src/jit/ICorJitInfo_API_wrapper.hpp | |
parent | 9509fc86a50ad107ee4d601e917cf072f135aa5e (diff) | |
download | coreclr-ccc5e17738a4b2f652059f31e8146513163dbee7.tar.gz coreclr-ccc5e17738a4b2f652059f31e8146513163dbee7.tar.bz2 coreclr-ccc5e17738a4b2f652059f31e8146513163dbee7.zip |
JIT: devirtualization support for EqualityComparer<T>.Default (#14125)
Mark `EqualityComparer<T>.Default`'s getter as `[Intrinsic]` so
the jit knows there is something special about it. Extend the jit's
named intrinsic recognizer to recognize this method.
Add a new jit interface method to determine the exact type returned
by `EqualityComparer<T>.Default`, given `T`. Compute the return type by
mirroring the logic used in the actual implementation. Bail out when
`T` is not final as those cases won't simplify down much and lead to
code bloat.
Invoke this interface method when trying to devirtualize calls where
the 'this' object in the call comes from `EqualityComparer<T>.Default`.
The devirtualized methods can then be inlined. Since the specific comparer
`Equal` and `GetHashCode` methods look more complicated in IL than they
really are, mark them with AggressiveInlining attributes.
If devirtualization and inlining happen, it is quite likely that the value
of the comparer object itself is not used in the body of the comparer. This
value comes from a static field cache on the comparer helper.
When the comparer value is ignored, the jit removes the field access since it
is non-faulting. It also removes the the class init helper that is there to
ensure that the (no-longer accessed) field is properly initialized. This helper
has relatively high overhead even in the fast case where the class has been
initialized aready.
Add a perf test.
Closes #6688.
Diffstat (limited to 'src/jit/ICorJitInfo_API_wrapper.hpp')
-rw-r--r-- | src/jit/ICorJitInfo_API_wrapper.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/jit/ICorJitInfo_API_wrapper.hpp b/src/jit/ICorJitInfo_API_wrapper.hpp index 78177e16d7..69311a5917 100644 --- a/src/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/jit/ICorJitInfo_API_wrapper.hpp @@ -1620,6 +1620,16 @@ CORINFO_METHOD_HANDLE WrapICorJitInfo::resolveVirtualMethod( return result; } +CORINFO_CLASS_HANDLE WrapICorJitInfo::getDefaultEqualityComparerClass( + CORINFO_CLASS_HANDLE elemType) +{ + API_ENTER(getDefaultEqualityComparerClass); + CORINFO_CLASS_HANDLE result = wrapHnd->getDefaultEqualityComparerClass(elemType); + API_LEAVE(getDefaultEqualityComparerClass); + return result; +} + + void WrapICorJitInfo::expandRawHandleIntrinsic( CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult) |