JIT-EE interface changes to support CoreRT
authorJan Kotas <jkotas@microsoft.com>
Tue, 10 May 2016 05:58:01 +0000 (22:58 -0700)
committerJan Kotas <jkotas@microsoft.com>
Tue, 10 May 2016 05:58:01 +0000 (22:58 -0700)
- 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]

Commit migrated from https://github.com/dotnet/coreclr/commit/3371367a399b87d637e52dba94eb252dcc3c6eb1

src/coreclr/src/inc/corinfo.h
src/coreclr/src/inc/corjit.h
src/coreclr/src/inc/jithelpers.h
src/coreclr/src/vm/jithelpers.cpp
src/coreclr/src/vm/jitinterface.cpp

index 0eca760..d3c18d9 100644 (file)
@@ -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;
index 8fbbbdc..8481d9a 100644 (file)
@@ -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
 };
 
index a6fd8f8..371143d 100644 (file)
@@ -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)
     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
index aa99f06..340d61b 100644 (file)
@@ -3451,6 +3451,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 */
 
 #include <optsmallperfcritical.h>
index bad7e37..470b26f 100644 (file)
@@ -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);