1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
10 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
11 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
14 // ONLY FUNCTIONS common to all variants of the JIT (EXE, DLL) should go here)
15 // otherwise they belong in the corresponding directory.
23 #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD)
26 #pragma warning(disable : 4701) // difficult to get rid of C4701 with 'sig' below
28 /*****************************************************************************/
30 /*****************************************************************************
32 * Filter wrapper to handle exception filtering.
33 * On Unix compilers don't support SEH.
36 struct FilterSuperPMIExceptionsParam_eeinterface
39 Compiler::Info* pJitInfo;
43 CORINFO_ARG_LIST_HANDLE argLst;
44 CORINFO_METHOD_HANDLE hnd;
45 const char* returnType;
46 EXCEPTION_POINTERS exceptionPointers;
49 static LONG FilterSuperPMIExceptions_eeinterface(PEXCEPTION_POINTERS pExceptionPointers, LPVOID lpvParam)
51 FilterSuperPMIExceptionsParam_eeinterface* pSPMIEParam = (FilterSuperPMIExceptionsParam_eeinterface*)lpvParam;
52 pSPMIEParam->exceptionPointers = *pExceptionPointers;
54 if (pSPMIEParam->pThis->IsSuperPMIException(pExceptionPointers->ExceptionRecord->ExceptionCode))
56 return EXCEPTION_EXECUTE_HANDLER;
59 return EXCEPTION_CONTINUE_SEARCH;
62 const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd)
64 const char* className;
65 const char* methodName = eeGetMethodName(hnd, &className);
66 if ((eeGetHelperNum(hnd) != CORINFO_HELP_UNDEF) || eeIsNativeMethod(hnd))
71 FilterSuperPMIExceptionsParam_eeinterface param;
72 param.returnType = nullptr;
74 param.hasThis = false;
77 param.pJitInfo = &info;
82 /* Generating the full signature is a two-pass process. First we have to walk
83 the components in order to assess the total size, then we allocate the buffer
84 and copy the elements into it.
87 /* Right now there is a race-condition in the EE, className can be nullptr */
89 /* initialize length with length of className and '.' */
93 length = strlen(className) + 1;
97 assert(strlen("<NULL>.") == 7);
101 /* add length of methodName and opening bracket */
102 length += strlen(methodName) + 1;
104 /* figure out the signature */
106 PAL_TRY(FilterSuperPMIExceptionsParam_eeinterface*, pParam, ¶m)
109 pParam->pThis->eeGetMethodSig(pParam->hnd, &pParam->sig);
110 pParam->argLst = pParam->sig.args;
112 for (i = 0; i < pParam->sig.numArgs; i++)
114 var_types type = pParam->pThis->eeGetArgType(pParam->argLst, &pParam->sig);
116 pParam->siglength += strlen(varTypeName(type));
117 pParam->argLst = pParam->pJitInfo->compCompHnd->getArgNext(pParam->argLst);
120 /* add ',' if there is more than one argument */
122 if (pParam->sig.numArgs > 1)
124 pParam->siglength += (pParam->sig.numArgs - 1);
127 if (JITtype2varType(pParam->sig.retType) != TYP_VOID)
129 pParam->returnType = varTypeName(JITtype2varType(pParam->sig.retType));
130 pParam->siglength += strlen(pParam->returnType) + 1; // don't forget the delimiter ':'
133 // Does it have a 'this' pointer? Don't count explicit this, which has the this pointer type as the first
134 // element of the arg type list
135 if (pParam->sig.hasThis() && !pParam->sig.hasExplicitThis())
137 assert(strlen(":this") == 5);
138 pParam->siglength += 5;
139 pParam->hasThis = true;
142 PAL_EXCEPT_FILTER(FilterSuperPMIExceptions_eeinterface)
148 /* add closing bracket and null terminator */
150 length += param.siglength + 2;
152 char* retName = (char*)compGetMem(length, CMK_DebugOnly);
154 /* Now generate the full signature string in the allocated buffer */
158 strcpy_s(retName, length, className);
159 strcat_s(retName, length, ":");
163 strcpy_s(retName, length, "<NULL>.");
166 strcat_s(retName, length, methodName);
168 // append the signature
169 strcat_s(retName, length, "(");
171 if (param.siglength > 0)
173 param.argLst = param.sig.args;
175 for (i = 0; i < param.sig.numArgs; i++)
177 var_types type = eeGetArgType(param.argLst, ¶m.sig);
178 strcat_s(retName, length, varTypeName(type));
180 param.argLst = info.compCompHnd->getArgNext(param.argLst);
181 if (i + 1 < param.sig.numArgs)
183 strcat_s(retName, length, ",");
188 strcat_s(retName, length, ")");
190 if (param.returnType != nullptr)
192 strcat_s(retName, length, ":");
193 strcat_s(retName, length, param.returnType);
198 strcat_s(retName, length, ":this");
201 assert(strlen(retName) == (length - 1));
208 #endif // defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD)
210 /*****************************************************************************/