From 3371367a399b87d637e52dba94eb252dcc3c6eb1 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 9 May 2016 22:58:01 -0700 Subject: JIT-EE interface changes to support CoreRT - Add flags and constants for reverse PInvoke transitions (https://github.com/dotnet/corert/issues/611) - Add new multi-dim array constructor that does not use varargs [tfs-changeset: 1603336] --- src/inc/corinfo.h | 25 ++++++++++++++++++------- src/inc/corjit.h | 1 + src/inc/jithelpers.h | 6 ++++++ src/vm/jithelpers.cpp | 19 +++++++++++++++++++ src/vm/jitinterface.cpp | 2 ++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h index 0eca760f38..d3c18d9898 100644 --- a/src/inc/corinfo.h +++ b/src/inc/corinfo.h @@ -231,11 +231,11 @@ TODO: Talk about initializing strutures before use #if COR_JIT_EE_VERSION > 460 // Update this one -SELECTANY const GUID JITEEVersionIdentifier = { /* 57813506-0058-41df-8b1b-e0b68c3a9da3 */ - 0x57813506, - 0x58, - 0x41df, - { 0x8b, 0x1b, 0xe0, 0xb6, 0x8c, 0x3a, 0x9d, 0xa3 } +SELECTANY const GUID JITEEVersionIdentifier = { /* 7fe8ebd7-2f61-41fc-8aac-2be394620be0 */ + 0x7fe8ebd7, + 0x2f61, + 0x41fc, + { 0x8a, 0xac, 0x2b, 0xe3, 0x94, 0x62, 0xb, 0xe0 } }; #else @@ -432,7 +432,10 @@ enum CorInfoHelpFunc CORINFO_HELP_NEWFAST, CORINFO_HELP_NEWSFAST, // allocator for small, non-finalizer, non-array object CORINFO_HELP_NEWSFAST_ALIGN8, // allocator for small, non-finalizer, non-array object, 8 byte aligned - CORINFO_HELP_NEW_MDARR, // multi-dim array helper (with or without lower bounds) + CORINFO_HELP_NEW_MDARR, // multi-dim array helper (with or without lower bounds - dimensions passed in as vararg) +#if COR_JIT_EE_VERSION > 460 + CORINFO_HELP_NEW_MDARR_NONVARARG,// multi-dim array helper (with or without lower bounds - dimensions passed in as unmanaged array) +#endif CORINFO_HELP_NEWARR_1_DIRECT, // helper for any one dimensional array creation CORINFO_HELP_NEWARR_1_OBJ, // optimized 1-D object arrays CORINFO_HELP_NEWARR_1_VC, // optimized 1-D value class arrays @@ -687,6 +690,9 @@ enum CorInfoHelpFunc CORINFO_HELP_JIT_PINVOKE_BEGIN, // Transition to preemptive mode before a P/Invoke, frame is the first argument CORINFO_HELP_JIT_PINVOKE_END, // Transition to cooperative mode after a P/Invoke, frame is the first argument + + CORINFO_HELP_JIT_REVERSE_PINVOKE_ENTER, // Transition to cooperative mode in reverse P/Invoke prolog, frame is the first argument + CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT, // Transition to preemptive mode in reverse P/Invoke epilog, frame is the first argument #endif CORINFO_HELP_COUNT, @@ -1773,7 +1779,7 @@ struct CORINFO_EE_INFO unsigned offsetOfReturnAddress; } inlinedCallFrameInfo; - + // Offsets into the Thread structure unsigned offsetOfThreadFrame; // offset of the current Frame unsigned offsetOfGCState; // offset of the preemptive/cooperative state of the Thread @@ -1789,6 +1795,11 @@ struct CORINFO_EE_INFO // Array offsets unsigned offsetOfObjArrayData; +#if COR_JIT_EE_VERSION > 460 + // Reverse PInvoke offsets + unsigned sizeOfReversePInvokeFrame; +#endif + CORINFO_OS osType; unsigned osMajor; unsigned osMinor; diff --git a/src/inc/corjit.h b/src/inc/corjit.h index 8fbbbdc0a3..8481d9acda 100644 --- a/src/inc/corjit.h +++ b/src/inc/corjit.h @@ -146,6 +146,7 @@ enum CorJitFlag2 CORJIT_FLG2_SAMPLING_JIT_BACKGROUND = 0x00000001, // JIT is being invoked as a result of stack sampling for hot methods in the background #if COR_JIT_EE_VERSION > 460 CORJIT_FLG2_USE_PINVOKE_HELPERS = 0x00000002, // The JIT should use the PINVOKE_{BEGIN,END} helpers instead of emitting inline transitions + CORJIT_FLG2_REVERSE_PINVOKE = 0x00000004, // The JIT should insert REVERSE_PINVOKE_{ENTER,EXIT} helpers into method prolog/epilog #endif }; diff --git a/src/inc/jithelpers.h b/src/inc/jithelpers.h index a6fd8f819c..371143d556 100644 --- a/src/inc/jithelpers.h +++ b/src/inc/jithelpers.h @@ -79,6 +79,9 @@ DYNAMICJITHELPER(CORINFO_HELP_NEWSFAST, JIT_New, CORINFO_HELP_SIG_REG_ONLY) DYNAMICJITHELPER(CORINFO_HELP_NEWSFAST_ALIGN8, JIT_New, CORINFO_HELP_SIG_REG_ONLY) JITHELPER(CORINFO_HELP_NEW_MDARR, JIT_NewMDArr,CORINFO_HELP_SIG_8_VA) +#if COR_JIT_EE_VERSION > 460 + JITHELPER(CORINFO_HELP_NEW_MDARR_NONVARARG, JIT_NewMDArrNonVarArg,CORINFO_HELP_SIG_4_STACK) +#endif JITHELPER(CORINFO_HELP_NEWARR_1_DIRECT, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) DYNAMICJITHELPER(CORINFO_HELP_NEWARR_1_OBJ, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) DYNAMICJITHELPER(CORINFO_HELP_NEWARR_1_VC, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) @@ -367,6 +370,9 @@ JITHELPER(CORINFO_HELP_JIT_PINVOKE_BEGIN, NULL, CORINFO_HELP_SIG_UNDEF) JITHELPER(CORINFO_HELP_JIT_PINVOKE_END, NULL, CORINFO_HELP_SIG_UNDEF) + JITHELPER(CORINFO_HELP_JIT_REVERSE_PINVOKE_ENTER, NULL, CORINFO_HELP_SIG_UNDEF) + JITHELPER(CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT, NULL, CORINFO_HELP_SIG_UNDEF) + #endif // COR_JIT_EE_VERSION #undef JITHELPER diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp index aa99f06ab9..340d61b838 100644 --- a/src/vm/jithelpers.cpp +++ b/src/vm/jithelpers.cpp @@ -3450,6 +3450,25 @@ HCIMPL2VA(Object*, JIT_NewMDArr, CORINFO_CLASS_HANDLE classHnd, unsigned dwNumAr } HCIMPLEND +/*************************************************************/ +HCIMPL3(Object*, JIT_NewMDArrNonVarArg, CORINFO_CLASS_HANDLE classHnd, unsigned dwNumArgs, INT32 * pArgList) +{ + FCALL_CONTRACT; + + OBJECTREF ret = 0; + HELPER_METHOD_FRAME_BEGIN_RET_1(ret); // Set up a frame + + TypeHandle typeHnd(classHnd); + typeHnd.CheckRestore(); + _ASSERTE(typeHnd.GetMethodTable()->IsArray()); + + ret = AllocateArrayEx(typeHnd, pArgList, dwNumArgs); + + HELPER_METHOD_FRAME_END(); + return OBJECTREFToObject(ret); +} +HCIMPLEND + /*************************************************************/ /* returns '&array[idx], after doing all the proper checks */ diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index bad7e3765b..470b26f680 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -9559,6 +9559,8 @@ void CEEInfo::getEEInfo(CORINFO_EE_INFO *pEEInfoOut) pEEInfoOut->offsetOfObjArrayData = (DWORD)PtrArray::GetDataOffset(); + pEEInfoOut->sizeOfReversePInvokeFrame = (DWORD)-1; + OSVERSIONINFO sVerInfo; sVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetOSVersion(&sVerInfo); -- cgit v1.2.3