Enable inlining of shared generics code within same type (#38229)
authorJan Kotas <jkotas@microsoft.com>
Sat, 27 Jun 2020 13:36:39 +0000 (06:36 -0700)
committerGitHub <noreply@github.com>
Sat, 27 Jun 2020 13:36:39 +0000 (06:36 -0700)
commit31699de92ba4dcb6b97625f712dbfc0ca74f1c35
treef2f506d306b212584c80acd57f769f2ad4f8f6aa
parent5e153a2ca1024b4a39c06dfb52fa19d9bfbe870f
Enable inlining of shared generics code within same type (#38229)

This change allows inlining of generic dictionary lookups when the caller and callee are the same exact type and instantiation.

Example:

```
class G<T>
{
    static bool M1() => typeof(T);

    object M2() => new T[1];

    bool M3() => Unsafe.SizeOf<T>();

    static string M()
    {
         // Assume that T is string
         // All M1, M2, M3 are inlined after this change, but were not inlined before this change
         M1(); M2(); M3();

         // Still not inlined - different instantiation, not the same exact type
         G<List<T>>.M1();

         // Still not inlined - different type.
         OtherG<T>.M();
    }
}
```
32 files changed:
src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
src/coreclr/src/inc/corinfo.h
src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp
src/coreclr/src/jit/compiler.cpp
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/ee_il_dll.hpp
src/coreclr/src/jit/flowgraph.cpp
src/coreclr/src/jit/gentree.cpp
src/coreclr/src/jit/importer.cpp
src/coreclr/src/jit/inline.def
src/coreclr/src/jit/morph.cpp
src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs
src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/src/tools/Common/JitInterface/CorInfoTypes.cs
src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt
src/coreclr/src/tools/Common/Sorting/MergeSortCore.cs
src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/GenericLookupSignature.cs
src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
src/coreclr/src/tools/aot/jitinterface/jitinterface.h
src/coreclr/src/tools/aot/jitinterface/jitwrapper.cpp
src/coreclr/src/vm/jitinterface.cpp
src/coreclr/src/vm/jitinterface.h
src/coreclr/src/zap/zapimport.cpp
src/coreclr/src/zap/zapimport.h
src/coreclr/src/zap/zapinfo.cpp
src/coreclr/src/zap/zapinfo.h