From abb4eef2a7b6f8a4fd3a9f0d899d0ce09b50dbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 13 Aug 2017 15:22:05 -0700 Subject: [PATCH] Update RyuJIT (#4314) Picks up dotnet/coreclr#13016. --- dependencies.props | 2 +- src/JitInterface/src/CorInfoBase.cs | 6 +++--- src/JitInterface/src/CorInfoImpl.cs | 4 +++- src/JitInterface/src/CorInfoTypes.cs | 5 +++++ .../src/ThunkGenerator/ThunkInput.txt | 2 +- src/JitInterface/src/ThunkGenerator/corinfo.h | 20 +++++++++++++------ src/JitInterface/src/ThunkGenerator/corjit.h | 4 +++- src/Native/jitinterface/jitinterface.h | 6 +++--- src/Native/jitinterface/jitwrapper.cpp | 10 +++++----- 9 files changed, 38 insertions(+), 21 deletions(-) diff --git a/dependencies.props b/dependencies.props index 0e2c3f08239..604ad7059fc 100644 --- a/dependencies.props +++ b/dependencies.props @@ -1,6 +1,6 @@ - 2.1.0-preview2-25509-03 + 2.1.0-preview2-25613-02 1.0.19-prerelease-00001 4.5.0-preview2-25510-01 2.0.0-beta-25021-03 diff --git a/src/JitInterface/src/CorInfoBase.cs b/src/JitInterface/src/CorInfoBase.cs index 5e356a488fb..cbd3a6a5bb6 100644 --- a/src/JitInterface/src/CorInfoBase.cs +++ b/src/JitInterface/src/CorInfoBase.cs @@ -34,7 +34,7 @@ unsafe partial class CorInfoImpl [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] delegate CORINFO_MODULE_STRUCT_* __getMethodModule(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method); [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] - delegate void __getMethodVTableOffset(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, ref uint offsetOfIndirection, ref uint offsetAfterIndirection); + delegate void __getMethodVTableOffset(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, ref uint offsetOfIndirection, ref uint offsetAfterIndirection, [MarshalAs(UnmanagedType.U1)] ref bool isRelative); [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] delegate CORINFO_METHOD_STRUCT_* __resolveVirtualMethod(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* virtualMethod, CORINFO_CLASS_STRUCT_* implementingClass, CORINFO_CONTEXT_STRUCT* ownerType); [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] @@ -491,12 +491,12 @@ static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_ST } } - static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, ref uint offsetOfIndirection, ref uint offsetAfterIndirection) + static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, ref uint offsetOfIndirection, ref uint offsetAfterIndirection, [MarshalAs(UnmanagedType.U1)] ref bool isRelative) { var _this = GetThis(thisHandle); try { - _this.getMethodVTableOffset(method, ref offsetOfIndirection, ref offsetAfterIndirection); + _this.getMethodVTableOffset(method, ref offsetOfIndirection, ref offsetAfterIndirection, ref isRelative); } catch (Exception ex) { diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs index 70585ca1742..8b78a3aaf88 100644 --- a/src/JitInterface/src/CorInfoImpl.cs +++ b/src/JitInterface/src/CorInfoImpl.cs @@ -803,11 +803,12 @@ private void getEHinfo(CORINFO_METHOD_STRUCT_* ftn, uint EHnumber, ref CORINFO_E private CORINFO_MODULE_STRUCT_* getMethodModule(CORINFO_METHOD_STRUCT_* method) { throw new NotImplementedException("getMethodModule"); } - private void getMethodVTableOffset(CORINFO_METHOD_STRUCT_* method, ref uint offsetOfIndirection, ref uint offsetAfterIndirection) + private void getMethodVTableOffset(CORINFO_METHOD_STRUCT_* method, ref uint offsetOfIndirection, ref uint offsetAfterIndirection, ref bool isRelative) { MethodDesc methodDesc = HandleToObject(method); int pointerSize = _compilation.TypeSystemContext.Target.PointerSize; offsetOfIndirection = (uint)CORINFO_VIRTUALCALL_NO_CHUNK.Value; + isRelative = false; // Normalize to the slot defining method. We don't have slot information for the overrides. methodDesc = MetadataVirtualMethodAlgorithm.FindSlotDefiningMethodForVirtualMethod(methodDesc); @@ -912,6 +913,7 @@ private void ComputeLookup(CORINFO_CONTEXT_STRUCT* pContextMethod, object entity lookup.runtimeLookup.testForFixup = false; // TODO: this will be needed in true multifile lookup.runtimeLookup.testForNull = false; lookup.runtimeLookup.indirectFirstOffset = false; + lookup.runtimeLookup.indirectSecondOffset = false; lookup.lookupKind.runtimeLookupFlags = 0; lookup.lookupKind.runtimeLookupArgs = null; } diff --git a/src/JitInterface/src/CorInfoTypes.cs b/src/JitInterface/src/CorInfoTypes.cs index 1d469336dde..821d4cc0ac9 100644 --- a/src/JitInterface/src/CorInfoTypes.cs +++ b/src/JitInterface/src/CorInfoTypes.cs @@ -283,6 +283,10 @@ public unsafe struct CORINFO_RUNTIME_LOOKUP public byte _indirectFirstOffset; public bool indirectFirstOffset { get { return _indirectFirstOffset != 0; } set { _indirectFirstOffset = value ? (byte)1 : (byte)0; } } + + public byte _indirectSecondOffset; + public bool indirectSecondOffset { get { return _indirectSecondOffset != 0; } set { _indirectSecondOffset = value ? (byte)1 : (byte)0; } } + } // Result of calling embedGenericHandle @@ -1478,6 +1482,7 @@ public enum CorJitFlag : uint CORJIT_FLAG_TIER0 = 39, // This is the initial tier for tiered compilation which should generate code as quickly as possible CORJIT_FLAG_TIER1 = 40, // This is the final tier (for now) for tiered compilation which should generate high quality code CORJIT_FLAG_RELATIVE_CODE_RELOCS = 41, // JIT should generate PC-relative address computations instead of EE relocation records + CORJIT_FLAG_NO_INLINING = 42, // JIT should not inline any called method into this method } public struct CORJIT_FLAGS diff --git a/src/JitInterface/src/ThunkGenerator/ThunkInput.txt b/src/JitInterface/src/ThunkGenerator/ThunkInput.txt index 25aaa420d02..3f39a5dd60c 100644 --- a/src/JitInterface/src/ThunkGenerator/ThunkInput.txt +++ b/src/JitInterface/src/ThunkGenerator/ThunkInput.txt @@ -169,7 +169,7 @@ FUNCTIONS void getEHinfo( CORINFO_METHOD_HANDLE ftn, unsigned EHnumber, CORINFO_EH_CLAUSE* clause ); CORINFO_CLASS_HANDLE getMethodClass( CORINFO_METHOD_HANDLE method ); CORINFO_MODULE_HANDLE getMethodModule( CORINFO_METHOD_HANDLE method ); - void getMethodVTableOffset( CORINFO_METHOD_HANDLE method, unsigned* offsetOfIndirection, unsigned* offsetAfterIndirection ); + void getMethodVTableOffset( CORINFO_METHOD_HANDLE method, unsigned* offsetOfIndirection, unsigned* offsetAfterIndirection, bool* isRelative); CORINFO_METHOD_HANDLE resolveVirtualMethod( CORINFO_METHOD_HANDLE virtualMethod, CORINFO_CLASS_HANDLE implementingClass, CORINFO_CONTEXT_HANDLE ownerType); void expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult); CorInfoIntrinsics getIntrinsicID( CORINFO_METHOD_HANDLE method , bool * pMustExpand); diff --git a/src/JitInterface/src/ThunkGenerator/corinfo.h b/src/JitInterface/src/ThunkGenerator/corinfo.h index 4af22e53f4b..084b9841bb6 100644 --- a/src/JitInterface/src/ThunkGenerator/corinfo.h +++ b/src/JitInterface/src/ThunkGenerator/corinfo.h @@ -213,11 +213,11 @@ TODO: Talk about initializing strutures before use #define SELECTANY extern __declspec(selectany) #endif -SELECTANY const GUID JITEEVersionIdentifier = { /* 28eb875f-b6a9-4a04-9ba7-69ba59deed46 */ - 0x28eb875f, - 0xb6a9, - 0x4a04, - { 0x9b, 0xa7, 0x69, 0xba, 0x59, 0xde, 0xed, 0x46 } +SELECTANY const GUID JITEEVersionIdentifier = { /* 5a1cfc89-a84a-4642-b01d-ead88e60c1ee */ + 0x5a1cfc89, + 0xa84a, + 0x4642, + { 0xb0, 0x1d, 0xea, 0xd8, 0x8e, 0x60, 0xc1, 0xee } }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1332,6 +1332,13 @@ struct CORINFO_RUNTIME_LOOKUP // 1 means that value stored at first offset (offsets[0]) from pointer is offset1, and the next pointer is // stored at pointer+offsets[0]+offset1. bool indirectFirstOffset; + + // If set, second offset is indirect. + // 0 means that value stored at second offset (offsets[1]) from pointer is next pointer, to which the next offset + // (offsets[2]) is added and so on. + // 1 means that value stored at second offset (offsets[1]) from pointer is offset2, and the next pointer is + // stored at pointer+offsets[1]+offset2. + bool indirectSecondOffset; } ; // Result of calling embedGenericHandle @@ -2062,7 +2069,8 @@ class ICorStaticInfo virtual void getMethodVTableOffset ( CORINFO_METHOD_HANDLE method, /* IN */ unsigned* offsetOfIndirection, /* OUT */ - unsigned* offsetAfterIndirection /* OUT */ + unsigned* offsetAfterIndirection, /* OUT */ + bool* isRelative /* OUT */ ) = 0; // Find the virtual method in implementingClass that overrides virtualMethod, diff --git a/src/JitInterface/src/ThunkGenerator/corjit.h b/src/JitInterface/src/ThunkGenerator/corjit.h index e6e8257afee..39eafe2a895 100644 --- a/src/JitInterface/src/ThunkGenerator/corjit.h +++ b/src/JitInterface/src/ThunkGenerator/corjit.h @@ -152,8 +152,10 @@ class CORJIT_FLAGS #if defined(_TARGET_ARM_) CORJIT_FLAG_RELATIVE_CODE_RELOCS = 41, // JIT should generate PC-relative address computations instead of EE relocation records #else // !defined(_TARGET_ARM_) - CORJIT_FLAG_UNUSED11 = 41 + CORJIT_FLAG_UNUSED11 = 41, #endif // !defined(_TARGET_ARM_) + + CORJIT_FLAG_NO_INLINING = 42 // JIT should not inline any called method into this method }; CORJIT_FLAGS() diff --git a/src/Native/jitinterface/jitinterface.h b/src/Native/jitinterface/jitinterface.h index c655eb1e56a..876be7f9b82 100644 --- a/src/Native/jitinterface/jitinterface.h +++ b/src/Native/jitinterface/jitinterface.h @@ -21,7 +21,7 @@ struct JitInterfaceCallbacks void (__stdcall * getEHinfo)(void * thisHandle, CorInfoException** ppException, void* ftn, unsigned EHnumber, void* clause); void* (__stdcall * getMethodClass)(void * thisHandle, CorInfoException** ppException, void* method); void* (__stdcall * getMethodModule)(void * thisHandle, CorInfoException** ppException, void* method); - void (__stdcall * getMethodVTableOffset)(void * thisHandle, CorInfoException** ppException, void* method, unsigned* offsetOfIndirection, unsigned* offsetAfterIndirection); + void (__stdcall * getMethodVTableOffset)(void * thisHandle, CorInfoException** ppException, void* method, unsigned* offsetOfIndirection, unsigned* offsetAfterIndirection, bool* isRelative); void* (__stdcall * resolveVirtualMethod)(void * thisHandle, CorInfoException** ppException, void* virtualMethod, void* implementingClass, void* ownerType); void (__stdcall * expandRawHandleIntrinsic)(void * thisHandle, CorInfoException** ppException, void* pResolvedToken, void* pResult); int (__stdcall * getIntrinsicID)(void * thisHandle, CorInfoException** ppException, void* method, bool* pMustExpand); @@ -283,10 +283,10 @@ class JitInterfaceWrapper return _ret; } - virtual void getMethodVTableOffset(void* method, unsigned* offsetOfIndirection, unsigned* offsetAfterIndirection) + virtual void getMethodVTableOffset(void* method, unsigned* offsetOfIndirection, unsigned* offsetAfterIndirection, bool* isRelative) { CorInfoException* pException = nullptr; - _callbacks->getMethodVTableOffset(_thisHandle, &pException, method, offsetOfIndirection, offsetAfterIndirection); + _callbacks->getMethodVTableOffset(_thisHandle, &pException, method, offsetOfIndirection, offsetAfterIndirection, isRelative); if (pException != nullptr) throw pException; } diff --git a/src/Native/jitinterface/jitwrapper.cpp b/src/Native/jitinterface/jitwrapper.cpp index c5ab925fa4a..ec926d46027 100644 --- a/src/Native/jitinterface/jitwrapper.cpp +++ b/src/Native/jitinterface/jitwrapper.cpp @@ -27,11 +27,11 @@ class CORJIT_FLAGS unsigned __int64 corJitFlags; }; -static const GUID JITEEVersionIdentifier = { /* 28eb875f-b6a9-4a04-9ba7-69ba59deed46 */ - 0x28eb875f, - 0xb6a9, - 0x4a04, - { 0x9b, 0xa7, 0x69, 0xba, 0x59, 0xde, 0xed, 0x46 } +static const GUID JITEEVersionIdentifier = { /* 5a1cfc89-a84a-4642-b01d-ead88e60c1ee */ + 0x5a1cfc89, + 0xa84a, + 0x4642, + { 0xb0, 0x1d, 0xea, 0xd8, 0x8e, 0x60, 0xc1, 0xee } }; class Jit