From 5c256884f6ef421b957591b904230ceaaf60694e Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 16:42:25 +0200 Subject: [PATCH 01/50] Clean up JIT<->EE "get class name" methods * Switch JIT to use appendClassName instead of getClassNameFromMetadata. This way it supports enclosing classes too when printing class names. * Switch appendClassName to UTF8 * Switch SIMD type recognition to use getTypeInstantiationArgument and getClassNameFromMetadata, to use of appendClassName (and depending on how it formats instantiations) * Add TypeString::FormatNoInst to avoid formatting instantiations, and use this for appendClassName --- src/coreclr/inc/corinfo.h | 14 +- src/coreclr/inc/icorjitinfoimpl_generated.h | 7 +- src/coreclr/jit/ICorJitInfo_API_wrapper.hpp | 9 +- src/coreclr/jit/compiler.h | 19 +- src/coreclr/jit/ee_il_dll.cpp | 27 +-- src/coreclr/jit/eeinterface.cpp | 132 +++++++---- src/coreclr/jit/gentree.cpp | 6 +- src/coreclr/jit/jitconfig.cpp | 1 - src/coreclr/jit/layout.cpp | 2 +- src/coreclr/jit/layout.h | 8 +- src/coreclr/jit/simd.cpp | 215 +++++++----------- .../tools/Common/JitInterface/CorInfoBase.cs | 7 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 20 +- .../ThunkGenerator/ThunkInput.txt | 3 +- .../tools/aot/jitinterface/jitinterface.h | 11 +- .../tools/superpmi/superpmi-shared/agnostic.h | 3 - .../superpmi-shared/methodcontext.cpp | 40 ++-- .../superpmi/superpmi-shared/methodcontext.h | 12 +- .../superpmi-shim-collector/icorjitinfo.cpp | 22 +- .../superpmi-shim-counter/icorjitinfo.cpp | 9 +- .../superpmi-shim-simple/icorjitinfo.cpp | 9 +- .../tools/superpmi/superpmi/icorjitinfo.cpp | 15 +- src/coreclr/vm/jitinterface.cpp | 21 +- src/coreclr/vm/typestring.cpp | 2 +- src/coreclr/vm/typestring.h | 1 + 25 files changed, 275 insertions(+), 340 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 2be3d438c9327..735962cdac111 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2297,13 +2297,11 @@ class ICorStaticInfo ) = 0; // Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer. + // Includes enclosing classes and namespaces. // // Arguments: // ppBuf - Pointer to buffer pointer. See below for details. // pnBufLen - Pointer to buffer length. Must not be nullptr. See below for details. - // fNamespace - If true, include the namespace/enclosing classes. - // fFullInst - If true (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters. - // fAssembly - If true, suffix with a comma and the full assembly qualification. // // Returns the length of the representation, as a count of characters (but not including a terminating null character). // Note that this will always be the actual number of characters required by the representation, even if the string @@ -2324,13 +2322,9 @@ class ICorStaticInfo // character that was added to the end of the name. // virtual int appendClassName( - _Outptr_opt_result_buffer_(*pnBufLen) char16_t** ppBuf, /* IN OUT */ - int* pnBufLen, /* IN OUT */ - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly - ) = 0; + _Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, /* IN OUT */ + int* pnBufLen, /* IN OUT */ + CORINFO_CLASS_HANDLE cls) = 0; // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & CORINFO_FLG_VALUECLASS, except faster. virtual bool isValueClass(CORINFO_CLASS_HANDLE cls) = 0; diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index 3a5a164e9aa71..e45d602edc122 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -190,12 +190,9 @@ CORINFO_CLASS_HANDLE getTypeInstantiationArgument( unsigned index) override; int appendClassName( - char16_t** ppBuf, + char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) override; + CORINFO_CLASS_HANDLE cls) override; bool isValueClass( CORINFO_CLASS_HANDLE cls) override; diff --git a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp index 96139cc6cd4ef..50ac90d19f8ae 100644 --- a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp @@ -413,15 +413,12 @@ CORINFO_CLASS_HANDLE WrapICorJitInfo::getTypeInstantiationArgument( } int WrapICorJitInfo::appendClassName( - char16_t** ppBuf, + char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) + CORINFO_CLASS_HANDLE cls) { API_ENTER(appendClassName); - int temp = wrapHnd->appendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly); + int temp = wrapHnd->appendClassName(ppBuf, pnBufLen, cls); API_LEAVE(appendClassName); return temp; } diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 6850cd9d2b170..d1e202223b5e3 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7540,17 +7540,14 @@ class Compiler void eePrintJitType(class StringPrinter* printer, var_types jitType); void eePrintType(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, - bool includeNamespaces, bool includeInstantiation); void eePrintTypeOrJitAlias(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, - bool includeNamespaces, bool includeInstantiation); void eePrintMethod(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methodHnd, CORINFO_SIG_INFO* sig, - bool includeNamespaces, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, @@ -7802,7 +7799,7 @@ class Compiler #if defined(DEBUG) const WCHAR* eeGetCPString(size_t stringHandle); unsigned eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd); - const char16_t* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd); + const char* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd); #endif const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd); @@ -8492,13 +8489,18 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX return CORINFO_TYPE_UNDEF; } + bool isNumericsNamespace(const char* ns) + { + return strcmp(ns, "System.Numerics") == 0; + } + bool isSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { if (isIntrinsicType(clsHnd)) { const char* namespaceName = nullptr; (void)getClassNameFromMetadata(clsHnd, &namespaceName); - return strcmp(namespaceName, "System.Numerics") == 0; + return isNumericsNamespace(namespaceName); } return false; } @@ -11288,6 +11290,7 @@ class StringPrinter size_t m_bufferMax; size_t m_bufferIndex = 0; + void Grow(size_t newSize); public: StringPrinter(CompAllocator alloc, char* buffer = nullptr, size_t bufferMax = 0) : m_alloc(alloc), m_buffer(buffer), m_bufferMax(bufferMax) @@ -11318,6 +11321,12 @@ class StringPrinter m_buffer[m_bufferIndex] = '\0'; } + // Allocate a chunk of 'size' bytes at the current location to be printed. + // Will increment the index by the size specified. Assumes the user will + // copy 'size' characters directly into the buffer returned. + // returned[size] will be null terminated. + char* AllocToPrint(size_t size); + void Printf(const char* format, ...); }; diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index fedbae80a624c..7ffd7dedda62f 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1417,7 +1417,7 @@ struct FilterSuperPMIExceptionsParam_ee_il CORINFO_CLASS_HANDLE clazz; const char** classNamePtr; const char* fieldOrMethodOrClassNamePtr; - char16_t* classNameWidePtr; + char* classNameWidePtr; unsigned classSize; EXCEPTION_POINTERS exceptionPointers; }; @@ -1515,7 +1515,7 @@ const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE field, const char** cl const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd) { StringPrinter printer(getAllocator(CMK_DebugOnly)); - if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true, true); })) + if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) { printer.Truncate(0); printer.Printf("hackishClassName"); @@ -1569,9 +1569,8 @@ unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) // Return value: // string class name. Note: unlike eeGetClassName/getClassName, this string is // allocated from the JIT heap, so care should possibly be taken to avoid leaking it. -// It returns a char16_t string, since that's what appendClassName returns. // -const char16_t* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) +const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) { FilterSuperPMIExceptionsParam_ee_il param; @@ -1582,23 +1581,17 @@ const char16_t* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) bool success = eeRunWithSPMIErrorTrap( [](FilterSuperPMIExceptionsParam_ee_il* pParam) { int len = 0; - constexpr bool fNamespace = true; - constexpr bool fFullInst = false; - constexpr bool fAssembly = false; - // Warning: crossgen2 doesn't fully implement the `appendClassName` API. // We need to pass size zero, get back the actual buffer size required, allocate that space, // and call the API again to get the full string. - int cchStrLen = pParam->pJitInfo->compCompHnd->appendClassName(nullptr, &len, pParam->clazz, fNamespace, - fFullInst, fAssembly); + int cchStrLen = pParam->pJitInfo->compCompHnd->appendClassName(nullptr, &len, pParam->clazz); size_t cchBufLen = (size_t)cchStrLen + /* null terminator */ 1; - pParam->classNameWidePtr = pParam->pThis->getAllocator(CMK_DebugOnly).allocate(cchBufLen); - char16_t* pbuf = pParam->classNameWidePtr; + pParam->classNameWidePtr = pParam->pThis->getAllocator(CMK_DebugOnly).allocate(cchBufLen); + char* pbuf = pParam->classNameWidePtr; len = (int)cchBufLen; - int cchResultStrLen = pParam->pJitInfo->compCompHnd->appendClassName(&pbuf, &len, pParam->clazz, fNamespace, - fFullInst, fAssembly); + int cchResultStrLen = pParam->pJitInfo->compCompHnd->appendClassName(&pbuf, &len, pParam->clazz); noway_assert(cchStrLen == cchResultStrLen); noway_assert(pParam->classNameWidePtr[cchResultStrLen] == 0); }, @@ -1606,10 +1599,10 @@ const char16_t* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) if (!success) { - const char16_t substituteClassName[] = u"hackishClassName"; + const char substituteClassName[] = "hackishClassName"; size_t cchLen = ArrLen(substituteClassName); - param.classNameWidePtr = getAllocator(CMK_DebugOnly).allocate(cchLen); - memcpy(param.classNameWidePtr, substituteClassName, cchLen * sizeof(char16_t)); + param.classNameWidePtr = getAllocator(CMK_DebugOnly).allocate(cchLen); + memcpy(param.classNameWidePtr, substituteClassName, cchLen * sizeof(char)); } return param.classNameWidePtr; diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 84d3c64eb52cb..17129730197da 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -19,6 +19,55 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #pragma hdrstop #endif +//------------------------------------------------------------------------ +// StringPrinter::Grow: +// Grow the internal buffer to a new specified size. +// +// Arguments: +// newSize - the new size. +// +void StringPrinter::Grow(size_t newSize) +{ + assert(newSize > m_bufferMax); + char* newBuffer = m_alloc.allocate(newSize); + memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too + + m_buffer = newBuffer; + m_bufferMax = newSize; +} + +//------------------------------------------------------------------------ +// StringPrinter::AllocToPrint: +// Allocate a chunk of characters to be filled in by the caller. +// +// Arguments: +// size - the number of characters. +// +// Returns: +// Pointer to the location to start filling in the characters. +// +// Remarks: +// This function will ensure that returned[size] == '\0'. It is expected that +// the caller fills in the characters returned[0..size - 1]. +// +char* StringPrinter::AllocToPrint(size_t size) +{ + size_t newMax = m_bufferMax; + while (newMax - m_bufferIndex <= size) // <= to fit null terminator + { + newMax *= 2; + } + + if (newMax != m_bufferMax) + { + Grow(newMax); + } + + m_bufferIndex += size; + m_buffer[m_bufferIndex] = '\0'; + return m_buffer + (m_bufferIndex - size); +} + //------------------------------------------------------------------------ // StringPrinter::Printf: // Print a formatted string. @@ -44,12 +93,7 @@ void StringPrinter::Printf(const char* format, ...) if (printed < 0) { // buffer too small - size_t newSize = m_bufferMax * 2; - char* newBuffer = m_alloc.allocate(newSize); - memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too - - m_buffer = newBuffer; - m_bufferMax = newSize; + Grow(m_bufferMax * 2); } else { @@ -88,46 +132,43 @@ void Compiler::eePrintJitType(StringPrinter* printer, var_types jitType) // void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, - bool includeNamespace, bool includeInstantiation) { - const char* namespaceName; - const char* className = info.compCompHnd->getClassNameFromMetadata(clsHnd, &namespaceName); - if (className == nullptr) + unsigned arrayRank = info.compCompHnd->getArrayRank(clsHnd); + if (arrayRank > 0) { - unsigned arrayRank = info.compCompHnd->getArrayRank(clsHnd); - if (arrayRank > 0) + CORINFO_CLASS_HANDLE childClsHnd; + CorInfoType childType = info.compCompHnd->getChildType(clsHnd, &childClsHnd); + if ((childType == CORINFO_TYPE_CLASS) || (childType == CORINFO_TYPE_VALUECLASS)) { - CORINFO_CLASS_HANDLE childClsHnd; - CorInfoType childType = info.compCompHnd->getChildType(clsHnd, &childClsHnd); - if ((childType == CORINFO_TYPE_CLASS) || (childType == CORINFO_TYPE_VALUECLASS)) - { - eePrintType(printer, childClsHnd, includeNamespace, includeInstantiation); - } - else - { - eePrintJitType(printer, JitType2PreciseVarType(childType)); - } - - printer->Printf("["); - for (unsigned i = 1; i < arrayRank; i++) - { - printer->Printf(","); - } - printer->Printf("]"); - return; + eePrintType(printer, childClsHnd, includeInstantiation); + } + else + { + eePrintJitType(printer, JitType2PreciseVarType(childType)); } - namespaceName = nullptr; - className = ""; + printer->Printf("["); + for (unsigned i = 1; i < arrayRank; i++) + { + printer->Printf(","); + } + printer->Printf("]"); + return; } - if (includeNamespace && (namespaceName != nullptr) && (namespaceName[0] != '\0')) + int size = 0; + int actualLen = info.compCompHnd->appendClassName(nullptr, &size, clsHnd); + if (actualLen <= 0) { - printer->Printf("%s.", namespaceName); + printer->Printf(""); + } + else + { + char* name = printer->AllocToPrint(static_cast(actualLen)); + actualLen++; // null-terminator + info.compCompHnd->appendClassName(&name, &actualLen, clsHnd); } - - printer->Printf("%s", className); if (!includeInstantiation) { @@ -146,7 +187,7 @@ void Compiler::eePrintType(StringPrinter* printer, printer->Printf("%c", pref); pref = ','; - eePrintTypeOrJitAlias(printer, typeArg, includeNamespace, true); + eePrintTypeOrJitAlias(printer, typeArg, true); } if (pref != '[') @@ -163,18 +204,16 @@ void Compiler::eePrintType(StringPrinter* printer, // Arguments: // printer - the printer // clsHnd - Handle for the class -// includeNamespace - Whether to print namespaces before type names // includeInstantiation - Whether to print the instantiation of the class // void Compiler::eePrintTypeOrJitAlias(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, - bool includeNamespace, bool includeInstantiation) { CorInfoType typ = info.compCompHnd->asCorInfoType(clsHnd); if ((typ == CORINFO_TYPE_CLASS) || (typ == CORINFO_TYPE_VALUECLASS)) { - eePrintType(printer, clsHnd, includeNamespace, includeInstantiation); + eePrintType(printer, clsHnd, includeInstantiation); } else { @@ -191,7 +230,6 @@ void Compiler::eePrintTypeOrJitAlias(StringPrinter* printer, // printer - the printer // clsHnd - Handle for the owning class, or NO_CLASS_HANDLE to not print the class. // sig - The signature of the method. -// includeNamespaces - Whether to print namespaces before type names. // includeClassInstantiation - Whether to print the class instantiation. Only valid when clsHnd is passed. // includeMethodInstantiation - Whether to print the method instantiation. Requires the signature to be passed. // includeSignature - Whether to print the signature. @@ -203,7 +241,6 @@ void Compiler::eePrintMethod(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, - bool includeNamespaces, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, @@ -212,7 +249,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, { if (clsHnd != NO_CLASS_HANDLE) { - eePrintType(printer, clsHnd, includeNamespaces, includeClassInstantiation); + eePrintType(printer, clsHnd, includeClassInstantiation); printer->Printf(":"); } @@ -229,7 +266,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, printer->Printf(","); } - eePrintTypeOrJitAlias(printer, sig->sigInst.methInst[i], includeNamespaces, true); + eePrintTypeOrJitAlias(printer, sig->sigInst.methInst[i], true); } printer->Printf("]"); } @@ -255,7 +292,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, // For some SIMD struct types we can get a nullptr back from eeGetArgClass on Linux/X64 if (clsHnd != NO_CLASS_HANDLE) { - eePrintType(printer, clsHnd, includeNamespaces, true); + eePrintType(printer, clsHnd, true); break; } } @@ -285,7 +322,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd = sig->retTypeClass; if (clsHnd != NO_CLASS_HANDLE) { - eePrintType(printer, clsHnd, includeNamespaces, true); + eePrintType(printer, clsHnd, true); break; } } @@ -334,7 +371,6 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ CORINFO_SIG_INFO sig; eeGetMethodSig(hnd, &sig); eePrintMethod(&p, clsHnd, hnd, &sig, - /* includeNamespaces */ true, /* includeClassInstantiation */ true, /* includeMethodInstantiation */ true, /* includeSignature */ true, includeReturnType, includeThisSpecifier); @@ -352,7 +388,6 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintMethod(&p, clsHnd, hnd, /* sig */ nullptr, - /* includeNamespaces */ true, /* includeClassInstantiation */ false, /* includeMethodInstantiation */ false, /* includeSignature */ false, @@ -371,7 +406,6 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintMethod(&p, nullptr, hnd, /* sig */ nullptr, - /* includeNamespaces */ true, /* includeClassInstantiation */ false, /* includeMethodInstantiation */ false, /* includeSignature */ false, diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 4838e8456a8e1..f62d699cc341b 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -10616,7 +10616,7 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_ if (varTypeIsStruct(elemType) && (elemClsHnd != NO_CLASS_HANDLE)) { - printf("%S[]", eeGetShortClassName(elemClsHnd)); + printf("%s[]", eeGetShortClassName(elemClsHnd)); } else { @@ -11057,11 +11057,11 @@ void Compiler::gtDispClassLayout(ClassLayout* layout, var_types type) } else if (varTypeIsSIMD(type)) { - printf("<%S>", layout->GetShortClassName()); + printf("<%s>", layout->GetShortClassName()); } else { - printf("<%S, %u>", layout->GetShortClassName(), layout->GetSize()); + printf("<%s, %u>", layout->GetShortClassName(), layout->GetSize()); } } diff --git a/src/coreclr/jit/jitconfig.cpp b/src/coreclr/jit/jitconfig.cpp index 7e055f0726bb9..3c85031cee6cd 100644 --- a/src/coreclr/jit/jitconfig.cpp +++ b/src/coreclr/jit/jitconfig.cpp @@ -166,7 +166,6 @@ bool JitConfigValues::MethodSet::contains(CORINFO_METHOD_HANDLE methodHnd, bool success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { comp->eePrintMethod(&printer, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, sigInfo, - /* includeNamespaces */ true, /* includeClassInstantiation */ name->m_classNameContainsInstantiation, /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, /* includeSignature */ name->m_containsSignature, diff --git a/src/coreclr/jit/layout.cpp b/src/coreclr/jit/layout.cpp index be1fe4ec4f583..26c77f9dfbcff 100644 --- a/src/coreclr/jit/layout.cpp +++ b/src/coreclr/jit/layout.cpp @@ -337,7 +337,7 @@ ClassLayout* ClassLayout::Create(Compiler* compiler, CORINFO_CLASS_HANDLE classH var_types type = compiler->impNormStructType(classHandle); INDEBUG(const char* className = compiler->eeGetClassName(classHandle);) - INDEBUG(const char16_t* shortClassName = compiler->eeGetShortClassName(classHandle);) + INDEBUG(const char* shortClassName = compiler->eeGetShortClassName(classHandle);) ClassLayout* layout = new (compiler, CMK_ClassLayout) ClassLayout(classHandle, isValueClass, size, type DEBUGARG(className) DEBUGARG(shortClassName)); diff --git a/src/coreclr/jit/layout.h b/src/coreclr/jit/layout.h index 01040f8eede39..b444a9aa63b41 100644 --- a/src/coreclr/jit/layout.h +++ b/src/coreclr/jit/layout.h @@ -42,7 +42,7 @@ class ClassLayout INDEBUG(const char* m_className;) // Shortened class name as constructed by Compiler::eeGetShortClassName() - INDEBUG(const char16_t* m_shortClassName;) + INDEBUG(const char* m_shortClassName;) // ClassLayout instances should only be obtained via ClassLayoutTable. friend class ClassLayoutTable; @@ -59,7 +59,7 @@ class ClassLayout , m_type(TYP_STRUCT) #ifdef DEBUG , m_className("block") - , m_shortClassName(u"block") + , m_shortClassName("block") #endif { } @@ -69,7 +69,7 @@ class ClassLayout ClassLayout(CORINFO_CLASS_HANDLE classHandle, bool isValueClass, unsigned size, - var_types type DEBUGARG(const char* className) DEBUGARG(const char16_t* shortClassName)) + var_types type DEBUGARG(const char* className) DEBUGARG(const char* shortClassName)) : m_classHandle(classHandle) , m_size(size) , m_isValueClass(isValueClass) @@ -107,7 +107,7 @@ class ClassLayout return m_className; } - const char16_t* GetShortClassName() const + const char* GetShortClassName() const { return m_shortClassName; } diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index 7c16993e4e16d..2d1559ff1580f 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -174,17 +174,19 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH } } - if (typeHnd == nullptr) + if ((typeHnd == nullptr) || !isIntrinsicType(typeHnd)) { return CORINFO_TYPE_UNDEF; } + const char* namespaceName; + const char* className = getClassNameFromMetadata(typeHnd, &namespaceName); + // fast path search using cached type handles of important types CorInfoType simdBaseJitType = CORINFO_TYPE_UNDEF; unsigned size = 0; - // TODO - Optimize SIMD type recognition by IntrinsicAttribute - if (isSIMDClass(typeHnd)) + if (isNumericsNamespace(namespaceName)) { // The most likely to be used type handles are looked up first followed by // less likely to be used type handles @@ -290,143 +292,103 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH // slow path search if (simdBaseJitType == CORINFO_TYPE_UNDEF) { - // Doesn't match with any of the cached type handles. - // Obtain base type by parsing fully qualified class name. - // - // TODO-Throughput: implement product shipping solution to query base type. - WCHAR className[256] = {0}; - WCHAR* pbuf = &className[0]; - int len = ArrLen(className); - int outlen = info.compCompHnd->appendClassName((char16_t**)&pbuf, &len, typeHnd, true, false, false); - noway_assert(outlen >= 0); - noway_assert((size_t)(outlen + 1) <= ArrLen(className)); - JITDUMP("SIMD Candidate Type %S\n", className); - - if (wcsncmp(className, W("System.Numerics."), 16) == 0) - { - if (wcsncmp(&(className[16]), W("Vector`1["), 9) == 0) - { - size = getSIMDVectorRegisterByteLength(); + JITDUMP("SIMD Candidate Type %s\n", className); - if (wcsncmp(&(className[25]), W("System.Single"), 13) == 0) - { - m_simdHandleCache->SIMDFloatHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_FLOAT; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.Int32"), 12) == 0) - { - m_simdHandleCache->SIMDIntHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_INT; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.UInt16"), 13) == 0) - { - m_simdHandleCache->SIMDUShortHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_USHORT; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.Byte"), 11) == 0) - { - m_simdHandleCache->SIMDUByteHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_UBYTE; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.Double"), 13) == 0) - { - m_simdHandleCache->SIMDDoubleHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_DOUBLE; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.Int64"), 12) == 0) - { - m_simdHandleCache->SIMDLongHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_LONG; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.Int16"), 12) == 0) - { - m_simdHandleCache->SIMDShortHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_SHORT; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.SByte"), 12) == 0) - { - m_simdHandleCache->SIMDByteHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_BYTE; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.UInt32"), 13) == 0) - { - m_simdHandleCache->SIMDUIntHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_UINT; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.UInt64"), 13) == 0) - { - m_simdHandleCache->SIMDULongHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_ULONG; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.IntPtr"), 13) == 0) - { - m_simdHandleCache->SIMDNIntHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_NATIVEINT; - JITDUMP(" Found type SIMD Vector\n"); - } - else if (wcsncmp(&(className[25]), W("System.UIntPtr"), 14) == 0) - { - m_simdHandleCache->SIMDNUIntHandle = typeHnd; - simdBaseJitType = CORINFO_TYPE_NATIVEUINT; - JITDUMP(" Found type SIMD Vector\n"); - } - else - { - JITDUMP(" Unknown SIMD Vector\n"); - } - } - else if (wcsncmp(&(className[16]), W("Vector2"), 8) == 0) - { - m_simdHandleCache->SIMDVector2Handle = typeHnd; + if (strcmp(className, "Vector`1") == 0) + { + CORINFO_CLASS_HANDLE typeArgHnd = info.compCompHnd->getTypeInstantiationArgument(typeHnd, 0); + simdBaseJitType = info.compCompHnd->asCorInfoType(typeArgHnd); - simdBaseJitType = CORINFO_TYPE_FLOAT; - size = 2 * genTypeSize(TYP_FLOAT); - assert(size == roundUp(info.compCompHnd->getClassSize(typeHnd), TARGET_POINTER_SIZE)); - JITDUMP(" Found Vector2\n"); - } - else if (wcsncmp(&(className[16]), W("Vector3"), 8) == 0) + switch (simdBaseJitType) { - m_simdHandleCache->SIMDVector3Handle = typeHnd; - - simdBaseJitType = CORINFO_TYPE_FLOAT; - size = 3 * genTypeSize(TYP_FLOAT); - assert(size == info.compCompHnd->getClassSize(typeHnd)); - JITDUMP(" Found Vector3\n"); + case CORINFO_TYPE_FLOAT: + m_simdHandleCache->SIMDFloatHandle = typeHnd; + break; + case CORINFO_TYPE_INT: + m_simdHandleCache->SIMDIntHandle = typeHnd; + break; + case CORINFO_TYPE_USHORT: + m_simdHandleCache->SIMDUShortHandle = typeHnd; + break; + case CORINFO_TYPE_UBYTE: + m_simdHandleCache->SIMDUByteHandle = typeHnd; + break; + case CORINFO_TYPE_DOUBLE: + m_simdHandleCache->SIMDDoubleHandle = typeHnd; + break; + case CORINFO_TYPE_LONG: + m_simdHandleCache->SIMDLongHandle = typeHnd; + break; + case CORINFO_TYPE_SHORT: + m_simdHandleCache->SIMDShortHandle = typeHnd; + break; + case CORINFO_TYPE_BYTE: + m_simdHandleCache->SIMDByteHandle = typeHnd; + break; + case CORINFO_TYPE_UINT: + m_simdHandleCache->SIMDUIntHandle = typeHnd; + break; + case CORINFO_TYPE_ULONG: + m_simdHandleCache->SIMDULongHandle = typeHnd; + break; + case CORINFO_TYPE_NATIVEINT: + m_simdHandleCache->SIMDNIntHandle = typeHnd; + break; + case CORINFO_TYPE_NATIVEUINT: + m_simdHandleCache->SIMDNUIntHandle = typeHnd; + break; + default: + simdBaseJitType = CORINFO_TYPE_UNDEF; + break; } - else if (wcsncmp(&(className[16]), W("Vector4"), 8) == 0) - { - m_simdHandleCache->SIMDVector4Handle = typeHnd; - simdBaseJitType = CORINFO_TYPE_FLOAT; - size = 4 * genTypeSize(TYP_FLOAT); - assert(size == roundUp(info.compCompHnd->getClassSize(typeHnd), TARGET_POINTER_SIZE)); - JITDUMP(" Found Vector4\n"); - } - else if (wcsncmp(&(className[16]), W("Vector"), 6) == 0) + if (simdBaseJitType != CORINFO_TYPE_UNDEF) { - m_simdHandleCache->SIMDVectorHandle = typeHnd; - size = getSIMDVectorRegisterByteLength(); - JITDUMP(" Found type Vector\n"); + JITDUMP(" Found type SIMD Vector<%s>\n", varTypeName(JitType2PreciseVarType(simdBaseJitType))); + size = getSIMDVectorRegisterByteLength(); } else { - JITDUMP(" Unknown SIMD Type\n"); + JITDUMP(" Unknown SIMD Vector\n"); } } + else if (strcmp(className, "Vector2") == 0) + { + m_simdHandleCache->SIMDVector2Handle = typeHnd; + + simdBaseJitType = CORINFO_TYPE_FLOAT; + size = 2 * genTypeSize(TYP_FLOAT); + assert(size == roundUp(info.compCompHnd->getClassSize(typeHnd), TARGET_POINTER_SIZE)); + JITDUMP(" Found Vector2\n"); + } + else if (strcmp(className, "Vector3") == 0) + { + m_simdHandleCache->SIMDVector3Handle = typeHnd; + + simdBaseJitType = CORINFO_TYPE_FLOAT; + size = 3 * genTypeSize(TYP_FLOAT); + assert(size == info.compCompHnd->getClassSize(typeHnd)); + JITDUMP(" Found Vector3\n"); + } + else if (strcmp(className, "Vector4") == 0) + { + m_simdHandleCache->SIMDVector4Handle = typeHnd; + + simdBaseJitType = CORINFO_TYPE_FLOAT; + size = 4 * genTypeSize(TYP_FLOAT); + assert(size == roundUp(info.compCompHnd->getClassSize(typeHnd), TARGET_POINTER_SIZE)); + JITDUMP(" Found Vector4\n"); + } + else if (strcmp(className, "Vector") == 0) + { + m_simdHandleCache->SIMDVectorHandle = typeHnd; + size = getSIMDVectorRegisterByteLength(); + JITDUMP(" Found type Vector\n"); + } } } #ifdef FEATURE_HW_INTRINSICS - else if (isIntrinsicType(typeHnd)) + else { const size_t Vector64SizeBytes = 64 / 8; const size_t Vector128SizeBytes = 128 / 8; @@ -662,7 +624,6 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH if (simdBaseJitType == CORINFO_TYPE_UNDEF) { // Doesn't match with any of the cached type handles. - const char* className = getClassNameFromMetadata(typeHnd, nullptr); CORINFO_CLASS_HANDLE baseTypeHnd = getTypeInstantiationArgument(typeHnd, 0); if (baseTypeHnd != nullptr) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index 2aa2105765b84..13b5663902a8f 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -614,12 +614,12 @@ private static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException } [UnmanagedCallersOnly] - private static int _appendClassName(IntPtr thisHandle, IntPtr* ppException, char** ppBuf, int* pnBufLen, CORINFO_CLASS_STRUCT_* cls, byte fNamespace, byte fFullInst, byte fAssembly) + private static int _appendClassName(IntPtr thisHandle, IntPtr* ppException, byte** ppBuf, int* pnBufLen, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try { - return _this.appendClassName(ppBuf, ref *pnBufLen, cls, fNamespace != 0, fFullInst != 0, fAssembly != 0); + return _this.appendClassName(ppBuf, ref *pnBufLen, cls); } catch (Exception ex) { @@ -2592,6 +2592,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ } } + private static IntPtr GetUnmanagedCallbacks() { void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 175); @@ -2637,7 +2638,7 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[38] = (delegate* unmanaged)&_getClassName; callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; - callbacks[41] = (delegate* unmanaged)&_appendClassName; + callbacks[41] = (delegate* unmanaged)&_appendClassName; callbacks[42] = (delegate* unmanaged)&_isValueClass; callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; callbacks[44] = (delegate* unmanaged)&_getClassAttribs; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 05ca31588c1c2..467a5fb469e89 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1868,29 +1868,27 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) } - private int appendClassName(char** ppBuf, ref int pnBufLen, CORINFO_CLASS_STRUCT_* cls, bool fNamespace, bool fFullInst, bool fAssembly) + private int appendClassName(byte** ppBuf, ref int pnBufLen, CORINFO_CLASS_STRUCT_* cls) { - // We support enough of this to make SIMD work, but not much else. - - Debug.Assert(fNamespace && !fFullInst && !fAssembly); - var type = HandleToObject(cls); string name = TypeString.Instance.FormatName(type); int length = name.Length; if (pnBufLen > 0) { - char* buffer = *ppBuf; - int lengthToCopy = Math.Min(name.Length, pnBufLen); + byte* buffer = *ppBuf; + byte[] utf8 = Encoding.UTF8.GetBytes(name); + int lengthToCopy = Math.Min(utf8.Length, pnBufLen); for (int i = 0; i < lengthToCopy; i++) - buffer[i] = name[i]; - if (name.Length < pnBufLen) + buffer[i] = utf8[i]; + + if (utf8.Length < pnBufLen) { - buffer[name.Length] = (char)0; + buffer[utf8.Length] = 0; } else { - buffer[pnBufLen - 1] = (char)0; + buffer[pnBufLen - 1] = 0; lengthToCopy -= 1; } diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index b69ab664bd483..bc1c40c69328d 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -62,6 +62,7 @@ void **,ref void* VOIDSTARSTAR,void **,void **,void ** int32_t*,int* char*,byte* +char**,byte** const char**,byte** char16_t**,char** char16_t *,char* @@ -196,7 +197,7 @@ FUNCTIONS const char* getClassName(CORINFO_CLASS_HANDLE cls) const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char **namespaceName) CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) - int appendClassName(char16_t** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly) + int appendClassName(char** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls) bool isValueClass(CORINFO_CLASS_HANDLE cls) CorInfoInlineTypeCheck canInlineTypeCheck(CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source) uint32_t getClassAttribs(CORINFO_CLASS_HANDLE cls) diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface.h b/src/coreclr/tools/aot/jitinterface/jitinterface.h index 96cb5bbb40967..0380d72ef9e97 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface.h @@ -52,7 +52,7 @@ struct JitInterfaceCallbacks const char* (* getClassName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); const char* (* getClassNameFromMetadata)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, const char** namespaceName); CORINFO_CLASS_HANDLE (* getTypeInstantiationArgument)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, unsigned index); - int (* appendClassName)(void * thisHandle, CorInfoExceptionClass** ppException, char16_t** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly); + int (* appendClassName)(void * thisHandle, CorInfoExceptionClass** ppException, char** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls); bool (* isValueClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); CorInfoInlineTypeCheck (* canInlineTypeCheck)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source); uint32_t (* getClassAttribs)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); @@ -602,15 +602,12 @@ class JitInterfaceWrapper : public ICorJitInfo } virtual int appendClassName( - char16_t** ppBuf, + char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) + CORINFO_CLASS_HANDLE cls) { CorInfoExceptionClass* pException = nullptr; - int temp = _callbacks->appendClassName(_thisHandle, &pException, ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly); + int temp = _callbacks->appendClassName(_thisHandle, &pException, ppBuf, pnBufLen, cls); if (pException != nullptr) throw pException; return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index c9b67a1da8525..e6b44260eb79b 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -388,9 +388,6 @@ struct Agnostic_AppendClassNameIn { DWORD nBufLenIsZero; DWORDLONG classHandle; - DWORD fNamespace; - DWORD fFullInst; - DWORD fAssembly; }; struct Agnostic_AppendClassNameOut diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 2faea5a996e80..6bf5ccf71b5ee 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -6507,11 +6507,8 @@ CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLAS void MethodContext::recAppendClassName( int nBufLenIn, CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly, int nLenOut, - const char16_t* result) + const char* result) { if (AppendClassName == nullptr) AppendClassName = new LightWeightMap(); @@ -6530,9 +6527,6 @@ void MethodContext::recAppendClassName( ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding key.nBufLenIsZero = (nBufLenIn == 0) ? 1 : 0; key.classHandle = CastHandle(cls); - key.fNamespace = fNamespace; - key.fFullInst = fFullInst; - key.fAssembly = fAssembly; Agnostic_AppendClassNameOut value; value.nLen = nLenOut; @@ -6544,7 +6538,7 @@ void MethodContext::recAppendClassName( { value.name_index = (DWORD)AppendClassName->AddBuffer( (unsigned char*)result, - (unsigned int)((wcslen((LPCWSTR)result) + 1) * sizeof(char16_t))); + (unsigned int)((strlen(result) + 1) * sizeof(char))); } AppendClassName->Add(key, value); @@ -6553,26 +6547,21 @@ void MethodContext::recAppendClassName( void MethodContext::dmpAppendClassName(const Agnostic_AppendClassNameIn& key, const Agnostic_AppendClassNameOut& value) { - const char16_t* name = (const char16_t*)AppendClassName->GetBuffer(value.name_index); - printf("AppendClassName key lenzero-%s cls-%016llX ns-%u fi-%u as-%u, value len-%u ni-%u name-%S", - key.nBufLenIsZero ? "true" : "false", key.classHandle, key.fNamespace, key.fFullInst, key.fAssembly, - value.nLen, value.name_index, (const WCHAR*)name); + const char* name = (const char*)AppendClassName->GetBuffer(value.name_index); + printf("AppendClassName key lenzero-%s cls-%016llX value len-%u ni-%u name-%s", + key.nBufLenIsZero ? "true" : "false", key.classHandle, value.nLen, value.name_index, name); AppendClassName->Unlock(); } -int MethodContext::repAppendClassName(char16_t** ppBuf, +int MethodContext::repAppendClassName(char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) -{ - static const char16_t unknownClass[] = u"hackishClassName"; - static const int unknownClassLength = (int)(ArrLen(unknownClass) - 1); // Don't include null terminator in length. + CORINFO_CLASS_HANDLE cls) { + static const char unknownClass[] = "hackishClassName"; + static const int unknownClassLength = (int)(ArrLen(unknownClass) - 1); // Don't include null terminator in length. // By default, at least return something. - const char16_t* name = unknownClass; - int nLen = unknownClassLength; + const char* name = unknownClass; + int nLen = unknownClassLength; if (AppendClassName != nullptr) { @@ -6580,9 +6569,6 @@ int MethodContext::repAppendClassName(char16_t** ppBuf, ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding key.nBufLenIsZero = (*pnBufLen == 0) ? 1 : 0; key.classHandle = CastHandle(cls); - key.fNamespace = fNamespace; - key.fFullInst = fFullInst; - key.fAssembly = fAssembly; // First, see if we have an entry for this query. int index = AppendClassName->GetIndex(key); @@ -6593,14 +6579,14 @@ int MethodContext::repAppendClassName(char16_t** ppBuf, DEBUG_REP(dmpAppendClassName(key, value)); nLen = value.nLen; - name = (const char16_t*)AppendClassName->GetBuffer(value.name_index); + name = (const char*)AppendClassName->GetBuffer(value.name_index); } } if ((ppBuf != nullptr) && (*ppBuf != nullptr) && (*pnBufLen > 0) && (name != nullptr)) { // Copy as much as will fit. - char16_t* pBuf = *ppBuf; + char* pBuf = *ppBuf; int nLenToCopy = min(*pnBufLen, nLen + /* null terminator */ 1); for (int i = 0; i < nLenToCopy - 1; i++) { diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 354cdb8213966..5b51d1b320159 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -803,18 +803,12 @@ class MethodContext void recAppendClassName(int nBufLenIn, CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly, int nLenOut, - const char16_t* result); + const char* result); void dmpAppendClassName(const Agnostic_AppendClassNameIn& key, const Agnostic_AppendClassNameOut& value); - int repAppendClassName(char16_t** ppBuf, + int repAppendClassName(char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly); + CORINFO_CLASS_HANDLE cls); void recGetTailCallHelpers( CORINFO_RESOLVED_TOKEN* callToken, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index ceb3f0b9e38ba..66cc57a4b4271 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -495,13 +495,11 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLAS } // Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer. +// Includes enclosing classes and namespaces. // // Arguments: // ppBuf - Pointer to buffer pointer. See below for details. // pnBufLen - Pointer to buffer length. Must not be nullptr. See below for details. -// fNamespace - If true, include the namespace/enclosing classes. -// fFullInst - If true (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters. -// fAssembly - If true, suffix with a comma and the full assembly qualification. // // Returns the length of the representation, as a count of characters (but not including a terminating null character). // Note that this will always be the actual number of characters required by the representation, even if the string @@ -521,18 +519,14 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLAS // number of characters that were actually copied to the buffer. Also, `*ppBuf` is updated to point at the null // character that was added to the end of the name. // -int interceptor_ICJI::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char16_t** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) -{ +int interceptor_ICJI::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, + int* pnBufLen, + CORINFO_CLASS_HANDLE cls) { mc->cr->AddCall("appendClassName"); - char16_t* pBufIn = (ppBuf == nullptr) ? nullptr : *ppBuf; - int nBufLenIn = (pnBufLen == nullptr) ? 0 : *pnBufLen; // pnBufLen should never be nullptr, but don't crash if it is. - int nLenOut = original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly); - mc->recAppendClassName(nBufLenIn, cls, fNamespace, fFullInst, fAssembly, nLenOut, pBufIn); + char* pBufIn = (ppBuf == nullptr) ? nullptr : *ppBuf; + int nBufLenIn = (pnBufLen == nullptr) ? 0 : *pnBufLen; // pnBufLen should never be nullptr, but don't crash if it is. + int nLenOut = original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls); + mc->recAppendClassName(nBufLenIn, cls, nLenOut, pBufIn); return nLenOut; } diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 4f8ed3ab023d6..1bc75caacb9a8 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -345,15 +345,12 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument( } int interceptor_ICJI::appendClassName( - char16_t** ppBuf, + char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) + CORINFO_CLASS_HANDLE cls) { mcs->AddCall("appendClassName"); - return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly); + return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls); } bool interceptor_ICJI::isValueClass( diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp index 7da0d2ebb4a45..55bd4a51c0f3e 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -304,14 +304,11 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument( } int interceptor_ICJI::appendClassName( - char16_t** ppBuf, + char** ppBuf, int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) + CORINFO_CLASS_HANDLE cls) { - return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly); + return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls); } bool interceptor_ICJI::isValueClass( diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 218123a05d891..15ac9f0fe6dd4 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -425,13 +425,11 @@ CORINFO_CLASS_HANDLE MyICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE c } // Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer. +// Includes enclosing classes and namespaces. // // Arguments: // ppBuf - Pointer to buffer pointer. See below for details. // pnBufLen - Pointer to buffer length. Must not be nullptr. See below for details. -// fNamespace - If true, include the namespace/enclosing classes. -// fFullInst - If true (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters. -// fAssembly - If true, suffix with a comma and the full assembly qualification. // // Returns the length of the representation, as a count of characters (but not including a terminating null character). // Note that this will always be the actual number of characters required by the representation, even if the string @@ -451,15 +449,12 @@ CORINFO_CLASS_HANDLE MyICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE c // number of characters that were actually copied to the buffer. Also, `*ppBuf` is updated to point at the null // character that was added to the end of the name. // -int MyICJI::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char16_t** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - bool fNamespace, - bool fFullInst, - bool fAssembly) +int MyICJI::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, + int* pnBufLen, + CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("appendClassName"); - return jitInstance->mc->repAppendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly); + return jitInstance->mc->repAppendClassName(ppBuf, pnBufLen, cls); } // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index ef511c1814fe0..3395a1f4f771a 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3341,13 +3341,9 @@ const char* CEEInfo::getHelperName (CorInfoHelpFunc ftnNum) /*********************************************************************/ -int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char16_t** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE clsHnd, - bool fNamespace, - bool fFullInst, - bool fAssembly) -{ +int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, + int* pnBufLen, + CORINFO_CLASS_HANDLE clsHnd) { CONTRACTL { MODE_PREEMPTIVE; THROWS; @@ -3360,16 +3356,13 @@ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char16_t** TypeHandle th(clsHnd); StackSString ss; - TypeString::AppendType(ss,th, - (fNamespace ? TypeString::FormatNamespace : 0) | - (fFullInst ? TypeString::FormatFullInst : 0) | - (fAssembly ? TypeString::FormatAssembly : 0)); - const WCHAR* szString = ss.GetUnicode(); - nLen = (int)wcslen(szString); + TypeString::AppendType(ss, th, TypeString::FormatNamespace | TypeString::FormatNoInst); + const char* szString = ss.GetUTF8(); + nLen = (int)strlen(szString); if (*pnBufLen > 0) { // Copy as much as will fit. - WCHAR* pBuf = (WCHAR*)*ppBuf; + char* pBuf = *ppBuf; int nLenToCopy = min(*pnBufLen, nLen + /* null terminator */ 1); for (int i = 0; i < nLenToCopy - 1; i++) { diff --git a/src/coreclr/vm/typestring.cpp b/src/coreclr/vm/typestring.cpp index 0a05972721a1a..8368d312add7b 100644 --- a/src/coreclr/vm/typestring.cpp +++ b/src/coreclr/vm/typestring.cpp @@ -789,7 +789,7 @@ void TypeString::AppendType(TypeNameBuilder& tnb, TypeHandle ty, Instantiation t } // Append the instantiation - if ((format & (FormatNamespace|FormatAssembly)) && ty.HasInstantiation() && (!ty.IsGenericTypeDefinition() || bToString)) + if ((format & (FormatNamespace|FormatAssembly)) && !(format & FormatNoInst) && ty.HasInstantiation() && (!ty.IsGenericTypeDefinition() || bToString)) { if (typeInstantiation.IsEmpty()) AppendInst(tnb, ty.GetInstantiation(), format); diff --git a/src/coreclr/vm/typestring.h b/src/coreclr/vm/typestring.h index f003984633c35..928ac0b31a7d4 100644 --- a/src/coreclr/vm/typestring.h +++ b/src/coreclr/vm/typestring.h @@ -158,6 +158,7 @@ class TypeString FormatAngleBrackets = 0x00000040, // Whether generic types are C or C[T] FormatStubInfo = 0x00000080, // Include stub info like {unbox-stub} FormatGenericParam = 0x00000100, // Use !name and !!name for generic type and method parameters + FormatNoInst = 0x00000200, // Do not include instantiation } FormatFlags; From a176df0d42949bb1d7f98112f6b9c40f8c8f8931 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 17:23:20 +0200 Subject: [PATCH 02/50] Further cleanups/fixes * Remove getClassName from JIT-EE interface * Remove TypeString.cs in favor of JitTypeNameFormatter that does exactly what we need * Bump JIT-EE GUID --- src/coreclr/inc/corinfo.h | 5 - src/coreclr/inc/icorjitinfoimpl_generated.h | 3 - src/coreclr/inc/jiteeversionguid.h | 10 +- src/coreclr/jit/ICorJitInfo_API_names.h | 1 - src/coreclr/jit/ICorJitInfo_API_wrapper.hpp | 9 - src/coreclr/jit/ee_il_dll.cpp | 2 +- .../tools/Common/JitInterface/CorInfoBase.cs | 290 +++++++++--------- .../tools/Common/JitInterface/CorInfoImpl.cs | 14 +- ...{TypeString.cs => JitTypeNameFormatter.cs} | 66 +--- .../ThunkGenerator/ThunkInput.txt | 1 - .../ILCompiler.ReadyToRun.csproj | 4 +- .../ObjectWriter/OutputInfoBuilder.cs | 2 +- .../ILCompiler.RyuJit.csproj | 4 +- .../tools/aot/jitinterface/jitinterface.h | 10 - .../tools/superpmi/mcs/verbdumpmap.cpp | 7 +- src/coreclr/tools/superpmi/mcs/verbildump.cpp | 16 +- src/coreclr/tools/superpmi/mcs/verbildump.h | 8 + .../tools/superpmi/superpmi-shared/lwmlist.h | 1 - .../superpmi-shared/methodcontext.cpp | 35 --- .../superpmi/superpmi-shared/methodcontext.h | 4 - .../icorjitcompiler.cpp | 1 - .../superpmi-shim-collector/icorjitinfo.cpp | 12 - .../superpmi-shim-counter/icorjitinfo.cpp | 7 - .../superpmi-shim-simple/icorjitinfo.cpp | 6 - .../tools/superpmi/superpmi/icorjitinfo.cpp | 8 - src/coreclr/vm/jitinterface.cpp | 39 --- 26 files changed, 192 insertions(+), 373 deletions(-) rename src/coreclr/tools/Common/JitInterface/{TypeString.cs => JitTypeNameFormatter.cs} (51%) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 735962cdac111..6ece16b0a74bc 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2277,11 +2277,6 @@ class ICorStaticInfo CORINFO_CLASS_HANDLE cls ) = 0; - // for completeness - virtual const char* getClassName ( - CORINFO_CLASS_HANDLE cls - ) = 0; - // Return class name as in metadata, or nullptr if there is none. // Suitable for non-debugging use. virtual const char* getClassNameFromMetadata ( diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index e45d602edc122..7c2940ed855ee 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -178,9 +178,6 @@ int getStringLiteral( CorInfoType asCorInfoType( CORINFO_CLASS_HANDLE cls) override; -const char* getClassName( - CORINFO_CLASS_HANDLE cls) override; - const char* getClassNameFromMetadata( CORINFO_CLASS_HANDLE cls, const char** namespaceName) override; diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 311217aee254b..d25e4fedf870f 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* eb8352bd-0a13-4b5b-badb-58f9ecc40c44 */ - 0xeb8352bd, - 0x0a13, - 0x4b5b, - {0xba, 0xdb, 0x58, 0xf9, 0xec, 0xc4, 0x0c, 0x44} +constexpr GUID JITEEVersionIdentifier = { /* 1e794e80-ec63-4d7a-b11f-fcda6e7fe4f4 */ + 0x1e794e80, + 0xec63, + 0x4d7a, + {0xb1, 0x1f, 0xfc, 0xda, 0x6e, 0x7f, 0xe4, 0xf4} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/jit/ICorJitInfo_API_names.h b/src/coreclr/jit/ICorJitInfo_API_names.h index 0c5af5b9e802a..923ed920bf2bd 100644 --- a/src/coreclr/jit/ICorJitInfo_API_names.h +++ b/src/coreclr/jit/ICorJitInfo_API_names.h @@ -42,7 +42,6 @@ DEF_CLR_API(isValidToken) DEF_CLR_API(isValidStringRef) DEF_CLR_API(getStringLiteral) DEF_CLR_API(asCorInfoType) -DEF_CLR_API(getClassName) DEF_CLR_API(getClassNameFromMetadata) DEF_CLR_API(getTypeInstantiationArgument) DEF_CLR_API(appendClassName) diff --git a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp index 50ac90d19f8ae..36bce479e8a07 100644 --- a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp @@ -383,15 +383,6 @@ CorInfoType WrapICorJitInfo::asCorInfoType( return temp; } -const char* WrapICorJitInfo::getClassName( - CORINFO_CLASS_HANDLE cls) -{ - API_ENTER(getClassName); - const char* temp = wrapHnd->getClassName(cls); - API_LEAVE(getClassName); - return temp; -} - const char* WrapICorJitInfo::getClassNameFromMetadata( CORINFO_CLASS_HANDLE cls, const char** namespaceName) diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 7ffd7dedda62f..7c236a1f78800 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1560,7 +1560,7 @@ unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) //------------------------------------------------------------------------ // eeGetShortClassName: wraps appendClassName to provide functionality -// similar to getClassName(), but returns a class name that is shortened, +// similar to eeGetClassName(), but returns a class name that is shortened, // not using full assembly info. // // Arguments: diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index 13b5663902a8f..c0e74de1002bb 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -568,21 +568,6 @@ private static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException } } - [UnmanagedCallersOnly] - private static byte* _getClassName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassName(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - [UnmanagedCallersOnly] private static byte* _getClassNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte** namespaceName) { @@ -2595,7 +2580,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 175); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 174); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; @@ -2635,143 +2620,142 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[35] = (delegate* unmanaged)&_isValidStringRef; callbacks[36] = (delegate* unmanaged)&_getStringLiteral; callbacks[37] = (delegate* unmanaged)&_asCorInfoType; - callbacks[38] = (delegate* unmanaged)&_getClassName; - callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; - callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; - callbacks[41] = (delegate* unmanaged)&_appendClassName; - callbacks[42] = (delegate* unmanaged)&_isValueClass; - callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; - callbacks[44] = (delegate* unmanaged)&_getClassAttribs; - callbacks[45] = (delegate* unmanaged)&_getClassModule; - callbacks[46] = (delegate* unmanaged)&_getModuleAssembly; - callbacks[47] = (delegate* unmanaged)&_getAssemblyName; - callbacks[48] = (delegate* unmanaged)&_LongLifetimeMalloc; - callbacks[49] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[50] = (delegate* unmanaged)&_getClassModuleIdForStatics; - callbacks[51] = (delegate* unmanaged)&_getClassSize; - callbacks[52] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[53] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[54] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[55] = (delegate* unmanaged)&_getClassGClayout; - callbacks[56] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[57] = (delegate* unmanaged)&_getFieldInClass; - callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[59] = (delegate* unmanaged)&_getNewHelper; - callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[61] = (delegate* unmanaged)&_getCastingHelper; - callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[63] = (delegate* unmanaged)&_getTypeForBox; - callbacks[64] = (delegate* unmanaged)&_getBoxHelper; - callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; - callbacks[66] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[67] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[68] = (delegate* unmanaged)&_getHelperName; - callbacks[69] = (delegate* unmanaged)&_initClass; - callbacks[70] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[71] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[72] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[74] = (delegate* unmanaged)&_canCast; - callbacks[75] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[76] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[77] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[78] = (delegate* unmanaged)&_mergeClasses; - callbacks[79] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[80] = (delegate* unmanaged)&_getParentType; - callbacks[81] = (delegate* unmanaged)&_getChildType; - callbacks[82] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[83] = (delegate* unmanaged)&_isSDArray; - callbacks[84] = (delegate* unmanaged)&_getArrayRank; - callbacks[85] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[86] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[87] = (delegate* unmanaged)&_canAccessClass; - callbacks[88] = (delegate* unmanaged)&_getFieldName; - callbacks[89] = (delegate* unmanaged)&_getFieldClass; - callbacks[90] = (delegate* unmanaged)&_getFieldType; - callbacks[91] = (delegate* unmanaged)&_getFieldOffset; - callbacks[92] = (delegate* unmanaged)&_getFieldInfo; - callbacks[93] = (delegate* unmanaged)&_isFieldStatic; - callbacks[94] = (delegate* unmanaged)&_getBoundaries; - callbacks[95] = (delegate* unmanaged)&_setBoundaries; - callbacks[96] = (delegate* unmanaged)&_getVars; - callbacks[97] = (delegate* unmanaged)&_setVars; - callbacks[98] = (delegate* unmanaged)&_reportRichMappings; - callbacks[99] = (delegate* unmanaged)&_allocateArray; - callbacks[100] = (delegate* unmanaged)&_freeArray; - callbacks[101] = (delegate* unmanaged)&_getArgNext; - callbacks[102] = (delegate* unmanaged)&_getArgType; - callbacks[103] = (delegate* unmanaged)&_getExactClasses; - callbacks[104] = (delegate* unmanaged)&_getArgClass; - callbacks[105] = (delegate* unmanaged)&_getHFAType; - callbacks[106] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[107] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[108] = (delegate* unmanaged)&_FilterException; - callbacks[109] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[110] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[111] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[112] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[113] = (delegate* unmanaged)&_getEEInfo; - callbacks[114] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[115] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[116] = (delegate* unmanaged)&_getMethodName; - callbacks[117] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[118] = (delegate* unmanaged)&_getMethodHash; - callbacks[119] = (delegate* unmanaged)&_findNameOfToken; - callbacks[120] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[121] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[122] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[123] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[124] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[125] = (delegate* unmanaged)&_getHelperFtn; - callbacks[126] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[127] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[128] = (delegate* unmanaged)&_getMethodSync; - callbacks[129] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[130] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[131] = (delegate* unmanaged)&_embedClassHandle; - callbacks[132] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[133] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[134] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[135] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[136] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[137] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[138] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[139] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[140] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[141] = (delegate* unmanaged)&_getCallInfo; - callbacks[142] = (delegate* unmanaged)&_canAccessFamily; - callbacks[143] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[144] = (delegate* unmanaged)&_getClassDomainID; - callbacks[145] = (delegate* unmanaged)&_getFieldAddress; - callbacks[146] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[147] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[148] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[149] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[150] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[151] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[152] = (delegate* unmanaged)&_addActiveDependency; - callbacks[153] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[154] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[155] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[156] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[157] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[158] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[159] = (delegate* unmanaged)&_allocMem; - callbacks[160] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[161] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[162] = (delegate* unmanaged)&_allocGCInfo; - callbacks[163] = (delegate* unmanaged)&_setEHcount; - callbacks[164] = (delegate* unmanaged)&_setEHinfo; - callbacks[165] = (delegate* unmanaged)&_logMsg; - callbacks[166] = (delegate* unmanaged)&_doAssert; - callbacks[167] = (delegate* unmanaged)&_reportFatalError; - callbacks[168] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[169] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[170] = (delegate* unmanaged)&_recordCallSite; - callbacks[171] = (delegate* unmanaged)&_recordRelocation; - callbacks[172] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[173] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[174] = (delegate* unmanaged)&_getJitFlags; + callbacks[38] = (delegate* unmanaged)&_getClassNameFromMetadata; + callbacks[39] = (delegate* unmanaged)&_getTypeInstantiationArgument; + callbacks[40] = (delegate* unmanaged)&_appendClassName; + callbacks[41] = (delegate* unmanaged)&_isValueClass; + callbacks[42] = (delegate* unmanaged)&_canInlineTypeCheck; + callbacks[43] = (delegate* unmanaged)&_getClassAttribs; + callbacks[44] = (delegate* unmanaged)&_getClassModule; + callbacks[45] = (delegate* unmanaged)&_getModuleAssembly; + callbacks[46] = (delegate* unmanaged)&_getAssemblyName; + callbacks[47] = (delegate* unmanaged)&_LongLifetimeMalloc; + callbacks[48] = (delegate* unmanaged)&_LongLifetimeFree; + callbacks[49] = (delegate* unmanaged)&_getClassModuleIdForStatics; + callbacks[50] = (delegate* unmanaged)&_getClassSize; + callbacks[51] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[52] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[53] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[54] = (delegate* unmanaged)&_getClassGClayout; + callbacks[55] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[56] = (delegate* unmanaged)&_getFieldInClass; + callbacks[57] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[58] = (delegate* unmanaged)&_getNewHelper; + callbacks[59] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[60] = (delegate* unmanaged)&_getCastingHelper; + callbacks[61] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[62] = (delegate* unmanaged)&_getTypeForBox; + callbacks[63] = (delegate* unmanaged)&_getBoxHelper; + callbacks[64] = (delegate* unmanaged)&_getUnBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[66] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[67] = (delegate* unmanaged)&_getHelperName; + callbacks[68] = (delegate* unmanaged)&_initClass; + callbacks[69] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[70] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[71] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[72] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[73] = (delegate* unmanaged)&_canCast; + callbacks[74] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[75] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[76] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[77] = (delegate* unmanaged)&_mergeClasses; + callbacks[78] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[79] = (delegate* unmanaged)&_getParentType; + callbacks[80] = (delegate* unmanaged)&_getChildType; + callbacks[81] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[82] = (delegate* unmanaged)&_isSDArray; + callbacks[83] = (delegate* unmanaged)&_getArrayRank; + callbacks[84] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[85] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[86] = (delegate* unmanaged)&_canAccessClass; + callbacks[87] = (delegate* unmanaged)&_getFieldName; + callbacks[88] = (delegate* unmanaged)&_getFieldClass; + callbacks[89] = (delegate* unmanaged)&_getFieldType; + callbacks[90] = (delegate* unmanaged)&_getFieldOffset; + callbacks[91] = (delegate* unmanaged)&_getFieldInfo; + callbacks[92] = (delegate* unmanaged)&_isFieldStatic; + callbacks[93] = (delegate* unmanaged)&_getBoundaries; + callbacks[94] = (delegate* unmanaged)&_setBoundaries; + callbacks[95] = (delegate* unmanaged)&_getVars; + callbacks[96] = (delegate* unmanaged)&_setVars; + callbacks[97] = (delegate* unmanaged)&_reportRichMappings; + callbacks[98] = (delegate* unmanaged)&_allocateArray; + callbacks[99] = (delegate* unmanaged)&_freeArray; + callbacks[100] = (delegate* unmanaged)&_getArgNext; + callbacks[101] = (delegate* unmanaged)&_getArgType; + callbacks[102] = (delegate* unmanaged)&_getExactClasses; + callbacks[103] = (delegate* unmanaged)&_getArgClass; + callbacks[104] = (delegate* unmanaged)&_getHFAType; + callbacks[105] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[106] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[107] = (delegate* unmanaged)&_FilterException; + callbacks[108] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[109] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[110] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[111] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[112] = (delegate* unmanaged)&_getEEInfo; + callbacks[113] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[114] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[115] = (delegate* unmanaged)&_getMethodName; + callbacks[116] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[117] = (delegate* unmanaged)&_getMethodHash; + callbacks[118] = (delegate* unmanaged)&_findNameOfToken; + callbacks[119] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[120] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[121] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[122] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[123] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[124] = (delegate* unmanaged)&_getHelperFtn; + callbacks[125] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[126] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[127] = (delegate* unmanaged)&_getMethodSync; + callbacks[128] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[129] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[130] = (delegate* unmanaged)&_embedClassHandle; + callbacks[131] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[132] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[133] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[134] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[135] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[136] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[137] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[138] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[139] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[140] = (delegate* unmanaged)&_getCallInfo; + callbacks[141] = (delegate* unmanaged)&_canAccessFamily; + callbacks[142] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[143] = (delegate* unmanaged)&_getClassDomainID; + callbacks[144] = (delegate* unmanaged)&_getFieldAddress; + callbacks[145] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[146] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[147] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[148] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[149] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[150] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[151] = (delegate* unmanaged)&_addActiveDependency; + callbacks[152] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[153] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[154] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[155] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[156] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[157] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[158] = (delegate* unmanaged)&_allocMem; + callbacks[159] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[160] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[161] = (delegate* unmanaged)&_allocGCInfo; + callbacks[162] = (delegate* unmanaged)&_setEHcount; + callbacks[163] = (delegate* unmanaged)&_setEHinfo; + callbacks[164] = (delegate* unmanaged)&_logMsg; + callbacks[165] = (delegate* unmanaged)&_doAssert; + callbacks[166] = (delegate* unmanaged)&_reportFatalError; + callbacks[167] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[168] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[169] = (delegate* unmanaged)&_recordCallSite; + callbacks[170] = (delegate* unmanaged)&_recordRelocation; + callbacks[171] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[172] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[173] = (delegate* unmanaged)&_getJitFlags; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 467a5fb469e89..6d1864c6c9abd 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1836,14 +1836,6 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) return asCorInfoType(type); } - private byte* getClassName(CORINFO_CLASS_STRUCT_* cls) - { - var type = HandleToObject(cls); - StringBuilder nameBuilder = new StringBuilder(); - TypeString.Instance.AppendName(nameBuilder, type); - return (byte*)GetPin(StringToUTF8(nameBuilder.ToString())); - } - private byte* getClassNameFromMetadata(CORINFO_CLASS_STRUCT_* cls, byte** namespaceName) { var type = HandleToObject(cls) as MetadataType; @@ -1871,13 +1863,13 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) private int appendClassName(byte** ppBuf, ref int pnBufLen, CORINFO_CLASS_STRUCT_* cls) { var type = HandleToObject(cls); - string name = TypeString.Instance.FormatName(type); + string name = JitTypeNameFormatter.Instance.FormatName(type); - int length = name.Length; + byte[] utf8 = Encoding.UTF8.GetBytes(name); + int length = utf8.Length; if (pnBufLen > 0) { byte* buffer = *ppBuf; - byte[] utf8 = Encoding.UTF8.GetBytes(name); int lengthToCopy = Math.Min(utf8.Length, pnBufLen); for (int i = 0; i < lengthToCopy; i++) buffer[i] = utf8[i]; diff --git a/src/coreclr/tools/Common/JitInterface/TypeString.cs b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs similarity index 51% rename from src/coreclr/tools/Common/JitInterface/TypeString.cs rename to src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs index 7bdb02e08107f..6210eae17f5fa 100644 --- a/src/coreclr/tools/Common/JitInterface/TypeString.cs +++ b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs @@ -1,94 +1,62 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics; using System.Text; using Internal.TypeSystem; namespace Internal.JitInterface { - // This is a very rough equivalent of typestring.cpp in the CLR. - // There's way more rules to capture. Hopefully, we'll only ever need this in the code to recognize SIMD intrisics - // and we won't need to replicate all the details around escaping and such. - internal sealed class TypeString : TypeNameFormatter + // This is a very rough equivalent of typestring.cpp in the CLR used with + // FormatNamespace|FormatNoInst. This is currently only used for + // appendClassName in the JIT-EE interface, which is used to print class + // names to use for the various method set JIT variables (JitDisasm for + // example). The JIT handles formatting of most type names on its own so we + // only need the basics here. + internal sealed class JitTypeNameFormatter : TypeNameFormatter { - public static TypeString Instance { get; } = new TypeString(); + public static JitTypeNameFormatter Instance { get; } = new JitTypeNameFormatter(); public override void AppendName(StringBuilder sb, PointerType type) { - AppendName(sb, type.ParameterType); - sb.Append('*'); + Debug.Fail("Unexpected pointer type in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, GenericParameterDesc type) { - string prefix = type.Kind == GenericParameterKind.Type ? "!" : "!!"; - sb.Append(prefix); - sb.Append(type.Name); + Debug.Fail("Unexpected generic parameter in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, SignatureTypeVariable type) { - sb.Append('!'); - sb.Append(type.Index); + Debug.Fail("Unexpected TVar in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, SignatureMethodVariable type) { - sb.Append("!!"); - sb.Append(type.Index); + Debug.Fail("Unexpected MVar in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, FunctionPointerType type) { - MethodSignature signature = type.Signature; - - AppendName(sb, signature.ReturnType); - - sb.Append(" ("); - for (int i = 0; i < signature.Length; i++) - { - if (i > 0) - sb.Append(", "); - AppendName(sb, signature[i]); - } - - sb.Append(')'); + Debug.Fail("Unexpected function pointer type in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, ByRefType type) { - AppendName(sb, type.ParameterType); - sb.Append('&'); + Debug.Fail("Unexpected ByRef type in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, ArrayType type) { - AppendName(sb, type.ElementType); - sb.Append('['); - - int rank = type.Rank; - if (rank == 1 && type.IsMdArray) - sb.Append('*'); - else - sb.Append(',', type.Rank - 1); - - sb.Append(']'); + Debug.Fail("Unexpected array type in JitTypeNameFormatter"); } protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType type) { AppendName(sb, type.GetTypeDefinition()); - sb.Append('['); - - for (int i = 0; i < type.Instantiation.Length; i++) - { - if (i > 0) - sb.Append(", "); - AppendName(sb, type.Instantiation[i]); - } - - sb.Append(']'); + // Instantiation itself is handled by JIT. } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index bc1c40c69328d..fc2523782157e 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -194,7 +194,6 @@ FUNCTIONS bool isValidStringRef(CORINFO_MODULE_HANDLE module, unsigned metaTOK) int getStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, char16_t* buffer, int bufferSize) CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls) - const char* getClassName(CORINFO_CLASS_HANDLE cls) const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char **namespaceName) CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) int appendClassName(char** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index 4b8361f944f69..426bdf6b12346 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -262,8 +262,8 @@ IL\HelperExtensions.cs - - JitInterface\TypeString.cs + + JitInterface\JitTypeNameFormatter.cs JitInterface\CorInfoBase.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs index 21f9169f294a7..cafa1a6f7b7ef 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs @@ -182,7 +182,7 @@ public bool FindSymbol(OutputItem item, out int index) public IEnumerable EnumerateMethods() { DebugNameFormatter nameFormatter = new DebugNameFormatter(); - TypeNameFormatter typeNameFormatter = new TypeString(); + TypeNameFormatter typeNameFormatter = new JitTypeNameFormatter(); foreach (KeyValuePair symbolMethodPair in _methodSymbolMap) { MethodInfo methodInfo = new MethodInfo(); diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj b/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj index 921059e06a008..965bf77d0798e 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj @@ -65,8 +65,8 @@ JitInterface\JitConfigProvider.cs - - JitInterface\TypeString.cs + + JitInterface\JitTypeNameFormatter.cs JitInterface\CorInfoBase.cs diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface.h b/src/coreclr/tools/aot/jitinterface/jitinterface.h index 0380d72ef9e97..a1b28dc41459b 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface.h @@ -49,7 +49,6 @@ struct JitInterfaceCallbacks bool (* isValidStringRef)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE module, unsigned metaTOK); int (* getStringLiteral)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE module, unsigned metaTOK, char16_t* buffer, int bufferSize); CorInfoType (* asCorInfoType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); - const char* (* getClassName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); const char* (* getClassNameFromMetadata)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, const char** namespaceName); CORINFO_CLASS_HANDLE (* getTypeInstantiationArgument)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, unsigned index); int (* appendClassName)(void * thisHandle, CorInfoExceptionClass** ppException, char** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls); @@ -572,15 +571,6 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } - virtual const char* getClassName( - CORINFO_CLASS_HANDLE cls) -{ - CorInfoExceptionClass* pException = nullptr; - const char* temp = _callbacks->getClassName(_thisHandle, &pException, cls); - if (pException != nullptr) throw pException; - return temp; -} - virtual const char* getClassNameFromMetadata( CORINFO_CLASS_HANDLE cls, const char** namespaceName) diff --git a/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp b/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp index 2ff9b3cbe3690..64c54bf074007 100644 --- a/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp +++ b/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp @@ -31,7 +31,8 @@ void DumpMap(int index, MethodContext* mc) const char* moduleName = nullptr; const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); - const char* className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); + char className[256]; + PrintClassName(mc, className, mc->repGetMethodClass(cmi.ftn)); printf("%d,", index); // printf("\"%s\",", mc->cr->repProcessName()); @@ -53,7 +54,7 @@ void DumpMap(int index, MethodContext* mc) for (unsigned i = 0; i < classInst; i++) { CORINFO_CLASS_HANDLE ci = sig.sigInst.classInst[i]; - className = mc->repGetClassName(ci); + PrintClassName(mc, className, ci); printf("%s%s%s%s", i == 0 ? "[" : "", @@ -69,7 +70,7 @@ void DumpMap(int index, MethodContext* mc) for (unsigned i = 0; i < methodInst; i++) { CORINFO_CLASS_HANDLE ci = sig.sigInst.methInst[i]; - className = mc->repGetClassName(ci); + PrintClassName(mc, className, ci); printf("%s%s%s%s", i == 0 ? "[" : "", diff --git a/src/coreclr/tools/superpmi/mcs/verbildump.cpp b/src/coreclr/tools/superpmi/mcs/verbildump.cpp index 506d14e587f99..95da3f62b727d 100644 --- a/src/coreclr/tools/superpmi/mcs/verbildump.cpp +++ b/src/coreclr/tools/superpmi/mcs/verbildump.cpp @@ -65,11 +65,17 @@ void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classH printf("byref"); return; case CORINFO_TYPE_VALUECLASS: - printf("valueclass %s", mc->repGetClassName((CORINFO_CLASS_HANDLE)classHandle)); - return; case CORINFO_TYPE_CLASS: - printf("class %s", mc->repGetClassName((CORINFO_CLASS_HANDLE)classHandle)); + { + char className[256]; + PrintClassName(mc, className, (CORINFO_CLASS_HANDLE)classHandle); + + printf( + "%s %s", + prim == CORINFO_TYPE_VALUECLASS ? "valueclass" : "class", + className); return; + } case CORINFO_TYPE_REFANY: printf("refany"); return; @@ -933,7 +939,9 @@ void DumpIL(MethodContext* mc) const char* moduleName = nullptr; const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); - const char* className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); + + char className[256]; + PrintClassName(mc, className, mc->repGetMethodClass(cmi.ftn)); printf("// ProcessName - '%s'\n", mc->cr->repProcessName()); printf(".assembly extern mscorlib{}\n"); diff --git a/src/coreclr/tools/superpmi/mcs/verbildump.h b/src/coreclr/tools/superpmi/mcs/verbildump.h index c78352f5a1240..43c9e608f56cb 100644 --- a/src/coreclr/tools/superpmi/mcs/verbildump.h +++ b/src/coreclr/tools/superpmi/mcs/verbildump.h @@ -19,4 +19,12 @@ void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classH void DumpSigToConsoleBare(MethodContext* mc, CORINFO_SIG_INFO* pSig); char* DumpAttributeToConsoleBare(DWORD attribute); +template +static void PrintClassName(MethodContext* mc, char (&buffer)[size], CORINFO_CLASS_HANDLE clsHnd) +{ + char* classNameMut = buffer; + int sizeMut = size; + mc->repAppendClassName(&classNameMut, &sizeMut, clsHnd); +} + #endif diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index ce147abc89be6..cb393068aa89d 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -66,7 +66,6 @@ LWM(GetClassAttribs, DWORDLONG, DWORD) LWM(GetClassDomainID, DWORDLONG, DLD) LWM(GetClassGClayout, DWORDLONG, Agnostic_GetClassGClayout) LWM(GetClassModuleIdForStatics, DWORDLONG, Agnostic_GetClassModuleIdForStatics) -LWM(GetClassName, DWORDLONG, DWORD) LWM(GetClassNameFromMetadata, DLD, DD) LWM(GetTypeInstantiationArgument, DLD, DWORDLONG) LWM(GetClassNumInstanceFields, DWORDLONG, DWORD) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 6bf5ccf71b5ee..737ce3744ed04 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -6358,41 +6358,6 @@ bool MethodContext::repIsValidToken(CORINFO_MODULE_HANDLE module, unsigned metaT return value != 0; } -void MethodContext::recGetClassName(CORINFO_CLASS_HANDLE cls, const char* result) -{ - if (GetClassName == nullptr) - GetClassName = new LightWeightMap(); - - DWORD value = (DWORD)-1; - if (result != nullptr) - value = (DWORD)GetClassName->AddBuffer((unsigned char*)result, (unsigned int)strlen(result) + 1); - - DWORDLONG key = CastHandle(cls); - GetClassName->Add(key, value); - DEBUG_REC(dmpGetClassName(key, value)); -} -void MethodContext::dmpGetClassName(DWORDLONG key, DWORD value) -{ - printf("GetClassName key %016llX, value %s", key, GetClassName->GetBuffer(value)); - GetClassName->Unlock(); -} -const char* MethodContext::repGetClassName(CORINFO_CLASS_HANDLE cls) -{ - DWORDLONG key = CastHandle(cls); - - if (GetClassName == nullptr) - return "hackishClassName"; - int index = GetClassName->GetIndex(key); - if (index == -1) - return "hackishClassName"; - - int offset = GetClassName->Get(key); - DEBUG_REP(dmpGetClassName(key, (DWORD)offset)); - - const char* name = (const char*)GetClassName->GetBuffer(offset); - return name; -} - void MethodContext::recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, char* className, const char** namespaceName) { if (GetClassNameFromMetadata == nullptr) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 5b51d1b320159..d12145a73d3e0 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -789,10 +789,6 @@ class MethodContext void dmpIsValidToken(DLD key, DWORD value); bool repIsValidToken(CORINFO_MODULE_HANDLE module, unsigned metaTOK); - void recGetClassName(CORINFO_CLASS_HANDLE cls, const char* result); - void dmpGetClassName(DWORDLONG key, DWORD value); - const char* repGetClassName(CORINFO_CLASS_HANDLE cls); - void recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, char* className, const char** namespaceName); void dmpGetClassNameFromMetadata(DLD key, DD value); const char* repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp index 723ee1d98ce80..5f7fb2d19ef01 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp @@ -72,7 +72,6 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp, // to build up a fat mc CORINFO_CLASS_HANDLE ourClass = our_ICorJitInfo.getMethodClass(info->ftn); our_ICorJitInfo.getClassAttribs(ourClass); - our_ICorJitInfo.getClassName(ourClass); our_ICorJitInfo.isValueClass(ourClass); our_ICorJitInfo.asCorInfoType(ourClass); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 66cc57a4b4271..86ec7dbb29a55 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -469,15 +469,6 @@ CorInfoType interceptor_ICJI::asCorInfoType(CORINFO_CLASS_HANDLE cls) return temp; } -// for completeness -const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls) -{ - mc->cr->AddCall("getClassName"); - const char* result = original_ICorJitInfo->getClassName(cls); - mc->recGetClassName(cls, result); - return result; -} - const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) { mc->cr->AddCall("getClassNameFromMetadata"); @@ -1268,9 +1259,6 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getArgClass(CORINFO_SIG_INFO* sig, [&](DWORD exceptionCode) { this->mc->recGetArgClass(sig, args, temp, exceptionCode); - - // to build up a fat mc - getClassName(temp); }); return temp; diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 1bc75caacb9a8..688d4f7584887 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -321,13 +321,6 @@ CorInfoType interceptor_ICJI::asCorInfoType( return original_ICorJitInfo->asCorInfoType(cls); } -const char* interceptor_ICJI::getClassName( - CORINFO_CLASS_HANDLE cls) -{ - mcs->AddCall("getClassName"); - return original_ICorJitInfo->getClassName(cls); -} - const char* interceptor_ICJI::getClassNameFromMetadata( CORINFO_CLASS_HANDLE cls, const char** namespaceName) diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp index 55bd4a51c0f3e..fe01357910c70 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -283,12 +283,6 @@ CorInfoType interceptor_ICJI::asCorInfoType( return original_ICorJitInfo->asCorInfoType(cls); } -const char* interceptor_ICJI::getClassName( - CORINFO_CLASS_HANDLE cls) -{ - return original_ICorJitInfo->getClassName(cls); -} - const char* interceptor_ICJI::getClassNameFromMetadata( CORINFO_CLASS_HANDLE cls, const char** namespaceName) diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 15ac9f0fe6dd4..277d2991f0999 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -402,14 +402,6 @@ CorInfoType MyICJI::asCorInfoType(CORINFO_CLASS_HANDLE cls) return jitInstance->mc->repAsCorInfoType(cls); } -// for completeness -const char* MyICJI::getClassName(CORINFO_CLASS_HANDLE cls) -{ - jitInstance->mc->cr->AddCall("getClassName"); - const char* result = jitInstance->mc->repGetClassName(cls); - return result; -} - const char* MyICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) { jitInstance->mc->cr->AddCall("getClassNameFromMetadata"); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 3395a1f4f771a..78331eaff6cbc 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3275,45 +3275,6 @@ void CEEInfo::ComputeRuntimeLookupForSharedGenericToken(DictionaryEntryKind entr } } - - -/*********************************************************************/ -const char* CEEInfo::getClassName (CORINFO_CLASS_HANDLE clsHnd) -{ - CONTRACTL { - THROWS; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } CONTRACTL_END; - - const char* result = NULL; - - JIT_TO_EE_TRANSITION(); - - TypeHandle VMClsHnd(clsHnd); - MethodTable* pMT = VMClsHnd.GetMethodTable(); - if (pMT == NULL) - { - result = ""; - } - else - { -#ifdef _DEBUG - result = pMT->GetDebugClassName(); -#else // !_DEBUG - // since this is for diagnostic purposes only, - // give up on the namespace, as we don't have a buffer to concat it - // also note this won't show array class names. - LPCUTF8 nameSpace; - result = pMT->GetFullyQualifiedNameInfo(&nameSpace); -#endif - } - - EE_TO_JIT_TRANSITION(); - - return result; -} - /***********************************************************************/ const char* CEEInfo::getHelperName (CorInfoHelpFunc ftnNum) { From 3bfb46f57990d19f137d299910587657c2bc6a75 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 17:30:38 +0200 Subject: [PATCH 03/50] Run jit-format --- src/coreclr/jit/compiler.h | 9 ++-- src/coreclr/jit/ee_il_dll.cpp | 10 ++--- src/coreclr/jit/eeinterface.cpp | 12 ++--- src/coreclr/jit/simd.cpp | 80 ++++++++++++++++----------------- 4 files changed, 52 insertions(+), 59 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index d1e202223b5e3..50501646a6e59 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7538,12 +7538,8 @@ class Compiler var_types eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd, CORINFO_CLASS_HANDLE* pStructHnd = nullptr); void eePrintJitType(class StringPrinter* printer, var_types jitType); - void eePrintType(class StringPrinter* printer, - CORINFO_CLASS_HANDLE clsHnd, - bool includeInstantiation); - void eePrintTypeOrJitAlias(class StringPrinter* printer, - CORINFO_CLASS_HANDLE clsHnd, - bool includeInstantiation); + void eePrintType(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation); + void eePrintTypeOrJitAlias(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation); void eePrintMethod(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methodHnd, @@ -11291,6 +11287,7 @@ class StringPrinter size_t m_bufferIndex = 0; void Grow(size_t newSize); + public: StringPrinter(CompAllocator alloc, char* buffer = nullptr, size_t bufferMax = 0) : m_alloc(alloc), m_buffer(buffer), m_bufferMax(bufferMax) diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 7c236a1f78800..1cb6bf57839da 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1417,7 +1417,7 @@ struct FilterSuperPMIExceptionsParam_ee_il CORINFO_CLASS_HANDLE clazz; const char** classNamePtr; const char* fieldOrMethodOrClassNamePtr; - char* classNameWidePtr; + char* classNameWidePtr; unsigned classSize; EXCEPTION_POINTERS exceptionPointers; }; @@ -1580,7 +1580,7 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) bool success = eeRunWithSPMIErrorTrap( [](FilterSuperPMIExceptionsParam_ee_il* pParam) { - int len = 0; + int len = 0; // Warning: crossgen2 doesn't fully implement the `appendClassName` API. // We need to pass size zero, get back the actual buffer size required, allocate that space, // and call the API again to get the full string. @@ -1588,7 +1588,7 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) size_t cchBufLen = (size_t)cchStrLen + /* null terminator */ 1; pParam->classNameWidePtr = pParam->pThis->getAllocator(CMK_DebugOnly).allocate(cchBufLen); - char* pbuf = pParam->classNameWidePtr; + char* pbuf = pParam->classNameWidePtr; len = (int)cchBufLen; int cchResultStrLen = pParam->pJitInfo->compCompHnd->appendClassName(&pbuf, &len, pParam->clazz); @@ -1600,8 +1600,8 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) if (!success) { const char substituteClassName[] = "hackishClassName"; - size_t cchLen = ArrLen(substituteClassName); - param.classNameWidePtr = getAllocator(CMK_DebugOnly).allocate(cchLen); + size_t cchLen = ArrLen(substituteClassName); + param.classNameWidePtr = getAllocator(CMK_DebugOnly).allocate(cchLen); memcpy(param.classNameWidePtr, substituteClassName, cchLen * sizeof(char)); } diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 17129730197da..dfedc144b210f 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -29,7 +29,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX void StringPrinter::Grow(size_t newSize) { assert(newSize > m_bufferMax); - char* newBuffer = m_alloc.allocate(newSize); + char* newBuffer = m_alloc.allocate(newSize); memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too m_buffer = newBuffer; @@ -130,9 +130,7 @@ void Compiler::eePrintJitType(StringPrinter* printer, var_types jitType) // includeNamespace - Whether to print namespaces before type names // includeInstantiation - Whether to print the instantiation of the class // -void Compiler::eePrintType(StringPrinter* printer, - CORINFO_CLASS_HANDLE clsHnd, - bool includeInstantiation) +void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation) { unsigned arrayRank = info.compCompHnd->getArrayRank(clsHnd); if (arrayRank > 0) @@ -157,7 +155,7 @@ void Compiler::eePrintType(StringPrinter* printer, return; } - int size = 0; + int size = 0; int actualLen = info.compCompHnd->appendClassName(nullptr, &size, clsHnd); if (actualLen <= 0) { @@ -206,9 +204,7 @@ void Compiler::eePrintType(StringPrinter* printer, // clsHnd - Handle for the class // includeInstantiation - Whether to print the instantiation of the class // -void Compiler::eePrintTypeOrJitAlias(StringPrinter* printer, - CORINFO_CLASS_HANDLE clsHnd, - bool includeInstantiation) +void Compiler::eePrintTypeOrJitAlias(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation) { CorInfoType typ = info.compCompHnd->asCorInfoType(clsHnd); if ((typ == CORINFO_TYPE_CLASS) || (typ == CORINFO_TYPE_VALUECLASS)) diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index 2d1559ff1580f..9d0def8f21a78 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -297,49 +297,49 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH if (strcmp(className, "Vector`1") == 0) { CORINFO_CLASS_HANDLE typeArgHnd = info.compCompHnd->getTypeInstantiationArgument(typeHnd, 0); - simdBaseJitType = info.compCompHnd->asCorInfoType(typeArgHnd); + simdBaseJitType = info.compCompHnd->asCorInfoType(typeArgHnd); switch (simdBaseJitType) { - case CORINFO_TYPE_FLOAT: - m_simdHandleCache->SIMDFloatHandle = typeHnd; - break; - case CORINFO_TYPE_INT: - m_simdHandleCache->SIMDIntHandle = typeHnd; - break; - case CORINFO_TYPE_USHORT: - m_simdHandleCache->SIMDUShortHandle = typeHnd; - break; - case CORINFO_TYPE_UBYTE: - m_simdHandleCache->SIMDUByteHandle = typeHnd; - break; - case CORINFO_TYPE_DOUBLE: - m_simdHandleCache->SIMDDoubleHandle = typeHnd; - break; - case CORINFO_TYPE_LONG: - m_simdHandleCache->SIMDLongHandle = typeHnd; - break; - case CORINFO_TYPE_SHORT: - m_simdHandleCache->SIMDShortHandle = typeHnd; - break; - case CORINFO_TYPE_BYTE: - m_simdHandleCache->SIMDByteHandle = typeHnd; - break; - case CORINFO_TYPE_UINT: - m_simdHandleCache->SIMDUIntHandle = typeHnd; - break; - case CORINFO_TYPE_ULONG: - m_simdHandleCache->SIMDULongHandle = typeHnd; - break; - case CORINFO_TYPE_NATIVEINT: - m_simdHandleCache->SIMDNIntHandle = typeHnd; - break; - case CORINFO_TYPE_NATIVEUINT: - m_simdHandleCache->SIMDNUIntHandle = typeHnd; - break; - default: - simdBaseJitType = CORINFO_TYPE_UNDEF; - break; + case CORINFO_TYPE_FLOAT: + m_simdHandleCache->SIMDFloatHandle = typeHnd; + break; + case CORINFO_TYPE_INT: + m_simdHandleCache->SIMDIntHandle = typeHnd; + break; + case CORINFO_TYPE_USHORT: + m_simdHandleCache->SIMDUShortHandle = typeHnd; + break; + case CORINFO_TYPE_UBYTE: + m_simdHandleCache->SIMDUByteHandle = typeHnd; + break; + case CORINFO_TYPE_DOUBLE: + m_simdHandleCache->SIMDDoubleHandle = typeHnd; + break; + case CORINFO_TYPE_LONG: + m_simdHandleCache->SIMDLongHandle = typeHnd; + break; + case CORINFO_TYPE_SHORT: + m_simdHandleCache->SIMDShortHandle = typeHnd; + break; + case CORINFO_TYPE_BYTE: + m_simdHandleCache->SIMDByteHandle = typeHnd; + break; + case CORINFO_TYPE_UINT: + m_simdHandleCache->SIMDUIntHandle = typeHnd; + break; + case CORINFO_TYPE_ULONG: + m_simdHandleCache->SIMDULongHandle = typeHnd; + break; + case CORINFO_TYPE_NATIVEINT: + m_simdHandleCache->SIMDNIntHandle = typeHnd; + break; + case CORINFO_TYPE_NATIVEUINT: + m_simdHandleCache->SIMDNUIntHandle = typeHnd; + break; + default: + simdBaseJitType = CORINFO_TYPE_UNDEF; + break; } if (simdBaseJitType != CORINFO_TYPE_UNDEF) From e8fa31d1c33c9e09dfcafb5cea7d6eaa69857dbb Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 18:01:28 +0200 Subject: [PATCH 04/50] Revert TypeString removal --- .../tools/Common/JitInterface/TypeString.cs | 112 ++++++++++++++++++ .../ILCompiler.ReadyToRun.csproj | 3 + .../ObjectWriter/OutputInfoBuilder.cs | 2 +- .../ILCompiler.RyuJit.csproj | 3 + 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/coreclr/tools/Common/JitInterface/TypeString.cs diff --git a/src/coreclr/tools/Common/JitInterface/TypeString.cs b/src/coreclr/tools/Common/JitInterface/TypeString.cs new file mode 100644 index 0000000000000..7bdb02e08107f --- /dev/null +++ b/src/coreclr/tools/Common/JitInterface/TypeString.cs @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text; + +using Internal.TypeSystem; + +namespace Internal.JitInterface +{ + // This is a very rough equivalent of typestring.cpp in the CLR. + // There's way more rules to capture. Hopefully, we'll only ever need this in the code to recognize SIMD intrisics + // and we won't need to replicate all the details around escaping and such. + internal sealed class TypeString : TypeNameFormatter + { + public static TypeString Instance { get; } = new TypeString(); + + public override void AppendName(StringBuilder sb, PointerType type) + { + AppendName(sb, type.ParameterType); + sb.Append('*'); + } + + public override void AppendName(StringBuilder sb, GenericParameterDesc type) + { + string prefix = type.Kind == GenericParameterKind.Type ? "!" : "!!"; + sb.Append(prefix); + sb.Append(type.Name); + } + + public override void AppendName(StringBuilder sb, SignatureTypeVariable type) + { + sb.Append('!'); + sb.Append(type.Index); + } + + public override void AppendName(StringBuilder sb, SignatureMethodVariable type) + { + sb.Append("!!"); + sb.Append(type.Index); + } + + public override void AppendName(StringBuilder sb, FunctionPointerType type) + { + MethodSignature signature = type.Signature; + + AppendName(sb, signature.ReturnType); + + sb.Append(" ("); + for (int i = 0; i < signature.Length; i++) + { + if (i > 0) + sb.Append(", "); + AppendName(sb, signature[i]); + } + + sb.Append(')'); + } + + public override void AppendName(StringBuilder sb, ByRefType type) + { + AppendName(sb, type.ParameterType); + sb.Append('&'); + } + + public override void AppendName(StringBuilder sb, ArrayType type) + { + AppendName(sb, type.ElementType); + sb.Append('['); + + int rank = type.Rank; + if (rank == 1 && type.IsMdArray) + sb.Append('*'); + else + sb.Append(',', type.Rank - 1); + + sb.Append(']'); + } + + protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType type) + { + AppendName(sb, type.GetTypeDefinition()); + sb.Append('['); + + for (int i = 0; i < type.Instantiation.Length; i++) + { + if (i > 0) + sb.Append(", "); + AppendName(sb, type.Instantiation[i]); + } + + sb.Append(']'); + } + + protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) + { + string ns = type.Namespace; + if (ns.Length > 0) + { + sb.Append(ns); + sb.Append('.'); + } + sb.Append(type.Name); + } + + protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) + { + AppendName(sb, containingType); + sb.Append('+'); + sb.Append(nestedType.Name); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index 426bdf6b12346..25726d7e2c549 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -262,6 +262,9 @@ IL\HelperExtensions.cs + + JitInterface\TypeString.cs + JitInterface\JitTypeNameFormatter.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs index cafa1a6f7b7ef..21f9169f294a7 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs @@ -182,7 +182,7 @@ public bool FindSymbol(OutputItem item, out int index) public IEnumerable EnumerateMethods() { DebugNameFormatter nameFormatter = new DebugNameFormatter(); - TypeNameFormatter typeNameFormatter = new JitTypeNameFormatter(); + TypeNameFormatter typeNameFormatter = new TypeString(); foreach (KeyValuePair symbolMethodPair in _methodSymbolMap) { MethodInfo methodInfo = new MethodInfo(); diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj b/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj index 965bf77d0798e..91cbc4903cc65 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj @@ -65,6 +65,9 @@ JitInterface\JitConfigProvider.cs + + JitInterface\TypeString.cs + JitInterface\JitTypeNameFormatter.cs From 42501aae85f11f01a8eef653ef69fb9a5ec86502 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 18:07:09 +0200 Subject: [PATCH 05/50] Use getTypeForPrimitiveNumericClass instead --- src/coreclr/jit/simd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index 9d0def8f21a78..f284afcc5d1da 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -297,7 +297,7 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH if (strcmp(className, "Vector`1") == 0) { CORINFO_CLASS_HANDLE typeArgHnd = info.compCompHnd->getTypeInstantiationArgument(typeHnd, 0); - simdBaseJitType = info.compCompHnd->asCorInfoType(typeArgHnd); + simdBaseJitType = info.compCompHnd->getTypeForPrimitiveNumericClass(typeArgHnd); switch (simdBaseJitType) { From 70d4370d720df973d9d916db9322ab48edfb66aa Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 18:12:07 +0200 Subject: [PATCH 06/50] Nit --- src/coreclr/jit/ee_il_dll.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 1cb6bf57839da..d574ce5b86fd3 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1417,7 +1417,7 @@ struct FilterSuperPMIExceptionsParam_ee_il CORINFO_CLASS_HANDLE clazz; const char** classNamePtr; const char* fieldOrMethodOrClassNamePtr; - char* classNameWidePtr; + char* className; unsigned classSize; EXCEPTION_POINTERS exceptionPointers; }; @@ -1586,14 +1586,14 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) // and call the API again to get the full string. int cchStrLen = pParam->pJitInfo->compCompHnd->appendClassName(nullptr, &len, pParam->clazz); - size_t cchBufLen = (size_t)cchStrLen + /* null terminator */ 1; - pParam->classNameWidePtr = pParam->pThis->getAllocator(CMK_DebugOnly).allocate(cchBufLen); - char* pbuf = pParam->classNameWidePtr; - len = (int)cchBufLen; + size_t cchBufLen = (size_t)cchStrLen + /* null terminator */ 1; + pParam->className = pParam->pThis->getAllocator(CMK_DebugOnly).allocate(cchBufLen); + char* pbuf = pParam->className; + len = (int)cchBufLen; int cchResultStrLen = pParam->pJitInfo->compCompHnd->appendClassName(&pbuf, &len, pParam->clazz); noway_assert(cchStrLen == cchResultStrLen); - noway_assert(pParam->classNameWidePtr[cchResultStrLen] == 0); + noway_assert(pParam->className[cchResultStrLen] == 0); }, ¶m); @@ -1601,11 +1601,11 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) { const char substituteClassName[] = "hackishClassName"; size_t cchLen = ArrLen(substituteClassName); - param.classNameWidePtr = getAllocator(CMK_DebugOnly).allocate(cchLen); - memcpy(param.classNameWidePtr, substituteClassName, cchLen * sizeof(char)); + param.className = getAllocator(CMK_DebugOnly).allocate(cchLen); + memcpy(param.className, substituteClassName, cchLen * sizeof(char)); } - return param.classNameWidePtr; + return param.className; } const WCHAR* Compiler::eeGetCPString(size_t strHandle) From e7d0aa90955f164cc6c220db6672f57b243eed23 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 2 Oct 2022 19:45:34 +0200 Subject: [PATCH 07/50] Fix unsupported test Apparently caller expects the size to be right even for unsupported SIMD types. --- src/coreclr/jit/simd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index f284afcc5d1da..a3f9fae4f3a0f 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -296,6 +296,8 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH if (strcmp(className, "Vector`1") == 0) { + size = getSIMDVectorRegisterByteLength(); + CORINFO_CLASS_HANDLE typeArgHnd = info.compCompHnd->getTypeInstantiationArgument(typeHnd, 0); simdBaseJitType = info.compCompHnd->getTypeForPrimitiveNumericClass(typeArgHnd); @@ -345,7 +347,6 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH if (simdBaseJitType != CORINFO_TYPE_UNDEF) { JITDUMP(" Found type SIMD Vector<%s>\n", varTypeName(JitType2PreciseVarType(simdBaseJitType))); - size = getSIMDVectorRegisterByteLength(); } else { From fcb4cc32623df954058bca912e24ee79a811eecf Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 3 Oct 2022 11:25:52 +0200 Subject: [PATCH 08/50] Address feedback --- src/coreclr/jit/ee_il_dll.cpp | 1 - .../ILCompiler.ReadyToRun.csproj | 4 +- .../ObjectWriter/OutputInfoBuilder.cs | 2 +- .../ObjectWriter/TypeString.cs | 112 ++++++++++++++++++ .../ILCompiler.RyuJit.csproj | 3 - 5 files changed, 114 insertions(+), 8 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index d574ce5b86fd3..f9654f53dab89 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1581,7 +1581,6 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) bool success = eeRunWithSPMIErrorTrap( [](FilterSuperPMIExceptionsParam_ee_il* pParam) { int len = 0; - // Warning: crossgen2 doesn't fully implement the `appendClassName` API. // We need to pass size zero, get back the actual buffer size required, allocate that space, // and call the API again to get the full string. int cchStrLen = pParam->pJitInfo->compCompHnd->appendClassName(nullptr, &len, pParam->clazz); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index 25726d7e2c549..b3e827c63592e 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -225,6 +225,7 @@ + @@ -262,9 +263,6 @@ IL\HelperExtensions.cs - - JitInterface\TypeString.cs - JitInterface\JitTypeNameFormatter.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs index 21f9169f294a7..4ffd41349451f 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs @@ -182,7 +182,7 @@ public bool FindSymbol(OutputItem item, out int index) public IEnumerable EnumerateMethods() { DebugNameFormatter nameFormatter = new DebugNameFormatter(); - TypeNameFormatter typeNameFormatter = new TypeString(); + TypeNameFormatter typeNameFormatter = TypeString.Instance; foreach (KeyValuePair symbolMethodPair in _methodSymbolMap) { MethodInfo methodInfo = new MethodInfo(); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs new file mode 100644 index 0000000000000..a0644eea58b06 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text; + +using Internal.TypeSystem; + +namespace ILCompiler.PEWriter +{ + // This is a very rough equivalent of typestring.cpp in the CLR with only + // basic formatting options. Only used to format type names for map + // files/symbol files. + internal sealed class TypeString : TypeNameFormatter + { + public static TypeString Instance { get; } = new TypeString(); + + public override void AppendName(StringBuilder sb, PointerType type) + { + AppendName(sb, type.ParameterType); + sb.Append('*'); + } + + public override void AppendName(StringBuilder sb, GenericParameterDesc type) + { + string prefix = type.Kind == GenericParameterKind.Type ? "!" : "!!"; + sb.Append(prefix); + sb.Append(type.Name); + } + + public override void AppendName(StringBuilder sb, SignatureTypeVariable type) + { + sb.Append('!'); + sb.Append(type.Index); + } + + public override void AppendName(StringBuilder sb, SignatureMethodVariable type) + { + sb.Append("!!"); + sb.Append(type.Index); + } + + public override void AppendName(StringBuilder sb, FunctionPointerType type) + { + MethodSignature signature = type.Signature; + + AppendName(sb, signature.ReturnType); + + sb.Append(" ("); + for (int i = 0; i < signature.Length; i++) + { + if (i > 0) + sb.Append(", "); + AppendName(sb, signature[i]); + } + + sb.Append(')'); + } + + public override void AppendName(StringBuilder sb, ByRefType type) + { + AppendName(sb, type.ParameterType); + sb.Append('&'); + } + + public override void AppendName(StringBuilder sb, ArrayType type) + { + AppendName(sb, type.ElementType); + sb.Append('['); + + int rank = type.Rank; + if (rank == 1 && type.IsMdArray) + sb.Append('*'); + else + sb.Append(',', type.Rank - 1); + + sb.Append(']'); + } + + protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType type) + { + AppendName(sb, type.GetTypeDefinition()); + sb.Append('['); + + for (int i = 0; i < type.Instantiation.Length; i++) + { + if (i > 0) + sb.Append(", "); + AppendName(sb, type.Instantiation[i]); + } + + sb.Append(']'); + } + + protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) + { + string ns = type.Namespace; + if (ns.Length > 0) + { + sb.Append(ns); + sb.Append('.'); + } + sb.Append(type.Name); + } + + protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) + { + AppendName(sb, containingType); + sb.Append('+'); + sb.Append(nestedType.Name); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj b/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj index 91cbc4903cc65..965bf77d0798e 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj @@ -65,9 +65,6 @@ JitInterface\JitConfigProvider.cs - - JitInterface\TypeString.cs - JitInterface\JitTypeNameFormatter.cs From 0449899cc299e872be76e9664e84f981488703cd Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 3 Oct 2022 11:34:17 +0200 Subject: [PATCH 09/50] Remove leftover file --- .../tools/Common/JitInterface/TypeString.cs | 112 ------------------ 1 file changed, 112 deletions(-) delete mode 100644 src/coreclr/tools/Common/JitInterface/TypeString.cs diff --git a/src/coreclr/tools/Common/JitInterface/TypeString.cs b/src/coreclr/tools/Common/JitInterface/TypeString.cs deleted file mode 100644 index 7bdb02e08107f..0000000000000 --- a/src/coreclr/tools/Common/JitInterface/TypeString.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text; - -using Internal.TypeSystem; - -namespace Internal.JitInterface -{ - // This is a very rough equivalent of typestring.cpp in the CLR. - // There's way more rules to capture. Hopefully, we'll only ever need this in the code to recognize SIMD intrisics - // and we won't need to replicate all the details around escaping and such. - internal sealed class TypeString : TypeNameFormatter - { - public static TypeString Instance { get; } = new TypeString(); - - public override void AppendName(StringBuilder sb, PointerType type) - { - AppendName(sb, type.ParameterType); - sb.Append('*'); - } - - public override void AppendName(StringBuilder sb, GenericParameterDesc type) - { - string prefix = type.Kind == GenericParameterKind.Type ? "!" : "!!"; - sb.Append(prefix); - sb.Append(type.Name); - } - - public override void AppendName(StringBuilder sb, SignatureTypeVariable type) - { - sb.Append('!'); - sb.Append(type.Index); - } - - public override void AppendName(StringBuilder sb, SignatureMethodVariable type) - { - sb.Append("!!"); - sb.Append(type.Index); - } - - public override void AppendName(StringBuilder sb, FunctionPointerType type) - { - MethodSignature signature = type.Signature; - - AppendName(sb, signature.ReturnType); - - sb.Append(" ("); - for (int i = 0; i < signature.Length; i++) - { - if (i > 0) - sb.Append(", "); - AppendName(sb, signature[i]); - } - - sb.Append(')'); - } - - public override void AppendName(StringBuilder sb, ByRefType type) - { - AppendName(sb, type.ParameterType); - sb.Append('&'); - } - - public override void AppendName(StringBuilder sb, ArrayType type) - { - AppendName(sb, type.ElementType); - sb.Append('['); - - int rank = type.Rank; - if (rank == 1 && type.IsMdArray) - sb.Append('*'); - else - sb.Append(',', type.Rank - 1); - - sb.Append(']'); - } - - protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType type) - { - AppendName(sb, type.GetTypeDefinition()); - sb.Append('['); - - for (int i = 0; i < type.Instantiation.Length; i++) - { - if (i > 0) - sb.Append(", "); - AppendName(sb, type.Instantiation[i]); - } - - sb.Append(']'); - } - - protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) - { - string ns = type.Namespace; - if (ns.Length > 0) - { - sb.Append(ns); - sb.Append('.'); - } - sb.Append(type.Name); - } - - protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) - { - AppendName(sb, containingType); - sb.Append('+'); - sb.Append(nestedType.Name); - } - } -} From 04def1fcb4e8dee93e88b40467e4923dcae0f68e Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 3 Oct 2022 20:41:35 +0200 Subject: [PATCH 10/50] Fix test failure --- src/coreclr/jit/simd.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index a3f9fae4f3a0f..5b6de344c8572 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -174,6 +174,11 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH } } + if (sizeBytes != nullptr) + { + *sizeBytes = 0; + } + if ((typeHnd == nullptr) || !isIntrinsicType(typeHnd)) { return CORINFO_TYPE_UNDEF; From 70866d0b06c1c78cce6a234f130c1ab0f03ad30a Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 03:20:27 +0200 Subject: [PATCH 11/50] Optimize * Avoid multiple calls into EE in common case of short strings * Remove StringPrinter::AllocToPrint complexity in face of above * Optimize appendClassName on EE side with inlined implementation of what we need from TypeString that avoids multiple roundtrips in and out of UTF8. Also copy resulting string directly into final buffer. * Revert TypeString::FormatNoInst --- src/coreclr/jit/compiler.h | 6 -- src/coreclr/jit/ee_il_dll.cpp | 41 ++--------- src/coreclr/jit/eeinterface.cpp | 75 ++++++-------------- src/coreclr/vm/jitinterface.cpp | 122 ++++++++++++++++++++++++++++---- src/coreclr/vm/typeparse.h | 19 +++++ src/coreclr/vm/typestring.cpp | 2 +- src/coreclr/vm/typestring.h | 1 - 7 files changed, 154 insertions(+), 112 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 50501646a6e59..3b36eb8f0c7d5 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -11318,12 +11318,6 @@ class StringPrinter m_buffer[m_bufferIndex] = '\0'; } - // Allocate a chunk of 'size' bytes at the current location to be printed. - // Will increment the index by the size specified. Assumes the user will - // copy 'size' characters directly into the buffer returned. - // returned[size] will be null terminated. - char* AllocToPrint(size_t size); - void Printf(const char* format, ...); }; diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index f9654f53dab89..c9c36dedc0b06 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1560,51 +1560,24 @@ unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) //------------------------------------------------------------------------ // eeGetShortClassName: wraps appendClassName to provide functionality -// similar to eeGetClassName(), but returns a class name that is shortened, -// not using full assembly info. +// similar to eeGetClassName(), but returns a class name without any instantiation. // // Arguments: // clsHnd - the class handle to get the type name of // // Return value: -// string class name. Note: unlike eeGetClassName/getClassName, this string is -// allocated from the JIT heap, so care should possibly be taken to avoid leaking it. +// String without instantiation. // const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) { - FilterSuperPMIExceptionsParam_ee_il param; - - param.pThis = this; - param.pJitInfo = &info; - param.clazz = clsHnd; - - bool success = eeRunWithSPMIErrorTrap( - [](FilterSuperPMIExceptionsParam_ee_il* pParam) { - int len = 0; - // We need to pass size zero, get back the actual buffer size required, allocate that space, - // and call the API again to get the full string. - int cchStrLen = pParam->pJitInfo->compCompHnd->appendClassName(nullptr, &len, pParam->clazz); - - size_t cchBufLen = (size_t)cchStrLen + /* null terminator */ 1; - pParam->className = pParam->pThis->getAllocator(CMK_DebugOnly).allocate(cchBufLen); - char* pbuf = pParam->className; - len = (int)cchBufLen; - - int cchResultStrLen = pParam->pJitInfo->compCompHnd->appendClassName(&pbuf, &len, pParam->clazz); - noway_assert(cchStrLen == cchResultStrLen); - noway_assert(pParam->className[cchResultStrLen] == 0); - }, - ¶m); - - if (!success) + StringPrinter printer(getAllocator(CMK_DebugOnly)); + if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, false); })) { - const char substituteClassName[] = "hackishClassName"; - size_t cchLen = ArrLen(substituteClassName); - param.className = getAllocator(CMK_DebugOnly).allocate(cchLen); - memcpy(param.className, substituteClassName, cchLen * sizeof(char)); + printer.Truncate(0); + printer.Printf("hackishClassName"); } - return param.className; + return printer.GetBuffer(); } const WCHAR* Compiler::eeGetCPString(size_t strHandle) diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index dfedc144b210f..f06cdafb88e3a 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -19,55 +19,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #pragma hdrstop #endif -//------------------------------------------------------------------------ -// StringPrinter::Grow: -// Grow the internal buffer to a new specified size. -// -// Arguments: -// newSize - the new size. -// -void StringPrinter::Grow(size_t newSize) -{ - assert(newSize > m_bufferMax); - char* newBuffer = m_alloc.allocate(newSize); - memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too - - m_buffer = newBuffer; - m_bufferMax = newSize; -} - -//------------------------------------------------------------------------ -// StringPrinter::AllocToPrint: -// Allocate a chunk of characters to be filled in by the caller. -// -// Arguments: -// size - the number of characters. -// -// Returns: -// Pointer to the location to start filling in the characters. -// -// Remarks: -// This function will ensure that returned[size] == '\0'. It is expected that -// the caller fills in the characters returned[0..size - 1]. -// -char* StringPrinter::AllocToPrint(size_t size) -{ - size_t newMax = m_bufferMax; - while (newMax - m_bufferIndex <= size) // <= to fit null terminator - { - newMax *= 2; - } - - if (newMax != m_bufferMax) - { - Grow(newMax); - } - - m_bufferIndex += size; - m_buffer[m_bufferIndex] = '\0'; - return m_buffer + (m_bufferIndex - size); -} - //------------------------------------------------------------------------ // StringPrinter::Printf: // Print a formatted string. @@ -93,7 +44,12 @@ void StringPrinter::Printf(const char* format, ...) if (printed < 0) { // buffer too small - Grow(m_bufferMax * 2); + size_t newSize = m_bufferMax * 2; + char* newBuffer = m_alloc.allocate(newSize); + memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too + + m_buffer = newBuffer; + m_bufferMax = newSize; } else { @@ -155,17 +111,26 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, return; } - int size = 0; - int actualLen = info.compCompHnd->appendClassName(nullptr, &size, clsHnd); + char buffer[256]; + char* pBufferMut = buffer; + int size = sizeof(buffer); + int actualLen = info.compCompHnd->appendClassName(&pBufferMut, &size, clsHnd); if (actualLen <= 0) { printer->Printf(""); } + else if (actualLen < sizeof(buffer)) + { + printer->Printf("%s", buffer); + } else { - char* name = printer->AllocToPrint(static_cast(actualLen)); - actualLen++; // null-terminator - info.compCompHnd->appendClassName(&name, &actualLen, clsHnd); + char* pBuffer = new (this, CMK_DebugOnly) char[actualLen + 1]; + pBufferMut = pBuffer; + size = actualLen + 1; + info.compCompHnd->appendClassName(&pBufferMut, &size, clsHnd); + + printer->Printf("%s", pBuffer); } if (!includeInstantiation) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 78331eaff6cbc..15000046cf6d4 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3300,6 +3300,46 @@ const char* CEEInfo::getHelperName (CorInfoHelpFunc ftnNum) return result; } +template +static void AppendTypeNameEscaped(const char* str, TAppend append) +{ + CONTRACTL { + MODE_PREEMPTIVE; + THROWS; + GC_TRIGGERS; + } CONTRACTL_END; + + bool hasReservedChar = false; + for (const char* curChar = str; *curChar; curChar++) + { + if (IsTypeNameReservedChar(*curChar)) + { + hasReservedChar = true; + break; + } + } + + if (!hasReservedChar) + { + append(str); + return; + } + + while (*str) + { + if (IsTypeNameReservedChar(*str)) + { + append("\\"); + } + else + { + char singleChar[2] = { *str, 0 }; + append(singleChar); + } + + str++; + } +} /*********************************************************************/ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, @@ -3316,25 +3356,77 @@ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBu JIT_TO_EE_TRANSITION(); TypeHandle th(clsHnd); - StackSString ss; - TypeString::AppendType(ss, th, TypeString::FormatNamespace | TypeString::FormatNoInst); - const char* szString = ss.GetUTF8(); - nLen = (int)strlen(szString); - if (*pnBufLen > 0) + IMDInternalImport* pImport = th.GetMethodTable()->GetMDImport(); + + auto append = [ppBuf, pnBufLen, &nLen](const char* str) { - // Copy as much as will fit. - char* pBuf = *ppBuf; - int nLenToCopy = min(*pnBufLen, nLen + /* null terminator */ 1); - for (int i = 0; i < nLenToCopy - 1; i++) + size_t strLen = strlen(str); + + if ((ppBuf != nullptr) && (pnBufLen != nullptr)) { - pBuf[i] = szString[i]; + if (strLen >= static_cast(*pnBufLen)) + { + if (*pnBufLen > 1) + { + memcpy(*ppBuf, str, *pnBufLen - 1); + *ppBuf += *pnBufLen - 1; + *pnBufLen = 1; + } + } + else + { + memcpy(*ppBuf, str, strLen); + *ppBuf += strLen; + } + } + + nLen += strLen; + }; + + // Subset of TypeString that does just what we need while staying in UTF8. + mdTypeDef td = th.GetCl(); + if (IsNilToken(td)) + { + append("(dynamicClass)"); + } + else + { + DWORD attr; + IfFailThrow(pImport->GetTypeDefProps(td, &attr, NULL)); + + StackSArray nestedHierarchy; + nestedHierarchy.Append(td); + + if (IsTdNested(attr)) + { + while (SUCCEEDED(pImport->GetNestedClassProps(td, &td))) + nestedHierarchy.Append(td); } - pBuf[nLenToCopy - 1] = 0; // null terminate the string if it wasn't already - // Update the buffer pointer and buffer size pointer based on the amount actually copied. - // Don't include the null terminator. `*ppBuf` will point at the added null terminator. - (*ppBuf) += nLenToCopy - 1; - (*pnBufLen) -= nLenToCopy - 1; + for (SCOUNT_T i = nestedHierarchy.GetCount() - 1; i >= 0; i--) + { + LPCUTF8 name; + LPCUTF8 nameSpace; + IfFailThrow(pImport->GetNameOfTypeDef(nestedHierarchy[i], &name, &nameSpace)); + + if ((nameSpace != NULL) && *nameSpace != '\0') + { + AppendTypeNameEscaped(nameSpace, append); + append("."); + } + + AppendTypeNameEscaped(name, append); + + if (i != 0) + { + append("+"); + } + } + } + + if (*pnBufLen > 0) + { + **ppBuf = '\0'; } EE_TO_JIT_TRANSITION(); diff --git a/src/coreclr/vm/typeparse.h b/src/coreclr/vm/typeparse.h index 8491e0deeb992..d30696568bec0 100644 --- a/src/coreclr/vm/typeparse.h +++ b/src/coreclr/vm/typeparse.h @@ -37,6 +37,25 @@ bool inline IsTypeNameReservedChar(WCHAR ch) } } +bool inline IsTypeNameReservedChar(char ch) +{ + LIMITED_METHOD_CONTRACT; + + switch (ch) + { + case ',': + case '[': + case ']': + case '&': + case '*': + case '+': + case '\\': + return true; + + default: + return false; + } +} DomainAssembly * LoadDomainAssembly( SString * psszAssemblySpec, diff --git a/src/coreclr/vm/typestring.cpp b/src/coreclr/vm/typestring.cpp index 8368d312add7b..0a05972721a1a 100644 --- a/src/coreclr/vm/typestring.cpp +++ b/src/coreclr/vm/typestring.cpp @@ -789,7 +789,7 @@ void TypeString::AppendType(TypeNameBuilder& tnb, TypeHandle ty, Instantiation t } // Append the instantiation - if ((format & (FormatNamespace|FormatAssembly)) && !(format & FormatNoInst) && ty.HasInstantiation() && (!ty.IsGenericTypeDefinition() || bToString)) + if ((format & (FormatNamespace|FormatAssembly)) && ty.HasInstantiation() && (!ty.IsGenericTypeDefinition() || bToString)) { if (typeInstantiation.IsEmpty()) AppendInst(tnb, ty.GetInstantiation(), format); diff --git a/src/coreclr/vm/typestring.h b/src/coreclr/vm/typestring.h index 928ac0b31a7d4..f003984633c35 100644 --- a/src/coreclr/vm/typestring.h +++ b/src/coreclr/vm/typestring.h @@ -158,7 +158,6 @@ class TypeString FormatAngleBrackets = 0x00000040, // Whether generic types are C or C[T] FormatStubInfo = 0x00000080, // Include stub info like {unbox-stub} FormatGenericParam = 0x00000100, // Use !name and !!name for generic type and method parameters - FormatNoInst = 0x00000200, // Do not include instantiation } FormatFlags; From 9b29a16c8ef25249dcac5ad9d1893cfb23117853 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 03:31:52 +0200 Subject: [PATCH 12/50] Remove StringPrinter::Grow --- src/coreclr/jit/compiler.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 3b36eb8f0c7d5..44960a79351c4 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -11286,8 +11286,6 @@ class StringPrinter size_t m_bufferMax; size_t m_bufferIndex = 0; - void Grow(size_t newSize); - public: StringPrinter(CompAllocator alloc, char* buffer = nullptr, size_t bufferMax = 0) : m_alloc(alloc), m_buffer(buffer), m_bufferMax(bufferMax) From 9bc66200f10e28023be671c0d251f3694f0f89b2 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 03:36:51 +0200 Subject: [PATCH 13/50] Fix contract, fix compiler error on x64 --- src/coreclr/vm/jitinterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 15000046cf6d4..04e1efe9ac5d7 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3305,8 +3305,8 @@ static void AppendTypeNameEscaped(const char* str, TAppend append) { CONTRACTL { MODE_PREEMPTIVE; - THROWS; - GC_TRIGGERS; + NOTHROW; + GC_NOTRIGGER; } CONTRACTL_END; bool hasReservedChar = false; @@ -3380,7 +3380,7 @@ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBu } } - nLen += strLen; + nLen = nLen + static_cast(strLen); }; // Subset of TypeString that does just what we need while staying in UTF8. From ffaf9a4c3958c91f39b31a11325e002370a02539 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 03:58:07 +0200 Subject: [PATCH 14/50] Fix escaping --- src/coreclr/vm/jitinterface.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 04e1efe9ac5d7..0909a277fb765 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3331,11 +3331,9 @@ static void AppendTypeNameEscaped(const char* str, TAppend append) { append("\\"); } - else - { - char singleChar[2] = { *str, 0 }; - append(singleChar); - } + + char singleChar[2] = { *str, 0 }; + append(singleChar); str++; } From 0f37c4ed27f8e08f04cc731c9d3ba87c6ae0c0a8 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 13:22:01 +0200 Subject: [PATCH 15/50] Fix GCC build --- src/coreclr/jit/eeinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index f06cdafb88e3a..6b1bb93263dac 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -119,7 +119,7 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, { printer->Printf(""); } - else if (actualLen < sizeof(buffer)) + else if (static_cast(actualLen) < sizeof(buffer)) { printer->Printf("%s", buffer); } From 77e799a94ac4ecd2fb5d180802a71d1c72b42693 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 13:24:39 +0200 Subject: [PATCH 16/50] Clarify comment --- src/coreclr/vm/jitinterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 0909a277fb765..3ad778b79021b 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3381,7 +3381,9 @@ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBu nLen = nLen + static_cast(strLen); }; - // Subset of TypeString that does just what we need while staying in UTF8. + // Subset of TypeString that does just what we need while staying in UTF8 + // and avoiding expensive copies. This function is called a lot in checked + // builds. mdTypeDef td = th.GetCl(); if (IsNilToken(td)) { From 0b588599320e6b7b9596d039aea2245ec0e6f205 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 14:01:07 +0200 Subject: [PATCH 17/50] Avoid unnecessary eeGetMethodName call We only use this name for helpers and it is actually very expensive to ask the EE for it due to generic instantiations. --- src/coreclr/jit/eeinterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 6b1bb93263dac..fa8d733d935dd 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -318,10 +318,10 @@ void Compiler::eePrintMethod(StringPrinter* printer, // const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType, bool includeThisSpecifier) { - const char* className; - const char* methodName = eeGetMethodName(hnd, &className); if ((eeGetHelperNum(hnd) != CORINFO_HELP_UNDEF) || eeIsNativeMethod(hnd)) { + const char* className; + const char* methodName = eeGetMethodName(hnd, &className); return methodName; } From b987608c927778e2bd0356845f86c0a8f174faeb Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 14:14:01 +0200 Subject: [PATCH 18/50] Nit --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 3ad778b79021b..1d9819bfe6483 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3409,7 +3409,7 @@ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBu LPCUTF8 nameSpace; IfFailThrow(pImport->GetNameOfTypeDef(nestedHierarchy[i], &name, &nameSpace)); - if ((nameSpace != NULL) && *nameSpace != '\0') + if ((nameSpace != NULL) && (*nameSpace != '\0')) { AppendTypeNameEscaped(nameSpace, append); append("."); From 17388ed15393477bc4074fa9213bdefa7f1c7e77 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 16:45:15 +0200 Subject: [PATCH 19/50] Remove StringPrinter::Printf in favor of Append __vsnprintf_s seems to allocate heap memory on Windows and ends up taking a lock. This can result in a ton of contention with checked JIT. The worst part is that we do not even need the format strings, so just get rid of it and use a simple memcpy to append. With this the PR makes crossgen2 with checked JIT around 2 seconds faster on my 5950X (32 threads, time goes from 7.5 seconds -> 5.5 seconds). --- src/coreclr/jit/compiler.h | 4 +- src/coreclr/jit/ee_il_dll.cpp | 4 +- src/coreclr/jit/eeinterface.cpp | 116 +++++++++++++++++++------------- 3 files changed, 74 insertions(+), 50 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 44960a79351c4..834b9d609ed48 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -11286,6 +11286,7 @@ class StringPrinter size_t m_bufferMax; size_t m_bufferIndex = 0; + void Grow(size_t newSize); public: StringPrinter(CompAllocator alloc, char* buffer = nullptr, size_t bufferMax = 0) : m_alloc(alloc), m_buffer(buffer), m_bufferMax(bufferMax) @@ -11316,7 +11317,8 @@ class StringPrinter m_buffer[m_bufferIndex] = '\0'; } - void Printf(const char* format, ...); + void Append(const char* str); + void Append(char chr); }; /***************************************************************************** diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index c9c36dedc0b06..30bf5d308e706 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1518,7 +1518,7 @@ const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd) if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) { printer.Truncate(0); - printer.Printf("hackishClassName"); + printer.Append("hackishClassName"); } return printer.GetBuffer(); @@ -1574,7 +1574,7 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, false); })) { printer.Truncate(0); - printer.Printf("hackishClassName"); + printer.Append("hackishClassName"); } return printer.GetBuffer(); diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index fa8d733d935dd..cd65d52db14c0 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -20,45 +20,67 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif //------------------------------------------------------------------------ -// StringPrinter::Printf: -// Print a formatted string. +// StringPrinter::Grow: +// Grow the internal buffer to a new specified size. // // Arguments: -// format - the format +// newSize - the new size. // -void StringPrinter::Printf(const char* format, ...) +void StringPrinter::Grow(size_t newSize) { - va_list args; - va_start(args, format); + assert(newSize > m_bufferMax); + char* newBuffer = m_alloc.allocate(newSize); + memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too - while (true) - { - size_t bufferLeft = m_bufferMax - m_bufferIndex; - assert(bufferLeft >= 1); // always fit null terminator + m_buffer = newBuffer; + m_bufferMax = newSize; +} - va_list argsCopy; - va_copy(argsCopy, args); - int printed = _vsnprintf_s(m_buffer + m_bufferIndex, bufferLeft, _TRUNCATE, format, argsCopy); - va_end(argsCopy); +//------------------------------------------------------------------------ +// StringPrinter::Append: +// Append a substring to the internal buffer. +// +// Arguments: +// str - the substring to append +// +void StringPrinter::Append(const char* str) +{ + size_t strLen = strlen(str); - if (printed < 0) - { - // buffer too small - size_t newSize = m_bufferMax * 2; - char* newBuffer = m_alloc.allocate(newSize); - memcpy(newBuffer, m_buffer, m_bufferIndex + 1); // copy null terminator too + size_t newIndex = m_bufferIndex + strLen; - m_buffer = newBuffer; - m_bufferMax = newSize; - } - else + if (newIndex >= m_bufferMax) + { + size_t newSize = m_bufferMax * 2; + while (newIndex >= newSize) { - m_bufferIndex = m_bufferIndex + static_cast(printed); - break; + newSize *= 2; } + + Grow(newSize); + } + + memcpy(&m_buffer[m_bufferIndex], str, strLen + 1); + m_bufferIndex += strLen; +} + +//------------------------------------------------------------------------ +// StringPrinter::Append: +// Append a single character to the internal buffer. +// +// Arguments: +// chr - the character +// +void StringPrinter::Append(char chr) +{ + if (m_bufferIndex + 1 >= m_bufferMax) + { + Grow(m_bufferMax * 2); } - va_end(args); + m_buffer[m_bufferIndex] = chr; + m_buffer[m_bufferIndex + 1] = '\0'; + m_bufferIndex++; } #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) @@ -73,7 +95,7 @@ void StringPrinter::Printf(const char* format, ...) // void Compiler::eePrintJitType(StringPrinter* printer, var_types jitType) { - printer->Printf("%s", varTypeName(jitType)); + printer->Append(varTypeName(jitType)); } //------------------------------------------------------------------------ @@ -102,12 +124,12 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, eePrintJitType(printer, JitType2PreciseVarType(childType)); } - printer->Printf("["); + printer->Append('['); for (unsigned i = 1; i < arrayRank; i++) { - printer->Printf(","); + printer->Append(','); } - printer->Printf("]"); + printer->Append(']'); return; } @@ -117,11 +139,11 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, int actualLen = info.compCompHnd->appendClassName(&pBufferMut, &size, clsHnd); if (actualLen <= 0) { - printer->Printf(""); + printer->Append(""); } else if (static_cast(actualLen) < sizeof(buffer)) { - printer->Printf("%s", buffer); + printer->Append(buffer); } else { @@ -130,7 +152,7 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, size = actualLen + 1; info.compCompHnd->appendClassName(&pBufferMut, &size, clsHnd); - printer->Printf("%s", pBuffer); + printer->Append(pBuffer); } if (!includeInstantiation) @@ -148,14 +170,14 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, break; } - printer->Printf("%c", pref); + printer->Append(pref); pref = ','; eePrintTypeOrJitAlias(printer, typeArg, true); } if (pref != '[') { - printer->Printf("]"); + printer->Append(']'); } } @@ -211,36 +233,36 @@ void Compiler::eePrintMethod(StringPrinter* printer, if (clsHnd != NO_CLASS_HANDLE) { eePrintType(printer, clsHnd, includeClassInstantiation); - printer->Printf(":"); + printer->Append(':'); } const char* methName = info.compCompHnd->getMethodName(methHnd, nullptr); - printer->Printf("%s", methName); + printer->Append(methName); if (includeMethodInstantiation && (sig->sigInst.methInstCount > 0)) { - printer->Printf("["); + printer->Append('['); for (unsigned i = 0; i < sig->sigInst.methInstCount; i++) { if (i > 0) { - printer->Printf(","); + printer->Append(','); } eePrintTypeOrJitAlias(printer, sig->sigInst.methInst[i], true); } - printer->Printf("]"); + printer->Append(']'); } if (includeSignature) { - printer->Printf("("); + printer->Append('('); CORINFO_ARG_LIST_HANDLE argLst = sig->args; for (unsigned i = 0; i < sig->numArgs; i++) { if (i > 0) - printer->Printf(","); + printer->Append(','); CORINFO_CLASS_HANDLE vcClsHnd; var_types type = JitType2PreciseVarType(strip(info.compCompHnd->getArgType(sig, argLst, &vcClsHnd))); @@ -267,14 +289,14 @@ void Compiler::eePrintMethod(StringPrinter* printer, argLst = info.compCompHnd->getArgNext(argLst); } - printer->Printf(")"); + printer->Append(')'); if (includeReturnType) { var_types retType = JitType2PreciseVarType(sig->retType); if (retType != TYP_VOID) { - printer->Printf(":"); + printer->Append(':'); switch (retType) { case TYP_REF: @@ -299,7 +321,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, // the this pointer type as the first element of the arg type list if (includeThisSpecifier && sig->hasThis() && !sig->hasExplicitThis()) { - printer->Printf(":this"); + printer->Append(":this"); } } } @@ -380,7 +402,7 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ } p.Truncate(0); - p.Printf("hackishClassName:hackishMethodName(?)"); + p.Append("hackishClassName:hackishMethodName(?)"); return p.GetBuffer(); } From 08a63d915c40e014642e02337c38677e7ff1b8b5 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 4 Oct 2022 16:50:16 +0200 Subject: [PATCH 20/50] Run jit-format --- src/coreclr/jit/compiler.h | 1 + src/coreclr/jit/eeinterface.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 834b9d609ed48..0bf643989a6af 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -11287,6 +11287,7 @@ class StringPrinter size_t m_bufferIndex = 0; void Grow(size_t newSize); + public: StringPrinter(CompAllocator alloc, char* buffer = nullptr, size_t bufferMax = 0) : m_alloc(alloc), m_buffer(buffer), m_bufferMax(bufferMax) diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index cd65d52db14c0..608286d7b8afc 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -78,7 +78,7 @@ void StringPrinter::Append(char chr) Grow(m_bufferMax * 2); } - m_buffer[m_bufferIndex] = chr; + m_buffer[m_bufferIndex] = chr; m_buffer[m_bufferIndex + 1] = '\0'; m_bufferIndex++; } From 37f5cfae99105231ac76a58e36726f9dbd3d5bc0 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sat, 8 Oct 2022 17:42:07 +0200 Subject: [PATCH 21/50] Fix build --- .../tools/Common/JitInterface/CorInfoBase.cs | 278 +++++++++--------- 1 file changed, 139 insertions(+), 139 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index 3df2ba5a77ea7..ba8637f79bc8c 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -2610,7 +2610,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 177); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 176); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; @@ -2651,146 +2651,146 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[36] = (delegate* unmanaged)&_getStringLiteral; callbacks[37] = (delegate* unmanaged)&_printObjectDescription; callbacks[38] = (delegate* unmanaged)&_asCorInfoType; - callbacks[39] = (delegate* unmanaged)&_getClassName; - callbacks[40] = (delegate* unmanaged)&_getClassNameFromMetadata; - callbacks[41] = (delegate* unmanaged)&_getTypeInstantiationArgument; - callbacks[42] = (delegate* unmanaged)&_appendClassName; - callbacks[43] = (delegate* unmanaged)&_isValueClass; - callbacks[44] = (delegate* unmanaged)&_canInlineTypeCheck; - callbacks[45] = (delegate* unmanaged)&_getClassAttribs; - callbacks[46] = (delegate* unmanaged)&_getClassModule; - callbacks[47] = (delegate* unmanaged)&_getModuleAssembly; - callbacks[48] = (delegate* unmanaged)&_getAssemblyName; - callbacks[49] = (delegate* unmanaged)&_LongLifetimeMalloc; - callbacks[50] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[51] = (delegate* unmanaged)&_getClassModuleIdForStatics; - callbacks[52] = (delegate* unmanaged)&_getClassSize; - callbacks[53] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[54] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[55] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[56] = (delegate* unmanaged)&_getClassGClayout; - callbacks[57] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[58] = (delegate* unmanaged)&_getFieldInClass; - callbacks[59] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[60] = (delegate* unmanaged)&_getNewHelper; - callbacks[61] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[62] = (delegate* unmanaged)&_getCastingHelper; - callbacks[63] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[64] = (delegate* unmanaged)&_getTypeForBox; - callbacks[65] = (delegate* unmanaged)&_getBoxHelper; - callbacks[66] = (delegate* unmanaged)&_getUnBoxHelper; - callbacks[67] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[68] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[69] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[70] = (delegate* unmanaged)&_getHelperName; - callbacks[71] = (delegate* unmanaged)&_initClass; - callbacks[72] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[73] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[76] = (delegate* unmanaged)&_canCast; - callbacks[77] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[78] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[79] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[80] = (delegate* unmanaged)&_mergeClasses; - callbacks[81] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[82] = (delegate* unmanaged)&_getParentType; - callbacks[83] = (delegate* unmanaged)&_getChildType; - callbacks[84] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[85] = (delegate* unmanaged)&_isSDArray; - callbacks[86] = (delegate* unmanaged)&_getArrayRank; - callbacks[87] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[88] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[89] = (delegate* unmanaged)&_canAccessClass; - callbacks[90] = (delegate* unmanaged)&_getFieldName; - callbacks[91] = (delegate* unmanaged)&_getFieldClass; - callbacks[92] = (delegate* unmanaged)&_getFieldType; - callbacks[93] = (delegate* unmanaged)&_getFieldOffset; - callbacks[94] = (delegate* unmanaged)&_getFieldInfo; - callbacks[95] = (delegate* unmanaged)&_isFieldStatic; - callbacks[96] = (delegate* unmanaged)&_getBoundaries; - callbacks[97] = (delegate* unmanaged)&_setBoundaries; - callbacks[98] = (delegate* unmanaged)&_getVars; - callbacks[99] = (delegate* unmanaged)&_setVars; - callbacks[100] = (delegate* unmanaged)&_reportRichMappings; - callbacks[101] = (delegate* unmanaged)&_allocateArray; - callbacks[102] = (delegate* unmanaged)&_freeArray; - callbacks[103] = (delegate* unmanaged)&_getArgNext; - callbacks[104] = (delegate* unmanaged)&_getArgType; - callbacks[105] = (delegate* unmanaged)&_getExactClasses; - callbacks[106] = (delegate* unmanaged)&_getArgClass; - callbacks[107] = (delegate* unmanaged)&_getHFAType; - callbacks[108] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[109] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[110] = (delegate* unmanaged)&_FilterException; - callbacks[111] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[112] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[113] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[114] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[115] = (delegate* unmanaged)&_getEEInfo; - callbacks[116] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[117] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[118] = (delegate* unmanaged)&_getMethodName; - callbacks[119] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[120] = (delegate* unmanaged)&_getMethodHash; - callbacks[121] = (delegate* unmanaged)&_findNameOfToken; - callbacks[122] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[123] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[124] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[125] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[126] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[127] = (delegate* unmanaged)&_getHelperFtn; - callbacks[128] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[129] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[130] = (delegate* unmanaged)&_getMethodSync; - callbacks[131] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[132] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[133] = (delegate* unmanaged)&_embedClassHandle; - callbacks[134] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[135] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[136] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[137] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[138] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[139] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[140] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[141] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[142] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[143] = (delegate* unmanaged)&_getCallInfo; - callbacks[144] = (delegate* unmanaged)&_canAccessFamily; - callbacks[145] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[146] = (delegate* unmanaged)&_getClassDomainID; - callbacks[147] = (delegate* unmanaged)&_getFieldAddress; - callbacks[148] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[149] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[150] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[151] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[152] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[153] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[154] = (delegate* unmanaged)&_addActiveDependency; - callbacks[155] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[156] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[157] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[158] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[159] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[160] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[161] = (delegate* unmanaged)&_allocMem; - callbacks[162] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[163] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[164] = (delegate* unmanaged)&_allocGCInfo; - callbacks[165] = (delegate* unmanaged)&_setEHcount; - callbacks[166] = (delegate* unmanaged)&_setEHinfo; - callbacks[167] = (delegate* unmanaged)&_logMsg; - callbacks[168] = (delegate* unmanaged)&_doAssert; - callbacks[169] = (delegate* unmanaged)&_reportFatalError; - callbacks[170] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[171] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[172] = (delegate* unmanaged)&_recordCallSite; - callbacks[173] = (delegate* unmanaged)&_recordRelocation; - callbacks[174] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[175] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[176] = (delegate* unmanaged)&_getJitFlags; + callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; + callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; + callbacks[41] = (delegate* unmanaged)&_appendClassName; + callbacks[42] = (delegate* unmanaged)&_isValueClass; + callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; + callbacks[44] = (delegate* unmanaged)&_getClassAttribs; + callbacks[45] = (delegate* unmanaged)&_getClassModule; + callbacks[46] = (delegate* unmanaged)&_getModuleAssembly; + callbacks[47] = (delegate* unmanaged)&_getAssemblyName; + callbacks[48] = (delegate* unmanaged)&_LongLifetimeMalloc; + callbacks[49] = (delegate* unmanaged)&_LongLifetimeFree; + callbacks[50] = (delegate* unmanaged)&_getClassModuleIdForStatics; + callbacks[51] = (delegate* unmanaged)&_getClassSize; + callbacks[52] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[53] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[54] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[55] = (delegate* unmanaged)&_getClassGClayout; + callbacks[56] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[57] = (delegate* unmanaged)&_getFieldInClass; + callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[59] = (delegate* unmanaged)&_getNewHelper; + callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[61] = (delegate* unmanaged)&_getCastingHelper; + callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[63] = (delegate* unmanaged)&_getTypeForBox; + callbacks[64] = (delegate* unmanaged)&_getBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; + callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[67] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[68] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[69] = (delegate* unmanaged)&_getHelperName; + callbacks[70] = (delegate* unmanaged)&_initClass; + callbacks[71] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[72] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[75] = (delegate* unmanaged)&_canCast; + callbacks[76] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[79] = (delegate* unmanaged)&_mergeClasses; + callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[81] = (delegate* unmanaged)&_getParentType; + callbacks[82] = (delegate* unmanaged)&_getChildType; + callbacks[83] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[84] = (delegate* unmanaged)&_isSDArray; + callbacks[85] = (delegate* unmanaged)&_getArrayRank; + callbacks[86] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[87] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[88] = (delegate* unmanaged)&_canAccessClass; + callbacks[89] = (delegate* unmanaged)&_getFieldName; + callbacks[90] = (delegate* unmanaged)&_getFieldClass; + callbacks[91] = (delegate* unmanaged)&_getFieldType; + callbacks[92] = (delegate* unmanaged)&_getFieldOffset; + callbacks[93] = (delegate* unmanaged)&_getFieldInfo; + callbacks[94] = (delegate* unmanaged)&_isFieldStatic; + callbacks[95] = (delegate* unmanaged)&_getBoundaries; + callbacks[96] = (delegate* unmanaged)&_setBoundaries; + callbacks[97] = (delegate* unmanaged)&_getVars; + callbacks[98] = (delegate* unmanaged)&_setVars; + callbacks[99] = (delegate* unmanaged)&_reportRichMappings; + callbacks[100] = (delegate* unmanaged)&_allocateArray; + callbacks[101] = (delegate* unmanaged)&_freeArray; + callbacks[102] = (delegate* unmanaged)&_getArgNext; + callbacks[103] = (delegate* unmanaged)&_getArgType; + callbacks[104] = (delegate* unmanaged)&_getExactClasses; + callbacks[105] = (delegate* unmanaged)&_getArgClass; + callbacks[106] = (delegate* unmanaged)&_getHFAType; + callbacks[107] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[108] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[109] = (delegate* unmanaged)&_FilterException; + callbacks[110] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[111] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[112] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[113] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[114] = (delegate* unmanaged)&_getEEInfo; + callbacks[115] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[116] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[117] = (delegate* unmanaged)&_getMethodName; + callbacks[118] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[119] = (delegate* unmanaged)&_getMethodHash; + callbacks[120] = (delegate* unmanaged)&_findNameOfToken; + callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[122] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[123] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[124] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[125] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[126] = (delegate* unmanaged)&_getHelperFtn; + callbacks[127] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[128] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[129] = (delegate* unmanaged)&_getMethodSync; + callbacks[130] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[131] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[132] = (delegate* unmanaged)&_embedClassHandle; + callbacks[133] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[134] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[135] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[136] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[137] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[138] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[139] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[140] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[141] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[142] = (delegate* unmanaged)&_getCallInfo; + callbacks[143] = (delegate* unmanaged)&_canAccessFamily; + callbacks[144] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[145] = (delegate* unmanaged)&_getClassDomainID; + callbacks[146] = (delegate* unmanaged)&_getFieldAddress; + callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[148] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[149] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[150] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[151] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[152] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[153] = (delegate* unmanaged)&_addActiveDependency; + callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[160] = (delegate* unmanaged)&_allocMem; + callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[163] = (delegate* unmanaged)&_allocGCInfo; + callbacks[164] = (delegate* unmanaged)&_setEHcount; + callbacks[165] = (delegate* unmanaged)&_setEHinfo; + callbacks[166] = (delegate* unmanaged)&_logMsg; + callbacks[167] = (delegate* unmanaged)&_doAssert; + callbacks[168] = (delegate* unmanaged)&_reportFatalError; + callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[171] = (delegate* unmanaged)&_recordCallSite; + callbacks[172] = (delegate* unmanaged)&_recordRelocation; + callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[175] = (delegate* unmanaged)&_getJitFlags; return (IntPtr)callbacks; } } } + From 539162c62bab50e84f2d2eabbe46d7ae440cfb19 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sat, 8 Oct 2022 20:38:44 +0200 Subject: [PATCH 22/50] appendClassName -> printClassName --- src/coreclr/inc/corinfo.h | 43 ++- src/coreclr/inc/icorjitinfoimpl_generated.h | 9 +- src/coreclr/jit/ICorJitInfo_API_names.h | 2 +- src/coreclr/jit/ICorJitInfo_API_wrapper.hpp | 15 +- src/coreclr/jit/ee_il_dll.cpp | 3 +- src/coreclr/jit/eeinterface.cpp | 18 +- .../tools/Common/JitInterface/CorInfoBase.cs | 7 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 33 +-- .../JitInterface/JitTypeNameFormatter.cs | 8 +- .../ThunkGenerator/ThunkInput.txt | 3 +- .../tools/aot/jitinterface/jitinterface.h | 13 +- src/coreclr/tools/superpmi/mcs/verbildump.h | 6 +- .../tools/superpmi/superpmi-shared/agnostic.h | 8 +- .../tools/superpmi/superpmi-shared/lwmlist.h | 4 +- .../superpmi-shared/methodcontext.cpp | 257 ++++++++---------- .../superpmi/superpmi-shared/methodcontext.h | 36 ++- .../superpmi-shim-collector/icorjitinfo.cpp | 40 +-- .../superpmi-shim-counter/icorjitinfo.cpp | 13 +- .../superpmi-shim-simple/icorjitinfo.cpp | 11 +- .../tools/superpmi/superpmi/icorjitinfo.cpp | 33 +-- src/coreclr/vm/jitinterface.cpp | 44 +-- 21 files changed, 262 insertions(+), 344 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 919edcf6359b1..0ea9a3ddd01f3 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2315,35 +2315,28 @@ class ICorStaticInfo unsigned index ) = 0; - // Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer. - // Includes enclosing classes and namespaces. + // printClassName: Prints the name for a specified class, taking namespaces + // and nested classes into account. // // Arguments: - // ppBuf - Pointer to buffer pointer. See below for details. - // pnBufLen - Pointer to buffer length. Must not be nullptr. See below for details. + // cls - Class handle + // buffer - Buffer to print chars into + // bufferSize - Buffer size + // pRequiredBufferSize - Required length of a buffer to fit the full + // name, including null terminator. // - // Returns the length of the representation, as a count of characters (but not including a terminating null character). - // Note that this will always be the actual number of characters required by the representation, even if the string - // was truncated when copied to the buffer. - // - // Operation: - // - // On entry, `*pnBufLen` specifies the size of the buffer pointed to by `*ppBuf` as a count of characters. - // There are two cases: - // 1. If the size is zero, the function computes the length of the representation and returns that. - // `ppBuf` is ignored (and may be nullptr) and `*ppBuf` and `*pnBufLen` are not updated. - // 2. If the size is non-zero, the buffer pointed to by `*ppBuf` is (at least) that size. The class name - // representation is copied to the buffer pointed to by `*ppBuf`. As many characters of the name as will fit in the - // buffer are copied. Thus, if the name is larger than the size of the buffer, the name will be truncated in the buffer. - // The buffer is guaranteed to be null terminated. Thus, the size must be large enough to include a terminating null - // character, or the string will be truncated to include one. On exit, `*pnBufLen` is updated by subtracting the - // number of characters that were actually copied to the buffer. Also, `*ppBuf` is updated to point at the null - // character that was added to the end of the name. + // Return Value: + // Number of bytes written in the buffer excluding the null terminator. // - virtual int appendClassName( - _Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, /* IN OUT */ - int* pnBufLen, /* IN OUT */ - CORINFO_CLASS_HANDLE cls) = 0; + // Notes: + // This function will always null terminate the buffer. + // + virtual size_t printClassName ( + CORINFO_CLASS_HANDLE cls, /* IN */ + char* buffer, /* OUT */ + size_t bufferSize, /* IN */ + size_t* pRequiredBufferSize = nullptr /* OUT */ + ) = 0; // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & CORINFO_FLG_VALUECLASS, except faster. virtual bool isValueClass(CORINFO_CLASS_HANDLE cls) = 0; diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index 1a568f6fa9575..38e007627e544 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -192,10 +192,11 @@ CORINFO_CLASS_HANDLE getTypeInstantiationArgument( CORINFO_CLASS_HANDLE cls, unsigned index) override; -int appendClassName( - char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) override; +size_t printClassName( + CORINFO_CLASS_HANDLE cls, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) override; bool isValueClass( CORINFO_CLASS_HANDLE cls) override; diff --git a/src/coreclr/jit/ICorJitInfo_API_names.h b/src/coreclr/jit/ICorJitInfo_API_names.h index 9ea5e91c55ce6..66b9e94bc47ed 100644 --- a/src/coreclr/jit/ICorJitInfo_API_names.h +++ b/src/coreclr/jit/ICorJitInfo_API_names.h @@ -45,7 +45,7 @@ DEF_CLR_API(printObjectDescription) DEF_CLR_API(asCorInfoType) DEF_CLR_API(getClassNameFromMetadata) DEF_CLR_API(getTypeInstantiationArgument) -DEF_CLR_API(appendClassName) +DEF_CLR_API(printClassName) DEF_CLR_API(isValueClass) DEF_CLR_API(canInlineTypeCheck) DEF_CLR_API(getClassAttribs) diff --git a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp index ceadca504c9f8..7318a7c0068f5 100644 --- a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp @@ -415,14 +415,15 @@ CORINFO_CLASS_HANDLE WrapICorJitInfo::getTypeInstantiationArgument( return temp; } -int WrapICorJitInfo::appendClassName( - char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) +size_t WrapICorJitInfo::printClassName( + CORINFO_CLASS_HANDLE cls, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - API_ENTER(appendClassName); - int temp = wrapHnd->appendClassName(ppBuf, pnBufLen, cls); - API_LEAVE(appendClassName); + API_ENTER(printClassName); + size_t temp = wrapHnd->printClassName(cls, buffer, bufferSize, pRequiredBufferSize); + API_LEAVE(printClassName); return temp; } diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index a0399fc3c9f27..beeab8756e688 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1559,8 +1559,7 @@ unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) } //------------------------------------------------------------------------ -// eeGetShortClassName: wraps appendClassName to provide functionality -// similar to eeGetClassName(), but returns a class name without any instantiation. +// eeGetShortClassName: Returns class name with no instantiation. // // Arguments: // clsHnd - the class handle to get the type name of diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 608286d7b8afc..2be2fd85da86b 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -133,25 +133,21 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, return; } - char buffer[256]; - char* pBufferMut = buffer; - int size = sizeof(buffer); - int actualLen = info.compCompHnd->appendClassName(&pBufferMut, &size, clsHnd); - if (actualLen <= 0) + size_t requiredBufferSize; + char buffer[256]; + size_t writtenBytes = info.compCompHnd->printClassName(clsHnd, buffer, sizeof(buffer), &requiredBufferSize); + if (writtenBytes <= 0) { printer->Append(""); } - else if (static_cast(actualLen) < sizeof(buffer)) + else if (requiredBufferSize <= sizeof(buffer)) { printer->Append(buffer); } else { - char* pBuffer = new (this, CMK_DebugOnly) char[actualLen + 1]; - pBufferMut = pBuffer; - size = actualLen + 1; - info.compCompHnd->appendClassName(&pBufferMut, &size, clsHnd); - + char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; + info.compCompHnd->printClassName(clsHnd, pBuffer, requiredBufferSize); printer->Append(pBuffer); } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index ba8637f79bc8c..5ce93e88c1925 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -614,12 +614,12 @@ private static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException } [UnmanagedCallersOnly] - private static int _appendClassName(IntPtr thisHandle, IntPtr* ppException, byte** ppBuf, int* pnBufLen, CORINFO_CLASS_STRUCT_* cls) + private static UIntPtr _printClassName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) { var _this = GetThis(thisHandle); try { - return _this.appendClassName(ppBuf, ref *pnBufLen, cls); + return _this.printClassName(cls, buffer, bufferSize, pRequiredBufferSize); } catch (Exception ex) { @@ -2653,7 +2653,7 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[38] = (delegate* unmanaged)&_asCorInfoType; callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; - callbacks[41] = (delegate* unmanaged)&_appendClassName; + callbacks[41] = (delegate* unmanaged)&_printClassName; callbacks[42] = (delegate* unmanaged)&_isValueClass; callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; callbacks[44] = (delegate* unmanaged)&_getClassAttribs; @@ -2793,4 +2793,3 @@ private static IntPtr GetUnmanagedCallbacks() } } } - diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 5c7e616fe7716..b05b21eaa80b2 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1882,35 +1882,26 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) } - private int appendClassName(byte** ppBuf, ref int pnBufLen, CORINFO_CLASS_STRUCT_* cls) + private nuint printClassName(CORINFO_CLASS_STRUCT_* cls, byte* buffer, nuint bufferSize, nuint* pRequiredBufferSize) { var type = HandleToObject(cls); string name = JitTypeNameFormatter.Instance.FormatName(type); - byte[] utf8 = Encoding.UTF8.GetBytes(name); - int length = utf8.Length; - if (pnBufLen > 0) - { - byte* buffer = *ppBuf; - int lengthToCopy = Math.Min(utf8.Length, pnBufLen); - for (int i = 0; i < lengthToCopy; i++) - buffer[i] = utf8[i]; - if (utf8.Length < pnBufLen) - { - buffer[utf8.Length] = 0; - } - else - { - buffer[pnBufLen - 1] = 0; - lengthToCopy -= 1; - } + if (pRequiredBufferSize != null) + { + *pRequiredBufferSize = (nuint)utf8.Length + 1; + } - pnBufLen -= lengthToCopy; - *ppBuf = buffer + lengthToCopy; + nuint writtenBytes = 0; + if (buffer != null && bufferSize > 0) + { + writtenBytes = Math.Min(bufferSize - 1, (nuint)utf8.Length); + utf8.AsSpan()[..(int)writtenBytes].CopyTo(new Span(buffer, (int)writtenBytes)); + buffer[writtenBytes] = 0; } - return length; + return writtenBytes; } private bool isValueClass(CORINFO_CLASS_STRUCT_* cls) diff --git a/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs index 6210eae17f5fa..8e1e66ecc1621 100644 --- a/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs +++ b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs @@ -10,10 +10,10 @@ namespace Internal.JitInterface { // This is a very rough equivalent of typestring.cpp in the CLR used with // FormatNamespace|FormatNoInst. This is currently only used for - // appendClassName in the JIT-EE interface, which is used to print class - // names to use for the various method set JIT variables (JitDisasm for - // example). The JIT handles formatting of most type names on its own so we - // only need the basics here. + // printClassName in the JIT-EE interface that is used for the various + // method set JIT variables (JitDisasm for example). The JIT handles + // formatting of most type names on its own so we only need the basics + // here. internal sealed class JitTypeNameFormatter : TypeNameFormatter { public static JitTypeNameFormatter Instance { get; } = new JitTypeNameFormatter(); diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 434b46168f9b2..40e62eb512ef1 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -62,7 +62,6 @@ void **,ref void* VOIDSTARSTAR,void **,void **,void ** int32_t*,int* char*,byte* -char**,byte** const char**,byte** char16_t**,char** char16_t *,char* @@ -197,7 +196,7 @@ FUNCTIONS CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls) const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char **namespaceName) CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) - int appendClassName(char** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls) + size_t printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) bool isValueClass(CORINFO_CLASS_HANDLE cls) CorInfoInlineTypeCheck canInlineTypeCheck(CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source) uint32_t getClassAttribs(CORINFO_CLASS_HANDLE cls) diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface.h b/src/coreclr/tools/aot/jitinterface/jitinterface.h index 0a3460fd92c56..4b34af51fda30 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface.h @@ -52,7 +52,7 @@ struct JitInterfaceCallbacks CorInfoType (* asCorInfoType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); const char* (* getClassNameFromMetadata)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, const char** namespaceName); CORINFO_CLASS_HANDLE (* getTypeInstantiationArgument)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, unsigned index); - int (* appendClassName)(void * thisHandle, CorInfoExceptionClass** ppException, char** ppBuf, int* pnBufLen, CORINFO_CLASS_HANDLE cls); + size_t (* printClassName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); bool (* isValueClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); CorInfoInlineTypeCheck (* canInlineTypeCheck)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source); uint32_t (* getClassAttribs)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); @@ -605,13 +605,14 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } - virtual int appendClassName( - char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) + virtual size_t printClassName( + CORINFO_CLASS_HANDLE cls, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { CorInfoExceptionClass* pException = nullptr; - int temp = _callbacks->appendClassName(_thisHandle, &pException, ppBuf, pnBufLen, cls); + size_t temp = _callbacks->printClassName(_thisHandle, &pException, cls, buffer, bufferSize, pRequiredBufferSize); if (pException != nullptr) throw pException; return temp; } diff --git a/src/coreclr/tools/superpmi/mcs/verbildump.h b/src/coreclr/tools/superpmi/mcs/verbildump.h index 43c9e608f56cb..ece5f95647acb 100644 --- a/src/coreclr/tools/superpmi/mcs/verbildump.h +++ b/src/coreclr/tools/superpmi/mcs/verbildump.h @@ -19,12 +19,10 @@ void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classH void DumpSigToConsoleBare(MethodContext* mc, CORINFO_SIG_INFO* pSig); char* DumpAttributeToConsoleBare(DWORD attribute); -template +template static void PrintClassName(MethodContext* mc, char (&buffer)[size], CORINFO_CLASS_HANDLE clsHnd) { - char* classNameMut = buffer; - int sizeMut = size; - mc->repAppendClassName(&classNameMut, &sizeMut, clsHnd); + mc->repPrintClassName(clsHnd, buffer, size, nullptr); } #endif diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index fbaa93e13541a..fcd5ce3713c60 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -766,11 +766,13 @@ struct Agnostic_RecordCallSite DWORDLONG methodHandle; }; -struct Agnostic_PrintObjectDescriptionResult +struct Agnostic_PrintEntityResult { - DWORDLONG bytesWritten; - DWORDLONG requiredBufferSize; + // Required size of a buffer to contain everything including null terminator. + // UINT_MAX if it was not determined during recording. + DWORD requiredBufferSize; DWORD buffer; + DWORD bufferSize; }; #pragma pack(pop) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index b4db01bf2235f..7285f9f141539 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -18,7 +18,7 @@ LWM(AllocPgoInstrumentationBySchema, DWORDLONG, Agnostic_AllocPgoInstrumentationBySchema) LWM(GetPgoInstrumentationResults, DWORDLONG, Agnostic_GetPgoInstrumentationResults) -LWM(AppendClassName, Agnostic_AppendClassNameIn, Agnostic_AppendClassNameOut) +LWM(PrintClassName, DWORDLONG, Agnostic_PrintEntityResult) LWM(AreTypesEquivalent, DLDL, DWORD) LWM(AsCorInfoType, DWORDLONG, DWORD) LWM(CanAccessClass, Agnostic_CanAccessClassIn, Agnostic_CanAccessClassOut) @@ -148,7 +148,7 @@ LWM(IsIntrinsicType, DWORDLONG, DWORD) LWM(IsSDArray, DWORDLONG, DWORD) LWM(IsValidStringRef, DLD, DWORD) LWM(GetStringLiteral, DLDD, DD) -LWM(PrintObjectDescription, DLDL, Agnostic_PrintObjectDescriptionResult) +LWM(PrintObjectDescription, DWORDLONG, Agnostic_PrintEntityResult) LWM(IsValidToken, DLD, DWORD) LWM(IsValueClass, DWORDLONG, DWORD) LWM(MergeClasses, DLDL, DWORDLONG) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index ec63bfac2886c..943a445ff063f 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -4898,75 +4898,134 @@ int MethodContext::repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned me } } -void MethodContext::recPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) +void MethodContext::recPrintEntity( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize, + size_t bytesWritten) { - if (PrintObjectDescription == nullptr) - PrintObjectDescription = new LightWeightMap(); + if (map == nullptr) + map = new LightWeightMap(); - DLDL key; - key.A = CastHandle(handle); - key.B = (DWORDLONG)bufferSize; + // Required size of a buffer that contains all data and null terminator. + UINT requiredBufferSize = UINT_MAX; + if (pRequiredBufferSize != nullptr) + { + requiredBufferSize = (UINT)(*pRequiredBufferSize); + } + else if (bytesWritten + 1 < bufferSize) + { + requiredBufferSize = (UINT)(bytesWritten + 1); + } - DWORD strBuf = (DWORD)-1; - if (buffer != nullptr && bytesWritten > 0) + Agnostic_PrintEntityResult res; + int index = map->GetIndex(handle); + if (index != -1) + { + // Merge with existing entry + + res = map->GetItem(index); + + if (requiredBufferSize != UINT_MAX) + { + res.requiredBufferSize = requiredBufferSize; + } + + if (bytesWritten > res.bufferSize) + { + // Always stored without null terminator. + res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + } + + map->Update(index, res); + + dmpPrintEntity(name, map, handle, res); + return; + } + + if (buffer != nullptr) { - size_t bufferRealSize = min(bytesWritten, bufferSize - 1); - strBuf = (DWORD)PrintObjectDescription->AddBuffer((unsigned char*)buffer, (DWORD)bufferRealSize); + res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + } + else + { + res.buffer = UINT_MAX; } - Agnostic_PrintObjectDescriptionResult value; - value.bytesWritten = (DWORDLONG)bytesWritten; - value.requiredBufferSize = (DWORDLONG)(pRequiredBufferSize == nullptr ? 0 : *pRequiredBufferSize); - value.buffer = (DWORD)strBuf; + res.bufferSize = (UINT)bytesWritten; + res.requiredBufferSize = requiredBufferSize; - PrintObjectDescription->Add(key, value); - DEBUG_REC(dmpPrintObjectDescription(key, value)); + map->Add(handle, res); + dmpPrintEntity(name, map, handle, res); } -void MethodContext::dmpPrintObjectDescription(DLDL key, Agnostic_PrintObjectDescriptionResult value) + +void MethodContext::dmpPrintEntity( + const char* name, + LightWeightMapBuffer* buffer, + DWORDLONG key, + const Agnostic_PrintEntityResult& value) { - printf("PrintObjectDescription key hnd-%016llX bufSize-%u, bytesWritten-%u, pRequiredBufferSize-%u", key.A, (unsigned)key.B, (unsigned)value.bytesWritten, (unsigned)value.requiredBufferSize); - PrintObjectDescription->Unlock(); + printf("%s key hnd-%016llX, bufferSize-%u, requiredBufferSize-%u", name, key, value.bufferSize, value.requiredBufferSize); + buffer->Unlock(); } -size_t MethodContext::repPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) + +size_t MethodContext::repPrintEntity( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - if (PrintObjectDescription == nullptr) - { - return 0; - } + AssertMapAndKeyExist(map, handle, ": map %s key %016llx", name, handle); - DLDL key; - key.A = CastHandle(handle); - key.B = (DWORDLONG)bufferSize; + Agnostic_PrintEntityResult res = map->Get(handle); + DEBUG_REP(dmpPrintEntity(name, buffer, handle, res)); - int itemIndex = PrintObjectDescription->GetIndex(key); - if (itemIndex < 0) - { - return 0; - } - else + if (pRequiredBufferSize != nullptr) { - Agnostic_PrintObjectDescriptionResult value = PrintObjectDescription->Get(key); - DEBUG_REP(dmpPrintObjectDescription(key, value)); - if (pRequiredBufferSize != nullptr) + if (res.requiredBufferSize == UINT_MAX) { - *pRequiredBufferSize = (size_t)value.requiredBufferSize; + LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (missing requiredBufferSize for %s key %016llx)", name, handle); } - size_t bytesWritten = 0; - - BYTE* srcBuffer = (BYTE*)PrintObjectDescription->GetBuffer(value.buffer); - Assert(srcBuffer != nullptr); + *pRequiredBufferSize = res.requiredBufferSize; + } - if (bufferSize > 0) - { - bytesWritten = min(bufferSize - 1, (size_t)value.bytesWritten); - memcpy(buffer, srcBuffer, bytesWritten); + // requiredBufferSize is with null terminator, but buffer is stored without null terminator. + // Determine if we have enough data to answer the call losslessly. + bool haveFullBuffer = (res.requiredBufferSize != UINT_MAX) && ((res.bufferSize + 1) >= res.requiredBufferSize); + if (!haveFullBuffer && (bufferSize > static_cast(res.bufferSize) + 1)) + { + LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (not enough buffer data for %s key %016llx)", name, handle); + } - // Always null-terminate - buffer[bytesWritten] = 0; - } - return bytesWritten; + size_t bytesWritten = 0; + if ((buffer != nullptr) && (bufferSize > 0)) + { + char* storedBuffer = (char*)map->GetBuffer(res.buffer); + bytesWritten = min(bufferSize - 1, res.bufferSize); + memcpy(buffer, storedBuffer, bytesWritten); + buffer[bytesWritten] = '\0'; } + + return bytesWritten; +} + +void MethodContext::recPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) +{ + recPrintEntity("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize, bytesWritten); +} +void MethodContext::dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintEntityResult& value) +{ + dmpPrintEntity("PrintObjectDescription", PrintObjectDescription, key, value); +} +size_t MethodContext::repPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ + return repPrintEntity("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize); } void MethodContext::recGetHelperName(CorInfoHelpFunc funcNum, const char* result) @@ -6563,103 +6622,17 @@ CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLAS return result; } -void MethodContext::recAppendClassName( - int nBufLenIn, - CORINFO_CLASS_HANDLE cls, - int nLenOut, - const char* result) +void MethodContext::recPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) { - if (AppendClassName == nullptr) - AppendClassName = new LightWeightMap(); - - // The API has two different behaviors depending on whether the input specified length is zero or non-zero: - // (1) zero: returns the length of the string (which the caller can use to allocate a buffer) - // (2) non-zero: fill as much of the buffer with the name as there is space available. - // We don't want the input length to be part of the key, since the caller could potentially pass in a smaller - // or larger buffer, and we'll fill in as much of the buffer as possible. We do need to handle both the zero - // and non-zero cases, though, so we'll get one record for first call using zero (with the correct buffer size result), - // and another for the second call with a big-enough buffer. We could presumably just store the second case - // (and overwrite the first record), since it contains the same output length, but it is useful to store - // (and see) all the JIT-EE interface calls. - - Agnostic_AppendClassNameIn key; - ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding - key.nBufLenIsZero = (nBufLenIn == 0) ? 1 : 0; - key.classHandle = CastHandle(cls); - - Agnostic_AppendClassNameOut value; - value.nLen = nLenOut; - value.name_index = (DWORD)-1; - - // Don't save the string buffer if the incoming buffer length is zero, even if the string buffer is non-null. - // In that case, the EE/crossgen2 don't zero-terminate the buffer (since they assume it is zero sized). - if ((result != nullptr) && (nBufLenIn > 0)) - { - value.name_index = (DWORD)AppendClassName->AddBuffer( - (unsigned char*)result, - (unsigned int)((strlen(result) + 1) * sizeof(char))); - } - - AppendClassName->Add(key, value); - DEBUG_REC(dmpAppendClassName(key, value)); + recPrintEntity("PrintClassName", PrintClassName, CastHandle(cls), buffer, bufferSize, pRequiredBufferSize, bytesWritten); } - -void MethodContext::dmpAppendClassName(const Agnostic_AppendClassNameIn& key, const Agnostic_AppendClassNameOut& value) +void MethodContext::dmpPrintClassName(DWORDLONG key, const Agnostic_PrintEntityResult& value) { - const char* name = (const char*)AppendClassName->GetBuffer(value.name_index); - printf("AppendClassName key lenzero-%s cls-%016llX value len-%u ni-%u name-%s", - key.nBufLenIsZero ? "true" : "false", key.classHandle, value.nLen, value.name_index, name); - AppendClassName->Unlock(); + dmpPrintEntity("PrintClassName", PrintClassName, key, value); } - -int MethodContext::repAppendClassName(char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) { - static const char unknownClass[] = "hackishClassName"; - static const int unknownClassLength = (int)(ArrLen(unknownClass) - 1); // Don't include null terminator in length. - - // By default, at least return something. - const char* name = unknownClass; - int nLen = unknownClassLength; - - if (AppendClassName != nullptr) - { - Agnostic_AppendClassNameIn key; - ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding - key.nBufLenIsZero = (*pnBufLen == 0) ? 1 : 0; - key.classHandle = CastHandle(cls); - - // First, see if we have an entry for this query. - int index = AppendClassName->GetIndex(key); - if (index != -1) - { - // Then, actually get the value. - Agnostic_AppendClassNameOut value = AppendClassName->Get(key); - DEBUG_REP(dmpAppendClassName(key, value)); - - nLen = value.nLen; - name = (const char*)AppendClassName->GetBuffer(value.name_index); - } - } - - if ((ppBuf != nullptr) && (*ppBuf != nullptr) && (*pnBufLen > 0) && (name != nullptr)) - { - // Copy as much as will fit. - char* pBuf = *ppBuf; - int nLenToCopy = min(*pnBufLen, nLen + /* null terminator */ 1); - for (int i = 0; i < nLenToCopy - 1; i++) - { - pBuf[i] = name[i]; - } - pBuf[nLenToCopy - 1] = 0; // null terminate the string if it wasn't already - - // Update the buffer pointer and buffer size pointer based on the amount actually copied. - // Don't include the null terminator. `*ppBuf` will point at the added null terminator. - (*ppBuf) += nLenToCopy - 1; - (*pnBufLen) -= nLenToCopy - 1; - } - - return nLen; +size_t MethodContext::repPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ + return repPrintEntity("PrintClassName", PrintClassName, CastHandle(cls), buffer, bufferSize, pRequiredBufferSize); } void MethodContext::recGetTailCallHelpers( diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 8eb4f176dff1b..81551b011ecff 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -622,8 +622,29 @@ class MethodContext void dmpGetStringLiteral(DLDD key, DD value); int repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, char16_t* buffer, int bufferSize); + void recPrintEntity( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize, + size_t bytesWritten); + void dmpPrintEntity( + const char* name, + LightWeightMapBuffer* buffer, + DWORDLONG key, + const Agnostic_PrintEntityResult& value); + size_t repPrintEntity( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize); + void recPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); - void dmpPrintObjectDescription(DLDL key, Agnostic_PrintObjectDescriptionResult value); + void dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintEntityResult& value); size_t repPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); void recGetHelperName(CorInfoHelpFunc funcNum, const char* result); @@ -805,14 +826,9 @@ class MethodContext void dmpGetTypeInstantiationArgument(DLD key, DWORDLONG value); CORINFO_CLASS_HANDLE repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index); - void recAppendClassName(int nBufLenIn, - CORINFO_CLASS_HANDLE cls, - int nLenOut, - const char* result); - void dmpAppendClassName(const Agnostic_AppendClassNameIn& key, const Agnostic_AppendClassNameOut& value); - int repAppendClassName(char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls); + void recPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); + void dmpPrintClassName(DWORDLONG cls, const Agnostic_PrintEntityResult& value); + size_t repPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); void recGetTailCallHelpers( CORINFO_RESOLVED_TOKEN* callToken, @@ -1081,7 +1097,7 @@ enum mcPackets //PacketCR_RecordCallSite = 146, Packet_GetLazyStringLiteralHelper = 147, Packet_IsIntrinsicType = 148, - Packet_AppendClassName = 149, + Packet_PrintClassName = 149, Packet_GetReadyToRunHelper = 150, Packet_GetIntConfigValue = 151, Packet_GetStringConfigValue = 152, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 3adca09e908f2..598530bd22757 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -497,40 +497,12 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLAS return result; } -// Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer. -// Includes enclosing classes and namespaces. -// -// Arguments: -// ppBuf - Pointer to buffer pointer. See below for details. -// pnBufLen - Pointer to buffer length. Must not be nullptr. See below for details. -// -// Returns the length of the representation, as a count of characters (but not including a terminating null character). -// Note that this will always be the actual number of characters required by the representation, even if the string -// was truncated when copied to the buffer. -// -// Operation: -// -// On entry, `*pnBufLen` specifies the size of the buffer pointed to by `*ppBuf` as a count of characters. -// There are two cases: -// 1. If the size is zero, the function computes the length of the representation and returns that. -// `ppBuf` is ignored (and may be nullptr) and `*ppBuf` and `*pnBufLen` are not updated. -// 2. If the size is non-zero, the buffer pointed to by `*ppBuf` is (at least) that size. The class name -// representation is copied to the buffer pointed to by `*ppBuf`. As many characters of the name as will fit in the -// buffer are copied. Thus, if the name is larger than the size of the buffer, the name will be truncated in the buffer. -// The buffer is guaranteed to be null terminated. Thus, the size must be large enough to include a terminating null -// character, or the string will be truncated to include one. On exit, `*pnBufLen` is updated by subtracting the -// number of characters that were actually copied to the buffer. Also, `*ppBuf` is updated to point at the null -// character that was added to the end of the name. -// -int interceptor_ICJI::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) { - mc->cr->AddCall("appendClassName"); - char* pBufIn = (ppBuf == nullptr) ? nullptr : *ppBuf; - int nBufLenIn = (pnBufLen == nullptr) ? 0 : *pnBufLen; // pnBufLen should never be nullptr, but don't crash if it is. - int nLenOut = original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls); - mc->recAppendClassName(nBufLenIn, cls, nLenOut, pBufIn); - return nLenOut; +size_t interceptor_ICJI::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ + mc->cr->AddCall("printClassName"); + size_t bytesWritten = original_ICorJitInfo->printClassName(cls, buffer, bufferSize, pRequiredBufferSize); + mc->recPrintClassName(cls, buffer, bufferSize, pRequiredBufferSize, bytesWritten); + return bytesWritten; } // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 08c0dd778c8d9..67d62ed7d2fd8 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -347,13 +347,14 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument( return original_ICorJitInfo->getTypeInstantiationArgument(cls, index); } -int interceptor_ICJI::appendClassName( - char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) +size_t interceptor_ICJI::printClassName( + CORINFO_CLASS_HANDLE cls, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - mcs->AddCall("appendClassName"); - return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls); + mcs->AddCall("printClassName"); + return original_ICorJitInfo->printClassName(cls, buffer, bufferSize, pRequiredBufferSize); } bool interceptor_ICJI::isValueClass( diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp index 0f4afb461d3cd..3a6463a8c5799 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -306,12 +306,13 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument( return original_ICorJitInfo->getTypeInstantiationArgument(cls, index); } -int interceptor_ICJI::appendClassName( - char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) +size_t interceptor_ICJI::printClassName( + CORINFO_CLASS_HANDLE cls, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls); + return original_ICorJitInfo->printClassName(cls, buffer, bufferSize, pRequiredBufferSize); } bool interceptor_ICJI::isValueClass( diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index f23b8aac60fd0..8767ec7ef1289 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -426,37 +426,10 @@ CORINFO_CLASS_HANDLE MyICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE c return result; } -// Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer. -// Includes enclosing classes and namespaces. -// -// Arguments: -// ppBuf - Pointer to buffer pointer. See below for details. -// pnBufLen - Pointer to buffer length. Must not be nullptr. See below for details. -// -// Returns the length of the representation, as a count of characters (but not including a terminating null character). -// Note that this will always be the actual number of characters required by the representation, even if the string -// was truncated when copied to the buffer. -// -// Operation: -// -// On entry, `*pnBufLen` specifies the size of the buffer pointed to by `*ppBuf` as a count of characters. -// There are two cases: -// 1. If the size is zero, the function computes the length of the representation and returns that. -// `ppBuf` is ignored (and may be nullptr) and `*ppBuf` and `*pnBufLen` are not updated. -// 2. If the size is non-zero, the buffer pointed to by `*ppBuf` is (at least) that size. The class name -// representation is copied to the buffer pointed to by `*ppBuf`. As many characters of the name as will fit in the -// buffer are copied. Thus, if the name is larger than the size of the buffer, the name will be truncated in the buffer. -// The buffer is guaranteed to be null terminated. Thus, the size must be large enough to include a terminating null -// character, or the string will be truncated to include one. On exit, `*pnBufLen` is updated by subtracting the -// number of characters that were actually copied to the buffer. Also, `*ppBuf` is updated to point at the null -// character that was added to the end of the name. -// -int MyICJI::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls) +size_t MyICJI::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { - jitInstance->mc->cr->AddCall("appendClassName"); - return jitInstance->mc->repAppendClassName(ppBuf, pnBufLen, cls); + jitInstance->mc->cr->AddCall("printClassName"); + return jitInstance->mc->repPrintClassName(cls, buffer, bufferSize, pRequiredBufferSize); } // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 870088def712f..1cf8ea7639d54 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3398,45 +3398,42 @@ static void AppendTypeNameEscaped(const char* str, TAppend append) } /*********************************************************************/ -int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE clsHnd) { +size_t CEEInfo::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ CONTRACTL { MODE_PREEMPTIVE; THROWS; GC_TRIGGERS; } CONTRACTL_END; - int nLen = 0; + size_t bytesWritten = 0; JIT_TO_EE_TRANSITION(); - TypeHandle th(clsHnd); + size_t requiredBufferSize = 0; + + TypeHandle th(cls); IMDInternalImport* pImport = th.GetMethodTable()->GetMDImport(); - auto append = [ppBuf, pnBufLen, &nLen](const char* str) + auto append = [buffer, bufferSize, &bytesWritten, &requiredBufferSize](const char* str) { size_t strLen = strlen(str); - if ((ppBuf != nullptr) && (pnBufLen != nullptr)) + if ((buffer != nullptr) && (bytesWritten + 1 < bufferSize)) { - if (strLen >= static_cast(*pnBufLen)) + if (bytesWritten + strLen >= bufferSize) { - if (*pnBufLen > 1) - { - memcpy(*ppBuf, str, *pnBufLen - 1); - *ppBuf += *pnBufLen - 1; - *pnBufLen = 1; - } + memcpy(buffer + bytesWritten, str, bufferSize - bytesWritten - 1); + bytesWritten = bufferSize - 1; } else { - memcpy(*ppBuf, str, strLen); - *ppBuf += strLen; + memcpy(buffer + bytesWritten, str, strLen); + bytesWritten += strLen; } } - nLen = nLen + static_cast(strLen); + requiredBufferSize += strLen; }; // Subset of TypeString that does just what we need while staying in UTF8 @@ -3482,15 +3479,20 @@ int CEEInfo::appendClassName(_Outptr_opt_result_buffer_(*pnBufLen) char** ppBu } } - if (*pnBufLen > 0) + if (bufferSize > 0) + { + _ASSERTE(bytesWritten < bufferSize); + buffer[bytesWritten] = '\0'; + } + + if (pRequiredBufferSize != nullptr) { - **ppBuf = '\0'; + *pRequiredBufferSize = requiredBufferSize; } EE_TO_JIT_TRANSITION(); - // Return the actual length of the string, not including the null terminator. - return nLen; + return bytesWritten; } /*********************************************************************/ From f1d6112051ed50249e6c9dcb4af40928e5ea5a6f Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 15:08:39 +0100 Subject: [PATCH 23/50] Fix build after merge --- .../JitInterface/CorInfoImpl_generated.cs | 287 +++++++++--------- .../superpmi-shared/methodcontext.cpp | 10 +- .../superpmi/superpmi-shared/methodcontext.h | 4 +- 3 files changed, 148 insertions(+), 153 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index 519cd590cab66..cc2415df59c39 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -2685,7 +2685,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 182); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 181); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; @@ -2726,149 +2726,148 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[36] = (delegate* unmanaged)&_getStringLiteral; callbacks[37] = (delegate* unmanaged)&_printObjectDescription; callbacks[38] = (delegate* unmanaged)&_asCorInfoType; - callbacks[39] = (delegate* unmanaged)&_getClassName; - callbacks[40] = (delegate* unmanaged)&_getClassNameFromMetadata; - callbacks[41] = (delegate* unmanaged)&_getTypeInstantiationArgument; - callbacks[42] = (delegate* unmanaged)&_appendClassName; - callbacks[43] = (delegate* unmanaged)&_isValueClass; - callbacks[44] = (delegate* unmanaged)&_canInlineTypeCheck; - callbacks[45] = (delegate* unmanaged)&_getClassAttribs; - callbacks[46] = (delegate* unmanaged)&_getClassModule; - callbacks[47] = (delegate* unmanaged)&_getModuleAssembly; - callbacks[48] = (delegate* unmanaged)&_getAssemblyName; - callbacks[49] = (delegate* unmanaged)&_LongLifetimeMalloc; - callbacks[50] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[51] = (delegate* unmanaged)&_getClassModuleIdForStatics; - callbacks[52] = (delegate* unmanaged)&_getClassSize; - callbacks[53] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[54] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[55] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[56] = (delegate* unmanaged)&_getClassGClayout; - callbacks[57] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[58] = (delegate* unmanaged)&_getFieldInClass; - callbacks[59] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[60] = (delegate* unmanaged)&_getNewHelper; - callbacks[61] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[62] = (delegate* unmanaged)&_getCastingHelper; - callbacks[63] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[64] = (delegate* unmanaged)&_getTypeForBox; - callbacks[65] = (delegate* unmanaged)&_getBoxHelper; - callbacks[66] = (delegate* unmanaged)&_getUnBoxHelper; - callbacks[67] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[68] = (delegate* unmanaged)&_isObjectImmutable; - callbacks[69] = (delegate* unmanaged)&_getObjectType; - callbacks[70] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[71] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[72] = (delegate* unmanaged)&_getHelperName; - callbacks[73] = (delegate* unmanaged)&_initClass; - callbacks[74] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[75] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[77] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[78] = (delegate* unmanaged)&_canCast; - callbacks[79] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[80] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[81] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[82] = (delegate* unmanaged)&_mergeClasses; - callbacks[83] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[84] = (delegate* unmanaged)&_isEnum; - callbacks[85] = (delegate* unmanaged)&_getParentType; - callbacks[86] = (delegate* unmanaged)&_getChildType; - callbacks[87] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[88] = (delegate* unmanaged)&_isSDArray; - callbacks[89] = (delegate* unmanaged)&_getArrayRank; - callbacks[90] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[91] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[92] = (delegate* unmanaged)&_canAccessClass; - callbacks[93] = (delegate* unmanaged)&_getFieldName; - callbacks[94] = (delegate* unmanaged)&_getFieldClass; - callbacks[95] = (delegate* unmanaged)&_getFieldType; - callbacks[96] = (delegate* unmanaged)&_getFieldOffset; - callbacks[97] = (delegate* unmanaged)&_getFieldInfo; - callbacks[98] = (delegate* unmanaged)&_isFieldStatic; - callbacks[99] = (delegate* unmanaged)&_getArrayOrStringLength; - callbacks[100] = (delegate* unmanaged)&_getBoundaries; - callbacks[101] = (delegate* unmanaged)&_setBoundaries; - callbacks[102] = (delegate* unmanaged)&_getVars; - callbacks[103] = (delegate* unmanaged)&_setVars; - callbacks[104] = (delegate* unmanaged)&_reportRichMappings; - callbacks[105] = (delegate* unmanaged)&_allocateArray; - callbacks[106] = (delegate* unmanaged)&_freeArray; - callbacks[107] = (delegate* unmanaged)&_getArgNext; - callbacks[108] = (delegate* unmanaged)&_getArgType; - callbacks[109] = (delegate* unmanaged)&_getExactClasses; - callbacks[110] = (delegate* unmanaged)&_getArgClass; - callbacks[111] = (delegate* unmanaged)&_getHFAType; - callbacks[112] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[113] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[114] = (delegate* unmanaged)&_FilterException; - callbacks[115] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[116] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[117] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[118] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[119] = (delegate* unmanaged)&_getEEInfo; - callbacks[120] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[121] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[122] = (delegate* unmanaged)&_getMethodName; - callbacks[123] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[124] = (delegate* unmanaged)&_getMethodHash; - callbacks[125] = (delegate* unmanaged)&_findNameOfToken; - callbacks[126] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[127] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[128] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[129] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[130] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[131] = (delegate* unmanaged)&_getHelperFtn; - callbacks[132] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[133] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[134] = (delegate* unmanaged)&_getMethodSync; - callbacks[135] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[136] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[137] = (delegate* unmanaged)&_embedClassHandle; - callbacks[138] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[139] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[140] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[141] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[142] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[143] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[144] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[145] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[146] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[147] = (delegate* unmanaged)&_getCallInfo; - callbacks[148] = (delegate* unmanaged)&_canAccessFamily; - callbacks[149] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[150] = (delegate* unmanaged)&_getClassDomainID; - callbacks[151] = (delegate* unmanaged)&_getFieldAddress; - callbacks[152] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; - callbacks[153] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[154] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[155] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[156] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[157] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[158] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[159] = (delegate* unmanaged)&_addActiveDependency; - callbacks[160] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[161] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[162] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[163] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[164] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[165] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[166] = (delegate* unmanaged)&_allocMem; - callbacks[167] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[168] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[169] = (delegate* unmanaged)&_allocGCInfo; - callbacks[170] = (delegate* unmanaged)&_setEHcount; - callbacks[171] = (delegate* unmanaged)&_setEHinfo; - callbacks[172] = (delegate* unmanaged)&_logMsg; - callbacks[173] = (delegate* unmanaged)&_doAssert; - callbacks[174] = (delegate* unmanaged)&_reportFatalError; - callbacks[175] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[176] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[177] = (delegate* unmanaged)&_recordCallSite; - callbacks[178] = (delegate* unmanaged)&_recordRelocation; - callbacks[179] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[180] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[181] = (delegate* unmanaged)&_getJitFlags; + callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; + callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; + callbacks[41] = (delegate* unmanaged)&_printClassName; + callbacks[42] = (delegate* unmanaged)&_isValueClass; + callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; + callbacks[44] = (delegate* unmanaged)&_getClassAttribs; + callbacks[45] = (delegate* unmanaged)&_getClassModule; + callbacks[46] = (delegate* unmanaged)&_getModuleAssembly; + callbacks[47] = (delegate* unmanaged)&_getAssemblyName; + callbacks[48] = (delegate* unmanaged)&_LongLifetimeMalloc; + callbacks[49] = (delegate* unmanaged)&_LongLifetimeFree; + callbacks[50] = (delegate* unmanaged)&_getClassModuleIdForStatics; + callbacks[51] = (delegate* unmanaged)&_getClassSize; + callbacks[52] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[53] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[54] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[55] = (delegate* unmanaged)&_getClassGClayout; + callbacks[56] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[57] = (delegate* unmanaged)&_getFieldInClass; + callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[59] = (delegate* unmanaged)&_getNewHelper; + callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[61] = (delegate* unmanaged)&_getCastingHelper; + callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[63] = (delegate* unmanaged)&_getTypeForBox; + callbacks[64] = (delegate* unmanaged)&_getBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; + callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[67] = (delegate* unmanaged)&_isObjectImmutable; + callbacks[68] = (delegate* unmanaged)&_getObjectType; + callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[71] = (delegate* unmanaged)&_getHelperName; + callbacks[72] = (delegate* unmanaged)&_initClass; + callbacks[73] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[74] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[77] = (delegate* unmanaged)&_canCast; + callbacks[78] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[79] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[80] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[81] = (delegate* unmanaged)&_mergeClasses; + callbacks[82] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[83] = (delegate* unmanaged)&_isEnum; + callbacks[84] = (delegate* unmanaged)&_getParentType; + callbacks[85] = (delegate* unmanaged)&_getChildType; + callbacks[86] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[87] = (delegate* unmanaged)&_isSDArray; + callbacks[88] = (delegate* unmanaged)&_getArrayRank; + callbacks[89] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[90] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[91] = (delegate* unmanaged)&_canAccessClass; + callbacks[92] = (delegate* unmanaged)&_getFieldName; + callbacks[93] = (delegate* unmanaged)&_getFieldClass; + callbacks[94] = (delegate* unmanaged)&_getFieldType; + callbacks[95] = (delegate* unmanaged)&_getFieldOffset; + callbacks[96] = (delegate* unmanaged)&_getFieldInfo; + callbacks[97] = (delegate* unmanaged)&_isFieldStatic; + callbacks[98] = (delegate* unmanaged)&_getArrayOrStringLength; + callbacks[99] = (delegate* unmanaged)&_getBoundaries; + callbacks[100] = (delegate* unmanaged)&_setBoundaries; + callbacks[101] = (delegate* unmanaged)&_getVars; + callbacks[102] = (delegate* unmanaged)&_setVars; + callbacks[103] = (delegate* unmanaged)&_reportRichMappings; + callbacks[104] = (delegate* unmanaged)&_allocateArray; + callbacks[105] = (delegate* unmanaged)&_freeArray; + callbacks[106] = (delegate* unmanaged)&_getArgNext; + callbacks[107] = (delegate* unmanaged)&_getArgType; + callbacks[108] = (delegate* unmanaged)&_getExactClasses; + callbacks[109] = (delegate* unmanaged)&_getArgClass; + callbacks[110] = (delegate* unmanaged)&_getHFAType; + callbacks[111] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[112] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[113] = (delegate* unmanaged)&_FilterException; + callbacks[114] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[115] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[116] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[117] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[118] = (delegate* unmanaged)&_getEEInfo; + callbacks[119] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[120] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[121] = (delegate* unmanaged)&_getMethodName; + callbacks[122] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[123] = (delegate* unmanaged)&_getMethodHash; + callbacks[124] = (delegate* unmanaged)&_findNameOfToken; + callbacks[125] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[126] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[128] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[129] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[130] = (delegate* unmanaged)&_getHelperFtn; + callbacks[131] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[132] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[133] = (delegate* unmanaged)&_getMethodSync; + callbacks[134] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[135] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[136] = (delegate* unmanaged)&_embedClassHandle; + callbacks[137] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[138] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[139] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[140] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[141] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[142] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[143] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[144] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[145] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[146] = (delegate* unmanaged)&_getCallInfo; + callbacks[147] = (delegate* unmanaged)&_canAccessFamily; + callbacks[148] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[149] = (delegate* unmanaged)&_getClassDomainID; + callbacks[150] = (delegate* unmanaged)&_getFieldAddress; + callbacks[151] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; + callbacks[152] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[153] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[154] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[155] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[156] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[157] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[158] = (delegate* unmanaged)&_addActiveDependency; + callbacks[159] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[160] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[161] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[162] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[163] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[164] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[165] = (delegate* unmanaged)&_allocMem; + callbacks[166] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[167] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[168] = (delegate* unmanaged)&_allocGCInfo; + callbacks[169] = (delegate* unmanaged)&_setEHcount; + callbacks[170] = (delegate* unmanaged)&_setEHinfo; + callbacks[171] = (delegate* unmanaged)&_logMsg; + callbacks[172] = (delegate* unmanaged)&_doAssert; + callbacks[173] = (delegate* unmanaged)&_reportFatalError; + callbacks[174] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[175] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[176] = (delegate* unmanaged)&_recordCallSite; + callbacks[177] = (delegate* unmanaged)&_recordRelocation; + callbacks[178] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[179] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[180] = (delegate* unmanaged)&_getJitFlags; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 19bd5115e912b..3308fb59e8bfe 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -4998,11 +4998,7 @@ void MethodContext::recPrintEntity( { res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); } - - size_t bytesWritten = 0; - - BYTE* srcBuffer = (BYTE*)PrintObjectDescription->GetBuffer(value.buffer); - if (bufferSize > 0) + else { res.buffer = UINT_MAX; } @@ -5067,7 +5063,7 @@ size_t MethodContext::repPrintEntity( return bytesWritten; } -void MethodContext::recPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) +void MethodContext::recPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) { recPrintEntity("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize, bytesWritten); } @@ -5075,7 +5071,7 @@ void MethodContext::dmpPrintObjectDescription(DWORDLONG key, const Agnostic_Prin { dmpPrintEntity("PrintObjectDescription", PrintObjectDescription, key, value); } -size_t MethodContext::repPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +size_t MethodContext::repPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { return repPrintEntity("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize); } diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 9bef165c915a1..d7cd53d309253 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -659,9 +659,9 @@ class MethodContext size_t bufferSize, size_t* pRequiredBufferSize); - void recPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); + void recPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); void dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintEntityResult& value); - size_t repPrintObjectDescription(void* handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); + size_t repPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); void recGetHelperName(CorInfoHelpFunc funcNum, const char* result); void dmpGetHelperName(DWORD key, DWORD value); From 2a76d181cf59b1cfb7e3552175ecad969de73504 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 15:34:37 +0100 Subject: [PATCH 24/50] Remove escaping type names complication --- src/coreclr/vm/jitinterface.cpp | 48 +++++---------------------------- src/coreclr/vm/typeparse.h | 20 -------------- 2 files changed, 7 insertions(+), 61 deletions(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index fb63c7420c74e..8f508857e652c 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3442,45 +3442,6 @@ const char* CEEInfo::getHelperName (CorInfoHelpFunc ftnNum) return result; } -template -static void AppendTypeNameEscaped(const char* str, TAppend append) -{ - CONTRACTL { - MODE_PREEMPTIVE; - NOTHROW; - GC_NOTRIGGER; - } CONTRACTL_END; - - bool hasReservedChar = false; - for (const char* curChar = str; *curChar; curChar++) - { - if (IsTypeNameReservedChar(*curChar)) - { - hasReservedChar = true; - break; - } - } - - if (!hasReservedChar) - { - append(str); - return; - } - - while (*str) - { - if (IsTypeNameReservedChar(*str)) - { - append("\\"); - } - - char singleChar[2] = { *str, 0 }; - append(singleChar); - - str++; - } -} - /*********************************************************************/ size_t CEEInfo::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { @@ -3523,6 +3484,11 @@ size_t CEEInfo::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bu // Subset of TypeString that does just what we need while staying in UTF8 // and avoiding expensive copies. This function is called a lot in checked // builds. + // One difference is that we do not handle escaping type names here (see + // IsTypeNameReservedChar). The situation is rare and somewhat complicated + // to handle since it requires iterating UTF8 encoded codepoints. Given + // that this function is only needed for diagnostics the complication seems + // unnecessary. mdTypeDef td = th.GetCl(); if (IsNilToken(td)) { @@ -3550,11 +3516,11 @@ size_t CEEInfo::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bu if ((nameSpace != NULL) && (*nameSpace != '\0')) { - AppendTypeNameEscaped(nameSpace, append); + append(nameSpace); append("."); } - AppendTypeNameEscaped(name, append); + append(name); if (i != 0) { diff --git a/src/coreclr/vm/typeparse.h b/src/coreclr/vm/typeparse.h index d30696568bec0..e5cf7408ac076 100644 --- a/src/coreclr/vm/typeparse.h +++ b/src/coreclr/vm/typeparse.h @@ -37,26 +37,6 @@ bool inline IsTypeNameReservedChar(WCHAR ch) } } -bool inline IsTypeNameReservedChar(char ch) -{ - LIMITED_METHOD_CONTRACT; - - switch (ch) - { - case ',': - case '[': - case ']': - case '&': - case '*': - case '+': - case '\\': - return true; - - default: - return false; - } -} - DomainAssembly * LoadDomainAssembly( SString * psszAssemblySpec, Assembly * pRequestingAssembly, From b8a05737b55e4af593228b8461118fed05ca7467 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sat, 8 Oct 2022 20:41:01 +0200 Subject: [PATCH 25/50] Nit --- src/coreclr/inc/corinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index a0eafe1e01585..33277816d5465 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2334,7 +2334,7 @@ class ICorStaticInfo // This function will always null terminate the buffer. // virtual size_t printClassName ( - CORINFO_CLASS_HANDLE cls, /* IN */ + CORINFO_CLASS_HANDLE cls, /* IN */ char* buffer, /* OUT */ size_t bufferSize, /* IN */ size_t* pRequiredBufferSize = nullptr /* OUT */ From e753c23077cd07beab750dfc8c9d3424e4cc123a Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sat, 8 Oct 2022 22:28:49 +0200 Subject: [PATCH 26/50] Factor PrintFromUtf16 --- .../tools/Common/JitInterface/CorInfoImpl.cs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index b5c71c2682746..4e228944e7993 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -1863,22 +1864,36 @@ private int getStringLiteral(CORINFO_MODULE_STRUCT_* module, uint metaTOK, char* private nuint printObjectDescription(CORINFO_OBJECT_STRUCT_* handle, byte* buffer, nuint bufferSize, nuint* pRequiredBufferSize) { - Debug.Assert(bufferSize > 0 && handle != null && buffer != null); + Debug.Assert(handle != null); - int bufferSize32 = checked((int)bufferSize); - ReadOnlySpan objStr = HandleToObject(handle).ToString(); + return PrintFromUtf16(HandleToObject(handle).ToString(), buffer, bufferSize, pRequiredBufferSize); + } + private nuint PrintFromUtf16(ReadOnlySpan utf16, byte* buffer, nuint bufferSize, nuint* pRequiredBufferSize) + { int written = 0; if (bufferSize > 0) { - Utf8.FromUtf16(objStr, new Span(buffer, checked((int)(bufferSize - 1))), out _, out written); + OperationStatus status = Utf8.FromUtf16(utf16, new Span(buffer, checked((int)(bufferSize - 1))), out _, out written); // Always null-terminate buffer[written] = 0; + + if (status == OperationStatus.Done) + { + if (pRequiredBufferSize != null) + { + *pRequiredBufferSize = (nuint)written + 1; + } + + return (nuint)written; + } } + if (pRequiredBufferSize != null) { - *pRequiredBufferSize = (nuint)Encoding.UTF8.GetByteCount(objStr) + 1; + *pRequiredBufferSize = (nuint)Encoding.UTF8.GetByteCount(utf16) + 1; } + return (nuint)written; } @@ -1916,22 +1931,7 @@ private nuint printClassName(CORINFO_CLASS_STRUCT_* cls, byte* buffer, nuint buf { var type = HandleToObject(cls); string name = JitTypeNameFormatter.Instance.FormatName(type); - byte[] utf8 = Encoding.UTF8.GetBytes(name); - - if (pRequiredBufferSize != null) - { - *pRequiredBufferSize = (nuint)utf8.Length + 1; - } - - nuint writtenBytes = 0; - if (buffer != null && bufferSize > 0) - { - writtenBytes = Math.Min(bufferSize - 1, (nuint)utf8.Length); - utf8.AsSpan()[..(int)writtenBytes].CopyTo(new Span(buffer, (int)writtenBytes)); - buffer[writtenBytes] = 0; - } - - return writtenBytes; + return PrintFromUtf16(name, buffer, bufferSize, pRequiredBufferSize); } private bool isValueClass(CORINFO_CLASS_STRUCT_* cls) From f61fc180032f2af729935dcd662b40d39f121192 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sat, 8 Oct 2022 22:43:47 +0200 Subject: [PATCH 27/50] Remove unnecessary function --- src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp | 6 +++--- src/coreclr/tools/superpmi/mcs/verbildump.cpp | 4 ++-- src/coreclr/tools/superpmi/mcs/verbildump.h | 6 ------ src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp b/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp index 64c54bf074007..78de9a8b17f7e 100644 --- a/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp +++ b/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp @@ -32,7 +32,7 @@ void DumpMap(int index, MethodContext* mc) const char* moduleName = nullptr; const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); char className[256]; - PrintClassName(mc, className, mc->repGetMethodClass(cmi.ftn)); + mc->repPrintClassName(mc->repGetMethodClass(cmi.ftn), className, sizeof(className)); printf("%d,", index); // printf("\"%s\",", mc->cr->repProcessName()); @@ -54,7 +54,7 @@ void DumpMap(int index, MethodContext* mc) for (unsigned i = 0; i < classInst; i++) { CORINFO_CLASS_HANDLE ci = sig.sigInst.classInst[i]; - PrintClassName(mc, className, ci); + mc->repPrintClassName(ci, className, sizeof(className)); printf("%s%s%s%s", i == 0 ? "[" : "", @@ -70,7 +70,7 @@ void DumpMap(int index, MethodContext* mc) for (unsigned i = 0; i < methodInst; i++) { CORINFO_CLASS_HANDLE ci = sig.sigInst.methInst[i]; - PrintClassName(mc, className, ci); + mc->repPrintClassName(ci, className, sizeof(className)); printf("%s%s%s%s", i == 0 ? "[" : "", diff --git a/src/coreclr/tools/superpmi/mcs/verbildump.cpp b/src/coreclr/tools/superpmi/mcs/verbildump.cpp index 95da3f62b727d..b123f3adcf815 100644 --- a/src/coreclr/tools/superpmi/mcs/verbildump.cpp +++ b/src/coreclr/tools/superpmi/mcs/verbildump.cpp @@ -68,7 +68,7 @@ void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classH case CORINFO_TYPE_CLASS: { char className[256]; - PrintClassName(mc, className, (CORINFO_CLASS_HANDLE)classHandle); + mc->repPrintClassName((CORINFO_CLASS_HANDLE)classHandle, className, sizeof(className)); printf( "%s %s", @@ -941,7 +941,7 @@ void DumpIL(MethodContext* mc) const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); char className[256]; - PrintClassName(mc, className, mc->repGetMethodClass(cmi.ftn)); + mc->repPrintClassName(mc->repGetMethodClass(cmi.ftn), className, sizeof(className)); printf("// ProcessName - '%s'\n", mc->cr->repProcessName()); printf(".assembly extern mscorlib{}\n"); diff --git a/src/coreclr/tools/superpmi/mcs/verbildump.h b/src/coreclr/tools/superpmi/mcs/verbildump.h index ece5f95647acb..c78352f5a1240 100644 --- a/src/coreclr/tools/superpmi/mcs/verbildump.h +++ b/src/coreclr/tools/superpmi/mcs/verbildump.h @@ -19,10 +19,4 @@ void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classH void DumpSigToConsoleBare(MethodContext* mc, CORINFO_SIG_INFO* pSig); char* DumpAttributeToConsoleBare(DWORD attribute); -template -static void PrintClassName(MethodContext* mc, char (&buffer)[size], CORINFO_CLASS_HANDLE clsHnd) -{ - mc->repPrintClassName(clsHnd, buffer, size, nullptr); -} - #endif diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index d7cd53d309253..69e8636c47eb5 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -848,7 +848,7 @@ class MethodContext void recPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); void dmpPrintClassName(DWORDLONG cls, const Agnostic_PrintEntityResult& value); - size_t repPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); + size_t repPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize = nullptr); void recGetTailCallHelpers( CORINFO_RESOLVED_TOKEN* callToken, From e16357b817fb35e5d5bf2b7a256475a79f1a97ed Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sat, 8 Oct 2022 23:31:52 +0200 Subject: [PATCH 28/50] Fix missing write --- src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 3308fb59e8bfe..9d92cd76d8e97 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -4986,6 +4986,7 @@ void MethodContext::recPrintEntity( { // Always stored without null terminator. res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + res.bufferSize = bytesWritten; } map->Update(index, res); From 62c262286c4c458b28f1f228b1dec0bc0b927e81 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 9 Oct 2022 00:22:50 +0200 Subject: [PATCH 29/50] Work on switching getMethodName and getFieldName to print --- src/coreclr/inc/corinfo.h | 56 +- src/coreclr/inc/icorjitinfoimpl_generated.h | 14 +- src/coreclr/jit/ICorJitInfo_names_generated.h | 4 +- .../jit/ICorJitInfo_wrapper_generated.hpp | 26 +- src/coreclr/jit/compiler.h | 4 +- src/coreclr/jit/ee_il_dll.cpp | 60 +- src/coreclr/jit/eeinterface.cpp | 15 +- src/coreclr/jit/importer.cpp | 1633 +++++++++ src/coreclr/jit/importercalls.cpp | 10 +- .../JitInterface/CorInfoImpl_generated.cs | 12 +- .../CorInfoImpl_generated.cs.orig | 3100 +++++++++++++++++ .../ThunkGenerator/ThunkInput.txt | 4 +- .../aot/jitinterface/jitinterface_generated.h | 22 +- .../superpmi-shim-collector/icorjitinfo.cpp | 27 +- .../icorjitinfo_generated.cpp | 22 +- .../icorjitinfo_generated.cpp | 18 +- .../tools/superpmi/superpmi/icorjitinfo.cpp | 22 +- src/coreclr/vm/jitinterface.cpp | 112 +- 18 files changed, 4922 insertions(+), 239 deletions(-) create mode 100644 src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 33277816d5465..500b7cbd49408 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2282,7 +2282,7 @@ class ICorStaticInfo // from that first attempt was not big enough. // // Return Value: - // Bytes written to the given buffer, the range is [0..bufferSize) + // Bytes written to the given buffer excluding the null terminator. The range is [0..bufferSize). // virtual size_t printObjectDescription ( CORINFO_OBJECT_HANDLE handle, /* IN */ @@ -2317,23 +2317,10 @@ class ICorStaticInfo unsigned index ) = 0; - // printClassName: Prints the name for a specified class, taking namespaces - // and nested classes into account. - // - // Arguments: - // cls - Class handle - // buffer - Buffer to print chars into - // bufferSize - Buffer size - // pRequiredBufferSize - Required length of a buffer to fit the full - // name, including null terminator. - // - // Return Value: - // Number of bytes written in the buffer excluding the null terminator. - // - // Notes: - // This function will always null terminate the buffer. - // - virtual size_t printClassName ( + // Prints the name for a specified class including namespaces and enclosing + // classes. + // See printObjectDescription for documentation for the parameters. + virtual size_t printClassName( CORINFO_CLASS_HANDLE cls, /* IN */ char* buffer, /* OUT */ size_t bufferSize, /* IN */ @@ -2683,12 +2670,12 @@ class ICorStaticInfo // /**********************************************************************************/ - // this function is for debugging only. It returns the field name - // and if 'moduleName' is non-null, it sets it to something that will - // says which method (a class name, or a module name) - virtual const char* getFieldName ( - CORINFO_FIELD_HANDLE ftn, /* IN */ - const char **moduleName /* OUT */ + // Prints the name of a field into a buffer. See printObjectDescription for more documentation. + virtual size_t printFieldName( + CORINFO_FIELD_HANDLE field, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize = nullptr ) = 0; // return class it belongs to @@ -2944,19 +2931,14 @@ class ICorStaticInfo CORINFO_METHOD_HANDLE hMethod ) = 0; - // This function returns the method name and if 'moduleName' is non-null, - // it sets it to something that contains the method (a class - // name, or a module name). Note that the moduleName parameter is for - // diagnostics only. - // - // The method name returned is the same as getMethodNameFromMetadata except - // in the case of functions without metadata (e.g. IL stubs), where this - // function still returns a reasonable name while getMethodNameFromMetadata - // returns null. - virtual const char* getMethodName ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - const char **moduleName /* OUT */ - ) = 0; + // This is similar to getMethodNameFromMetadata except that it also returns + // reasonable names for functions without metadata. + // See printObjectDescription for documentation of parameters. + virtual size_t printMethodName( + CORINFO_METHOD_HANDLE ftn, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize = nullptr) = 0; // Return method name as in metadata, or nullptr if there is none, // and optionally return the class, enclosing class, and namespace names diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index f2b1804ab38be..eda13303a780f 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -379,9 +379,11 @@ CorInfoIsAccessAllowedResult canAccessClass( CORINFO_METHOD_HANDLE callerHandle, CORINFO_HELPER_DESC* pAccessHelper) override; -const char* getFieldName( - CORINFO_FIELD_HANDLE ftn, - const char** moduleName) override; +size_t printFieldName( + CORINFO_FIELD_HANDLE field, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) override; CORINFO_CLASS_HANDLE getFieldClass( CORINFO_FIELD_HANDLE field) override; @@ -492,9 +494,11 @@ const char16_t* getJitTimeLogFilename() override; mdMethodDef getMethodDefFromMethod( CORINFO_METHOD_HANDLE hMethod) override; -const char* getMethodName( +size_t printMethodName( CORINFO_METHOD_HANDLE ftn, - const char** moduleName) override; + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) override; const char* getMethodNameFromMetadata( CORINFO_METHOD_HANDLE ftn, diff --git a/src/coreclr/jit/ICorJitInfo_names_generated.h b/src/coreclr/jit/ICorJitInfo_names_generated.h index 0bda516266f63..79684bce3c013 100644 --- a/src/coreclr/jit/ICorJitInfo_names_generated.h +++ b/src/coreclr/jit/ICorJitInfo_names_generated.h @@ -96,7 +96,7 @@ DEF_CLR_API(getArrayRank) DEF_CLR_API(getArrayIntrinsicID) DEF_CLR_API(getArrayInitializationData) DEF_CLR_API(canAccessClass) -DEF_CLR_API(getFieldName) +DEF_CLR_API(printFieldName) DEF_CLR_API(getFieldClass) DEF_CLR_API(getFieldType) DEF_CLR_API(getFieldOffset) @@ -125,7 +125,7 @@ DEF_CLR_API(runWithSPMIErrorTrap) DEF_CLR_API(getEEInfo) DEF_CLR_API(getJitTimeLogFilename) DEF_CLR_API(getMethodDefFromMethod) -DEF_CLR_API(getMethodName) +DEF_CLR_API(printMethodName) DEF_CLR_API(getMethodNameFromMetadata) DEF_CLR_API(getMethodHash) DEF_CLR_API(findNameOfToken) diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index 6603a2097bc8c..14935b6915adf 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -905,13 +905,15 @@ CorInfoIsAccessAllowedResult WrapICorJitInfo::canAccessClass( return temp; } -const char* WrapICorJitInfo::getFieldName( - CORINFO_FIELD_HANDLE ftn, - const char** moduleName) +size_t WrapICorJitInfo::printFieldName( + CORINFO_FIELD_HANDLE field, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - API_ENTER(getFieldName); - const char* temp = wrapHnd->getFieldName(ftn, moduleName); - API_LEAVE(getFieldName); + API_ENTER(printFieldName); + size_t temp = wrapHnd->printFieldName(field, buffer, bufferSize, pRequiredBufferSize); + API_LEAVE(printFieldName); return temp; } @@ -1182,13 +1184,15 @@ mdMethodDef WrapICorJitInfo::getMethodDefFromMethod( return temp; } -const char* WrapICorJitInfo::getMethodName( +size_t WrapICorJitInfo::printMethodName( CORINFO_METHOD_HANDLE ftn, - const char** moduleName) + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - API_ENTER(getMethodName); - const char* temp = wrapHnd->getMethodName(ftn, moduleName); - API_LEAVE(getMethodName); + API_ENTER(printMethodName); + size_t temp = wrapHnd->printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); + API_LEAVE(printMethodName); return temp; } diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 6f9a164dfec41..95832e0252057 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7602,7 +7602,7 @@ class Compiler bool includeThisSpecifier); #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS) - const char* eeGetMethodName(CORINFO_METHOD_HANDLE hnd, const char** className); + const char* eeGetMethodName(CORINFO_METHOD_HANDLE hnd); const char* eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType = true, bool includeThisSpecifier = true); @@ -7841,7 +7841,7 @@ class Compiler // Utility functions - const char* eeGetFieldName(CORINFO_FIELD_HANDLE fieldHnd, const char** classNamePtr = nullptr); + const char* eePrintFieldName(CORINFO_FIELD_HANDLE fieldHnd, char* buffer, size_t bufferSize); #if defined(DEBUG) void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle); diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 6b39ad5b5e823..367a434e85176 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1437,14 +1437,16 @@ struct FilterSuperPMIExceptionsParam_ee_il EXCEPTION_POINTERS exceptionPointers; }; -const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method, const char** classNamePtr) +template +static const char* PrintEntityToAllocatedBuffer(Compiler* comp, THandle handle, char* failureName) +{ + +} + +const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method) { if (eeGetHelperNum(method) != CORINFO_HELP_UNDEF) { - if (classNamePtr != nullptr) - { - *classNamePtr = "HELPER"; - } CorInfoHelpFunc ftnNum = eeGetHelperNum(method); const char* name = info.compCompHnd->getHelperName(ftnNum); @@ -1461,13 +1463,15 @@ const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method, const char** if (eeIsNativeMethod(method)) { - if (classNamePtr != nullptr) - { - *classNamePtr = "NATIVE"; - } method = eeGetMethodHandleForNative(method); } + char buffer[256]; + size_t written = 0; + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + written = info.compCompHnd->printMethodName(method, buffer, sizeof(buffer)); + }); + FilterSuperPMIExceptionsParam_ee_il param; param.pThis = this; @@ -1495,28 +1499,34 @@ const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method, const char** return param.fieldOrMethodOrClassNamePtr; } -const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE field, const char** classNamePtr) +const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE field) { - FilterSuperPMIExceptionsParam_ee_il param; - - param.pThis = this; - param.pJitInfo = &info; - param.field = field; - param.classNamePtr = classNamePtr; - - bool success = eeRunWithSPMIErrorTrap( - [](FilterSuperPMIExceptionsParam_ee_il* pParam) { - pParam->fieldOrMethodOrClassNamePtr = - pParam->pJitInfo->compCompHnd->getFieldName(pParam->field, pParam->classNamePtr); - }, - ¶m); + char buffer[256]; + size_t written = 0; + size_t requiredBufferSize = 0; + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + written = info.compCompHnd->printFieldName(field, buffer, sizeof(buffer), &requiredBufferSize); + }); if (!success) { - param.fieldOrMethodOrClassNamePtr = "hackishFieldName"; + return "hackishFieldName"; } - return param.fieldOrMethodOrClassNamePtr; + char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; + if (requiredBufferSize <= sizeof(buffer)) + { + memcpy(pBuffer, buffer, written + 1); + } + else + { + success = eeRunFunctorWithSPMIErrorTrap([&]() { + + }); + info.compCompHnd-> + } + + char* pBuffer = } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 2be2fd85da86b..1e0f4d1486ee2 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -232,8 +232,19 @@ void Compiler::eePrintMethod(StringPrinter* printer, printer->Append(':'); } - const char* methName = info.compCompHnd->getMethodName(methHnd, nullptr); - printer->Append(methName); + size_t requiredBufferSize; + char buffer[256]; + info.compCompHnd->printMethodName(methHnd, buffer, sizeof(buffer), &requiredBufferSize); + if (sizeof(buffer) <= requiredBufferSize) + { + printer->Append(buffer); + } + else + { + char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; + info.compCompHnd->printMethodName(methHnd, pBuffer, requiredBufferSize); + printer->Append(pBuffer); + } if (includeMethodInstantiation && (sig->sigInst.methInstCount > 0)) { diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 19e2c842393b5..d52f0c4a55b6d 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -4727,6 +4727,1639 @@ bool Compiler::impIsImplicitTailCallCandidate( #endif // FEATURE_TAILCALL_OPT } +//------------------------------------------------------------------------ +// impImportCall: import a call-inspiring opcode +// +// Arguments: +// opcode - opcode that inspires the call +// pResolvedToken - resolved token for the call target +// pConstrainedResolvedToken - resolved constraint token (or nullptr) +// newObjThis - tree for this pointer or uninitialized newobj temp (or nullptr) +// prefixFlags - IL prefix flags for the call +// callInfo - EE supplied info for the call +// rawILOffset - IL offset of the opcode, used for guarded devirtualization. +// +// Returns: +// Type of the call's return value. +// If we're importing an inlinee and have realized the inline must fail, the call return type should be TYP_UNDEF. +// However we can't assert for this here yet because there are cases we miss. See issue #13272. +// +// +// Notes: +// opcode can be CEE_CALL, CEE_CALLI, CEE_CALLVIRT, or CEE_NEWOBJ. +// +// For CEE_NEWOBJ, newobjThis should be the temp grabbed for the allocated +// uninitialized object. + +#ifdef _PREFAST_ +#pragma warning(push) +#pragma warning(disable : 21000) // Suppress PREFast warning about overly large function +#endif + +var_types Compiler::impImportCall(OPCODE opcode, + CORINFO_RESOLVED_TOKEN* pResolvedToken, + CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, + GenTree* newobjThis, + int prefixFlags, + CORINFO_CALL_INFO* callInfo, + IL_OFFSET rawILOffset) +{ + assert(opcode == CEE_CALL || opcode == CEE_CALLVIRT || opcode == CEE_NEWOBJ || opcode == CEE_CALLI); + + // The current statement DI may not refer to the exact call, but for calls + // we wish to be able to attach the exact IL instruction to get "return + // value" support in the debugger, so create one with the exact IL offset. + DebugInfo di = impCreateDIWithCurrentStackInfo(rawILOffset, true); + + var_types callRetTyp = TYP_COUNT; + CORINFO_SIG_INFO* sig = nullptr; + CORINFO_METHOD_HANDLE methHnd = nullptr; + CORINFO_CLASS_HANDLE clsHnd = nullptr; + unsigned clsFlags = 0; + unsigned mflags = 0; + GenTree* call = nullptr; + CORINFO_THIS_TRANSFORM constraintCallThisTransform = CORINFO_NO_THIS_TRANSFORM; + CORINFO_CONTEXT_HANDLE exactContextHnd = nullptr; + bool exactContextNeedsRuntimeLookup = false; + bool canTailCall = true; + const char* szCanTailCallFailReason = nullptr; + const int tailCallFlags = (prefixFlags & PREFIX_TAILCALL); + const bool isReadonlyCall = (prefixFlags & PREFIX_READONLY) != 0; + + methodPointerInfo* ldftnInfo = nullptr; + + // Synchronized methods need to call CORINFO_HELP_MON_EXIT at the end. We could + // do that before tailcalls, but that is probably not the intended + // semantic. So just disallow tailcalls from synchronized methods. + // Also, popping arguments in a varargs function is more work and NYI + // If we have a security object, we have to keep our frame around for callers + // to see any imperative security. + // Reverse P/Invokes need a call to CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT + // at the end, so tailcalls should be disabled. + if (info.compFlags & CORINFO_FLG_SYNCH) + { + canTailCall = false; + szCanTailCallFailReason = "Caller is synchronized"; + } + else if (opts.IsReversePInvoke()) + { + canTailCall = false; + szCanTailCallFailReason = "Caller is Reverse P/Invoke"; + } +#if !FEATURE_FIXED_OUT_ARGS + else if (info.compIsVarArgs) + { + canTailCall = false; + szCanTailCallFailReason = "Caller is varargs"; + } +#endif // FEATURE_FIXED_OUT_ARGS + + // We only need to cast the return value of pinvoke inlined calls that return small types + + bool checkForSmallType = false; + bool bIntrinsicImported = false; + + CORINFO_SIG_INFO calliSig; + NewCallArg extraArg; + + /*------------------------------------------------------------------------- + * First create the call node + */ + + if (opcode == CEE_CALLI) + { + if (IsTargetAbi(CORINFO_NATIVEAOT_ABI)) + { + // See comment in impCheckForPInvokeCall + BasicBlock* block = compIsForInlining() ? impInlineInfo->iciBlock : compCurBB; + if (info.compCompHnd->convertPInvokeCalliToCall(pResolvedToken, !impCanPInvokeInlineCallSite(block))) + { + eeGetCallInfo(pResolvedToken, nullptr, CORINFO_CALLINFO_ALLOWINSTPARAM, callInfo); + return impImportCall(CEE_CALL, pResolvedToken, nullptr, nullptr, prefixFlags, callInfo, rawILOffset); + } + } + + /* Get the call site sig */ + eeGetSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, &calliSig); + + callRetTyp = JITtype2varType(calliSig.retType); + + call = impImportIndirectCall(&calliSig, di); + + // We don't know the target method, so we have to infer the flags, or + // assume the worst-case. + mflags = (calliSig.callConv & CORINFO_CALLCONV_HASTHIS) ? 0 : CORINFO_FLG_STATIC; + +#ifdef DEBUG + if (verbose) + { + unsigned structSize = (callRetTyp == TYP_STRUCT) ? eeTryGetClassSize(calliSig.retTypeSigClass) : 0; + printf("\nIn Compiler::impImportCall: opcode is %s, kind=%d, callRetType is %s, structSize is %u\n", + opcodeNames[opcode], callInfo->kind, varTypeName(callRetTyp), structSize); + } +#endif + sig = &calliSig; + } + else // (opcode != CEE_CALLI) + { + NamedIntrinsic ni = NI_Illegal; + + // Passing CORINFO_CALLINFO_ALLOWINSTPARAM indicates that this JIT is prepared to + // supply the instantiation parameters necessary to make direct calls to underlying + // shared generic code, rather than calling through instantiating stubs. If the + // returned signature has CORINFO_CALLCONV_PARAMTYPE then this indicates that the JIT + // must indeed pass an instantiation parameter. + + methHnd = callInfo->hMethod; + + sig = &(callInfo->sig); + callRetTyp = JITtype2varType(sig->retType); + + mflags = callInfo->methodFlags; + +#ifdef DEBUG + if (verbose) + { + unsigned structSize = (callRetTyp == TYP_STRUCT) ? eeTryGetClassSize(sig->retTypeSigClass) : 0; + printf("\nIn Compiler::impImportCall: opcode is %s, kind=%d, callRetType is %s, structSize is %u\n", + opcodeNames[opcode], callInfo->kind, varTypeName(callRetTyp), structSize); + } +#endif + if (compIsForInlining()) + { + /* Does the inlinee use StackCrawlMark */ + + if (mflags & CORINFO_FLG_DONT_INLINE_CALLER) + { + compInlineResult->NoteFatal(InlineObservation::CALLEE_STACK_CRAWL_MARK); + return TYP_UNDEF; + } + + /* For now ignore varargs */ + if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_NATIVEVARARG) + { + compInlineResult->NoteFatal(InlineObservation::CALLEE_HAS_NATIVE_VARARGS); + return TYP_UNDEF; + } + + if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG) + { + compInlineResult->NoteFatal(InlineObservation::CALLEE_HAS_MANAGED_VARARGS); + return TYP_UNDEF; + } + + if ((mflags & CORINFO_FLG_VIRTUAL) && (sig->sigInst.methInstCount != 0) && (opcode == CEE_CALLVIRT)) + { + compInlineResult->NoteFatal(InlineObservation::CALLEE_IS_GENERIC_VIRTUAL); + return TYP_UNDEF; + } + } + + clsHnd = pResolvedToken->hClass; + + clsFlags = callInfo->classFlags; + +#ifdef DEBUG + // If this is a call to JitTestLabel.Mark, do "early inlining", and record the test attribute. + + // This recognition should really be done by knowing the methHnd of the relevant Mark method(s). + // These should be in corelib.h, and available through a JIT/EE interface call. + const char* namespaceName; + const char* className; + const char* methodName = info.compCompHnd->getMethodNameFromMetadata(methHnd, &className, &namespaceName, nullptr); + if ((strcmp(namespaceName, "System.Runtime.CompilerServices") == 0) && + (strcmp(className, "JitTestLabel") == 0) && + (strcmp(methodName, "Mark") == 0)) + { + return impImportJitTestLabelMark(sig->numArgs); + } +#endif // DEBUG + + const bool isIntrinsic = (mflags & CORINFO_FLG_INTRINSIC) != 0; + + // Factor this into getCallInfo + bool isSpecialIntrinsic = false; + + if (isIntrinsic || !info.compMatchedVM) + { + // For mismatched VM (AltJit) we want to check all methods as intrinsic to ensure + // we get more accurate codegen. This particularly applies to HWIntrinsic usage + + const bool isTailCall = canTailCall && (tailCallFlags != 0); + + call = + impIntrinsic(newobjThis, clsHnd, methHnd, sig, mflags, pResolvedToken->token, isReadonlyCall, + isTailCall, pConstrainedResolvedToken, callInfo->thisTransform, &ni, &isSpecialIntrinsic); + + if (compDonotInline()) + { + return TYP_UNDEF; + } + + if (call != nullptr) + { +#ifdef FEATURE_READYTORUN + if (call->OperGet() == GT_INTRINSIC) + { + if (opts.IsReadyToRun()) + { + noway_assert(callInfo->kind == CORINFO_CALL); + call->AsIntrinsic()->gtEntryPoint = callInfo->codePointerLookup.constLookup; + } + else + { + call->AsIntrinsic()->gtEntryPoint.addr = nullptr; + call->AsIntrinsic()->gtEntryPoint.accessType = IAT_VALUE; + } + } +#endif + + bIntrinsicImported = true; + goto DONE_CALL; + } + } + +#ifdef FEATURE_SIMD + call = impSIMDIntrinsic(opcode, newobjThis, clsHnd, methHnd, sig, mflags, pResolvedToken->token); + if (call != nullptr) + { + bIntrinsicImported = true; + goto DONE_CALL; + } +#endif // FEATURE_SIMD + + if ((mflags & CORINFO_FLG_VIRTUAL) && (mflags & CORINFO_FLG_EnC) && (opcode == CEE_CALLVIRT)) + { + NO_WAY("Virtual call to a function added via EnC is not supported"); + } + + if ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_DEFAULT && + (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG && + (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG) + { + BADCODE("Bad calling convention"); + } + + //------------------------------------------------------------------------- + // Construct the call node + // + // Work out what sort of call we're making. + // Dispense with virtual calls implemented via LDVIRTFTN immediately. + + constraintCallThisTransform = callInfo->thisTransform; + exactContextHnd = callInfo->contextHandle; + exactContextNeedsRuntimeLookup = callInfo->exactContextNeedsRuntimeLookup; + + switch (callInfo->kind) + { + case CORINFO_VIRTUALCALL_STUB: + { + assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method + assert(!(clsFlags & CORINFO_FLG_VALUECLASS)); + if (callInfo->stubLookup.lookupKind.needsRuntimeLookup) + { + if (callInfo->stubLookup.lookupKind.runtimeLookupKind == CORINFO_LOOKUP_NOT_SUPPORTED) + { + // Runtime does not support inlining of all shapes of runtime lookups + // Inlining has to be aborted in such a case + compInlineResult->NoteFatal(InlineObservation::CALLSITE_HAS_COMPLEX_HANDLE); + return TYP_UNDEF; + } + + GenTree* stubAddr = impRuntimeLookupToTree(pResolvedToken, &callInfo->stubLookup, methHnd); + + // stubAddr tree may require a new temp. + // If we're inlining, this may trigger the too many locals inline failure. + // + // If so, we need to bail out. + // + if (compDonotInline()) + { + return TYP_UNDEF; + } + + // This is the rough code to set up an indirect stub call + assert(stubAddr != nullptr); + + // The stubAddr may be a + // complex expression. As it is evaluated after the args, + // it may cause registered args to be spilled. Simply spill it. + // + unsigned const lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall with runtime lookup")); + if (compDonotInline()) + { + return TYP_UNDEF; + } + + impAssignTempGen(lclNum, stubAddr, CHECK_SPILL_NONE); + stubAddr = gtNewLclvNode(lclNum, TYP_I_IMPL); + + // Create the actual call node + + assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG && + (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG); + + call = gtNewIndCallNode(stubAddr, callRetTyp); + + call->gtFlags |= GTF_EXCEPT | (stubAddr->gtFlags & GTF_GLOB_EFFECT); + call->gtFlags |= GTF_CALL_VIRT_STUB; + +#ifdef TARGET_X86 + // No tailcalls allowed for these yet... + canTailCall = false; + szCanTailCallFailReason = "VirtualCall with runtime lookup"; +#endif + } + else + { + // The stub address is known at compile time + call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di); + call->AsCall()->gtStubCallStubAddr = callInfo->stubLookup.constLookup.addr; + call->gtFlags |= GTF_CALL_VIRT_STUB; + assert(callInfo->stubLookup.constLookup.accessType != IAT_PPVALUE && + callInfo->stubLookup.constLookup.accessType != IAT_RELPVALUE); + if (callInfo->stubLookup.constLookup.accessType == IAT_PVALUE) + { + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_VIRTSTUB_REL_INDIRECT; + } + } + +#ifdef FEATURE_READYTORUN + if (opts.IsReadyToRun()) + { + // Null check is sometimes needed for ready to run to handle + // non-virtual <-> virtual changes between versions + if (callInfo->nullInstanceCheck) + { + call->gtFlags |= GTF_CALL_NULLCHECK; + } + } +#endif + + break; + } + + case CORINFO_VIRTUALCALL_VTABLE: + { + assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method + assert(!(clsFlags & CORINFO_FLG_VALUECLASS)); + call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di); + call->gtFlags |= GTF_CALL_VIRT_VTABLE; + + // Mark this method to expand the virtual call target early in fgMorphCall + call->AsCall()->SetExpandedEarly(); + break; + } + + case CORINFO_VIRTUALCALL_LDVIRTFTN: + { + if (compIsForInlining()) + { + compInlineResult->NoteFatal(InlineObservation::CALLSITE_HAS_CALL_VIA_LDVIRTFTN); + return TYP_UNDEF; + } + + assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method + assert(!(clsFlags & CORINFO_FLG_VALUECLASS)); + // OK, We've been told to call via LDVIRTFTN, so just + // take the call now.... + call = gtNewIndCallNode(nullptr, callRetTyp, di); + + impPopCallArgs(sig, call->AsCall()); + + GenTree* thisPtr = impPopStack().val; + thisPtr = impTransformThis(thisPtr, pConstrainedResolvedToken, callInfo->thisTransform); + assert(thisPtr != nullptr); + + // Clone the (possibly transformed) "this" pointer + GenTree* thisPtrCopy; + thisPtr = impCloneExpr(thisPtr, &thisPtrCopy, NO_CLASS_HANDLE, CHECK_SPILL_ALL, + nullptr DEBUGARG("LDVIRTFTN this pointer")); + + GenTree* fptr = impImportLdvirtftn(thisPtr, pResolvedToken, callInfo); + assert(fptr != nullptr); + + call->AsCall() + ->gtArgs.PushFront(this, NewCallArg::Primitive(thisPtrCopy).WellKnown(WellKnownArg::ThisPointer)); + + // Now make an indirect call through the function pointer + + unsigned lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall through function pointer")); + impAssignTempGen(lclNum, fptr, CHECK_SPILL_ALL); + fptr = gtNewLclvNode(lclNum, TYP_I_IMPL); + + call->AsCall()->gtCallAddr = fptr; + call->gtFlags |= GTF_EXCEPT | (fptr->gtFlags & GTF_GLOB_EFFECT); + + if ((sig->sigInst.methInstCount != 0) && IsTargetAbi(CORINFO_NATIVEAOT_ABI)) + { + // NativeAOT generic virtual method: need to handle potential fat function pointers + addFatPointerCandidate(call->AsCall()); + } +#ifdef FEATURE_READYTORUN + if (opts.IsReadyToRun()) + { + // Null check is needed for ready to run to handle + // non-virtual <-> virtual changes between versions + call->gtFlags |= GTF_CALL_NULLCHECK; + } +#endif + + // Sine we are jumping over some code, check that its OK to skip that code + assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG && + (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG); + goto DONE; + } + + case CORINFO_CALL: + { + // This is for a non-virtual, non-interface etc. call + call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di); + + // We remove the nullcheck for the GetType call intrinsic. + // TODO-CQ: JIT64 does not introduce the null check for many more helper calls + // and intrinsics. + if (callInfo->nullInstanceCheck && + !((mflags & CORINFO_FLG_INTRINSIC) != 0 && (ni == NI_System_Object_GetType))) + { + call->gtFlags |= GTF_CALL_NULLCHECK; + } + +#ifdef FEATURE_READYTORUN + if (opts.IsReadyToRun()) + { + call->AsCall()->setEntryPoint(callInfo->codePointerLookup.constLookup); + } +#endif + break; + } + + case CORINFO_CALL_CODE_POINTER: + { + // The EE has asked us to call by computing a code pointer and then doing an + // indirect call. This is because a runtime lookup is required to get the code entry point. + + // These calls always follow a uniform calling convention, i.e. no extra hidden params + assert((sig->callConv & CORINFO_CALLCONV_PARAMTYPE) == 0); + + assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG); + assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG); + + GenTree* fptr = + impLookupToTree(pResolvedToken, &callInfo->codePointerLookup, GTF_ICON_FTN_ADDR, callInfo->hMethod); + + if (compDonotInline()) + { + return TYP_UNDEF; + } + + // Now make an indirect call through the function pointer + + unsigned lclNum = lvaGrabTemp(true DEBUGARG("Indirect call through function pointer")); + impAssignTempGen(lclNum, fptr, CHECK_SPILL_ALL); + fptr = gtNewLclvNode(lclNum, TYP_I_IMPL); + + call = gtNewIndCallNode(fptr, callRetTyp, di); + call->gtFlags |= GTF_EXCEPT | (fptr->gtFlags & GTF_GLOB_EFFECT); + if (callInfo->nullInstanceCheck) + { + call->gtFlags |= GTF_CALL_NULLCHECK; + } + + break; + } + + default: + assert(!"unknown call kind"); + break; + } + + //------------------------------------------------------------------------- + // Set more flags + + PREFIX_ASSUME(call != nullptr); + + if (mflags & CORINFO_FLG_NOGCCHECK) + { + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_NOGCCHECK; + } + + // Mark call if it's one of the ones we will maybe treat as an intrinsic + if (isSpecialIntrinsic) + { + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_SPECIAL_INTRINSIC; + } + } + assert(sig); + assert(clsHnd || (opcode == CEE_CALLI)); // We're never verifying for CALLI, so this is not set. + + /* Some sanity checks */ + + // CALL_VIRT and NEWOBJ must have a THIS pointer + assert((opcode != CEE_CALLVIRT && opcode != CEE_NEWOBJ) || (sig->callConv & CORINFO_CALLCONV_HASTHIS)); + // static bit and hasThis are negations of one another + assert(((mflags & CORINFO_FLG_STATIC) != 0) == ((sig->callConv & CORINFO_CALLCONV_HASTHIS) == 0)); + assert(call != nullptr); + + /*------------------------------------------------------------------------- + * Check special-cases etc + */ + + /* Special case - Check if it is a call to Delegate.Invoke(). */ + + if (mflags & CORINFO_FLG_DELEGATE_INVOKE) + { + assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method + assert(mflags & CORINFO_FLG_FINAL); + + /* Set the delegate flag */ + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_DELEGATE_INV; + + if (callInfo->wrapperDelegateInvoke) + { + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_WRAPPER_DELEGATE_INV; + } + + if (opcode == CEE_CALLVIRT) + { + assert(mflags & CORINFO_FLG_FINAL); + + /* It should have the GTF_CALL_NULLCHECK flag set. Reset it */ + assert(call->gtFlags & GTF_CALL_NULLCHECK); + call->gtFlags &= ~GTF_CALL_NULLCHECK; + } + } + + CORINFO_CLASS_HANDLE actualMethodRetTypeSigClass; + actualMethodRetTypeSigClass = sig->retTypeSigClass; + + /* Check for varargs */ + if (!compFeatureVarArg() && ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG || + (sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_NATIVEVARARG)) + { + BADCODE("Varargs not supported."); + } + + if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG || + (sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_NATIVEVARARG) + { + assert(!compIsForInlining()); + + /* Set the right flags */ + + call->gtFlags |= GTF_CALL_POP_ARGS; + call->AsCall()->gtArgs.SetIsVarArgs(); + + /* Can't allow tailcall for varargs as it is caller-pop. The caller + will be expecting to pop a certain number of arguments, but if we + tailcall to a function with a different number of arguments, we + are hosed. There are ways around this (caller remembers esp value, + varargs is not caller-pop, etc), but not worth it. */ + CLANG_FORMAT_COMMENT_ANCHOR; + +#ifdef TARGET_X86 + if (canTailCall) + { + canTailCall = false; + szCanTailCallFailReason = "Callee is varargs"; + } +#endif + + /* Get the total number of arguments - this is already correct + * for CALLI - for methods we have to get it from the call site */ + + if (opcode != CEE_CALLI) + { +#ifdef DEBUG + unsigned numArgsDef = sig->numArgs; +#endif + eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, sig); + + // For vararg calls we must be sure to load the return type of the + // method actually being called, as well as the return types of the + // specified in the vararg signature. With type equivalency, these types + // may not be the same. + if (sig->retTypeSigClass != actualMethodRetTypeSigClass) + { + if (actualMethodRetTypeSigClass != nullptr && sig->retType != CORINFO_TYPE_CLASS && + sig->retType != CORINFO_TYPE_BYREF && sig->retType != CORINFO_TYPE_PTR && + sig->retType != CORINFO_TYPE_VAR) + { + // Make sure that all valuetypes (including enums) that we push are loaded. + // This is to guarantee that if a GC is triggered from the prestub of this methods, + // all valuetypes in the method signature are already loaded. + // We need to be able to find the size of the valuetypes, but we cannot + // do a class-load from within GC. + info.compCompHnd->classMustBeLoadedBeforeCodeIsRun(actualMethodRetTypeSigClass); + } + } + + assert(numArgsDef <= sig->numArgs); + } + + /* We will have "cookie" as the last argument but we cannot push + * it on the operand stack because we may overflow, so we append it + * to the arg list next after we pop them */ + } + + //--------------------------- Inline NDirect ------------------------------ + + // For inline cases we technically should look at both the current + // block and the call site block (or just the latter if we've + // fused the EH trees). However the block-related checks pertain to + // EH and we currently won't inline a method with EH. So for + // inlinees, just checking the call site block is sufficient. + { + // New lexical block here to avoid compilation errors because of GOTOs. + BasicBlock* block = compIsForInlining() ? impInlineInfo->iciBlock : compCurBB; + impCheckForPInvokeCall(call->AsCall(), methHnd, sig, mflags, block); + } + +#ifdef UNIX_X86_ABI + // On Unix x86 we use caller-cleaned convention. + if ((call->gtFlags & GTF_CALL_UNMANAGED) == 0) + call->gtFlags |= GTF_CALL_POP_ARGS; +#endif // UNIX_X86_ABI + + if (call->gtFlags & GTF_CALL_UNMANAGED) + { + // We set up the unmanaged call by linking the frame, disabling GC, etc + // This needs to be cleaned up on return. + // In addition, native calls have different normalization rules than managed code + // (managed calling convention always widens return values in the callee) + if (canTailCall) + { + canTailCall = false; + szCanTailCallFailReason = "Callee is native"; + } + + checkForSmallType = true; + + impPopArgsForUnmanagedCall(call->AsCall(), sig); + + goto DONE; + } + else if ((opcode == CEE_CALLI) && ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_DEFAULT) && + ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG)) + { + if (!info.compCompHnd->canGetCookieForPInvokeCalliSig(sig)) + { + // Normally this only happens with inlining. + // However, a generic method (or type) being NGENd into another module + // can run into this issue as well. There's not an easy fall-back for NGEN + // so instead we fallback to JIT. + if (compIsForInlining()) + { + compInlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_EMBED_PINVOKE_COOKIE); + } + else + { + IMPL_LIMITATION("Can't get PInvoke cookie (cross module generics)"); + } + + return TYP_UNDEF; + } + + GenTree* cookie = eeGetPInvokeCookie(sig); + + // This cookie is required to be either a simple GT_CNS_INT or + // an indirection of a GT_CNS_INT + // + GenTree* cookieConst = cookie; + if (cookie->gtOper == GT_IND) + { + cookieConst = cookie->AsOp()->gtOp1; + } + assert(cookieConst->gtOper == GT_CNS_INT); + + // Setting GTF_DONT_CSE on the GT_CNS_INT as well as on the GT_IND (if it exists) will ensure that + // we won't allow this tree to participate in any CSE logic + // + cookie->gtFlags |= GTF_DONT_CSE; + cookieConst->gtFlags |= GTF_DONT_CSE; + + call->AsCall()->gtCallCookie = cookie; + + if (canTailCall) + { + canTailCall = false; + szCanTailCallFailReason = "PInvoke calli"; + } + } + + /*------------------------------------------------------------------------- + * Create the argument list + */ + + //------------------------------------------------------------------------- + // Special case - for varargs we have an implicit last argument + + if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG) + { + assert(!compIsForInlining()); + + void *varCookie, *pVarCookie; + if (!info.compCompHnd->canGetVarArgsHandle(sig)) + { + compInlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_EMBED_VARARGS_COOKIE); + return TYP_UNDEF; + } + + varCookie = info.compCompHnd->getVarArgsHandle(sig, &pVarCookie); + assert((!varCookie) != (!pVarCookie)); + GenTree* cookieNode = gtNewIconEmbHndNode(varCookie, pVarCookie, GTF_ICON_VARG_HDL, sig); + assert(extraArg.Node == nullptr); + extraArg = NewCallArg::Primitive(cookieNode).WellKnown(WellKnownArg::VarArgsCookie); + } + + //------------------------------------------------------------------------- + // Extra arg for shared generic code and array methods + // + // Extra argument containing instantiation information is passed in the + // following circumstances: + // (a) To the "Address" method on array classes; the extra parameter is + // the array's type handle (a TypeDesc) + // (b) To shared-code instance methods in generic structs; the extra parameter + // is the struct's type handle (a vtable ptr) + // (c) To shared-code per-instantiation non-generic static methods in generic + // classes and structs; the extra parameter is the type handle + // (d) To shared-code generic methods; the extra parameter is an + // exact-instantiation MethodDesc + // + // We also set the exact type context associated with the call so we can + // inline the call correctly later on. + + if (sig->callConv & CORINFO_CALLCONV_PARAMTYPE) + { + assert(call->AsCall()->gtCallType == CT_USER_FUNC); + if (clsHnd == nullptr) + { + NO_WAY("CALLI on parameterized type"); + } + + assert(opcode != CEE_CALLI); + + GenTree* instParam; + bool runtimeLookup; + + // Instantiated generic method + if (((SIZE_T)exactContextHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_METHOD) + { + assert(exactContextHnd != METHOD_BEING_COMPILED_CONTEXT()); + + CORINFO_METHOD_HANDLE exactMethodHandle = + (CORINFO_METHOD_HANDLE)((SIZE_T)exactContextHnd & ~CORINFO_CONTEXTFLAGS_MASK); + + if (!exactContextNeedsRuntimeLookup) + { +#ifdef FEATURE_READYTORUN + if (opts.IsReadyToRun()) + { + instParam = + impReadyToRunLookupToTree(&callInfo->instParamLookup, GTF_ICON_METHOD_HDL, exactMethodHandle); + if (instParam == nullptr) + { + assert(compDonotInline()); + return TYP_UNDEF; + } + } + else +#endif + { + instParam = gtNewIconEmbMethHndNode(exactMethodHandle); + info.compCompHnd->methodMustBeLoadedBeforeCodeIsRun(exactMethodHandle); + } + } + else + { + instParam = impTokenToHandle(pResolvedToken, &runtimeLookup, true /*mustRestoreHandle*/); + if (instParam == nullptr) + { + assert(compDonotInline()); + return TYP_UNDEF; + } + } + } + + // otherwise must be an instance method in a generic struct, + // a static method in a generic type, or a runtime-generated array method + else + { + assert(((SIZE_T)exactContextHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_CLASS); + CORINFO_CLASS_HANDLE exactClassHandle = eeGetClassFromContext(exactContextHnd); + + if (compIsForInlining() && (clsFlags & CORINFO_FLG_ARRAY) != 0) + { + compInlineResult->NoteFatal(InlineObservation::CALLEE_IS_ARRAY_METHOD); + return TYP_UNDEF; + } + + if ((clsFlags & CORINFO_FLG_ARRAY) && isReadonlyCall) + { + // We indicate "readonly" to the Address operation by using a null + // instParam. + instParam = gtNewIconNode(0, TYP_REF); + } + else if (!exactContextNeedsRuntimeLookup) + { +#ifdef FEATURE_READYTORUN + if (opts.IsReadyToRun()) + { + instParam = + impReadyToRunLookupToTree(&callInfo->instParamLookup, GTF_ICON_CLASS_HDL, exactClassHandle); + if (instParam == nullptr) + { + assert(compDonotInline()); + return TYP_UNDEF; + } + } + else +#endif + { + instParam = gtNewIconEmbClsHndNode(exactClassHandle); + info.compCompHnd->classMustBeLoadedBeforeCodeIsRun(exactClassHandle); + } + } + else + { + instParam = impParentClassTokenToHandle(pResolvedToken, &runtimeLookup, true /*mustRestoreHandle*/); + if (instParam == nullptr) + { + assert(compDonotInline()); + return TYP_UNDEF; + } + } + } + + assert(extraArg.Node == nullptr); + extraArg = NewCallArg::Primitive(instParam).WellKnown(WellKnownArg::InstParam); + } + + if ((opcode == CEE_NEWOBJ) && ((clsFlags & CORINFO_FLG_DELEGATE) != 0)) + { + // Only verifiable cases are supported. + // dup; ldvirtftn; newobj; or ldftn; newobj. + // IL test could contain unverifiable sequence, in this case optimization should not be done. + if (impStackHeight() > 0) + { + typeInfo delegateTypeInfo = impStackTop().seTypeInfo; + if (delegateTypeInfo.IsMethod()) + { + ldftnInfo = delegateTypeInfo.GetMethodPointerInfo(); + } + } + } + + //------------------------------------------------------------------------- + // The main group of arguments + + impPopCallArgs(sig, call->AsCall()); + if (extraArg.Node != nullptr) + { + if (Target::g_tgtArgOrder == Target::ARG_ORDER_R2L) + { + call->AsCall()->gtArgs.PushFront(this, extraArg); + } + else + { + call->AsCall()->gtArgs.PushBack(this, extraArg); + } + + call->gtFlags |= extraArg.Node->gtFlags & GTF_GLOB_EFFECT; + } + + //------------------------------------------------------------------------- + // The "this" pointer + + if (((mflags & CORINFO_FLG_STATIC) == 0) && ((sig->callConv & CORINFO_CALLCONV_EXPLICITTHIS) == 0) && + !((opcode == CEE_NEWOBJ) && (newobjThis == nullptr))) + { + GenTree* obj; + + if (opcode == CEE_NEWOBJ) + { + obj = newobjThis; + } + else + { + obj = impPopStack().val; + obj = impTransformThis(obj, pConstrainedResolvedToken, constraintCallThisTransform); + if (compDonotInline()) + { + return TYP_UNDEF; + } + } + + // Store the "this" value in the call + call->gtFlags |= obj->gtFlags & GTF_GLOB_EFFECT; + call->AsCall()->gtArgs.PushFront(this, NewCallArg::Primitive(obj).WellKnown(WellKnownArg::ThisPointer)); + + if (impIsThis(obj)) + { + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_NONVIRT_SAME_THIS; + } + } + + bool probing; + probing = impConsiderCallProbe(call->AsCall(), rawILOffset); + + // See if we can devirt if we aren't probing. + if (!probing && opts.OptimizationEnabled()) + { + if (call->AsCall()->IsVirtual()) + { + // only true object pointers can be virtual + assert(call->AsCall()->gtArgs.HasThisPointer() && + call->AsCall()->gtArgs.GetThisArg()->GetNode()->TypeIs(TYP_REF)); + + // See if we can devirtualize. + + const bool isExplicitTailCall = (tailCallFlags & PREFIX_TAILCALL_EXPLICIT) != 0; + const bool isLateDevirtualization = false; + impDevirtualizeCall(call->AsCall(), pResolvedToken, &callInfo->hMethod, &callInfo->methodFlags, + &callInfo->contextHandle, &exactContextHnd, isLateDevirtualization, isExplicitTailCall, + // Take care to pass raw IL offset here as the 'debug info' might be different for + // inlinees. + rawILOffset); + + // Devirtualization may change which method gets invoked. Update our local cache. + // + methHnd = callInfo->hMethod; + } + else if (call->AsCall()->IsDelegateInvoke()) + { + considerGuardedDevirtualization(call->AsCall(), rawILOffset, false, NO_METHOD_HANDLE, NO_CLASS_HANDLE, + nullptr); + } + } + + //------------------------------------------------------------------------- + // The "this" pointer for "newobj" + + if (opcode == CEE_NEWOBJ) + { + if (clsFlags & CORINFO_FLG_VAROBJSIZE) + { + assert(!(clsFlags & CORINFO_FLG_ARRAY)); // arrays handled separately + // This is a 'new' of a variable sized object, wher + // the constructor is to return the object. In this case + // the constructor claims to return VOID but we know it + // actually returns the new object + assert(callRetTyp == TYP_VOID); + callRetTyp = TYP_REF; + call->gtType = TYP_REF; + impSpillSpecialSideEff(); + + impPushOnStack(call, typeInfo(TI_REF, clsHnd)); + } + else + { + if (clsFlags & CORINFO_FLG_DELEGATE) + { + // New inliner morph it in impImportCall. + // This will allow us to inline the call to the delegate constructor. + call = fgOptimizeDelegateConstructor(call->AsCall(), &exactContextHnd, ldftnInfo); + } + + if (!bIntrinsicImported) + { + +#if defined(DEBUG) || defined(INLINE_DATA) + + // Keep track of the raw IL offset of the call + call->AsCall()->gtRawILOffset = rawILOffset; + +#endif // defined(DEBUG) || defined(INLINE_DATA) + + // Is it an inline candidate? + impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo, rawILOffset); + } + + // append the call node. + impAppendTree(call, CHECK_SPILL_ALL, impCurStmtDI); + + // Now push the value of the 'new onto the stack + + // This is a 'new' of a non-variable sized object. + // Append the new node (op1) to the statement list, + // and then push the local holding the value of this + // new instruction on the stack. + + if (clsFlags & CORINFO_FLG_VALUECLASS) + { + assert(newobjThis->gtOper == GT_ADDR && newobjThis->AsOp()->gtOp1->gtOper == GT_LCL_VAR); + + unsigned tmp = newobjThis->AsOp()->gtOp1->AsLclVarCommon()->GetLclNum(); + impPushOnStack(gtNewLclvNode(tmp, lvaGetRealType(tmp)), verMakeTypeInfo(clsHnd).NormaliseForStack()); + } + else + { + if (newobjThis->gtOper == GT_COMMA) + { + // We must have inserted the callout. Get the real newobj. + newobjThis = newobjThis->AsOp()->gtOp2; + } + + assert(newobjThis->gtOper == GT_LCL_VAR); + impPushOnStack(gtNewLclvNode(newobjThis->AsLclVarCommon()->GetLclNum(), TYP_REF), + typeInfo(TI_REF, clsHnd)); + } + } + return callRetTyp; + } + +DONE: + +#ifdef DEBUG + // In debug we want to be able to register callsites with the EE. + assert(call->AsCall()->callSig == nullptr); + call->AsCall()->callSig = new (this, CMK_Generic) CORINFO_SIG_INFO; + *call->AsCall()->callSig = *sig; +#endif + + // Final importer checks for calls flagged as tail calls. + // + if (tailCallFlags != 0) + { + const bool isExplicitTailCall = (tailCallFlags & PREFIX_TAILCALL_EXPLICIT) != 0; + const bool isImplicitTailCall = (tailCallFlags & PREFIX_TAILCALL_IMPLICIT) != 0; + const bool isStressTailCall = (tailCallFlags & PREFIX_TAILCALL_STRESS) != 0; + + // Exactly one of these should be true. + assert(isExplicitTailCall != isImplicitTailCall); + + // This check cannot be performed for implicit tail calls for the reason + // that impIsImplicitTailCallCandidate() is not checking whether return + // types are compatible before marking a call node with PREFIX_TAILCALL_IMPLICIT. + // As a result it is possible that in the following case, we find that + // the type stack is non-empty if Callee() is considered for implicit + // tail calling. + // int Caller(..) { .... void Callee(); ret val; ... } + // + // Note that we cannot check return type compatibility before ImpImportCall() + // as we don't have required info or need to duplicate some of the logic of + // ImpImportCall(). + // + // For implicit tail calls, we perform this check after return types are + // known to be compatible. + if (isExplicitTailCall && (verCurrentState.esStackDepth != 0)) + { + BADCODE("Stack should be empty after tailcall"); + } + + // For opportunistic tailcalls we allow implicit widening, i.e. tailcalls from int32 -> int16, since the + // managed calling convention dictates that the callee widens the value. For explicit tailcalls we don't + // want to require this detail of the calling convention to bubble up to the tailcall helpers + bool allowWidening = isImplicitTailCall; + if (canTailCall && + !impTailCallRetTypeCompatible(allowWidening, info.compRetType, info.compMethodInfo->args.retTypeClass, + info.compCallConv, callRetTyp, sig->retTypeClass, + call->AsCall()->GetUnmanagedCallConv())) + { + canTailCall = false; + szCanTailCallFailReason = "Return types are not tail call compatible"; + } + + // Stack empty check for implicit tail calls. + if (canTailCall && isImplicitTailCall && (verCurrentState.esStackDepth != 0)) + { +#ifdef TARGET_AMD64 + // JIT64 Compatibility: Opportunistic tail call stack mismatch throws a VerificationException + // in JIT64, not an InvalidProgramException. + Verify(false, "Stack should be empty after tailcall"); +#else // TARGET_64BIT + BADCODE("Stack should be empty after tailcall"); +#endif //! TARGET_64BIT + } + + // assert(compCurBB is not a catch, finally or filter block); + // assert(compCurBB is not a try block protected by a finally block); + assert(!isExplicitTailCall || compCurBB->bbJumpKind == BBJ_RETURN); + + // Ask VM for permission to tailcall + if (canTailCall) + { + // True virtual or indirect calls, shouldn't pass in a callee handle. + CORINFO_METHOD_HANDLE exactCalleeHnd = + ((call->AsCall()->gtCallType != CT_USER_FUNC) || call->AsCall()->IsVirtual()) ? nullptr : methHnd; + + if (info.compCompHnd->canTailCall(info.compMethodHnd, methHnd, exactCalleeHnd, isExplicitTailCall)) + { + if (isExplicitTailCall) + { + // In case of explicit tail calls, mark it so that it is not considered + // for in-lining. + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_EXPLICIT_TAILCALL; + JITDUMP("\nGTF_CALL_M_EXPLICIT_TAILCALL set for call [%06u]\n", dspTreeID(call)); + + if (isStressTailCall) + { + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_STRESS_TAILCALL; + JITDUMP("\nGTF_CALL_M_STRESS_TAILCALL set for call [%06u]\n", dspTreeID(call)); + } + } + else + { +#if FEATURE_TAILCALL_OPT + // Must be an implicit tail call. + assert(isImplicitTailCall); + + // It is possible that a call node is both an inline candidate and marked + // for opportunistic tail calling. In-lining happens before morhphing of + // trees. If in-lining of an in-line candidate gets aborted for whatever + // reason, it will survive to the morphing stage at which point it will be + // transformed into a tail call after performing additional checks. + + call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_IMPLICIT_TAILCALL; + JITDUMP("\nGTF_CALL_M_IMPLICIT_TAILCALL set for call [%06u]\n", dspTreeID(call)); + +#else //! FEATURE_TAILCALL_OPT + NYI("Implicit tail call prefix on a target which doesn't support opportunistic tail calls"); + +#endif // FEATURE_TAILCALL_OPT + } + + // This might or might not turn into a tailcall. We do more + // checks in morph. For explicit tailcalls we need more + // information in morph in case it turns out to be a + // helper-based tailcall. + if (isExplicitTailCall) + { + assert(call->AsCall()->tailCallInfo == nullptr); + call->AsCall()->tailCallInfo = new (this, CMK_CorTailCallInfo) TailCallSiteInfo; + switch (opcode) + { + case CEE_CALLI: + call->AsCall()->tailCallInfo->SetCalli(sig); + break; + case CEE_CALLVIRT: + call->AsCall()->tailCallInfo->SetCallvirt(sig, pResolvedToken); + break; + default: + call->AsCall()->tailCallInfo->SetCall(sig, pResolvedToken); + break; + } + } + } + else + { + // canTailCall reported its reasons already + canTailCall = false; + JITDUMP("\ninfo.compCompHnd->canTailCall returned false for call [%06u]\n", dspTreeID(call)); + } + } + else + { + // If this assert fires it means that canTailCall was set to false without setting a reason! + assert(szCanTailCallFailReason != nullptr); + JITDUMP("\nRejecting %splicit tail call for [%06u], reason: '%s'\n", isExplicitTailCall ? "ex" : "im", + dspTreeID(call), szCanTailCallFailReason); + info.compCompHnd->reportTailCallDecision(info.compMethodHnd, methHnd, isExplicitTailCall, TAILCALL_FAIL, + szCanTailCallFailReason); + } + } + + // Note: we assume that small return types are already normalized by the managed callee + // or by the pinvoke stub for calls to unmanaged code. + + if (!bIntrinsicImported) + { + // + // Things needed to be checked when bIntrinsicImported is false. + // + + assert(call->gtOper == GT_CALL); + assert(callInfo != nullptr); + + if (compIsForInlining() && opcode == CEE_CALLVIRT) + { + assert(call->AsCall()->gtArgs.HasThisPointer()); + GenTree* callObj = call->AsCall()->gtArgs.GetThisArg()->GetEarlyNode(); + + if ((call->AsCall()->IsVirtual() || (call->gtFlags & GTF_CALL_NULLCHECK)) && + impInlineIsGuaranteedThisDerefBeforeAnySideEffects(nullptr, &call->AsCall()->gtArgs, callObj, + impInlineInfo->inlArgInfo)) + { + impInlineInfo->thisDereferencedFirst = true; + } + } + +#if defined(DEBUG) || defined(INLINE_DATA) + + // Keep track of the raw IL offset of the call + call->AsCall()->gtRawILOffset = rawILOffset; + +#endif // defined(DEBUG) || defined(INLINE_DATA) + + // Is it an inline candidate? + impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo, rawILOffset); + } + + // Extra checks for tail calls and tail recursion. + // + // A tail recursive call is a potential loop from the current block to the start of the root method. + // If we see a tail recursive call, mark the blocks from the call site back to the entry as potentially + // being in a loop. + // + // Note: if we're importing an inlinee we don't mark the right set of blocks, but by then it's too + // late. Currently this doesn't lead to problems. See GitHub issue 33529. + // + // OSR also needs to handle tail calls specially: + // * block profiling in OSR methods needs to ensure probes happen before tail calls, not after. + // * the root method entry must be imported if there's a recursive tail call or a potentially + // inlineable tail call. + // + if ((tailCallFlags != 0) && canTailCall) + { + if (gtIsRecursiveCall(methHnd)) + { + assert(verCurrentState.esStackDepth == 0); + BasicBlock* loopHead = nullptr; + if (!compIsForInlining() && opts.IsOSR()) + { + // For root method OSR we may branch back to the actual method entry, + // which is not fgFirstBB, and which we will need to import. + assert(fgEntryBB != nullptr); + loopHead = fgEntryBB; + } + else + { + // For normal jitting we may branch back to the firstBB; this + // should already be imported. + loopHead = fgFirstBB; + } + + JITDUMP("\nTail recursive call [%06u] in the method. Mark " FMT_BB " to " FMT_BB + " as having a backward branch.\n", + dspTreeID(call), loopHead->bbNum, compCurBB->bbNum); + fgMarkBackwardJump(loopHead, compCurBB); + + compMayConvertTailCallToLoop = true; + } + + // We only do these OSR checks in the root method because: + // * If we fail to import the root method entry when importing the root method, we can't go back + // and import it during inlining. So instead of checking just for recursive tail calls we also + // have to check for anything that might introduce a recursive tail call. + // * We only instrument root method blocks in OSR methods, + // + if (opts.IsOSR() && !compIsForInlining()) + { + // If a root method tail call candidate block is not a BBJ_RETURN, it should have a unique + // BBJ_RETURN successor. Mark that successor so we can handle it specially during profile + // instrumentation. + // + if (compCurBB->bbJumpKind != BBJ_RETURN) + { + BasicBlock* const successor = compCurBB->GetUniqueSucc(); + assert(successor->bbJumpKind == BBJ_RETURN); + successor->bbFlags |= BBF_TAILCALL_SUCCESSOR; + optMethodFlags |= OMF_HAS_TAILCALL_SUCCESSOR; + } + + // If this call might eventually turn into a loop back to method entry, make sure we + // import the method entry. + // + assert(call->IsCall()); + GenTreeCall* const actualCall = call->AsCall(); + const bool mustImportEntryBlock = gtIsRecursiveCall(methHnd) || actualCall->IsInlineCandidate() || + actualCall->IsGuardedDevirtualizationCandidate(); + + // Only schedule importation if we're not currently importing. + // + if (mustImportEntryBlock && (compCurBB != fgEntryBB)) + { + JITDUMP("\nOSR: inlineable or recursive tail call [%06u] in the method, so scheduling " FMT_BB + " for importation\n", + dspTreeID(call), fgEntryBB->bbNum); + impImportBlockPending(fgEntryBB); + } + } + } + + if ((sig->flags & CORINFO_SIGFLAG_FAT_CALL) != 0) + { + assert(opcode == CEE_CALLI || callInfo->kind == CORINFO_CALL_CODE_POINTER); + addFatPointerCandidate(call->AsCall()); + } + +DONE_CALL: + // Push or append the result of the call + if (callRetTyp == TYP_VOID) + { + if (opcode == CEE_NEWOBJ) + { + // we actually did push something, so don't spill the thing we just pushed. + assert(verCurrentState.esStackDepth > 0); + impAppendTree(call, verCurrentState.esStackDepth - 1, impCurStmtDI); + } + else + { + impAppendTree(call, CHECK_SPILL_ALL, impCurStmtDI); + } + } + else + { + impSpillSpecialSideEff(); + + if (clsFlags & CORINFO_FLG_ARRAY) + { + eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, sig); + } + + typeInfo tiRetVal = verMakeTypeInfo(sig->retType, sig->retTypeClass); + tiRetVal.NormaliseForStack(); + + if (call->IsCall()) + { + // Sometimes "call" is not a GT_CALL (if we imported an intrinsic that didn't turn into a call) + + GenTreeCall* origCall = call->AsCall(); + + const bool isFatPointerCandidate = origCall->IsFatPointerCandidate(); + const bool isInlineCandidate = origCall->IsInlineCandidate(); + const bool isGuardedDevirtualizationCandidate = origCall->IsGuardedDevirtualizationCandidate(); + + if (varTypeIsStruct(callRetTyp)) + { + // Need to treat all "split tree" cases here, not just inline candidates + call = impFixupCallStructReturn(call->AsCall(), sig->retTypeClass); + } + + // TODO: consider handling fatcalli cases this way too...? + if (isInlineCandidate || isGuardedDevirtualizationCandidate) + { + // We should not have made any adjustments in impFixupCallStructReturn + // as we defer those until we know the fate of the call. + assert(call == origCall); + + assert(opts.OptEnabled(CLFLG_INLINING)); + assert(!isFatPointerCandidate); // We should not try to inline calli. + + // Make the call its own tree (spill the stack if needed). + // Do not consume the debug info here. This is particularly + // important if we give up on the inline, in which case the + // call will typically end up in the statement that contains + // the GT_RET_EXPR that we leave on the stack. + impAppendTree(call, CHECK_SPILL_ALL, impCurStmtDI, false); + + // TODO: Still using the widened type. + GenTree* retExpr = gtNewInlineCandidateReturnExpr(call, genActualType(callRetTyp), compCurBB->bbFlags); + + // Link the retExpr to the call so if necessary we can manipulate it later. + origCall->gtInlineCandidateInfo->retExpr = retExpr; + + // Propagate retExpr as the placeholder for the call. + call = retExpr; + } + else + { + // If the call is virtual, and has a generics context, and is not going to have a class probe, + // record the context for possible use during late devirt. + // + // If we ever want to devirt at Tier0, and/or see issues where OSR methods under PGO lose + // important devirtualizations, we'll want to allow both a class probe and a captured context. + // + if (origCall->IsVirtual() && (origCall->gtCallType != CT_INDIRECT) && (exactContextHnd != nullptr) && + (origCall->gtHandleHistogramProfileCandidateInfo == nullptr)) + { + JITDUMP("\nSaving context %p for call [%06u]\n", exactContextHnd, dspTreeID(origCall)); + origCall->gtCallMoreFlags |= GTF_CALL_M_HAS_LATE_DEVIRT_INFO; + LateDevirtualizationInfo* const info = new (this, CMK_Inlining) LateDevirtualizationInfo; + info->exactContextHnd = exactContextHnd; + origCall->gtLateDevirtualizationInfo = info; + } + + if (isFatPointerCandidate) + { + // fatPointer candidates should be in statements of the form call() or var = call(). + // Such form allows to find statements with fat calls without walking through whole trees + // and removes problems with cutting trees. + assert(!bIntrinsicImported); + assert(IsTargetAbi(CORINFO_NATIVEAOT_ABI)); + if (call->OperGet() != GT_LCL_VAR) // can be already converted by impFixupCallStructReturn. + { + unsigned calliSlot = lvaGrabTemp(true DEBUGARG("calli")); + LclVarDsc* varDsc = lvaGetDesc(calliSlot); + + impAssignTempGen(calliSlot, call, tiRetVal.GetClassHandle(), CHECK_SPILL_NONE); + // impAssignTempGen can change src arg list and return type for call that returns struct. + var_types type = genActualType(lvaTable[calliSlot].TypeGet()); + call = gtNewLclvNode(calliSlot, type); + } + } + + // For non-candidates we must also spill, since we + // might have locals live on the eval stack that this + // call can modify. + // + // Suppress this for certain well-known call targets + // that we know won't modify locals, eg calls that are + // recognized in gtCanOptimizeTypeEquality. Otherwise + // we may break key fragile pattern matches later on. + bool spillStack = true; + if (call->IsCall()) + { + GenTreeCall* callNode = call->AsCall(); + if ((callNode->gtCallType == CT_HELPER) && (gtIsTypeHandleToRuntimeTypeHelper(callNode) || + gtIsTypeHandleToRuntimeTypeHandleHelper(callNode))) + { + spillStack = false; + } + else if ((callNode->gtCallMoreFlags & GTF_CALL_M_SPECIAL_INTRINSIC) != 0) + { + spillStack = false; + } + } + + if (spillStack) + { + impSpillSideEffects(true, CHECK_SPILL_ALL DEBUGARG("non-inline candidate call")); + } + } + } + + if (!bIntrinsicImported) + { + //------------------------------------------------------------------------- + // + /* If the call is of a small type and the callee is managed, the callee will normalize the result + before returning. + However, we need to normalize small type values returned by unmanaged + functions (pinvoke). The pinvoke stub does the normalization, but we need to do it here + if we use the shorter inlined pinvoke stub. */ + + if (checkForSmallType && varTypeIsIntegral(callRetTyp) && genTypeSize(callRetTyp) < genTypeSize(TYP_INT)) + { + call = gtNewCastNode(genActualType(callRetTyp), call, false, callRetTyp); + } + } + + impPushOnStack(call, tiRetVal); + } + + // VSD functions get a new call target each time we getCallInfo, so clear the cache. + // Also, the call info cache for CALLI instructions is largely incomplete, so clear it out. + // if ( (opcode == CEE_CALLI) || (callInfoCache.fetchCallInfo().kind == CORINFO_VIRTUALCALL_STUB)) + // callInfoCache.uncacheCallInfo(); + + return callRetTyp; +} +#ifdef _PREFAST_ +#pragma warning(pop) +#endif + +#ifdef DEBUG +// +var_types Compiler::impImportJitTestLabelMark(int numArgs) +{ + TestLabelAndNum tlAndN; + if (numArgs == 2) + { + tlAndN.m_num = 0; + StackEntry se = impPopStack(); + assert(se.seTypeInfo.GetType() == TI_INT); + GenTree* val = se.val; + assert(val->IsCnsIntOrI()); + tlAndN.m_tl = (TestLabel)val->AsIntConCommon()->IconValue(); + } + else if (numArgs == 3) + { + StackEntry se = impPopStack(); + assert(se.seTypeInfo.GetType() == TI_INT); + GenTree* val = se.val; + assert(val->IsCnsIntOrI()); + tlAndN.m_num = val->AsIntConCommon()->IconValue(); + se = impPopStack(); + assert(se.seTypeInfo.GetType() == TI_INT); + val = se.val; + assert(val->IsCnsIntOrI()); + tlAndN.m_tl = (TestLabel)val->AsIntConCommon()->IconValue(); + } + else + { + assert(false); + } + + StackEntry expSe = impPopStack(); + GenTree* node = expSe.val; + + // There are a small number of special cases, where we actually put the annotation on a subnode. + if (tlAndN.m_tl == TL_LoopHoist && tlAndN.m_num >= 100) + { + // A loop hoist annotation with value >= 100 means that the expression should be a static field access, + // a GT_IND of a static field address, which should be the sum of a (hoistable) helper call and possibly some + // offset within the static field block whose address is returned by the helper call. + // The annotation is saying that this address calculation, but not the entire access, should be hoisted. + assert(node->OperGet() == GT_IND); + tlAndN.m_num -= 100; + GetNodeTestData()->Set(node->AsOp()->gtOp1, tlAndN); + GetNodeTestData()->Remove(node); + } + else + { + GetNodeTestData()->Set(node, tlAndN); + } + + impPushOnStack(node, expSe.seTypeInfo); + return node->TypeGet(); +} +#endif // DEBUG + +//----------------------------------------------------------------------------------- +// impFixupCallStructReturn: For a call node that returns a struct do one of the following: +// - set the flag to indicate struct return via retbuf arg; +// - adjust the return type to a SIMD type if it is returned in 1 reg; +// - spill call result into a temp if it is returned into 2 registers or more and not tail call or inline candidate. +// +// Arguments: +// call - GT_CALL GenTree node +// retClsHnd - Class handle of return type of the call +// +// Return Value: +// Returns new GenTree node after fixing struct return of call node +// +GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HANDLE retClsHnd) +{ + if (!varTypeIsStruct(call)) + { + return call; + } + + call->gtRetClsHnd = retClsHnd; + +#if FEATURE_MULTIREG_RET + call->InitializeStructReturnType(this, retClsHnd, call->GetUnmanagedCallConv()); + const ReturnTypeDesc* retTypeDesc = call->GetReturnTypeDesc(); + const unsigned retRegCount = retTypeDesc->GetReturnRegCount(); +#else // !FEATURE_MULTIREG_RET + const unsigned retRegCount = 1; +#endif // !FEATURE_MULTIREG_RET + + structPassingKind howToReturnStruct; + var_types returnType = getReturnTypeForStruct(retClsHnd, call->GetUnmanagedCallConv(), &howToReturnStruct); + + if (howToReturnStruct == SPK_ByReference) + { + assert(returnType == TYP_UNKNOWN); + call->gtCallMoreFlags |= GTF_CALL_M_RETBUFFARG; + + if (call->IsUnmanaged()) + { + // Native ABIs do not allow retbufs to alias anything. + // This is allowed by the managed ABI and impAssignStructPtr will + // never introduce copies due to this. + unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Retbuf for unmanaged call")); + impAssignTempGen(tmpNum, call, retClsHnd, CHECK_SPILL_ALL); + return gtNewLclvNode(tmpNum, lvaGetDesc(tmpNum)->TypeGet()); + } + + return call; + } + + // Recognize SIMD types as we do for LCL_VARs, + // note it could be not the ABI specific type, for example, on x64 we can set 'TYP_SIMD8` + // for `System.Numerics.Vector2` here but lower will change it to long as ABI dictates. + var_types simdReturnType = impNormStructType(call->gtRetClsHnd); + if (simdReturnType != call->TypeGet()) + { + assert(varTypeIsSIMD(simdReturnType)); + JITDUMP("changing the type of a call [%06u] from %s to %s\n", dspTreeID(call), varTypeName(call->TypeGet()), + varTypeName(simdReturnType)); + call->ChangeType(simdReturnType); + } + + if (retRegCount == 1) + { + return call; + } + +#if FEATURE_MULTIREG_RET + assert(varTypeIsStruct(call)); // It could be a SIMD returned in several regs. + assert(returnType == TYP_STRUCT); + assert((howToReturnStruct == SPK_ByValueAsHfa) || (howToReturnStruct == SPK_ByValue)); + +#ifdef UNIX_AMD64_ABI + // must be a struct returned in two registers + assert(retRegCount == 2); +#else // not UNIX_AMD64_ABI + assert(retRegCount >= 2); +#endif // not UNIX_AMD64_ABI + + if (!call->CanTailCall() && !call->IsInlineCandidate()) + { + // Force a call returning multi-reg struct to be always of the IR form + // tmp = call + // + // No need to assign a multi-reg struct to a local var if: + // - It is a tail call or + // - The call is marked for in-lining later + return impAssignMultiRegTypeToVar(call, retClsHnd DEBUGARG(call->GetUnmanagedCallConv())); + } + return call; +#endif // FEATURE_MULTIREG_RET +} + /***************************************************************************** For struct return values, re-type the operand in the case where the ABI does not use a struct return buffer diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index b2cbc6965f578..a0f8c0c2143a1 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -209,12 +209,12 @@ var_types Compiler::impImportCall(OPCODE opcode, // This recognition should really be done by knowing the methHnd of the relevant Mark method(s). // These should be in corelib.h, and available through a JIT/EE interface call. - const char* modName; + const char* namespaceName; const char* className; - const char* methodName; - if ((className = eeGetClassName(clsHnd)) != nullptr && - strcmp(className, "System.Runtime.CompilerServices.JitTestLabel") == 0 && - (methodName = eeGetMethodName(methHnd, &modName)) != nullptr && strcmp(methodName, "Mark") == 0) + const char* methodName = info.compCompHnd->getMethodNameFromMetadata(methHnd, &className, &namespaceName, nullptr); + if ((strcmp(namespaceName, "System.Runtime.CompilerServices") == 0) && + (strcmp(className, "JitTestLabel") == 0) && + (strcmp(methodName, "Mark") == 0)) { return impImportJitTestLabelMark(sig->numArgs); } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index cc2415df59c39..26e52540226ba 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -1376,12 +1376,12 @@ private static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, I } [UnmanagedCallersOnly] - private static byte* _getFieldName(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* ftn, byte** moduleName) + private static UIntPtr _printFieldName(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) { var _this = GetThis(thisHandle); try { - return _this.getFieldName(ftn, moduleName); + return _this.printFieldName(field, buffer, bufferSize, pRequiredBufferSize); } catch (Exception ex) { @@ -1801,12 +1801,12 @@ private static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppExce } [UnmanagedCallersOnly] - private static byte* _getMethodName(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** moduleName) + private static UIntPtr _printMethodName(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) { var _this = GetThis(thisHandle); try { - return _this.getMethodName(ftn, moduleName); + return _this.printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); } catch (Exception ex) { @@ -2779,7 +2779,7 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[89] = (delegate* unmanaged)&_getArrayIntrinsicID; callbacks[90] = (delegate* unmanaged)&_getArrayInitializationData; callbacks[91] = (delegate* unmanaged)&_canAccessClass; - callbacks[92] = (delegate* unmanaged)&_getFieldName; + callbacks[92] = (delegate* unmanaged)&_printFieldName; callbacks[93] = (delegate* unmanaged)&_getFieldClass; callbacks[94] = (delegate* unmanaged)&_getFieldType; callbacks[95] = (delegate* unmanaged)&_getFieldOffset; @@ -2808,7 +2808,7 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[118] = (delegate* unmanaged)&_getEEInfo; callbacks[119] = (delegate* unmanaged)&_getJitTimeLogFilename; callbacks[120] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[121] = (delegate* unmanaged)&_getMethodName; + callbacks[121] = (delegate* unmanaged)&_printMethodName; callbacks[122] = (delegate* unmanaged)&_getMethodNameFromMetadata; callbacks[123] = (delegate* unmanaged)&_getMethodHash; callbacks[124] = (delegate* unmanaged)&_findNameOfToken; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig new file mode 100644 index 0000000000000..cadf59f72de57 --- /dev/null +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig @@ -0,0 +1,3100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// DO NOT EDIT THIS FILE! IT IS AUTOGENERATED +// To regenerate run the gen script in src/coreclr/tools/Common/JitInterface/ThunkGenerator +// and follow the instructions in docs/project/updating-jitinterface.md + +using System; +using System.Runtime.InteropServices; + +namespace Internal.JitInterface +{ + internal unsafe partial class CorInfoImpl + { + [UnmanagedCallersOnly] + private static byte _isIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + { + var _this = GetThis(thisHandle); + try + { + return _this.isIntrinsic(ftn) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodAttribs(ftn); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _setMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CorInfoMethodRuntimeFlags attribs) + { + var _this = GetThis(thisHandle); + try + { + _this.setMethodAttribs(ftn, attribs); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getMethodSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_SIG_INFO* sig, CORINFO_CLASS_STRUCT_* memberParent) + { + var _this = GetThis(thisHandle); + try + { + _this.getMethodSig(ftn, sig, memberParent); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _getMethodInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_METHOD_INFO* info) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodInfo(ftn, info) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoInline _canInline(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd) + { + var _this = GetThis(thisHandle); + try + { + return _this.canInline(callerHnd, calleeHnd); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _beginInlining(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd) + { + var _this = GetThis(thisHandle); + try + { + _this.beginInlining(inlinerHnd, inlineeHnd); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _reportInliningDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd, CorInfoInline inlineResult, byte* reason) + { + var _this = GetThis(thisHandle); + try + { + _this.reportInliningDecision(inlinerHnd, inlineeHnd, inlineResult, reason); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _canTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* declaredCalleeHnd, CORINFO_METHOD_STRUCT_* exactCalleeHnd, byte fIsTailPrefix) + { + var _this = GetThis(thisHandle); + try + { + return _this.canTailCall(callerHnd, declaredCalleeHnd, exactCalleeHnd, fIsTailPrefix != 0) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _reportTailCallDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd, byte fIsTailPrefix, CorInfoTailCall tailCallResult, byte* reason) + { + var _this = GetThis(thisHandle); + try + { + _this.reportTailCallDecision(callerHnd, calleeHnd, fIsTailPrefix != 0, tailCallResult, reason); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint EHnumber, CORINFO_EH_CLAUSE* clause) + { + var _this = GetThis(thisHandle); + try + { + _this.getEHinfo(ftn, EHnumber, ref *clause); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getMethodClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodClass(method); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_MODULE_STRUCT_* _getMethodModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodModule(method); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, uint* offsetOfIndirection, uint* offsetAfterIndirection, bool* isRelative) + { + var _this = GetThis(thisHandle); + try + { + _this.getMethodVTableOffset(method, ref *offsetOfIndirection, ref *offsetAfterIndirection, ref *isRelative); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_DEVIRTUALIZATION_INFO* info) + { + var _this = GetThis(thisHandle); + try + { + return _this.resolveVirtualMethod(info) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_METHOD_STRUCT_* _getUnboxedEntry(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, bool* requiresInstMethodTableArg) + { + var _this = GetThis(thisHandle); + try + { + return _this.getUnboxedEntry(ftn, ref *requiresInstMethodTableArg); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getDefaultComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) + { + var _this = GetThis(thisHandle); + try + { + return _this.getDefaultComparerClass(elemType); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getDefaultEqualityComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) + { + var _this = GetThis(thisHandle); + try + { + return _this.getDefaultEqualityComparerClass(elemType); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _expandRawHandleIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) + { + var _this = GetThis(thisHandle); + try + { + _this.expandRawHandleIntrinsic(ref *pResolvedToken, ref *pResult); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _isIntrinsicType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd) + { + var _this = GetThis(thisHandle); + try + { + return _this.isIntrinsicType(classHnd) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoCallConvExtension _getUnmanagedCallConv(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig, bool* pSuppressGCTransition) + { + var _this = GetThis(thisHandle); + try + { + return _this.getUnmanagedCallConv(method, callSiteSig, ref *pSuppressGCTransition); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _pInvokeMarshalingRequired(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig) + { + var _this = GetThis(thisHandle); + try + { + return _this.pInvokeMarshalingRequired(method, callSiteSig) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _satisfiesMethodConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* parent, CORINFO_METHOD_STRUCT_* method) + { + var _this = GetThis(thisHandle); + try + { + return _this.satisfiesMethodConstraints(parent, method) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isCompatibleDelegate(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* objCls, CORINFO_CLASS_STRUCT_* methodParentCls, CORINFO_METHOD_STRUCT_* method, CORINFO_CLASS_STRUCT_* delegateCls, bool* pfIsOpenDelegate) + { + var _this = GetThis(thisHandle); + try + { + return _this.isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, ref *pfIsOpenDelegate) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _methodMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + { + var _this = GetThis(thisHandle); + try + { + _this.methodMustBeLoadedBeforeCodeIsRun(method); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static CORINFO_METHOD_STRUCT_* _mapMethodDeclToMethodImpl(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + { + var _this = GetThis(thisHandle); + try + { + return _this.mapMethodDeclToMethodImpl(method); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getGSCookie(IntPtr thisHandle, IntPtr* ppException, IntPtr* pCookieVal, IntPtr** ppCookieVal) + { + var _this = GetThis(thisHandle); + try + { + _this.getGSCookie(pCookieVal, ppCookieVal); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _setPatchpointInfo(IntPtr thisHandle, IntPtr* ppException, PatchpointInfo* patchpointInfo) + { + var _this = GetThis(thisHandle); + try + { + _this.setPatchpointInfo(patchpointInfo); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static PatchpointInfo* _getOSRInfo(IntPtr thisHandle, IntPtr* ppException, uint* ilOffset) + { + var _this = GetThis(thisHandle); + try + { + return _this.getOSRInfo(ref *ilOffset); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) + { + var _this = GetThis(thisHandle); + try + { + _this.resolveToken(ref *pResolvedToken); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _tryResolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) + { + var _this = GetThis(thisHandle); + try + { + return _this.tryResolveToken(ref *pResolvedToken) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _findSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint sigTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) + { + var _this = GetThis(thisHandle); + try + { + _this.findSig(module, sigTOK, context, sig); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _findCallSiteSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint methTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) + { + var _this = GetThis(thisHandle); + try + { + _this.findCallSiteSig(module, methTOK, context, sig); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getTokenTypeAsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) + { + var _this = GetThis(thisHandle); + try + { + return _this.getTokenTypeAsHandle(ref *pResolvedToken); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isValidToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) + { + var _this = GetThis(thisHandle); + try + { + return _this.isValidToken(module, metaTOK) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isValidStringRef(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) + { + var _this = GetThis(thisHandle); + try + { + return _this.isValidStringRef(module, metaTOK) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static int _getStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK, char* buffer, int bufferSize, int startIndex) + { + var _this = GetThis(thisHandle); + try + { + return _this.getStringLiteral(module, metaTOK, buffer, bufferSize, startIndex); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static UIntPtr _printObjectDescription(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* handle, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) + { + var _this = GetThis(thisHandle); + try + { + return _this.printObjectDescription(handle, buffer, bufferSize, pRequiredBufferSize); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.asCorInfoType(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte* _getClassNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte** namespaceName) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassNameFromMetadata(cls, namespaceName); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getTypeInstantiationArgument(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, uint index) + { + var _this = GetThis(thisHandle); + try + { + return _this.getTypeInstantiationArgument(cls, index); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static UIntPtr _printClassName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) + { + var _this = GetThis(thisHandle); + try + { + return _this.printClassName(cls, buffer, bufferSize, pRequiredBufferSize); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.isValueClass(cls) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoInlineTypeCheck _canInlineTypeCheck(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CorInfoInlineTypeCheckSource source) + { + var _this = GetThis(thisHandle); + try + { + return _this.canInlineTypeCheck(cls, source); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassAttribs(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_MODULE_STRUCT_* _getClassModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassModule(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_ASSEMBLY_STRUCT_* _getModuleAssembly(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* mod) + { + var _this = GetThis(thisHandle); + try + { + return _this.getModuleAssembly(mod); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte* _getAssemblyName(IntPtr thisHandle, IntPtr* ppException, CORINFO_ASSEMBLY_STRUCT_* assem) + { + var _this = GetThis(thisHandle); + try + { + return _this.getAssemblyName(assem); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void* _LongLifetimeMalloc(IntPtr thisHandle, IntPtr* ppException, UIntPtr sz) + { + var _this = GetThis(thisHandle); + try + { + return _this.LongLifetimeMalloc(sz); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _LongLifetimeFree(IntPtr thisHandle, IntPtr* ppException, void* obj) + { + var _this = GetThis(thisHandle); + try + { + _this.LongLifetimeFree(obj); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static UIntPtr _getClassModuleIdForStatics(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CORINFO_MODULE_STRUCT_** pModule, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassModuleIdForStatics(cls, pModule, ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassSize(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getHeapClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getHeapClassSize(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _canAllocateOnStack(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.canAllocateOnStack(cls) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getClassAlignmentRequirement(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte fDoubleAlignHint) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassAlignmentRequirement(cls, fDoubleAlignHint != 0); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getClassGClayout(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* gcPtrs) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassGClayout(cls, gcPtrs); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getClassNumInstanceFields(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassNumInstanceFields(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_FIELD_STRUCT_* _getFieldInClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, int num) + { + var _this = GetThis(thisHandle); + try + { + return _this.getFieldInClass(clsHnd, num); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _checkMethodModifier(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod, byte* modifier, byte fOptional) + { + var _this = GetThis(thisHandle); + try + { + return _this.checkMethodModifier(hMethod, modifier, fOptional != 0) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getNewHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, bool* pHasSideEffects) + { + var _this = GetThis(thisHandle); + try + { + return _this.getNewHelper(ref *pResolvedToken, callerHandle, ref *pHasSideEffects); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getNewArrHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* arrayCls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getNewArrHelper(arrayCls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getCastingHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fThrowing) + { + var _this = GetThis(thisHandle); + try + { + return _this.getCastingHelper(ref *pResolvedToken, fThrowing != 0); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getSharedCCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd) + { + var _this = GetThis(thisHandle); + try + { + return _this.getSharedCCtorHelper(clsHnd); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getTypeForBox(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getTypeForBox(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getBoxHelper(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getUnBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getUnBoxHelper(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_OBJECT_STRUCT_* _getRuntimeTypePointer(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getRuntimeTypePointer(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isObjectImmutable(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* objPtr) + { + var _this = GetThis(thisHandle); + try + { + return _this.isObjectImmutable(objPtr) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getObjectType(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* objPtr) + { + var _this = GetThis(thisHandle); + try + { + return _this.getObjectType(objPtr); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup) + { + var _this = GetThis(thisHandle); + try + { + return _this.getReadyToRunHelper(ref *pResolvedToken, ref *pGenericLookupKind, id, ref *pLookup) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pTargetMethod, mdToken targetConstraint, CORINFO_CLASS_STRUCT_* delegateType, CORINFO_LOOKUP* pLookup) + { + var _this = GetThis(thisHandle); + try + { + _this.getReadyToRunDelegateCtorHelper(ref *pTargetMethod, targetConstraint, delegateType, ref *pLookup); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte* _getHelperName(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc helpFunc) + { + var _this = GetThis(thisHandle); + try + { + return _this.getHelperName(helpFunc); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoInitClassResult _initClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_METHOD_STRUCT_* method, CORINFO_CONTEXT_STRUCT* context) + { + var _this = GetThis(thisHandle); + try + { + return _this.initClass(field, method, context); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _classMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + _this.classMustBeLoadedBeforeCodeIsRun(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getBuiltinClass(IntPtr thisHandle, IntPtr* ppException, CorInfoClassId classId) + { + var _this = GetThis(thisHandle); + try + { + return _this.getBuiltinClass(classId); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoType _getTypeForPrimitiveValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getTypeForPrimitiveValueClass(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoType _getTypeForPrimitiveNumericClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getTypeForPrimitiveNumericClass(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _canCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* child, CORINFO_CLASS_STRUCT_* parent) + { + var _this = GetThis(thisHandle); + try + { + return _this.canCast(child, parent) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _areTypesEquivalent(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + { + var _this = GetThis(thisHandle); + try + { + return _this.areTypesEquivalent(cls1, cls2) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static TypeCompareState _compareTypesForCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* fromClass, CORINFO_CLASS_STRUCT_* toClass) + { + var _this = GetThis(thisHandle); + try + { + return _this.compareTypesForCast(fromClass, toClass); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static TypeCompareState _compareTypesForEquality(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + { + var _this = GetThis(thisHandle); + try + { + return _this.compareTypesForEquality(cls1, cls2); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _mergeClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + { + var _this = GetThis(thisHandle); + try + { + return _this.mergeClasses(cls1, cls2); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isMoreSpecificType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + { + var _this = GetThis(thisHandle); + try + { + return _this.isMoreSpecificType(cls1, cls2) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static TypeCompareState _isEnum(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CORINFO_CLASS_STRUCT_** underlyingType) + { + var _this = GetThis(thisHandle); + try + { + return _this.isEnum(cls, underlyingType); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getParentType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getParentType(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoType _getChildType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_CLASS_STRUCT_** clsRet) + { + var _this = GetThis(thisHandle); + try + { + return _this.getChildType(clsHnd, clsRet); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _satisfiesClassConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.satisfiesClassConstraints(cls) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isSDArray(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.isSDArray(cls) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getArrayRank(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArrayRank(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoArrayIntrinsic _getArrayIntrinsicID(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArrayIntrinsicID(ftn); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void* _getArrayInitializationData(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, uint size) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArrayInitializationData(field, size); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_HELPER_DESC* pAccessHelper) + { + var _this = GetThis(thisHandle); + try + { + return _this.canAccessClass(ref *pResolvedToken, callerHandle, ref *pAccessHelper); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static UIntPtr _printFieldName(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) + { + var _this = GetThis(thisHandle); + try + { + return _this.printFieldName(field, buffer, bufferSize, pRequiredBufferSize); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getFieldClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) + { + var _this = GetThis(thisHandle); + try + { + return _this.getFieldClass(field); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoType _getFieldType(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_CLASS_STRUCT_** structType, CORINFO_CLASS_STRUCT_* memberParent) + { + var _this = GetThis(thisHandle); + try + { + return _this.getFieldType(field, structType, memberParent); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getFieldOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) + { + var _this = GetThis(thisHandle); + try + { + return _this.getFieldOffset(field); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getFieldInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult) + { + var _this = GetThis(thisHandle); + try + { + _this.getFieldInfo(ref *pResolvedToken, callerHandle, flags, pResult); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _isFieldStatic(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* fldHnd) + { + var _this = GetThis(thisHandle); + try + { + return _this.isFieldStatic(fldHnd) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static int _getArrayOrStringLength(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* objHnd) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArrayOrStringLength(objHnd); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cILOffsets, uint** pILOffsets, BoundaryTypes* implicitBoundaries) + { + var _this = GetThis(thisHandle); + try + { + _this.getBoundaries(ftn, ref *cILOffsets, ref *pILOffsets, implicitBoundaries); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _setBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping* pMap) + { + var _this = GetThis(thisHandle); + try + { + _this.setBoundaries(ftn, cMap, pMap); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cVars, ILVarInfo** vars, bool* extendOthers) + { + var _this = GetThis(thisHandle); + try + { + _this.getVars(ftn, ref *cVars, vars, ref *extendOthers); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _setVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cVars, NativeVarInfo* vars) + { + var _this = GetThis(thisHandle); + try + { + _this.setVars(ftn, cVars, vars); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _reportRichMappings(IntPtr thisHandle, IntPtr* ppException, InlineTreeNode* inlineTreeNodes, uint numInlineTreeNodes, RichOffsetMapping* mappings, uint numMappings) + { + var _this = GetThis(thisHandle); + try + { + _this.reportRichMappings(inlineTreeNodes, numInlineTreeNodes, mappings, numMappings); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void* _allocateArray(IntPtr thisHandle, IntPtr* ppException, UIntPtr cBytes) + { + var _this = GetThis(thisHandle); + try + { + return _this.allocateArray(cBytes); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _freeArray(IntPtr thisHandle, IntPtr* ppException, void* array) + { + var _this = GetThis(thisHandle); + try + { + _this.freeArray(array); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static CORINFO_ARG_LIST_STRUCT_* _getArgNext(IntPtr thisHandle, IntPtr* ppException, CORINFO_ARG_LIST_STRUCT_* args) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArgNext(args); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoTypeWithMod _getArgType(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args, CORINFO_CLASS_STRUCT_** vcTypeRet) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArgType(sig, args, vcTypeRet); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static int _getExactClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* baseType, int maxExactClasses, CORINFO_CLASS_STRUCT_** exactClsRet) + { + var _this = GetThis(thisHandle); + try + { + return _this.getExactClasses(baseType, maxExactClasses, exactClsRet); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getArgClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args) + { + var _this = GetThis(thisHandle); + try + { + return _this.getArgClass(sig, args); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHFAElemType _getHFAType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* hClass) + { + var _this = GetThis(thisHandle); + try + { + return _this.getHFAType(hClass); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static HRESULT _GetErrorHRESULT(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) + { + var _this = GetThis(thisHandle); + try + { + return _this.GetErrorHRESULT(pExceptionPointers); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _GetErrorMessage(IntPtr thisHandle, IntPtr* ppException, char* buffer, uint bufferLength) + { + var _this = GetThis(thisHandle); + try + { + return _this.GetErrorMessage(buffer, bufferLength); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static int _FilterException(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) + { + var _this = GetThis(thisHandle); + try + { + return _this.FilterException(pExceptionPointers); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _ThrowExceptionForJitResult(IntPtr thisHandle, IntPtr* ppException, HRESULT result) + { + var _this = GetThis(thisHandle); + try + { + _this.ThrowExceptionForJitResult(result); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _ThrowExceptionForHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_HELPER_DESC* throwHelper) + { + var _this = GetThis(thisHandle); + try + { + _this.ThrowExceptionForHelper(ref *throwHelper); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _runWithErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) + { + var _this = GetThis(thisHandle); + try + { + return _this.runWithErrorTrap(function, parameter) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _runWithSPMIErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) + { + var _this = GetThis(thisHandle); + try + { + return _this.runWithSPMIErrorTrap(function, parameter) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getEEInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_EE_INFO* pEEInfoOut) + { + var _this = GetThis(thisHandle); + try + { + _this.getEEInfo(ref *pEEInfoOut); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static char* _getJitTimeLogFilename(IntPtr thisHandle, IntPtr* ppException) + { + var _this = GetThis(thisHandle); + try + { + return _this.getJitTimeLogFilename(); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodDefFromMethod(hMethod); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static UIntPtr _printMethodName(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) + { + var _this = GetThis(thisHandle); + try + { + return _this.printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte* _getMethodNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** className, byte** namespaceName, byte** enclosingClassName) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodNameFromMetadata(ftn, className, namespaceName, enclosingClassName); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getMethodHash(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodHash(ftn); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static UIntPtr _findNameOfToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleHandle, mdToken token, byte* szFQName, UIntPtr FQNameCapacity) + { + var _this = GetThis(thisHandle); + try + { + return _this.findNameOfToken(moduleHandle, token, szFQName, FQNameCapacity); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _getSystemVAmd64PassStructInRegisterDescriptor(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd, SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr) + { + var _this = GetThis(thisHandle); + try + { + return _this.getSystemVAmd64PassStructInRegisterDescriptor(structHnd, structPassInRegDescPtr) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getLoongArch64PassStructInRegisterFlags(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd) + { + var _this = GetThis(thisHandle); + try + { + return _this.getLoongArch64PassStructInRegisterFlags(structHnd); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getThreadTLSIndex(ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void* _getInlinedCallFrameVptr(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getInlinedCallFrameVptr(ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static int* _getAddrOfCaptureThreadGlobal(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getAddrOfCaptureThreadGlobal(ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void* _getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getHelperFtn(ftnNum, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _getFunctionEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_CONST_LOOKUP* pResult, CORINFO_ACCESS_FLAGS accessFlags) + { + var _this = GetThis(thisHandle); + try + { + _this.getFunctionEntryPoint(ftn, ref *pResult, accessFlags); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP* pResult) + { + var _this = GetThis(thisHandle); + try + { + _this.getFunctionFixedEntryPoint(ftn, isUnsafeFunctionPointer != 0, ref *pResult); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void* _getMethodSync(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getMethodSync(ftn, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle) + { + var _this = GetThis(thisHandle); + try + { + return _this.getLazyStringLiteralHelper(handle); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_MODULE_STRUCT_* _embedModuleHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.embedModuleHandle(handle, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _embedClassHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* handle, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.embedClassHandle(handle, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_METHOD_STRUCT_* _embedMethodHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* handle, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.embedMethodHandle(handle, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_FIELD_STRUCT_* _embedFieldHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* handle, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.embedFieldHandle(handle, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _embedGenericHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fEmbedParent, CORINFO_GENERICHANDLE_RESULT* pResult) + { + var _this = GetThis(thisHandle); + try + { + _this.embedGenericHandle(ref *pResolvedToken, fEmbedParent != 0, ref *pResult); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getLocationOfThisType(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* context, CORINFO_LOOKUP_KIND* pLookupKind) + { + var _this = GetThis(thisHandle); + try + { + _this.getLocationOfThisType(context, ref *pLookupKind); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getAddressOfPInvokeTarget(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_CONST_LOOKUP* pLookup) + { + var _this = GetThis(thisHandle); + try + { + _this.getAddressOfPInvokeTarget(method, ref *pLookup); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void* _GetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.GetCookieForPInvokeCalliSig(szMetaSig, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _canGetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig) + { + var _this = GetThis(thisHandle); + try + { + return _this.canGetCookieForPInvokeCalliSig(szMetaSig) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_JUST_MY_CODE_HANDLE_* _getJustMyCodeHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_JUST_MY_CODE_HANDLE_** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getJustMyCodeHandle(method, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _GetProfilingHandle(IntPtr thisHandle, IntPtr* ppException, bool* pbHookFunction, void** pProfilerHandle, bool* pbIndirectedHandles) + { + var _this = GetThis(thisHandle); + try + { + _this.GetProfilingHandle(ref *pbHookFunction, ref *pProfilerHandle, ref *pbIndirectedHandles); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _getCallInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, CORINFO_CALL_INFO* pResult) + { + var _this = GetThis(thisHandle); + try + { + _this.getCallInfo(ref *pResolvedToken, pConstrainedResolvedToken, callerHandle, flags, pResult); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _canAccessFamily(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hCaller, CORINFO_CLASS_STRUCT_* hInstanceType) + { + var _this = GetThis(thisHandle); + try + { + return _this.canAccessFamily(hCaller, hInstanceType) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _isRIDClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.isRIDClassDomainID(cls) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getClassDomainID(cls, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void* _getFieldAddress(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getFieldAddress(field, ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _getReadonlyStaticFieldValue(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* buffer, int bufferSize, byte ignoreMovableObjects) + { + var _this = GetThis(thisHandle); + try + { + return _this.getReadonlyStaticFieldValue(field, buffer, bufferSize, ignoreMovableObjects != 0) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static CORINFO_CLASS_STRUCT_* _getStaticFieldCurrentClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* pIsSpeculative) + { + var _this = GetThis(thisHandle); + try + { + return _this.getStaticFieldCurrentClass(field, pIsSpeculative); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static IntPtr _getVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getVarArgsHandle(pSig, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _canGetVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig) + { + var _this = GetThis(thisHandle); + try + { + return _this.canGetVarArgsHandle(pSig) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static InfoAccessType _constructStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, mdToken metaTok, void** ppValue) + { + var _this = GetThis(thisHandle); + try + { + return _this.constructStringLiteral(module, metaTok, ref *ppValue); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static InfoAccessType _emptyStringLiteral(IntPtr thisHandle, IntPtr* ppException, void** ppValue) + { + var _this = GetThis(thisHandle); + try + { + return _this.emptyStringLiteral(ref *ppValue); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getFieldThreadLocalStoreID(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) + { + var _this = GetThis(thisHandle); + try + { + return _this.getFieldThreadLocalStoreID(field, ref *ppIndirection); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _addActiveDependency(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleFrom, CORINFO_MODULE_STRUCT_* moduleTo) + { + var _this = GetThis(thisHandle); + try + { + _this.addActiveDependency(moduleFrom, moduleTo); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static CORINFO_METHOD_STRUCT_* _GetDelegateCtor(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_METHOD_STRUCT_* targetMethodHnd, DelegateCtorArgs* pCtorData) + { + var _this = GetThis(thisHandle); + try + { + return _this.GetDelegateCtor(methHnd, clsHnd, targetMethodHnd, ref *pCtorData); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _MethodCompileComplete(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd) + { + var _this = GetThis(thisHandle); + try + { + _this.MethodCompileComplete(methHnd); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _getTailCallHelpers(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, CORINFO_TAILCALL_HELPERS* pResult) + { + var _this = GetThis(thisHandle); + try + { + return _this.getTailCallHelpers(ref *callToken, sig, flags, ref *pResult) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _convertPInvokeCalliToCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte mustConvert) + { + var _this = GetThis(thisHandle); + try + { + return _this.convertPInvokeCalliToCall(ref *pResolvedToken, mustConvert != 0) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static byte _notifyInstructionSetUsage(IntPtr thisHandle, IntPtr* ppException, InstructionSet instructionSet, byte supportEnabled) + { + var _this = GetThis(thisHandle); + try + { + return _this.notifyInstructionSetUsage(instructionSet, supportEnabled != 0) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _updateEntryPointForTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_CONST_LOOKUP* entryPoint) + { + var _this = GetThis(thisHandle); + try + { + _this.updateEntryPointForTailCall(ref *entryPoint); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _allocMem(IntPtr thisHandle, IntPtr* ppException, AllocMemArgs* pArgs) + { + var _this = GetThis(thisHandle); + try + { + _this.allocMem(ref *pArgs); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _reserveUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte isFunclet, byte isColdCode, uint unwindSize) + { + var _this = GetThis(thisHandle); + try + { + _this.reserveUnwindInfo(isFunclet != 0, isColdCode != 0, unwindSize); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _allocUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte* pHotCode, byte* pColdCode, uint startOffset, uint endOffset, uint unwindSize, byte* pUnwindBlock, CorJitFuncKind funcKind) + { + var _this = GetThis(thisHandle); + try + { + _this.allocUnwindInfo(pHotCode, pColdCode, startOffset, endOffset, unwindSize, pUnwindBlock, funcKind); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void* _allocGCInfo(IntPtr thisHandle, IntPtr* ppException, UIntPtr size) + { + var _this = GetThis(thisHandle); + try + { + return _this.allocGCInfo(size); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _setEHcount(IntPtr thisHandle, IntPtr* ppException, uint cEH) + { + var _this = GetThis(thisHandle); + try + { + _this.setEHcount(cEH); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _setEHinfo(IntPtr thisHandle, IntPtr* ppException, uint EHnumber, CORINFO_EH_CLAUSE* clause) + { + var _this = GetThis(thisHandle); + try + { + _this.setEHinfo(EHnumber, ref *clause); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static byte _logMsg(IntPtr thisHandle, IntPtr* ppException, uint level, byte* fmt, IntPtr args) + { + var _this = GetThis(thisHandle); + try + { + return _this.logMsg(level, fmt, args) ? (byte)1 : (byte)0; + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static int _doAssert(IntPtr thisHandle, IntPtr* ppException, byte* szFile, int iLine, byte* szExpr) + { + var _this = GetThis(thisHandle); + try + { + return _this.doAssert(szFile, iLine, szExpr); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _reportFatalError(IntPtr thisHandle, IntPtr* ppException, CorJitResult result) + { + var _this = GetThis(thisHandle); + try + { + _this.reportFatalError(result); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static HRESULT _getPgoInstrumentationResults(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema** pSchema, uint* pCountSchemaItems, byte** pInstrumentationData, PgoSource* pgoSource) + { + var _this = GetThis(thisHandle); + try + { + return _this.getPgoInstrumentationResults(ftnHnd, ref *pSchema, ref *pCountSchemaItems, pInstrumentationData, ref *pgoSource); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static HRESULT _allocPgoInstrumentationBySchema(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema* pSchema, uint countSchemaItems, byte** pInstrumentationData) + { + var _this = GetThis(thisHandle); + try + { + return _this.allocPgoInstrumentationBySchema(ftnHnd, pSchema, countSchemaItems, pInstrumentationData); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_STRUCT_* methodHandle) + { + var _this = GetThis(thisHandle); + try + { + _this.recordCallSite(instrOffset, callSig, methodHandle); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta) + { + var _this = GetThis(thisHandle); + try + { + _this.recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + } + } + + [UnmanagedCallersOnly] + private static ushort _getRelocTypeHint(IntPtr thisHandle, IntPtr* ppException, void* target) + { + var _this = GetThis(thisHandle); + try + { + return _this.getRelocTypeHint(target); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getExpectedTargetArchitecture(IntPtr thisHandle, IntPtr* ppException) + { + var _this = GetThis(thisHandle); + try + { + return _this.getExpectedTargetArchitecture(); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + [UnmanagedCallersOnly] + private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_FLAGS* flags, uint sizeInBytes) + { + var _this = GetThis(thisHandle); + try + { + return _this.getJitFlags(ref *flags, sizeInBytes); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + + + private static IntPtr GetUnmanagedCallbacks() + { + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 181); + + callbacks[0] = (delegate* unmanaged)&_isIntrinsic; + callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; + callbacks[2] = (delegate* unmanaged)&_setMethodAttribs; + callbacks[3] = (delegate* unmanaged)&_getMethodSig; + callbacks[4] = (delegate* unmanaged)&_getMethodInfo; + callbacks[5] = (delegate* unmanaged)&_canInline; + callbacks[6] = (delegate* unmanaged)&_beginInlining; + callbacks[7] = (delegate* unmanaged)&_reportInliningDecision; + callbacks[8] = (delegate* unmanaged)&_canTailCall; + callbacks[9] = (delegate* unmanaged)&_reportTailCallDecision; + callbacks[10] = (delegate* unmanaged)&_getEHinfo; + callbacks[11] = (delegate* unmanaged)&_getMethodClass; + callbacks[12] = (delegate* unmanaged)&_getMethodModule; + callbacks[13] = (delegate* unmanaged)&_getMethodVTableOffset; + callbacks[14] = (delegate* unmanaged)&_resolveVirtualMethod; + callbacks[15] = (delegate* unmanaged)&_getUnboxedEntry; + callbacks[16] = (delegate* unmanaged)&_getDefaultComparerClass; + callbacks[17] = (delegate* unmanaged)&_getDefaultEqualityComparerClass; + callbacks[18] = (delegate* unmanaged)&_expandRawHandleIntrinsic; + callbacks[19] = (delegate* unmanaged)&_isIntrinsicType; + callbacks[20] = (delegate* unmanaged)&_getUnmanagedCallConv; + callbacks[21] = (delegate* unmanaged)&_pInvokeMarshalingRequired; + callbacks[22] = (delegate* unmanaged)&_satisfiesMethodConstraints; + callbacks[23] = (delegate* unmanaged)&_isCompatibleDelegate; + callbacks[24] = (delegate* unmanaged)&_methodMustBeLoadedBeforeCodeIsRun; + callbacks[25] = (delegate* unmanaged)&_mapMethodDeclToMethodImpl; + callbacks[26] = (delegate* unmanaged)&_getGSCookie; + callbacks[27] = (delegate* unmanaged)&_setPatchpointInfo; + callbacks[28] = (delegate* unmanaged)&_getOSRInfo; + callbacks[29] = (delegate* unmanaged)&_resolveToken; + callbacks[30] = (delegate* unmanaged)&_tryResolveToken; + callbacks[31] = (delegate* unmanaged)&_findSig; + callbacks[32] = (delegate* unmanaged)&_findCallSiteSig; + callbacks[33] = (delegate* unmanaged)&_getTokenTypeAsHandle; + callbacks[34] = (delegate* unmanaged)&_isValidToken; + callbacks[35] = (delegate* unmanaged)&_isValidStringRef; + callbacks[36] = (delegate* unmanaged)&_getStringLiteral; + callbacks[37] = (delegate* unmanaged)&_printObjectDescription; + callbacks[38] = (delegate* unmanaged)&_asCorInfoType; + callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; + callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; + callbacks[41] = (delegate* unmanaged)&_printClassName; + callbacks[42] = (delegate* unmanaged)&_isValueClass; + callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; + callbacks[44] = (delegate* unmanaged)&_getClassAttribs; + callbacks[45] = (delegate* unmanaged)&_getClassModule; + callbacks[46] = (delegate* unmanaged)&_getModuleAssembly; + callbacks[47] = (delegate* unmanaged)&_getAssemblyName; + callbacks[48] = (delegate* unmanaged)&_LongLifetimeMalloc; + callbacks[49] = (delegate* unmanaged)&_LongLifetimeFree; + callbacks[50] = (delegate* unmanaged)&_getClassModuleIdForStatics; + callbacks[51] = (delegate* unmanaged)&_getClassSize; + callbacks[52] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[53] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[54] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[55] = (delegate* unmanaged)&_getClassGClayout; + callbacks[56] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[57] = (delegate* unmanaged)&_getFieldInClass; + callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[59] = (delegate* unmanaged)&_getNewHelper; + callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[61] = (delegate* unmanaged)&_getCastingHelper; + callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[63] = (delegate* unmanaged)&_getTypeForBox; + callbacks[64] = (delegate* unmanaged)&_getBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; +<<<<<<< HEAD:src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs + callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[67] = (delegate* unmanaged)&_isObjectImmutable; + callbacks[68] = (delegate* unmanaged)&_getObjectType; + callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[71] = (delegate* unmanaged)&_getHelperName; + callbacks[72] = (delegate* unmanaged)&_initClass; + callbacks[73] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[74] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[77] = (delegate* unmanaged)&_canCast; + callbacks[78] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[79] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[80] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[81] = (delegate* unmanaged)&_mergeClasses; + callbacks[82] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[83] = (delegate* unmanaged)&_isEnum; + callbacks[84] = (delegate* unmanaged)&_getParentType; + callbacks[85] = (delegate* unmanaged)&_getChildType; + callbacks[86] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[87] = (delegate* unmanaged)&_isSDArray; + callbacks[88] = (delegate* unmanaged)&_getArrayRank; + callbacks[89] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[90] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[91] = (delegate* unmanaged)&_canAccessClass; + callbacks[92] = (delegate* unmanaged)&_getFieldName; + callbacks[93] = (delegate* unmanaged)&_getFieldClass; + callbacks[94] = (delegate* unmanaged)&_getFieldType; + callbacks[95] = (delegate* unmanaged)&_getFieldOffset; + callbacks[96] = (delegate* unmanaged)&_getFieldInfo; + callbacks[97] = (delegate* unmanaged)&_isFieldStatic; + callbacks[98] = (delegate* unmanaged)&_getArrayOrStringLength; + callbacks[99] = (delegate* unmanaged)&_getBoundaries; + callbacks[100] = (delegate* unmanaged)&_setBoundaries; + callbacks[101] = (delegate* unmanaged)&_getVars; + callbacks[102] = (delegate* unmanaged)&_setVars; + callbacks[103] = (delegate* unmanaged)&_reportRichMappings; + callbacks[104] = (delegate* unmanaged)&_allocateArray; + callbacks[105] = (delegate* unmanaged)&_freeArray; + callbacks[106] = (delegate* unmanaged)&_getArgNext; + callbacks[107] = (delegate* unmanaged)&_getArgType; + callbacks[108] = (delegate* unmanaged)&_getExactClasses; + callbacks[109] = (delegate* unmanaged)&_getArgClass; + callbacks[110] = (delegate* unmanaged)&_getHFAType; + callbacks[111] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[112] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[113] = (delegate* unmanaged)&_FilterException; + callbacks[114] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[115] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[116] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[117] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[118] = (delegate* unmanaged)&_getEEInfo; + callbacks[119] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[120] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[121] = (delegate* unmanaged)&_getMethodName; + callbacks[122] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[123] = (delegate* unmanaged)&_getMethodHash; + callbacks[124] = (delegate* unmanaged)&_findNameOfToken; + callbacks[125] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[126] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[128] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[129] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[130] = (delegate* unmanaged)&_getHelperFtn; + callbacks[131] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[132] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[133] = (delegate* unmanaged)&_getMethodSync; + callbacks[134] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[135] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[136] = (delegate* unmanaged)&_embedClassHandle; + callbacks[137] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[138] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[139] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[140] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[141] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[142] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[143] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[144] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[145] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[146] = (delegate* unmanaged)&_getCallInfo; + callbacks[147] = (delegate* unmanaged)&_canAccessFamily; + callbacks[148] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[149] = (delegate* unmanaged)&_getClassDomainID; + callbacks[150] = (delegate* unmanaged)&_getFieldAddress; + callbacks[151] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; + callbacks[152] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[153] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[154] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[155] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[156] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[157] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[158] = (delegate* unmanaged)&_addActiveDependency; + callbacks[159] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[160] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[161] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[162] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[163] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[164] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[165] = (delegate* unmanaged)&_allocMem; + callbacks[166] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[167] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[168] = (delegate* unmanaged)&_allocGCInfo; + callbacks[169] = (delegate* unmanaged)&_setEHcount; + callbacks[170] = (delegate* unmanaged)&_setEHinfo; + callbacks[171] = (delegate* unmanaged)&_logMsg; + callbacks[172] = (delegate* unmanaged)&_doAssert; + callbacks[173] = (delegate* unmanaged)&_reportFatalError; + callbacks[174] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[175] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[176] = (delegate* unmanaged)&_recordCallSite; + callbacks[177] = (delegate* unmanaged)&_recordRelocation; + callbacks[178] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[179] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[180] = (delegate* unmanaged)&_getJitFlags; +||||||| parent of 35ee62dcc42 (Work on switching getMethodName and getFieldName to print):src/coreclr/tools/Common/JitInterface/CorInfoBase.cs + callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[67] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[68] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[69] = (delegate* unmanaged)&_getHelperName; + callbacks[70] = (delegate* unmanaged)&_initClass; + callbacks[71] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[72] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[75] = (delegate* unmanaged)&_canCast; + callbacks[76] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[79] = (delegate* unmanaged)&_mergeClasses; + callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[81] = (delegate* unmanaged)&_getParentType; + callbacks[82] = (delegate* unmanaged)&_getChildType; + callbacks[83] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[84] = (delegate* unmanaged)&_isSDArray; + callbacks[85] = (delegate* unmanaged)&_getArrayRank; + callbacks[86] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[87] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[88] = (delegate* unmanaged)&_canAccessClass; + callbacks[89] = (delegate* unmanaged)&_getFieldName; + callbacks[90] = (delegate* unmanaged)&_getFieldClass; + callbacks[91] = (delegate* unmanaged)&_getFieldType; + callbacks[92] = (delegate* unmanaged)&_getFieldOffset; + callbacks[93] = (delegate* unmanaged)&_getFieldInfo; + callbacks[94] = (delegate* unmanaged)&_isFieldStatic; + callbacks[95] = (delegate* unmanaged)&_getBoundaries; + callbacks[96] = (delegate* unmanaged)&_setBoundaries; + callbacks[97] = (delegate* unmanaged)&_getVars; + callbacks[98] = (delegate* unmanaged)&_setVars; + callbacks[99] = (delegate* unmanaged)&_reportRichMappings; + callbacks[100] = (delegate* unmanaged)&_allocateArray; + callbacks[101] = (delegate* unmanaged)&_freeArray; + callbacks[102] = (delegate* unmanaged)&_getArgNext; + callbacks[103] = (delegate* unmanaged)&_getArgType; + callbacks[104] = (delegate* unmanaged)&_getExactClasses; + callbacks[105] = (delegate* unmanaged)&_getArgClass; + callbacks[106] = (delegate* unmanaged)&_getHFAType; + callbacks[107] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[108] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[109] = (delegate* unmanaged)&_FilterException; + callbacks[110] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[111] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[112] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[113] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[114] = (delegate* unmanaged)&_getEEInfo; + callbacks[115] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[116] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[117] = (delegate* unmanaged)&_getMethodName; + callbacks[118] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[119] = (delegate* unmanaged)&_getMethodHash; + callbacks[120] = (delegate* unmanaged)&_findNameOfToken; + callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[122] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[123] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[124] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[125] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[126] = (delegate* unmanaged)&_getHelperFtn; + callbacks[127] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[128] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[129] = (delegate* unmanaged)&_getMethodSync; + callbacks[130] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[131] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[132] = (delegate* unmanaged)&_embedClassHandle; + callbacks[133] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[134] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[135] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[136] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[137] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[138] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[139] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[140] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[141] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[142] = (delegate* unmanaged)&_getCallInfo; + callbacks[143] = (delegate* unmanaged)&_canAccessFamily; + callbacks[144] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[145] = (delegate* unmanaged)&_getClassDomainID; + callbacks[146] = (delegate* unmanaged)&_getFieldAddress; + callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[148] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[149] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[150] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[151] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[152] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[153] = (delegate* unmanaged)&_addActiveDependency; + callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[160] = (delegate* unmanaged)&_allocMem; + callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[163] = (delegate* unmanaged)&_allocGCInfo; + callbacks[164] = (delegate* unmanaged)&_setEHcount; + callbacks[165] = (delegate* unmanaged)&_setEHinfo; + callbacks[166] = (delegate* unmanaged)&_logMsg; + callbacks[167] = (delegate* unmanaged)&_doAssert; + callbacks[168] = (delegate* unmanaged)&_reportFatalError; + callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[171] = (delegate* unmanaged)&_recordCallSite; + callbacks[172] = (delegate* unmanaged)&_recordRelocation; + callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[175] = (delegate* unmanaged)&_getJitFlags; +======= + callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[67] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[68] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[69] = (delegate* unmanaged)&_getHelperName; + callbacks[70] = (delegate* unmanaged)&_initClass; + callbacks[71] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[72] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[75] = (delegate* unmanaged)&_canCast; + callbacks[76] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[79] = (delegate* unmanaged)&_mergeClasses; + callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[81] = (delegate* unmanaged)&_getParentType; + callbacks[82] = (delegate* unmanaged)&_getChildType; + callbacks[83] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[84] = (delegate* unmanaged)&_isSDArray; + callbacks[85] = (delegate* unmanaged)&_getArrayRank; + callbacks[86] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[87] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[88] = (delegate* unmanaged)&_canAccessClass; + callbacks[89] = (delegate* unmanaged)&_printFieldName; + callbacks[90] = (delegate* unmanaged)&_getFieldClass; + callbacks[91] = (delegate* unmanaged)&_getFieldType; + callbacks[92] = (delegate* unmanaged)&_getFieldOffset; + callbacks[93] = (delegate* unmanaged)&_getFieldInfo; + callbacks[94] = (delegate* unmanaged)&_isFieldStatic; + callbacks[95] = (delegate* unmanaged)&_getBoundaries; + callbacks[96] = (delegate* unmanaged)&_setBoundaries; + callbacks[97] = (delegate* unmanaged)&_getVars; + callbacks[98] = (delegate* unmanaged)&_setVars; + callbacks[99] = (delegate* unmanaged)&_reportRichMappings; + callbacks[100] = (delegate* unmanaged)&_allocateArray; + callbacks[101] = (delegate* unmanaged)&_freeArray; + callbacks[102] = (delegate* unmanaged)&_getArgNext; + callbacks[103] = (delegate* unmanaged)&_getArgType; + callbacks[104] = (delegate* unmanaged)&_getExactClasses; + callbacks[105] = (delegate* unmanaged)&_getArgClass; + callbacks[106] = (delegate* unmanaged)&_getHFAType; + callbacks[107] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[108] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[109] = (delegate* unmanaged)&_FilterException; + callbacks[110] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[111] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[112] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[113] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[114] = (delegate* unmanaged)&_getEEInfo; + callbacks[115] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[116] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[117] = (delegate* unmanaged)&_printMethodName; + callbacks[118] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[119] = (delegate* unmanaged)&_getMethodHash; + callbacks[120] = (delegate* unmanaged)&_findNameOfToken; + callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[122] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[123] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[124] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[125] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[126] = (delegate* unmanaged)&_getHelperFtn; + callbacks[127] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[128] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[129] = (delegate* unmanaged)&_getMethodSync; + callbacks[130] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[131] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[132] = (delegate* unmanaged)&_embedClassHandle; + callbacks[133] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[134] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[135] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[136] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[137] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[138] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[139] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[140] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[141] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[142] = (delegate* unmanaged)&_getCallInfo; + callbacks[143] = (delegate* unmanaged)&_canAccessFamily; + callbacks[144] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[145] = (delegate* unmanaged)&_getClassDomainID; + callbacks[146] = (delegate* unmanaged)&_getFieldAddress; + callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[148] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[149] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[150] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[151] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[152] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[153] = (delegate* unmanaged)&_addActiveDependency; + callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[160] = (delegate* unmanaged)&_allocMem; + callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[163] = (delegate* unmanaged)&_allocGCInfo; + callbacks[164] = (delegate* unmanaged)&_setEHcount; + callbacks[165] = (delegate* unmanaged)&_setEHinfo; + callbacks[166] = (delegate* unmanaged)&_logMsg; + callbacks[167] = (delegate* unmanaged)&_doAssert; + callbacks[168] = (delegate* unmanaged)&_reportFatalError; + callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[171] = (delegate* unmanaged)&_recordCallSite; + callbacks[172] = (delegate* unmanaged)&_recordRelocation; + callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[175] = (delegate* unmanaged)&_getJitFlags; +>>>>>>> 35ee62dcc42 (Work on switching getMethodName and getFieldName to print):src/coreclr/tools/Common/JitInterface/CorInfoBase.cs + + return (IntPtr)callbacks; + } + } +} + diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 68b5ad9d479e7..78eecc913ca28 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -248,7 +248,7 @@ FUNCTIONS CorInfoArrayIntrinsic getArrayIntrinsicID(CORINFO_METHOD_HANDLE ftn) void* getArrayInitializationData(CORINFO_FIELD_HANDLE field, uint32_t size) CorInfoIsAccessAllowedResult canAccessClass(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE callerHandle, CORINFO_HELPER_DESC* pAccessHelper) - const char* getFieldName(CORINFO_FIELD_HANDLE ftn, const char** moduleName) + size_t printFieldName(CORINFO_FIELD_HANDLE field, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) CORINFO_CLASS_HANDLE getFieldClass(CORINFO_FIELD_HANDLE field) CorInfoType getFieldType(CORINFO_FIELD_HANDLE field, CORINFO_CLASS_HANDLE* structType, CORINFO_CLASS_HANDLE memberParent) unsigned getFieldOffset(CORINFO_FIELD_HANDLE field) @@ -277,7 +277,7 @@ FUNCTIONS void getEEInfo(CORINFO_EE_INFO* pEEInfoOut); const char16_t * getJitTimeLogFilename(); mdMethodDef getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMethod); - const char* getMethodName(CORINFO_METHOD_HANDLE ftn, const char **moduleName); + size_t printMethodName(CORINFO_METHOD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) const char* getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, const char **className, const char **namespaceName, const char **enclosingClassName); unsigned getMethodHash(CORINFO_METHOD_HANDLE ftn); size_t findNameOfToken(CORINFO_MODULE_HANDLE moduleHandle,mdToken token, char * szFQName,size_t FQNameCapacity); diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index 2020a6ea8e9b6..068c7e298acc1 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -103,7 +103,7 @@ struct JitInterfaceCallbacks CorInfoArrayIntrinsic (* getArrayIntrinsicID)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn); void* (* getArrayInitializationData)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, uint32_t size); CorInfoIsAccessAllowedResult (* canAccessClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE callerHandle, CORINFO_HELPER_DESC* pAccessHelper); - const char* (* getFieldName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE ftn, const char** moduleName); + size_t (* printFieldName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); CORINFO_CLASS_HANDLE (* getFieldClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field); CorInfoType (* getFieldType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, CORINFO_CLASS_HANDLE* structType, CORINFO_CLASS_HANDLE memberParent); unsigned (* getFieldOffset)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field); @@ -132,7 +132,7 @@ struct JitInterfaceCallbacks void (* getEEInfo)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_EE_INFO* pEEInfoOut); const char16_t* (* getJitTimeLogFilename)(void * thisHandle, CorInfoExceptionClass** ppException); mdMethodDef (* getMethodDefFromMethod)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE hMethod); - const char* (* getMethodName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, const char** moduleName); + size_t (* printMethodName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); const char* (* getMethodNameFromMetadata)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, const char** className, const char** namespaceName, const char** enclosingClassName); unsigned (* getMethodHash)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn); size_t (* findNameOfToken)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE moduleHandle, unsigned int token, char* szFQName, size_t FQNameCapacity); @@ -1100,12 +1100,14 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } - virtual const char* getFieldName( - CORINFO_FIELD_HANDLE ftn, - const char** moduleName) + virtual size_t printFieldName( + CORINFO_FIELD_HANDLE field, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { CorInfoExceptionClass* pException = nullptr; - const char* temp = _callbacks->getFieldName(_thisHandle, &pException, ftn, moduleName); + size_t temp = _callbacks->printFieldName(_thisHandle, &pException, field, buffer, bufferSize, pRequiredBufferSize); if (pException != nullptr) throw pException; return temp; } @@ -1359,12 +1361,14 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } - virtual const char* getMethodName( + virtual size_t printMethodName( CORINFO_METHOD_HANDLE ftn, - const char** moduleName) + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { CorInfoExceptionClass* pException = nullptr; - const char* temp = _callbacks->getMethodName(_thisHandle, &pException, ftn, moduleName); + size_t temp = _callbacks->printMethodName(_thisHandle, &pException, ftn, buffer, bufferSize, pRequiredBufferSize); if (pException != nullptr) throw pException; return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 14f41af5c96e2..ba3bde9e949a5 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1031,16 +1031,12 @@ CorInfoIsAccessAllowedResult interceptor_ICJI::canAccessClass( // ICorFieldInfo // /**********************************************************************************/ -// this function is for debugging only. It returns the field name -// and if 'moduleName' is non-null, it sets it to something that will -// says which method (a class name, or a module name) -const char* interceptor_ICJI::getFieldName(CORINFO_FIELD_HANDLE ftn, /* IN */ - const char** moduleName /* OUT */ - ) + +size_t interceptor_ICJI::printFieldName(CORINFO_FIELD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { - mc->cr->AddCall("getFieldName"); - const char* temp = original_ICorJitInfo->getFieldName(ftn, moduleName); - mc->recGetFieldName(ftn, moduleName, temp); + mc->cr->AddCall("printFieldName"); + size_t temp = original_ICorJitInfo->printFieldName(ftn, buffer, bufferSize, pRequiredBufferSize); + mc->recPrintFieldName(ftn, buffer, bufferSize, pRequiredBufferSize, temp); return temp; } @@ -1394,16 +1390,11 @@ mdMethodDef interceptor_ICJI::getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMeth return result; } -// this function is for debugging only. It returns the method name -// and if 'moduleName' is non-null, it sets it to something that will -// says which method (a class name, or a module name) -const char* interceptor_ICJI::getMethodName(CORINFO_METHOD_HANDLE ftn, /* IN */ - const char** moduleName /* OUT */ - ) +size_t interceptor_ICJI::printMethodName(CORINFO_METHOD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { - mc->cr->AddCall("getMethodName"); - const char* temp = original_ICorJitInfo->getMethodName(ftn, moduleName); - mc->recGetMethodName(ftn, (char*)temp, moduleName); + mc->cr->AddCall("printMethodName"); + size_t temp = original_ICorJitInfo->printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); + mc->recPrintMethodName(ftn, buffer, bufferSize, pRequiredBufferSize, temp); return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp index 8f0a33becff53..cc101731caa42 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -738,12 +738,14 @@ CorInfoIsAccessAllowedResult interceptor_ICJI::canAccessClass( return original_ICorJitInfo->canAccessClass(pResolvedToken, callerHandle, pAccessHelper); } -const char* interceptor_ICJI::getFieldName( - CORINFO_FIELD_HANDLE ftn, - const char** moduleName) +size_t interceptor_ICJI::printFieldName( + CORINFO_FIELD_HANDLE field, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - mcs->AddCall("getFieldName"); - return original_ICorJitInfo->getFieldName(ftn, moduleName); + mcs->AddCall("printFieldName"); + return original_ICorJitInfo->printFieldName(field, buffer, bufferSize, pRequiredBufferSize); } CORINFO_CLASS_HANDLE interceptor_ICJI::getFieldClass( @@ -967,12 +969,14 @@ mdMethodDef interceptor_ICJI::getMethodDefFromMethod( return original_ICorJitInfo->getMethodDefFromMethod(hMethod); } -const char* interceptor_ICJI::getMethodName( +size_t interceptor_ICJI::printMethodName( CORINFO_METHOD_HANDLE ftn, - const char** moduleName) + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - mcs->AddCall("getMethodName"); - return original_ICorJitInfo->getMethodName(ftn, moduleName); + mcs->AddCall("printMethodName"); + return original_ICorJitInfo->printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); } const char* interceptor_ICJI::getMethodNameFromMetadata( diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp index 90473927abf54..7040aba565405 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -646,11 +646,13 @@ CorInfoIsAccessAllowedResult interceptor_ICJI::canAccessClass( return original_ICorJitInfo->canAccessClass(pResolvedToken, callerHandle, pAccessHelper); } -const char* interceptor_ICJI::getFieldName( - CORINFO_FIELD_HANDLE ftn, - const char** moduleName) +size_t interceptor_ICJI::printFieldName( + CORINFO_FIELD_HANDLE field, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - return original_ICorJitInfo->getFieldName(ftn, moduleName); + return original_ICorJitInfo->printFieldName(field, buffer, bufferSize, pRequiredBufferSize); } CORINFO_CLASS_HANDLE interceptor_ICJI::getFieldClass( @@ -846,11 +848,13 @@ mdMethodDef interceptor_ICJI::getMethodDefFromMethod( return original_ICorJitInfo->getMethodDefFromMethod(hMethod); } -const char* interceptor_ICJI::getMethodName( +size_t interceptor_ICJI::printMethodName( CORINFO_METHOD_HANDLE ftn, - const char** moduleName) + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) { - return original_ICorJitInfo->getMethodName(ftn, moduleName); + return original_ICorJitInfo->printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); } const char* interceptor_ICJI::getMethodNameFromMetadata( diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 825c91c467539..16e1aa1448655 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -863,15 +863,10 @@ CorInfoIsAccessAllowedResult MyICJI::canAccessClass(CORINFO_RESOLVED_TOKEN* pRes // /**********************************************************************************/ -// this function is for debugging only. It returns the field name -// and if 'moduleName' is non-null, it sets it to something that will -// says which method (a class name, or a module name) -const char* MyICJI::getFieldName(CORINFO_FIELD_HANDLE ftn, /* IN */ - const char** moduleName /* OUT */ - ) +size_t MyICJI::printFieldName(CORINFO_FIELD_HANDLE field, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { - jitInstance->mc->cr->AddCall("getFieldName"); - return jitInstance->mc->repGetFieldName(ftn, moduleName); + jitInstance->mc->cr->AddCall("printFieldName"); + return jitInstance->mc->repPrintFieldName(field, buffer, bufferSize, pRequiredBufferSize); } // return class it belongs to @@ -1225,15 +1220,10 @@ mdMethodDef MyICJI::getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMethod) return result; } -// this function is for debugging only. It returns the method name -// and if 'moduleName' is non-null, it sets it to something that will -// says which method (a class name, or a module name) -const char* MyICJI::getMethodName(CORINFO_METHOD_HANDLE ftn, /* IN */ - const char** moduleName /* OUT */ - ) +size_t MyICJI::printMethodName(CORINFO_METHOD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { - jitInstance->mc->cr->AddCall("getMethodName"); - return jitInstance->mc->repGetMethodName(ftn, moduleName); + jitInstance->mc->cr->AddCall("printMethodName"); + return jitInstance->mc->repPrintMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); } const char* MyICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, /* IN */ diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 8f508857e652c..eaf61f1859cb0 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -6363,7 +6363,7 @@ unsigned CEEInfo::getMethodHash (CORINFO_METHOD_HANDLE ftnHnd) } /***********************************************************************/ -const char* CEEInfo::getMethodName (CORINFO_METHOD_HANDLE ftnHnd, const char** scopeName) +size_t CEEInfo::printMethodName(CORINFO_METHOD_HANDLE ftnHnd, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { CONTRACTL { THROWS; @@ -6371,75 +6371,29 @@ const char* CEEInfo::getMethodName (CORINFO_METHOD_HANDLE ftnHnd, const char** s MODE_PREEMPTIVE; } CONTRACTL_END; - const char* result = NULL; + size_t bytesWritten = 0; JIT_TO_EE_TRANSITION(); - MethodDesc *ftn; - - ftn = GetMethod(ftnHnd); + MethodDesc* ftn = GetMethod(ftnHnd); + char* ftnName = ftn->GetName(); - if (scopeName != 0) + size_t len = strlen(ftnName); + if (bufferSize > 0) { - if (ftn->IsLCGMethod()) - { - *scopeName = "DynamicClass"; - } - else if (ftn->IsILStub()) - { - *scopeName = ILStubResolver::GetStubClassName(ftn); - } - else - { - MethodTable * pMT = ftn->GetMethodTable(); -#if defined(_DEBUG) -#ifdef FEATURE_SYMDIFF - if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_SymDiffDump)) - { - if (pMT->IsArray()) - { - ssClsNameBuff.Clear(); - ssClsNameBuff.SetUTF8(pMT->GetDebugClassName()); - } - else - pMT->_GetFullyQualifiedNameForClassNestedAware(ssClsNameBuff); - } - else - { -#endif - // Calling _GetFullyQualifiedNameForClass in chk build is very expensive - // since it construct the class name everytime we call this method. In chk - // builds we already have a cheaper way to get the class name - - // GetDebugClassName - which doesn't calculate the class name everytime. - // This results in huge saving in Ngen time for checked builds. - ssClsNameBuff.Clear(); - ssClsNameBuff.SetUTF8(pMT->GetDebugClassName()); - -#ifdef FEATURE_SYMDIFF - } -#endif - // Append generic instantiation at the end - Instantiation inst = pMT->GetInstantiation(); - if (!inst.IsEmpty()) - TypeString::AppendInst(ssClsNameBuff, inst); - - ssClsNameBuffUTF8.SetAndConvertToUTF8(ssClsNameBuff.GetUnicode()); - *scopeName = ssClsNameBuffUTF8.GetUTF8(); -#else // !_DEBUG - // since this is for diagnostic purposes only, - // give up on the namespace, as we don't have a buffer to concat it - // also note this won't show array class names. - LPCUTF8 nameSpace; - *scopeName= pMT->GetFullyQualifiedNameInfo(&nameSpace); -#endif // !_DEBUG - } + bytesWritten = min(len, bufferSize - 1); + memcpy(buffer, ftnName, bytesWritten); + buffer[bytesWritten] = '\0'; } - result = ftn->GetName(); + if (pRequiredBufferSize != NULL) + { + *pRequiredBufferSize = len + 1; + } EE_TO_JIT_TRANSITION(); - return result; + return bytesWritten; } const char* CEEInfo::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftnHnd, const char** className, const char** namespaceName, const char **enclosingClassName) @@ -9312,44 +9266,36 @@ void CEEInfo::getFunctionFixedEntryPoint(CORINFO_METHOD_HANDLE ftn, } /*********************************************************************/ -const char* CEEInfo::getFieldName (CORINFO_FIELD_HANDLE fieldHnd, const char** scopeName) +size_t CEEInfo::printFieldName(CORINFO_FIELD_HANDLE fieldHnd, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; MODE_PREEMPTIVE; } CONTRACTL_END; - const char* result = NULL; - + size_t bytesWritten = 0; JIT_TO_EE_TRANSITION(); FieldDesc* field = (FieldDesc*) fieldHnd; - if (scopeName != 0) + char* fieldName = field->GetName(); + + size_t len = strlen(fieldName); + if (bufferSize > 0) { - TypeHandle t = TypeHandle(field->GetApproxEnclosingMethodTable()); - *scopeName = ""; - if (!t.IsNull()) - { -#ifdef _DEBUG - t.GetName(ssClsNameBuff); - ssClsNameBuffUTF8.SetAndConvertToUTF8(ssClsNameBuff.GetUnicode()); - *scopeName = ssClsNameBuffUTF8.GetUTF8(); -#else // !_DEBUG - // since this is for diagnostic purposes only, - // give up on the namespace, as we don't have a buffer to concat it - // also note this won't show array class names. - LPCUTF8 nameSpace; - *scopeName= t.GetMethodTable()->GetFullyQualifiedNameInfo(&nameSpace); -#endif // !_DEBUG - } + bytesWritten = min(len, bufferSize - 1); + memcpy(buffer, fieldName, len); + buffer[bytesWritten] = '\0'; } - result = field->GetName(); + if (pRequiredBufferSize != NULL) + { + *pRequiredBufferSize = len + 1; + } EE_TO_JIT_TRANSITION(); - return result; + return bytesWritten; } /*********************************************************************/ From f5447b3b43acdca03764a73fa01e761b0c1b5f42 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 10 Oct 2022 11:41:20 +0200 Subject: [PATCH 30/50] More work --- src/coreclr/gcinfo/gcinfoencoder.cpp | 23 ++--- src/coreclr/inc/gcinfoencoder.h | 4 - src/coreclr/jit/codegencommon.cpp | 3 +- src/coreclr/jit/compiler.cpp | 2 +- src/coreclr/jit/compiler.h | 6 +- src/coreclr/jit/ee_il_dll.cpp | 149 +++++++++++++-------------- src/coreclr/jit/eeinterface.cpp | 4 +- src/coreclr/jit/emit.cpp | 58 ++--------- src/coreclr/jit/emit.h | 3 - src/coreclr/jit/emitxarch.cpp | 3 +- src/coreclr/jit/gentree.cpp | 25 +++-- src/coreclr/jit/importer.cpp | 2 - src/coreclr/jit/lclvars.cpp | 9 +- src/coreclr/jit/valuenum.cpp | 13 +-- src/coreclr/vm/jitinterface.cpp | 4 +- 15 files changed, 122 insertions(+), 186 deletions(-) diff --git a/src/coreclr/gcinfo/gcinfoencoder.cpp b/src/coreclr/gcinfo/gcinfoencoder.cpp index d4596334bd3dc..57649af29bcd0 100644 --- a/src/coreclr/gcinfo/gcinfoencoder.cpp +++ b/src/coreclr/gcinfo/gcinfoencoder.cpp @@ -454,16 +454,6 @@ GcInfoEncoder::GcInfoEncoder( m_pAllocator = pJitAllocator; m_pNoMem = pNoMem; -#ifdef _DEBUG - CORINFO_METHOD_HANDLE methodHandle = pMethodInfo->ftn; - - // Get the name of the current method along with the enclosing class - // or module name. - m_MethodName = - pCorJitInfo->getMethodName(methodHandle, (const char **)&m_ModuleName); -#endif - - m_SlotTableSize = m_SlotTableInitialSize; m_SlotTable = (GcSlotDesc*) m_pAllocator->Alloc( m_SlotTableSize*sizeof(GcSlotDesc) ); m_NumSlots = 0; @@ -991,14 +981,19 @@ void GcInfoEncoder::Build() { #ifdef _DEBUG _ASSERTE(m_IsSlotTableFrozen || m_NumSlots == 0); -#endif _ASSERTE((1 << NUM_NORM_CODE_OFFSETS_PER_CHUNK_LOG2) == NUM_NORM_CODE_OFFSETS_PER_CHUNK); + char methodName[256]; + m_pCorJitInfo->printMethodName(m_pMethodInfo->ftn, methodName, sizeof(methodName)); + + char className[256]; + m_pCorJitInfo->printClassName(m_pCorJitInfo->getMethodClass(m_pMethodInfo->ftn), className, sizeof(className)); + LOG((LF_GCINFO, LL_INFO100, - "Entering GcInfoEncoder::Build() for method %s[%s]\n", - m_MethodName, m_ModuleName - )); + "Entering GcInfoEncoder::Build() for method %s:%s\n", + className, methodName)); +#endif /////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/inc/gcinfoencoder.h b/src/coreclr/inc/gcinfoencoder.h index 33c1054aba718..490aacf8ede25 100644 --- a/src/coreclr/inc/gcinfoencoder.h +++ b/src/coreclr/inc/gcinfoencoder.h @@ -485,10 +485,6 @@ class GcInfoEncoder IAllocator* m_pAllocator; NoMemoryFunction m_pNoMem; -#ifdef _DEBUG - const char *m_MethodName, *m_ModuleName; -#endif - BitStreamWriter m_Info1; // Used for everything except for chunk encodings BitStreamWriter m_Info2; // Used for chunk encodings diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index 0c660d71b52eb..0c65564e5effa 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -7548,8 +7548,7 @@ void CodeGen::genReportRichDebugInfoInlineTreeToFile(FILE* file, InlineContext* fprintf(file, "\"ILOffset\":%u,", context->GetLocation().GetOffset()); fprintf(file, "\"LocationFlags\":%u,", (uint32_t)context->GetLocation().EncodeSourceTypes()); fprintf(file, "\"ExactILOffset\":%u,", context->GetActualCallOffset()); - const char* className; - const char* methodName = compiler->eeGetMethodName(context->GetCallee(), &className); + const char* methodName = compiler->eeGetMethodName(context->GetCallee()); fprintf(file, "\"MethodName\":\"%s\",", methodName); fprintf(file, "\"Inlinees\":["); if (context->GetChild() != nullptr) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index e14f3439ee643..fde3d27730dcb 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -1789,7 +1789,7 @@ void Compiler::compInit(ArenaAllocator* pAlloc, info.compClassName = nullptr; info.compFullName = nullptr; - info.compMethodName = eeGetMethodName(methodHnd, nullptr); + info.compMethodName = eeGetMethodName(methodHnd); info.compClassName = eeGetClassName(info.compClassHnd); info.compFullName = eeGetMethodFullName(methodHnd); info.compPerfScore = 0.0; diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 95832e0252057..2dc5983f4a561 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7602,7 +7602,6 @@ class Compiler bool includeThisSpecifier); #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS) - const char* eeGetMethodName(CORINFO_METHOD_HANDLE hnd); const char* eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType = true, bool includeThisSpecifier = true); @@ -7841,7 +7840,6 @@ class Compiler // Utility functions - const char* eePrintFieldName(CORINFO_FIELD_HANDLE fieldHnd, char* buffer, size_t bufferSize); #if defined(DEBUG) void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle); @@ -7849,7 +7847,9 @@ class Compiler const char* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd); #endif - const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd); + const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer = nullptr, size_t bufferSize = 0); + const char* eeGetFieldName(CORINFO_FIELD_HANDLE fieldHnd, bool includeClass, char* buffer = nullptr, size_t bufferSize = 0); + const char* eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer = nullptr, size_t bufferSize = 0); static CORINFO_METHOD_HANDLE eeFindHelper(unsigned helper); static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 367a434e85176..a094965a25d34 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1437,109 +1437,58 @@ struct FilterSuperPMIExceptionsParam_ee_il EXCEPTION_POINTERS exceptionPointers; }; -template -static const char* PrintEntityToAllocatedBuffer(Compiler* comp, THandle handle, char* failureName) +template +static void eePrint(StringPrinter* sp, Compiler* comp, const char* defaultName, T handle) { - -} - -const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method) -{ - if (eeGetHelperNum(method) != CORINFO_HELP_UNDEF) - { - CorInfoHelpFunc ftnNum = eeGetHelperNum(method); - const char* name = info.compCompHnd->getHelperName(ftnNum); - - // If it's something unknown from a RET VM, or from SuperPMI, then use our own helper name table. - if ((strcmp(name, "AnyJITHelper") == 0) || (strcmp(name, "Yickish helper name") == 0)) - { - if ((unsigned)ftnNum < CORINFO_HELP_COUNT) - { - name = jitHlpFuncTable[ftnNum]; - } - } - return name; - } - - if (eeIsNativeMethod(method)) - { - method = eeGetMethodHandleForNative(method); - } - char buffer[256]; - size_t written = 0; - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { - written = info.compCompHnd->printMethodName(method, buffer, sizeof(buffer)); + size_t requiredBufferSize; + bool success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { + (comp->info.compCompHnd->*print)(handle, buffer, sizeof(buffer), &requiredBufferSize); }); - FilterSuperPMIExceptionsParam_ee_il param; - - param.pThis = this; - param.pJitInfo = &info; - param.method = method; - param.classNamePtr = classNamePtr; - - bool success = eeRunWithSPMIErrorTrap( - [](FilterSuperPMIExceptionsParam_ee_il* pParam) { - pParam->fieldOrMethodOrClassNamePtr = - pParam->pJitInfo->compCompHnd->getMethodName(pParam->method, pParam->classNamePtr); - }, - ¶m); - if (!success) { - if (param.classNamePtr != nullptr) - { - *(param.classNamePtr) = "hackishClassName"; - } - - param.fieldOrMethodOrClassNamePtr = "hackishMethodName"; + sp->Append(defaultName); + return; } - return param.fieldOrMethodOrClassNamePtr; -} + if (bufferSize >= requiredBufferSize) + { + sp->Append(buffer); + return; + } -const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE field) -{ - char buffer[256]; - size_t written = 0; - size_t requiredBufferSize = 0; - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { - written = info.compCompHnd->printFieldName(field, buffer, sizeof(buffer), &requiredBufferSize); + char* pBuffer = new (comp, CMK_DebugOnly) char[requiredBufferSize]; + success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { + (comp->info.compCompHnd->*print)(handle, pBuffer, requiredBufferSize); }); if (!success) { - return "hackishFieldName"; - } - - char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; - if (requiredBufferSize <= sizeof(buffer)) - { - memcpy(pBuffer, buffer, written + 1); - } - else - { - success = eeRunFunctorWithSPMIErrorTrap([&]() { - - }); - info.compCompHnd-> + sp->Append(defaultName); + return; } - char* pBuffer = + sp->Append(pBuffer); } + //------------------------------------------------------------------------ // eeGetClassName: // Get the name (including namespace and instantiation) of a type. // If missing information (in SPMI), then return a placeholder string. // +// Parameters: +// clsHnd - the handle of the class +// buffer - a buffer to use for scratch space, or null pointer to allocate a new string. +// bufferSize - the size of buffer. If the final class name is longer a new string will be allocated. +// // Return value: // The name string. // -const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd) +const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer, size_t bufferSize) { - StringPrinter printer(getAllocator(CMK_DebugOnly)); + StringPrinter printer(getAllocator(CMK_DebugOnly), buffer, bufferSize); if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) { printer.Truncate(0); @@ -1549,7 +1498,51 @@ const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd) return printer.GetBuffer(); } -#endif // DEBUG || FEATURE_JIT_METHOD_PERF +const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE field, bool includeClass, char* buffer, size_t bufferSize) +{ + StringPrinter printer(getAllocator(CMK_DebugOnly), buffer, bufferSize); + if (includeClass) + { + if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, info.compCompHnd->getFieldClass(field), true); })) + { + printer.Append("hackishClassName"); + } + + printer.Append(':'); + } + + eePrint(&printer, this, "hackishFieldName", field); + return printer.GetBuffer(); +} + +const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method, char* buffer, size_t bufferSize) +{ + if (eeGetHelperNum(method) != CORINFO_HELP_UNDEF) + { + CorInfoHelpFunc ftnNum = eeGetHelperNum(method); + const char* name = info.compCompHnd->getHelperName(ftnNum); + + // If it's something unknown from a RET VM, or from SuperPMI, then use our own helper name table. + if ((strcmp(name, "AnyJITHelper") == 0) || (strcmp(name, "Yickish helper name") == 0)) + { + if ((unsigned)ftnNum < CORINFO_HELP_COUNT) + { + name = jitHlpFuncTable[ftnNum]; + } + } + + return name; + } + + if (eeIsNativeMethod(method)) + { + method = eeGetMethodHandleForNative(method); + } + + return eePrint(this, "hackishMethodName", method, buffer, bufferSize); +} + +#endif #ifdef DEBUG diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 1e0f4d1486ee2..cbe29237f60ed 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -349,9 +349,7 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ { if ((eeGetHelperNum(hnd) != CORINFO_HELP_UNDEF) || eeIsNativeMethod(hnd)) { - const char* className; - const char* methodName = eeGetMethodName(hnd, &className); - return methodName; + return eeGetMethodName(hnd);; } StringPrinter p(getAllocator(CMK_DebugOnly)); diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index a7644c3bcbd0f..3c769f92d6d08 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -3355,48 +3355,6 @@ emitter::instrDesc* emitter::emitNewInstrCallDir(int argCnt, } } -/*****************************************************************************/ -#ifdef DEBUG -/***************************************************************************** - * - * Return a string with the name of the given class field (blank string (not - * NULL) is returned when the name isn't available). - */ - -const char* emitter::emitFldName(CORINFO_FIELD_HANDLE fieldVal) -{ - if (emitComp->opts.varNames) - { - const char* memberName; - const char* className; - - const int TEMP_BUFFER_LEN = 1024; - static char buff[TEMP_BUFFER_LEN]; - - memberName = emitComp->eeGetFieldName(fieldVal, &className); - - sprintf_s(buff, TEMP_BUFFER_LEN, "'<%s>.%s'", className, memberName); - return buff; - } - else - { - return ""; - } -} - -/***************************************************************************** - * - * Return a string with the name of the given function (blank string (not - * NULL) is returned when the name isn't available). - */ - -const char* emitter::emitFncName(CORINFO_METHOD_HANDLE methHnd) -{ - return emitComp->eeGetMethodFullName(methHnd); -} - -#endif // DEBUG - /***************************************************************************** * * Be very careful, some instruction descriptors are allocated as "tiny" and @@ -4104,20 +4062,15 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag { if (flag == GTF_ICON_FTN_ADDR) { - const char* className = nullptr; - const char* methName = - emitComp->eeGetMethodName(reinterpret_cast(cookie), &className); - printf("%s code for %s:%s", commentPrefix, className, methName); + printf("%s code for ", commentPrefix); + emitComp->eePrintMethodName(reinterpret_cast(cookie), true); return; } if ((flag == GTF_ICON_STATIC_HDL) || (flag == GTF_ICON_STATIC_BOX_PTR)) { - const char* className = nullptr; - const char* fieldName = - emitComp->eeGetFieldName(reinterpret_cast(cookie), &className); - printf("%s %s for %s%s%s", commentPrefix, flag == GTF_ICON_STATIC_HDL ? "data" : "box", className, - className != nullptr ? ":" : "", fieldName); + printf("%s %s for ", commentPrefix, flag == GTF_ICON_STATIC_HDL ? "data" : "box"); + emitComp->eePrintFieldName(reinterpret_cast(cookie), true); return; } } @@ -4154,7 +4107,8 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag } else if (flag == GTF_ICON_FIELD_HDL) { - str = emitComp->eeGetFieldName(reinterpret_cast(handle)); + printf("%s ", commentPrefix); + emitComp->eePrintFieldName(reinterpret_cast(handle), true); } else if (flag == GTF_ICON_STATIC_HDL) { diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index dc4278a82e71e..0d915876dcd0a 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -1729,9 +1729,6 @@ class emitter const char* emitRegName(regNumber reg, emitAttr size = EA_PTRSIZE, bool varName = true); const char* emitFloatRegName(regNumber reg, emitAttr size = EA_PTRSIZE, bool varName = true); - const char* emitFldName(CORINFO_FIELD_HANDLE fieldVal); - const char* emitFncName(CORINFO_METHOD_HANDLE callVal); - // GC Info changes are not readily available at each instruction. // We use debug-only sets to track the per-instruction state, and to remember // what the state was at the last time it was output (instruction or label). diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 5dacf783fa5df..7ad8f8c423497 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -9516,7 +9516,8 @@ void emitter::emitDispClsVar(CORINFO_FIELD_HANDLE fldHnd, ssize_t offs, bool rel #ifdef DEBUG if (emitComp->opts.varNames && offs < 0) { - printf("'%s", emitComp->eeGetFieldName(fldHnd)); + printf("'"); + emitComp->eePrintFieldName(fldHnd); if (offs) { printf("%+Id", offs); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 8ed5ba7906393..a6bd5b7225612 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -11501,8 +11501,8 @@ void Compiler::gtDispFieldSeq(FieldSeq* fieldSeq, ssize_t offset) return; } - printf(" Fseq["); - printf("%s", eeGetFieldName(fieldSeq->GetFieldHandle())); + char buffer[128]; + printf(" Fseq[%s", eeGetFieldName(fieldSeq->GetFieldHandle(), buffer, sizeof(buffer))); if (offset != 0) { printf(", %zd", offset); @@ -11583,11 +11583,11 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) { unsigned fieldLclNum = varDsc->lvFieldLclStart + index; LclVarDsc* fieldVarDsc = lvaGetDesc(fieldLclNum); - const char* fieldName; + char fieldName[64]; #if !defined(TARGET_64BIT) if (varTypeIsLong(varDsc)) { - fieldName = (index == 0) ? "lo" : "hi"; + strcpy_s(fieldName, sizeof(fieldName), (index == 0) ? "lo" : "hi"); } else #endif // !defined(TARGET_64BIT) @@ -11595,7 +11595,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) CORINFO_CLASS_HANDLE typeHnd = varDsc->GetStructHnd(); CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(typeHnd, fieldVarDsc->lvFldOrdinal); - fieldName = eeGetFieldName(fldHnd); + eePrintFieldNameToBuffer(fldHnd, fieldName, sizeof(fieldName)); } printf("\n"); @@ -11635,8 +11635,8 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) const char* methodName; const char* className; - methodName = eeGetMethodName((CORINFO_METHOD_HANDLE)tree->AsVal()->gtVal1, &className); - printf(" %s.%s\n", className, methodName); + printf(" "); + eePrintMethodName((CORINFO_METHOD_HANDLE)tree->AsVal()->gtVal1, true); } break; @@ -11942,7 +11942,8 @@ void Compiler::gtDispTree(GenTree* tree, if (tree->OperIs(GT_FIELD, GT_FIELD_ADDR)) { - printf(" %s", eeGetFieldName(tree->AsField()->gtFldHnd), 0); + char buffer[128]; + printf(" %s", eeGetFieldName(tree->AsField()->gtFldHnd, buffer, sizeof(buffer))); } if (tree->gtOper == GT_INTRINSIC) @@ -18303,12 +18304,10 @@ CORINFO_CLASS_HANDLE Compiler::gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldH if (queryForCurrentClass) { - #if DEBUG - const char* fieldClassName = nullptr; - const char* fieldName = eeGetFieldName(fieldHnd, &fieldClassName); - JITDUMP("Querying runtime about current class of field %s.%s (declared as %s)\n", fieldClassName, fieldName, - eeGetClassName(fieldClass)); + JITDUMP("Querying runtime about current class of field "); + eePrintFieldName(fieldHnd, true); + printf(" (declared as %s)\n", eeGetClassName(fieldClass)); #endif // DEBUG // Is this a fully initialized init-only static field? diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index d52f0c4a55b6d..44537027746de 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -3622,8 +3622,6 @@ int Compiler::impBoxPatternMatch(CORINFO_RESOLVED_TOKEN* pResolvedToken, info.compCompHnd->getFieldInClass(nullableCls, 0); assert(info.compCompHnd->getFieldOffset(hasValueFldHnd) == 0); - assert(!strcmp(info.compCompHnd->getFieldName(hasValueFldHnd, nullptr), - "hasValue")); GenTree* objToBox = impPopStack().val; diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 3a28914e956b6..e39c91a5dc997 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -2415,9 +2415,12 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum) // Now grab the temp for the field local. #ifdef DEBUG + char fieldName[64]; + compiler->eePrintFieldNameToBuffer(pFieldInfo->fldHnd, fieldName, sizeof(fieldName)); + char buf[200]; sprintf_s(buf, sizeof(buf), "%s V%02u.%s (fldOffset=0x%x)", "field", lclNum, - compiler->eeGetFieldName(pFieldInfo->fldHnd), pFieldInfo->fldOffset); + fieldName, pFieldInfo->fldOffset); // We need to copy 'buf' as lvaGrabTemp() below caches a copy to its argument. size_t len = strlen(buf) + 1; @@ -7830,7 +7833,9 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r CORINFO_CLASS_HANDLE typeHnd = parentvarDsc->GetStructHnd(); CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(typeHnd, varDsc->lvFldOrdinal); - printf(" V%02u.%s(offs=0x%02x)", varDsc->lvParentLcl, eeGetFieldName(fldHnd), varDsc->lvFldOffset); + printf(" V%02u.", varDsc->lvParentLcl); + eePrintFieldName(fldHnd); + printf("(offs=0x%02x)", varDsc->lvFldOffset); lvaPromotionType promotionType = lvaGetPromotionType(parentvarDsc); switch (promotionType) diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index e80b667da6e6d..64550d2cf8369 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -2974,9 +2974,10 @@ ValueNum ValueNumStore::VNForFieldSelector(CORINFO_FIELD_HANDLE fieldHnd, var_ty #ifdef DEBUG if (m_pComp->verbose) { - const char* modName; - const char* fldName = m_pComp->eeGetFieldName(fieldHnd, &modName); - printf(" VNForHandle(%s) is " FMT_VN ", fieldType is %s", fldName, fldHndVN, varTypeName(fieldType)); + printf(" VNForHandle("); + m_pComp->eePrintFieldName(fieldHnd); + printf(") is " FMT_VN ", fieldType is %s", fldHndVN, varTypeName(fieldType)); + if (size != 0) { printf(", size = %u", size); @@ -8041,9 +8042,9 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, #ifdef DEBUG if (verbose) { - const char* modName; - const char* fldName = eeGetFieldName(fldHnd, &modName); - printf(" VNForHandle(%s) is " FMT_VN "\n", fldName, fldHndVN); + printf(" VNForHandle("); + eePrintFieldName(fldHnd); + printf(") is " FMT_VN "\n", fldHndVN); } #endif // DEBUG diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index eaf61f1859cb0..7ebaf9b25b170 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -6376,7 +6376,7 @@ size_t CEEInfo::printMethodName(CORINFO_METHOD_HANDLE ftnHnd, char* buffer, size JIT_TO_EE_TRANSITION(); MethodDesc* ftn = GetMethod(ftnHnd); - char* ftnName = ftn->GetName(); + const char* ftnName = ftn->GetName(); size_t len = strlen(ftnName); if (bufferSize > 0) @@ -9278,7 +9278,7 @@ size_t CEEInfo::printFieldName(CORINFO_FIELD_HANDLE fieldHnd, char* buffer, size JIT_TO_EE_TRANSITION(); FieldDesc* field = (FieldDesc*) fieldHnd; - char* fieldName = field->GetName(); + const char* fieldName = field->GetName(); size_t len = strlen(fieldName); if (bufferSize > 0) From d9643e181e33caed5ce44afa09ba9141cfb895a5 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 15:59:40 +0100 Subject: [PATCH 31/50] Fix bad merge --- src/coreclr/jit/importer.cpp | 1633 ---------------------------------- 1 file changed, 1633 deletions(-) diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 44537027746de..6185804f898ff 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -4725,1639 +4725,6 @@ bool Compiler::impIsImplicitTailCallCandidate( #endif // FEATURE_TAILCALL_OPT } -//------------------------------------------------------------------------ -// impImportCall: import a call-inspiring opcode -// -// Arguments: -// opcode - opcode that inspires the call -// pResolvedToken - resolved token for the call target -// pConstrainedResolvedToken - resolved constraint token (or nullptr) -// newObjThis - tree for this pointer or uninitialized newobj temp (or nullptr) -// prefixFlags - IL prefix flags for the call -// callInfo - EE supplied info for the call -// rawILOffset - IL offset of the opcode, used for guarded devirtualization. -// -// Returns: -// Type of the call's return value. -// If we're importing an inlinee and have realized the inline must fail, the call return type should be TYP_UNDEF. -// However we can't assert for this here yet because there are cases we miss. See issue #13272. -// -// -// Notes: -// opcode can be CEE_CALL, CEE_CALLI, CEE_CALLVIRT, or CEE_NEWOBJ. -// -// For CEE_NEWOBJ, newobjThis should be the temp grabbed for the allocated -// uninitialized object. - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable : 21000) // Suppress PREFast warning about overly large function -#endif - -var_types Compiler::impImportCall(OPCODE opcode, - CORINFO_RESOLVED_TOKEN* pResolvedToken, - CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, - GenTree* newobjThis, - int prefixFlags, - CORINFO_CALL_INFO* callInfo, - IL_OFFSET rawILOffset) -{ - assert(opcode == CEE_CALL || opcode == CEE_CALLVIRT || opcode == CEE_NEWOBJ || opcode == CEE_CALLI); - - // The current statement DI may not refer to the exact call, but for calls - // we wish to be able to attach the exact IL instruction to get "return - // value" support in the debugger, so create one with the exact IL offset. - DebugInfo di = impCreateDIWithCurrentStackInfo(rawILOffset, true); - - var_types callRetTyp = TYP_COUNT; - CORINFO_SIG_INFO* sig = nullptr; - CORINFO_METHOD_HANDLE methHnd = nullptr; - CORINFO_CLASS_HANDLE clsHnd = nullptr; - unsigned clsFlags = 0; - unsigned mflags = 0; - GenTree* call = nullptr; - CORINFO_THIS_TRANSFORM constraintCallThisTransform = CORINFO_NO_THIS_TRANSFORM; - CORINFO_CONTEXT_HANDLE exactContextHnd = nullptr; - bool exactContextNeedsRuntimeLookup = false; - bool canTailCall = true; - const char* szCanTailCallFailReason = nullptr; - const int tailCallFlags = (prefixFlags & PREFIX_TAILCALL); - const bool isReadonlyCall = (prefixFlags & PREFIX_READONLY) != 0; - - methodPointerInfo* ldftnInfo = nullptr; - - // Synchronized methods need to call CORINFO_HELP_MON_EXIT at the end. We could - // do that before tailcalls, but that is probably not the intended - // semantic. So just disallow tailcalls from synchronized methods. - // Also, popping arguments in a varargs function is more work and NYI - // If we have a security object, we have to keep our frame around for callers - // to see any imperative security. - // Reverse P/Invokes need a call to CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT - // at the end, so tailcalls should be disabled. - if (info.compFlags & CORINFO_FLG_SYNCH) - { - canTailCall = false; - szCanTailCallFailReason = "Caller is synchronized"; - } - else if (opts.IsReversePInvoke()) - { - canTailCall = false; - szCanTailCallFailReason = "Caller is Reverse P/Invoke"; - } -#if !FEATURE_FIXED_OUT_ARGS - else if (info.compIsVarArgs) - { - canTailCall = false; - szCanTailCallFailReason = "Caller is varargs"; - } -#endif // FEATURE_FIXED_OUT_ARGS - - // We only need to cast the return value of pinvoke inlined calls that return small types - - bool checkForSmallType = false; - bool bIntrinsicImported = false; - - CORINFO_SIG_INFO calliSig; - NewCallArg extraArg; - - /*------------------------------------------------------------------------- - * First create the call node - */ - - if (opcode == CEE_CALLI) - { - if (IsTargetAbi(CORINFO_NATIVEAOT_ABI)) - { - // See comment in impCheckForPInvokeCall - BasicBlock* block = compIsForInlining() ? impInlineInfo->iciBlock : compCurBB; - if (info.compCompHnd->convertPInvokeCalliToCall(pResolvedToken, !impCanPInvokeInlineCallSite(block))) - { - eeGetCallInfo(pResolvedToken, nullptr, CORINFO_CALLINFO_ALLOWINSTPARAM, callInfo); - return impImportCall(CEE_CALL, pResolvedToken, nullptr, nullptr, prefixFlags, callInfo, rawILOffset); - } - } - - /* Get the call site sig */ - eeGetSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, &calliSig); - - callRetTyp = JITtype2varType(calliSig.retType); - - call = impImportIndirectCall(&calliSig, di); - - // We don't know the target method, so we have to infer the flags, or - // assume the worst-case. - mflags = (calliSig.callConv & CORINFO_CALLCONV_HASTHIS) ? 0 : CORINFO_FLG_STATIC; - -#ifdef DEBUG - if (verbose) - { - unsigned structSize = (callRetTyp == TYP_STRUCT) ? eeTryGetClassSize(calliSig.retTypeSigClass) : 0; - printf("\nIn Compiler::impImportCall: opcode is %s, kind=%d, callRetType is %s, structSize is %u\n", - opcodeNames[opcode], callInfo->kind, varTypeName(callRetTyp), structSize); - } -#endif - sig = &calliSig; - } - else // (opcode != CEE_CALLI) - { - NamedIntrinsic ni = NI_Illegal; - - // Passing CORINFO_CALLINFO_ALLOWINSTPARAM indicates that this JIT is prepared to - // supply the instantiation parameters necessary to make direct calls to underlying - // shared generic code, rather than calling through instantiating stubs. If the - // returned signature has CORINFO_CALLCONV_PARAMTYPE then this indicates that the JIT - // must indeed pass an instantiation parameter. - - methHnd = callInfo->hMethod; - - sig = &(callInfo->sig); - callRetTyp = JITtype2varType(sig->retType); - - mflags = callInfo->methodFlags; - -#ifdef DEBUG - if (verbose) - { - unsigned structSize = (callRetTyp == TYP_STRUCT) ? eeTryGetClassSize(sig->retTypeSigClass) : 0; - printf("\nIn Compiler::impImportCall: opcode is %s, kind=%d, callRetType is %s, structSize is %u\n", - opcodeNames[opcode], callInfo->kind, varTypeName(callRetTyp), structSize); - } -#endif - if (compIsForInlining()) - { - /* Does the inlinee use StackCrawlMark */ - - if (mflags & CORINFO_FLG_DONT_INLINE_CALLER) - { - compInlineResult->NoteFatal(InlineObservation::CALLEE_STACK_CRAWL_MARK); - return TYP_UNDEF; - } - - /* For now ignore varargs */ - if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_NATIVEVARARG) - { - compInlineResult->NoteFatal(InlineObservation::CALLEE_HAS_NATIVE_VARARGS); - return TYP_UNDEF; - } - - if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG) - { - compInlineResult->NoteFatal(InlineObservation::CALLEE_HAS_MANAGED_VARARGS); - return TYP_UNDEF; - } - - if ((mflags & CORINFO_FLG_VIRTUAL) && (sig->sigInst.methInstCount != 0) && (opcode == CEE_CALLVIRT)) - { - compInlineResult->NoteFatal(InlineObservation::CALLEE_IS_GENERIC_VIRTUAL); - return TYP_UNDEF; - } - } - - clsHnd = pResolvedToken->hClass; - - clsFlags = callInfo->classFlags; - -#ifdef DEBUG - // If this is a call to JitTestLabel.Mark, do "early inlining", and record the test attribute. - - // This recognition should really be done by knowing the methHnd of the relevant Mark method(s). - // These should be in corelib.h, and available through a JIT/EE interface call. - const char* namespaceName; - const char* className; - const char* methodName = info.compCompHnd->getMethodNameFromMetadata(methHnd, &className, &namespaceName, nullptr); - if ((strcmp(namespaceName, "System.Runtime.CompilerServices") == 0) && - (strcmp(className, "JitTestLabel") == 0) && - (strcmp(methodName, "Mark") == 0)) - { - return impImportJitTestLabelMark(sig->numArgs); - } -#endif // DEBUG - - const bool isIntrinsic = (mflags & CORINFO_FLG_INTRINSIC) != 0; - - // Factor this into getCallInfo - bool isSpecialIntrinsic = false; - - if (isIntrinsic || !info.compMatchedVM) - { - // For mismatched VM (AltJit) we want to check all methods as intrinsic to ensure - // we get more accurate codegen. This particularly applies to HWIntrinsic usage - - const bool isTailCall = canTailCall && (tailCallFlags != 0); - - call = - impIntrinsic(newobjThis, clsHnd, methHnd, sig, mflags, pResolvedToken->token, isReadonlyCall, - isTailCall, pConstrainedResolvedToken, callInfo->thisTransform, &ni, &isSpecialIntrinsic); - - if (compDonotInline()) - { - return TYP_UNDEF; - } - - if (call != nullptr) - { -#ifdef FEATURE_READYTORUN - if (call->OperGet() == GT_INTRINSIC) - { - if (opts.IsReadyToRun()) - { - noway_assert(callInfo->kind == CORINFO_CALL); - call->AsIntrinsic()->gtEntryPoint = callInfo->codePointerLookup.constLookup; - } - else - { - call->AsIntrinsic()->gtEntryPoint.addr = nullptr; - call->AsIntrinsic()->gtEntryPoint.accessType = IAT_VALUE; - } - } -#endif - - bIntrinsicImported = true; - goto DONE_CALL; - } - } - -#ifdef FEATURE_SIMD - call = impSIMDIntrinsic(opcode, newobjThis, clsHnd, methHnd, sig, mflags, pResolvedToken->token); - if (call != nullptr) - { - bIntrinsicImported = true; - goto DONE_CALL; - } -#endif // FEATURE_SIMD - - if ((mflags & CORINFO_FLG_VIRTUAL) && (mflags & CORINFO_FLG_EnC) && (opcode == CEE_CALLVIRT)) - { - NO_WAY("Virtual call to a function added via EnC is not supported"); - } - - if ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_DEFAULT && - (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG && - (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG) - { - BADCODE("Bad calling convention"); - } - - //------------------------------------------------------------------------- - // Construct the call node - // - // Work out what sort of call we're making. - // Dispense with virtual calls implemented via LDVIRTFTN immediately. - - constraintCallThisTransform = callInfo->thisTransform; - exactContextHnd = callInfo->contextHandle; - exactContextNeedsRuntimeLookup = callInfo->exactContextNeedsRuntimeLookup; - - switch (callInfo->kind) - { - case CORINFO_VIRTUALCALL_STUB: - { - assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method - assert(!(clsFlags & CORINFO_FLG_VALUECLASS)); - if (callInfo->stubLookup.lookupKind.needsRuntimeLookup) - { - if (callInfo->stubLookup.lookupKind.runtimeLookupKind == CORINFO_LOOKUP_NOT_SUPPORTED) - { - // Runtime does not support inlining of all shapes of runtime lookups - // Inlining has to be aborted in such a case - compInlineResult->NoteFatal(InlineObservation::CALLSITE_HAS_COMPLEX_HANDLE); - return TYP_UNDEF; - } - - GenTree* stubAddr = impRuntimeLookupToTree(pResolvedToken, &callInfo->stubLookup, methHnd); - - // stubAddr tree may require a new temp. - // If we're inlining, this may trigger the too many locals inline failure. - // - // If so, we need to bail out. - // - if (compDonotInline()) - { - return TYP_UNDEF; - } - - // This is the rough code to set up an indirect stub call - assert(stubAddr != nullptr); - - // The stubAddr may be a - // complex expression. As it is evaluated after the args, - // it may cause registered args to be spilled. Simply spill it. - // - unsigned const lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall with runtime lookup")); - if (compDonotInline()) - { - return TYP_UNDEF; - } - - impAssignTempGen(lclNum, stubAddr, CHECK_SPILL_NONE); - stubAddr = gtNewLclvNode(lclNum, TYP_I_IMPL); - - // Create the actual call node - - assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG && - (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG); - - call = gtNewIndCallNode(stubAddr, callRetTyp); - - call->gtFlags |= GTF_EXCEPT | (stubAddr->gtFlags & GTF_GLOB_EFFECT); - call->gtFlags |= GTF_CALL_VIRT_STUB; - -#ifdef TARGET_X86 - // No tailcalls allowed for these yet... - canTailCall = false; - szCanTailCallFailReason = "VirtualCall with runtime lookup"; -#endif - } - else - { - // The stub address is known at compile time - call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di); - call->AsCall()->gtStubCallStubAddr = callInfo->stubLookup.constLookup.addr; - call->gtFlags |= GTF_CALL_VIRT_STUB; - assert(callInfo->stubLookup.constLookup.accessType != IAT_PPVALUE && - callInfo->stubLookup.constLookup.accessType != IAT_RELPVALUE); - if (callInfo->stubLookup.constLookup.accessType == IAT_PVALUE) - { - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_VIRTSTUB_REL_INDIRECT; - } - } - -#ifdef FEATURE_READYTORUN - if (opts.IsReadyToRun()) - { - // Null check is sometimes needed for ready to run to handle - // non-virtual <-> virtual changes between versions - if (callInfo->nullInstanceCheck) - { - call->gtFlags |= GTF_CALL_NULLCHECK; - } - } -#endif - - break; - } - - case CORINFO_VIRTUALCALL_VTABLE: - { - assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method - assert(!(clsFlags & CORINFO_FLG_VALUECLASS)); - call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di); - call->gtFlags |= GTF_CALL_VIRT_VTABLE; - - // Mark this method to expand the virtual call target early in fgMorphCall - call->AsCall()->SetExpandedEarly(); - break; - } - - case CORINFO_VIRTUALCALL_LDVIRTFTN: - { - if (compIsForInlining()) - { - compInlineResult->NoteFatal(InlineObservation::CALLSITE_HAS_CALL_VIA_LDVIRTFTN); - return TYP_UNDEF; - } - - assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method - assert(!(clsFlags & CORINFO_FLG_VALUECLASS)); - // OK, We've been told to call via LDVIRTFTN, so just - // take the call now.... - call = gtNewIndCallNode(nullptr, callRetTyp, di); - - impPopCallArgs(sig, call->AsCall()); - - GenTree* thisPtr = impPopStack().val; - thisPtr = impTransformThis(thisPtr, pConstrainedResolvedToken, callInfo->thisTransform); - assert(thisPtr != nullptr); - - // Clone the (possibly transformed) "this" pointer - GenTree* thisPtrCopy; - thisPtr = impCloneExpr(thisPtr, &thisPtrCopy, NO_CLASS_HANDLE, CHECK_SPILL_ALL, - nullptr DEBUGARG("LDVIRTFTN this pointer")); - - GenTree* fptr = impImportLdvirtftn(thisPtr, pResolvedToken, callInfo); - assert(fptr != nullptr); - - call->AsCall() - ->gtArgs.PushFront(this, NewCallArg::Primitive(thisPtrCopy).WellKnown(WellKnownArg::ThisPointer)); - - // Now make an indirect call through the function pointer - - unsigned lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall through function pointer")); - impAssignTempGen(lclNum, fptr, CHECK_SPILL_ALL); - fptr = gtNewLclvNode(lclNum, TYP_I_IMPL); - - call->AsCall()->gtCallAddr = fptr; - call->gtFlags |= GTF_EXCEPT | (fptr->gtFlags & GTF_GLOB_EFFECT); - - if ((sig->sigInst.methInstCount != 0) && IsTargetAbi(CORINFO_NATIVEAOT_ABI)) - { - // NativeAOT generic virtual method: need to handle potential fat function pointers - addFatPointerCandidate(call->AsCall()); - } -#ifdef FEATURE_READYTORUN - if (opts.IsReadyToRun()) - { - // Null check is needed for ready to run to handle - // non-virtual <-> virtual changes between versions - call->gtFlags |= GTF_CALL_NULLCHECK; - } -#endif - - // Sine we are jumping over some code, check that its OK to skip that code - assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG && - (sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG); - goto DONE; - } - - case CORINFO_CALL: - { - // This is for a non-virtual, non-interface etc. call - call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di); - - // We remove the nullcheck for the GetType call intrinsic. - // TODO-CQ: JIT64 does not introduce the null check for many more helper calls - // and intrinsics. - if (callInfo->nullInstanceCheck && - !((mflags & CORINFO_FLG_INTRINSIC) != 0 && (ni == NI_System_Object_GetType))) - { - call->gtFlags |= GTF_CALL_NULLCHECK; - } - -#ifdef FEATURE_READYTORUN - if (opts.IsReadyToRun()) - { - call->AsCall()->setEntryPoint(callInfo->codePointerLookup.constLookup); - } -#endif - break; - } - - case CORINFO_CALL_CODE_POINTER: - { - // The EE has asked us to call by computing a code pointer and then doing an - // indirect call. This is because a runtime lookup is required to get the code entry point. - - // These calls always follow a uniform calling convention, i.e. no extra hidden params - assert((sig->callConv & CORINFO_CALLCONV_PARAMTYPE) == 0); - - assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG); - assert((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_NATIVEVARARG); - - GenTree* fptr = - impLookupToTree(pResolvedToken, &callInfo->codePointerLookup, GTF_ICON_FTN_ADDR, callInfo->hMethod); - - if (compDonotInline()) - { - return TYP_UNDEF; - } - - // Now make an indirect call through the function pointer - - unsigned lclNum = lvaGrabTemp(true DEBUGARG("Indirect call through function pointer")); - impAssignTempGen(lclNum, fptr, CHECK_SPILL_ALL); - fptr = gtNewLclvNode(lclNum, TYP_I_IMPL); - - call = gtNewIndCallNode(fptr, callRetTyp, di); - call->gtFlags |= GTF_EXCEPT | (fptr->gtFlags & GTF_GLOB_EFFECT); - if (callInfo->nullInstanceCheck) - { - call->gtFlags |= GTF_CALL_NULLCHECK; - } - - break; - } - - default: - assert(!"unknown call kind"); - break; - } - - //------------------------------------------------------------------------- - // Set more flags - - PREFIX_ASSUME(call != nullptr); - - if (mflags & CORINFO_FLG_NOGCCHECK) - { - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_NOGCCHECK; - } - - // Mark call if it's one of the ones we will maybe treat as an intrinsic - if (isSpecialIntrinsic) - { - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_SPECIAL_INTRINSIC; - } - } - assert(sig); - assert(clsHnd || (opcode == CEE_CALLI)); // We're never verifying for CALLI, so this is not set. - - /* Some sanity checks */ - - // CALL_VIRT and NEWOBJ must have a THIS pointer - assert((opcode != CEE_CALLVIRT && opcode != CEE_NEWOBJ) || (sig->callConv & CORINFO_CALLCONV_HASTHIS)); - // static bit and hasThis are negations of one another - assert(((mflags & CORINFO_FLG_STATIC) != 0) == ((sig->callConv & CORINFO_CALLCONV_HASTHIS) == 0)); - assert(call != nullptr); - - /*------------------------------------------------------------------------- - * Check special-cases etc - */ - - /* Special case - Check if it is a call to Delegate.Invoke(). */ - - if (mflags & CORINFO_FLG_DELEGATE_INVOKE) - { - assert(!(mflags & CORINFO_FLG_STATIC)); // can't call a static method - assert(mflags & CORINFO_FLG_FINAL); - - /* Set the delegate flag */ - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_DELEGATE_INV; - - if (callInfo->wrapperDelegateInvoke) - { - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_WRAPPER_DELEGATE_INV; - } - - if (opcode == CEE_CALLVIRT) - { - assert(mflags & CORINFO_FLG_FINAL); - - /* It should have the GTF_CALL_NULLCHECK flag set. Reset it */ - assert(call->gtFlags & GTF_CALL_NULLCHECK); - call->gtFlags &= ~GTF_CALL_NULLCHECK; - } - } - - CORINFO_CLASS_HANDLE actualMethodRetTypeSigClass; - actualMethodRetTypeSigClass = sig->retTypeSigClass; - - /* Check for varargs */ - if (!compFeatureVarArg() && ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG || - (sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_NATIVEVARARG)) - { - BADCODE("Varargs not supported."); - } - - if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG || - (sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_NATIVEVARARG) - { - assert(!compIsForInlining()); - - /* Set the right flags */ - - call->gtFlags |= GTF_CALL_POP_ARGS; - call->AsCall()->gtArgs.SetIsVarArgs(); - - /* Can't allow tailcall for varargs as it is caller-pop. The caller - will be expecting to pop a certain number of arguments, but if we - tailcall to a function with a different number of arguments, we - are hosed. There are ways around this (caller remembers esp value, - varargs is not caller-pop, etc), but not worth it. */ - CLANG_FORMAT_COMMENT_ANCHOR; - -#ifdef TARGET_X86 - if (canTailCall) - { - canTailCall = false; - szCanTailCallFailReason = "Callee is varargs"; - } -#endif - - /* Get the total number of arguments - this is already correct - * for CALLI - for methods we have to get it from the call site */ - - if (opcode != CEE_CALLI) - { -#ifdef DEBUG - unsigned numArgsDef = sig->numArgs; -#endif - eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, sig); - - // For vararg calls we must be sure to load the return type of the - // method actually being called, as well as the return types of the - // specified in the vararg signature. With type equivalency, these types - // may not be the same. - if (sig->retTypeSigClass != actualMethodRetTypeSigClass) - { - if (actualMethodRetTypeSigClass != nullptr && sig->retType != CORINFO_TYPE_CLASS && - sig->retType != CORINFO_TYPE_BYREF && sig->retType != CORINFO_TYPE_PTR && - sig->retType != CORINFO_TYPE_VAR) - { - // Make sure that all valuetypes (including enums) that we push are loaded. - // This is to guarantee that if a GC is triggered from the prestub of this methods, - // all valuetypes in the method signature are already loaded. - // We need to be able to find the size of the valuetypes, but we cannot - // do a class-load from within GC. - info.compCompHnd->classMustBeLoadedBeforeCodeIsRun(actualMethodRetTypeSigClass); - } - } - - assert(numArgsDef <= sig->numArgs); - } - - /* We will have "cookie" as the last argument but we cannot push - * it on the operand stack because we may overflow, so we append it - * to the arg list next after we pop them */ - } - - //--------------------------- Inline NDirect ------------------------------ - - // For inline cases we technically should look at both the current - // block and the call site block (or just the latter if we've - // fused the EH trees). However the block-related checks pertain to - // EH and we currently won't inline a method with EH. So for - // inlinees, just checking the call site block is sufficient. - { - // New lexical block here to avoid compilation errors because of GOTOs. - BasicBlock* block = compIsForInlining() ? impInlineInfo->iciBlock : compCurBB; - impCheckForPInvokeCall(call->AsCall(), methHnd, sig, mflags, block); - } - -#ifdef UNIX_X86_ABI - // On Unix x86 we use caller-cleaned convention. - if ((call->gtFlags & GTF_CALL_UNMANAGED) == 0) - call->gtFlags |= GTF_CALL_POP_ARGS; -#endif // UNIX_X86_ABI - - if (call->gtFlags & GTF_CALL_UNMANAGED) - { - // We set up the unmanaged call by linking the frame, disabling GC, etc - // This needs to be cleaned up on return. - // In addition, native calls have different normalization rules than managed code - // (managed calling convention always widens return values in the callee) - if (canTailCall) - { - canTailCall = false; - szCanTailCallFailReason = "Callee is native"; - } - - checkForSmallType = true; - - impPopArgsForUnmanagedCall(call->AsCall(), sig); - - goto DONE; - } - else if ((opcode == CEE_CALLI) && ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_DEFAULT) && - ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG)) - { - if (!info.compCompHnd->canGetCookieForPInvokeCalliSig(sig)) - { - // Normally this only happens with inlining. - // However, a generic method (or type) being NGENd into another module - // can run into this issue as well. There's not an easy fall-back for NGEN - // so instead we fallback to JIT. - if (compIsForInlining()) - { - compInlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_EMBED_PINVOKE_COOKIE); - } - else - { - IMPL_LIMITATION("Can't get PInvoke cookie (cross module generics)"); - } - - return TYP_UNDEF; - } - - GenTree* cookie = eeGetPInvokeCookie(sig); - - // This cookie is required to be either a simple GT_CNS_INT or - // an indirection of a GT_CNS_INT - // - GenTree* cookieConst = cookie; - if (cookie->gtOper == GT_IND) - { - cookieConst = cookie->AsOp()->gtOp1; - } - assert(cookieConst->gtOper == GT_CNS_INT); - - // Setting GTF_DONT_CSE on the GT_CNS_INT as well as on the GT_IND (if it exists) will ensure that - // we won't allow this tree to participate in any CSE logic - // - cookie->gtFlags |= GTF_DONT_CSE; - cookieConst->gtFlags |= GTF_DONT_CSE; - - call->AsCall()->gtCallCookie = cookie; - - if (canTailCall) - { - canTailCall = false; - szCanTailCallFailReason = "PInvoke calli"; - } - } - - /*------------------------------------------------------------------------- - * Create the argument list - */ - - //------------------------------------------------------------------------- - // Special case - for varargs we have an implicit last argument - - if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG) - { - assert(!compIsForInlining()); - - void *varCookie, *pVarCookie; - if (!info.compCompHnd->canGetVarArgsHandle(sig)) - { - compInlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_EMBED_VARARGS_COOKIE); - return TYP_UNDEF; - } - - varCookie = info.compCompHnd->getVarArgsHandle(sig, &pVarCookie); - assert((!varCookie) != (!pVarCookie)); - GenTree* cookieNode = gtNewIconEmbHndNode(varCookie, pVarCookie, GTF_ICON_VARG_HDL, sig); - assert(extraArg.Node == nullptr); - extraArg = NewCallArg::Primitive(cookieNode).WellKnown(WellKnownArg::VarArgsCookie); - } - - //------------------------------------------------------------------------- - // Extra arg for shared generic code and array methods - // - // Extra argument containing instantiation information is passed in the - // following circumstances: - // (a) To the "Address" method on array classes; the extra parameter is - // the array's type handle (a TypeDesc) - // (b) To shared-code instance methods in generic structs; the extra parameter - // is the struct's type handle (a vtable ptr) - // (c) To shared-code per-instantiation non-generic static methods in generic - // classes and structs; the extra parameter is the type handle - // (d) To shared-code generic methods; the extra parameter is an - // exact-instantiation MethodDesc - // - // We also set the exact type context associated with the call so we can - // inline the call correctly later on. - - if (sig->callConv & CORINFO_CALLCONV_PARAMTYPE) - { - assert(call->AsCall()->gtCallType == CT_USER_FUNC); - if (clsHnd == nullptr) - { - NO_WAY("CALLI on parameterized type"); - } - - assert(opcode != CEE_CALLI); - - GenTree* instParam; - bool runtimeLookup; - - // Instantiated generic method - if (((SIZE_T)exactContextHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_METHOD) - { - assert(exactContextHnd != METHOD_BEING_COMPILED_CONTEXT()); - - CORINFO_METHOD_HANDLE exactMethodHandle = - (CORINFO_METHOD_HANDLE)((SIZE_T)exactContextHnd & ~CORINFO_CONTEXTFLAGS_MASK); - - if (!exactContextNeedsRuntimeLookup) - { -#ifdef FEATURE_READYTORUN - if (opts.IsReadyToRun()) - { - instParam = - impReadyToRunLookupToTree(&callInfo->instParamLookup, GTF_ICON_METHOD_HDL, exactMethodHandle); - if (instParam == nullptr) - { - assert(compDonotInline()); - return TYP_UNDEF; - } - } - else -#endif - { - instParam = gtNewIconEmbMethHndNode(exactMethodHandle); - info.compCompHnd->methodMustBeLoadedBeforeCodeIsRun(exactMethodHandle); - } - } - else - { - instParam = impTokenToHandle(pResolvedToken, &runtimeLookup, true /*mustRestoreHandle*/); - if (instParam == nullptr) - { - assert(compDonotInline()); - return TYP_UNDEF; - } - } - } - - // otherwise must be an instance method in a generic struct, - // a static method in a generic type, or a runtime-generated array method - else - { - assert(((SIZE_T)exactContextHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_CLASS); - CORINFO_CLASS_HANDLE exactClassHandle = eeGetClassFromContext(exactContextHnd); - - if (compIsForInlining() && (clsFlags & CORINFO_FLG_ARRAY) != 0) - { - compInlineResult->NoteFatal(InlineObservation::CALLEE_IS_ARRAY_METHOD); - return TYP_UNDEF; - } - - if ((clsFlags & CORINFO_FLG_ARRAY) && isReadonlyCall) - { - // We indicate "readonly" to the Address operation by using a null - // instParam. - instParam = gtNewIconNode(0, TYP_REF); - } - else if (!exactContextNeedsRuntimeLookup) - { -#ifdef FEATURE_READYTORUN - if (opts.IsReadyToRun()) - { - instParam = - impReadyToRunLookupToTree(&callInfo->instParamLookup, GTF_ICON_CLASS_HDL, exactClassHandle); - if (instParam == nullptr) - { - assert(compDonotInline()); - return TYP_UNDEF; - } - } - else -#endif - { - instParam = gtNewIconEmbClsHndNode(exactClassHandle); - info.compCompHnd->classMustBeLoadedBeforeCodeIsRun(exactClassHandle); - } - } - else - { - instParam = impParentClassTokenToHandle(pResolvedToken, &runtimeLookup, true /*mustRestoreHandle*/); - if (instParam == nullptr) - { - assert(compDonotInline()); - return TYP_UNDEF; - } - } - } - - assert(extraArg.Node == nullptr); - extraArg = NewCallArg::Primitive(instParam).WellKnown(WellKnownArg::InstParam); - } - - if ((opcode == CEE_NEWOBJ) && ((clsFlags & CORINFO_FLG_DELEGATE) != 0)) - { - // Only verifiable cases are supported. - // dup; ldvirtftn; newobj; or ldftn; newobj. - // IL test could contain unverifiable sequence, in this case optimization should not be done. - if (impStackHeight() > 0) - { - typeInfo delegateTypeInfo = impStackTop().seTypeInfo; - if (delegateTypeInfo.IsMethod()) - { - ldftnInfo = delegateTypeInfo.GetMethodPointerInfo(); - } - } - } - - //------------------------------------------------------------------------- - // The main group of arguments - - impPopCallArgs(sig, call->AsCall()); - if (extraArg.Node != nullptr) - { - if (Target::g_tgtArgOrder == Target::ARG_ORDER_R2L) - { - call->AsCall()->gtArgs.PushFront(this, extraArg); - } - else - { - call->AsCall()->gtArgs.PushBack(this, extraArg); - } - - call->gtFlags |= extraArg.Node->gtFlags & GTF_GLOB_EFFECT; - } - - //------------------------------------------------------------------------- - // The "this" pointer - - if (((mflags & CORINFO_FLG_STATIC) == 0) && ((sig->callConv & CORINFO_CALLCONV_EXPLICITTHIS) == 0) && - !((opcode == CEE_NEWOBJ) && (newobjThis == nullptr))) - { - GenTree* obj; - - if (opcode == CEE_NEWOBJ) - { - obj = newobjThis; - } - else - { - obj = impPopStack().val; - obj = impTransformThis(obj, pConstrainedResolvedToken, constraintCallThisTransform); - if (compDonotInline()) - { - return TYP_UNDEF; - } - } - - // Store the "this" value in the call - call->gtFlags |= obj->gtFlags & GTF_GLOB_EFFECT; - call->AsCall()->gtArgs.PushFront(this, NewCallArg::Primitive(obj).WellKnown(WellKnownArg::ThisPointer)); - - if (impIsThis(obj)) - { - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_NONVIRT_SAME_THIS; - } - } - - bool probing; - probing = impConsiderCallProbe(call->AsCall(), rawILOffset); - - // See if we can devirt if we aren't probing. - if (!probing && opts.OptimizationEnabled()) - { - if (call->AsCall()->IsVirtual()) - { - // only true object pointers can be virtual - assert(call->AsCall()->gtArgs.HasThisPointer() && - call->AsCall()->gtArgs.GetThisArg()->GetNode()->TypeIs(TYP_REF)); - - // See if we can devirtualize. - - const bool isExplicitTailCall = (tailCallFlags & PREFIX_TAILCALL_EXPLICIT) != 0; - const bool isLateDevirtualization = false; - impDevirtualizeCall(call->AsCall(), pResolvedToken, &callInfo->hMethod, &callInfo->methodFlags, - &callInfo->contextHandle, &exactContextHnd, isLateDevirtualization, isExplicitTailCall, - // Take care to pass raw IL offset here as the 'debug info' might be different for - // inlinees. - rawILOffset); - - // Devirtualization may change which method gets invoked. Update our local cache. - // - methHnd = callInfo->hMethod; - } - else if (call->AsCall()->IsDelegateInvoke()) - { - considerGuardedDevirtualization(call->AsCall(), rawILOffset, false, NO_METHOD_HANDLE, NO_CLASS_HANDLE, - nullptr); - } - } - - //------------------------------------------------------------------------- - // The "this" pointer for "newobj" - - if (opcode == CEE_NEWOBJ) - { - if (clsFlags & CORINFO_FLG_VAROBJSIZE) - { - assert(!(clsFlags & CORINFO_FLG_ARRAY)); // arrays handled separately - // This is a 'new' of a variable sized object, wher - // the constructor is to return the object. In this case - // the constructor claims to return VOID but we know it - // actually returns the new object - assert(callRetTyp == TYP_VOID); - callRetTyp = TYP_REF; - call->gtType = TYP_REF; - impSpillSpecialSideEff(); - - impPushOnStack(call, typeInfo(TI_REF, clsHnd)); - } - else - { - if (clsFlags & CORINFO_FLG_DELEGATE) - { - // New inliner morph it in impImportCall. - // This will allow us to inline the call to the delegate constructor. - call = fgOptimizeDelegateConstructor(call->AsCall(), &exactContextHnd, ldftnInfo); - } - - if (!bIntrinsicImported) - { - -#if defined(DEBUG) || defined(INLINE_DATA) - - // Keep track of the raw IL offset of the call - call->AsCall()->gtRawILOffset = rawILOffset; - -#endif // defined(DEBUG) || defined(INLINE_DATA) - - // Is it an inline candidate? - impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo, rawILOffset); - } - - // append the call node. - impAppendTree(call, CHECK_SPILL_ALL, impCurStmtDI); - - // Now push the value of the 'new onto the stack - - // This is a 'new' of a non-variable sized object. - // Append the new node (op1) to the statement list, - // and then push the local holding the value of this - // new instruction on the stack. - - if (clsFlags & CORINFO_FLG_VALUECLASS) - { - assert(newobjThis->gtOper == GT_ADDR && newobjThis->AsOp()->gtOp1->gtOper == GT_LCL_VAR); - - unsigned tmp = newobjThis->AsOp()->gtOp1->AsLclVarCommon()->GetLclNum(); - impPushOnStack(gtNewLclvNode(tmp, lvaGetRealType(tmp)), verMakeTypeInfo(clsHnd).NormaliseForStack()); - } - else - { - if (newobjThis->gtOper == GT_COMMA) - { - // We must have inserted the callout. Get the real newobj. - newobjThis = newobjThis->AsOp()->gtOp2; - } - - assert(newobjThis->gtOper == GT_LCL_VAR); - impPushOnStack(gtNewLclvNode(newobjThis->AsLclVarCommon()->GetLclNum(), TYP_REF), - typeInfo(TI_REF, clsHnd)); - } - } - return callRetTyp; - } - -DONE: - -#ifdef DEBUG - // In debug we want to be able to register callsites with the EE. - assert(call->AsCall()->callSig == nullptr); - call->AsCall()->callSig = new (this, CMK_Generic) CORINFO_SIG_INFO; - *call->AsCall()->callSig = *sig; -#endif - - // Final importer checks for calls flagged as tail calls. - // - if (tailCallFlags != 0) - { - const bool isExplicitTailCall = (tailCallFlags & PREFIX_TAILCALL_EXPLICIT) != 0; - const bool isImplicitTailCall = (tailCallFlags & PREFIX_TAILCALL_IMPLICIT) != 0; - const bool isStressTailCall = (tailCallFlags & PREFIX_TAILCALL_STRESS) != 0; - - // Exactly one of these should be true. - assert(isExplicitTailCall != isImplicitTailCall); - - // This check cannot be performed for implicit tail calls for the reason - // that impIsImplicitTailCallCandidate() is not checking whether return - // types are compatible before marking a call node with PREFIX_TAILCALL_IMPLICIT. - // As a result it is possible that in the following case, we find that - // the type stack is non-empty if Callee() is considered for implicit - // tail calling. - // int Caller(..) { .... void Callee(); ret val; ... } - // - // Note that we cannot check return type compatibility before ImpImportCall() - // as we don't have required info or need to duplicate some of the logic of - // ImpImportCall(). - // - // For implicit tail calls, we perform this check after return types are - // known to be compatible. - if (isExplicitTailCall && (verCurrentState.esStackDepth != 0)) - { - BADCODE("Stack should be empty after tailcall"); - } - - // For opportunistic tailcalls we allow implicit widening, i.e. tailcalls from int32 -> int16, since the - // managed calling convention dictates that the callee widens the value. For explicit tailcalls we don't - // want to require this detail of the calling convention to bubble up to the tailcall helpers - bool allowWidening = isImplicitTailCall; - if (canTailCall && - !impTailCallRetTypeCompatible(allowWidening, info.compRetType, info.compMethodInfo->args.retTypeClass, - info.compCallConv, callRetTyp, sig->retTypeClass, - call->AsCall()->GetUnmanagedCallConv())) - { - canTailCall = false; - szCanTailCallFailReason = "Return types are not tail call compatible"; - } - - // Stack empty check for implicit tail calls. - if (canTailCall && isImplicitTailCall && (verCurrentState.esStackDepth != 0)) - { -#ifdef TARGET_AMD64 - // JIT64 Compatibility: Opportunistic tail call stack mismatch throws a VerificationException - // in JIT64, not an InvalidProgramException. - Verify(false, "Stack should be empty after tailcall"); -#else // TARGET_64BIT - BADCODE("Stack should be empty after tailcall"); -#endif //! TARGET_64BIT - } - - // assert(compCurBB is not a catch, finally or filter block); - // assert(compCurBB is not a try block protected by a finally block); - assert(!isExplicitTailCall || compCurBB->bbJumpKind == BBJ_RETURN); - - // Ask VM for permission to tailcall - if (canTailCall) - { - // True virtual or indirect calls, shouldn't pass in a callee handle. - CORINFO_METHOD_HANDLE exactCalleeHnd = - ((call->AsCall()->gtCallType != CT_USER_FUNC) || call->AsCall()->IsVirtual()) ? nullptr : methHnd; - - if (info.compCompHnd->canTailCall(info.compMethodHnd, methHnd, exactCalleeHnd, isExplicitTailCall)) - { - if (isExplicitTailCall) - { - // In case of explicit tail calls, mark it so that it is not considered - // for in-lining. - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_EXPLICIT_TAILCALL; - JITDUMP("\nGTF_CALL_M_EXPLICIT_TAILCALL set for call [%06u]\n", dspTreeID(call)); - - if (isStressTailCall) - { - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_STRESS_TAILCALL; - JITDUMP("\nGTF_CALL_M_STRESS_TAILCALL set for call [%06u]\n", dspTreeID(call)); - } - } - else - { -#if FEATURE_TAILCALL_OPT - // Must be an implicit tail call. - assert(isImplicitTailCall); - - // It is possible that a call node is both an inline candidate and marked - // for opportunistic tail calling. In-lining happens before morhphing of - // trees. If in-lining of an in-line candidate gets aborted for whatever - // reason, it will survive to the morphing stage at which point it will be - // transformed into a tail call after performing additional checks. - - call->AsCall()->gtCallMoreFlags |= GTF_CALL_M_IMPLICIT_TAILCALL; - JITDUMP("\nGTF_CALL_M_IMPLICIT_TAILCALL set for call [%06u]\n", dspTreeID(call)); - -#else //! FEATURE_TAILCALL_OPT - NYI("Implicit tail call prefix on a target which doesn't support opportunistic tail calls"); - -#endif // FEATURE_TAILCALL_OPT - } - - // This might or might not turn into a tailcall. We do more - // checks in morph. For explicit tailcalls we need more - // information in morph in case it turns out to be a - // helper-based tailcall. - if (isExplicitTailCall) - { - assert(call->AsCall()->tailCallInfo == nullptr); - call->AsCall()->tailCallInfo = new (this, CMK_CorTailCallInfo) TailCallSiteInfo; - switch (opcode) - { - case CEE_CALLI: - call->AsCall()->tailCallInfo->SetCalli(sig); - break; - case CEE_CALLVIRT: - call->AsCall()->tailCallInfo->SetCallvirt(sig, pResolvedToken); - break; - default: - call->AsCall()->tailCallInfo->SetCall(sig, pResolvedToken); - break; - } - } - } - else - { - // canTailCall reported its reasons already - canTailCall = false; - JITDUMP("\ninfo.compCompHnd->canTailCall returned false for call [%06u]\n", dspTreeID(call)); - } - } - else - { - // If this assert fires it means that canTailCall was set to false without setting a reason! - assert(szCanTailCallFailReason != nullptr); - JITDUMP("\nRejecting %splicit tail call for [%06u], reason: '%s'\n", isExplicitTailCall ? "ex" : "im", - dspTreeID(call), szCanTailCallFailReason); - info.compCompHnd->reportTailCallDecision(info.compMethodHnd, methHnd, isExplicitTailCall, TAILCALL_FAIL, - szCanTailCallFailReason); - } - } - - // Note: we assume that small return types are already normalized by the managed callee - // or by the pinvoke stub for calls to unmanaged code. - - if (!bIntrinsicImported) - { - // - // Things needed to be checked when bIntrinsicImported is false. - // - - assert(call->gtOper == GT_CALL); - assert(callInfo != nullptr); - - if (compIsForInlining() && opcode == CEE_CALLVIRT) - { - assert(call->AsCall()->gtArgs.HasThisPointer()); - GenTree* callObj = call->AsCall()->gtArgs.GetThisArg()->GetEarlyNode(); - - if ((call->AsCall()->IsVirtual() || (call->gtFlags & GTF_CALL_NULLCHECK)) && - impInlineIsGuaranteedThisDerefBeforeAnySideEffects(nullptr, &call->AsCall()->gtArgs, callObj, - impInlineInfo->inlArgInfo)) - { - impInlineInfo->thisDereferencedFirst = true; - } - } - -#if defined(DEBUG) || defined(INLINE_DATA) - - // Keep track of the raw IL offset of the call - call->AsCall()->gtRawILOffset = rawILOffset; - -#endif // defined(DEBUG) || defined(INLINE_DATA) - - // Is it an inline candidate? - impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo, rawILOffset); - } - - // Extra checks for tail calls and tail recursion. - // - // A tail recursive call is a potential loop from the current block to the start of the root method. - // If we see a tail recursive call, mark the blocks from the call site back to the entry as potentially - // being in a loop. - // - // Note: if we're importing an inlinee we don't mark the right set of blocks, but by then it's too - // late. Currently this doesn't lead to problems. See GitHub issue 33529. - // - // OSR also needs to handle tail calls specially: - // * block profiling in OSR methods needs to ensure probes happen before tail calls, not after. - // * the root method entry must be imported if there's a recursive tail call or a potentially - // inlineable tail call. - // - if ((tailCallFlags != 0) && canTailCall) - { - if (gtIsRecursiveCall(methHnd)) - { - assert(verCurrentState.esStackDepth == 0); - BasicBlock* loopHead = nullptr; - if (!compIsForInlining() && opts.IsOSR()) - { - // For root method OSR we may branch back to the actual method entry, - // which is not fgFirstBB, and which we will need to import. - assert(fgEntryBB != nullptr); - loopHead = fgEntryBB; - } - else - { - // For normal jitting we may branch back to the firstBB; this - // should already be imported. - loopHead = fgFirstBB; - } - - JITDUMP("\nTail recursive call [%06u] in the method. Mark " FMT_BB " to " FMT_BB - " as having a backward branch.\n", - dspTreeID(call), loopHead->bbNum, compCurBB->bbNum); - fgMarkBackwardJump(loopHead, compCurBB); - - compMayConvertTailCallToLoop = true; - } - - // We only do these OSR checks in the root method because: - // * If we fail to import the root method entry when importing the root method, we can't go back - // and import it during inlining. So instead of checking just for recursive tail calls we also - // have to check for anything that might introduce a recursive tail call. - // * We only instrument root method blocks in OSR methods, - // - if (opts.IsOSR() && !compIsForInlining()) - { - // If a root method tail call candidate block is not a BBJ_RETURN, it should have a unique - // BBJ_RETURN successor. Mark that successor so we can handle it specially during profile - // instrumentation. - // - if (compCurBB->bbJumpKind != BBJ_RETURN) - { - BasicBlock* const successor = compCurBB->GetUniqueSucc(); - assert(successor->bbJumpKind == BBJ_RETURN); - successor->bbFlags |= BBF_TAILCALL_SUCCESSOR; - optMethodFlags |= OMF_HAS_TAILCALL_SUCCESSOR; - } - - // If this call might eventually turn into a loop back to method entry, make sure we - // import the method entry. - // - assert(call->IsCall()); - GenTreeCall* const actualCall = call->AsCall(); - const bool mustImportEntryBlock = gtIsRecursiveCall(methHnd) || actualCall->IsInlineCandidate() || - actualCall->IsGuardedDevirtualizationCandidate(); - - // Only schedule importation if we're not currently importing. - // - if (mustImportEntryBlock && (compCurBB != fgEntryBB)) - { - JITDUMP("\nOSR: inlineable or recursive tail call [%06u] in the method, so scheduling " FMT_BB - " for importation\n", - dspTreeID(call), fgEntryBB->bbNum); - impImportBlockPending(fgEntryBB); - } - } - } - - if ((sig->flags & CORINFO_SIGFLAG_FAT_CALL) != 0) - { - assert(opcode == CEE_CALLI || callInfo->kind == CORINFO_CALL_CODE_POINTER); - addFatPointerCandidate(call->AsCall()); - } - -DONE_CALL: - // Push or append the result of the call - if (callRetTyp == TYP_VOID) - { - if (opcode == CEE_NEWOBJ) - { - // we actually did push something, so don't spill the thing we just pushed. - assert(verCurrentState.esStackDepth > 0); - impAppendTree(call, verCurrentState.esStackDepth - 1, impCurStmtDI); - } - else - { - impAppendTree(call, CHECK_SPILL_ALL, impCurStmtDI); - } - } - else - { - impSpillSpecialSideEff(); - - if (clsFlags & CORINFO_FLG_ARRAY) - { - eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, sig); - } - - typeInfo tiRetVal = verMakeTypeInfo(sig->retType, sig->retTypeClass); - tiRetVal.NormaliseForStack(); - - if (call->IsCall()) - { - // Sometimes "call" is not a GT_CALL (if we imported an intrinsic that didn't turn into a call) - - GenTreeCall* origCall = call->AsCall(); - - const bool isFatPointerCandidate = origCall->IsFatPointerCandidate(); - const bool isInlineCandidate = origCall->IsInlineCandidate(); - const bool isGuardedDevirtualizationCandidate = origCall->IsGuardedDevirtualizationCandidate(); - - if (varTypeIsStruct(callRetTyp)) - { - // Need to treat all "split tree" cases here, not just inline candidates - call = impFixupCallStructReturn(call->AsCall(), sig->retTypeClass); - } - - // TODO: consider handling fatcalli cases this way too...? - if (isInlineCandidate || isGuardedDevirtualizationCandidate) - { - // We should not have made any adjustments in impFixupCallStructReturn - // as we defer those until we know the fate of the call. - assert(call == origCall); - - assert(opts.OptEnabled(CLFLG_INLINING)); - assert(!isFatPointerCandidate); // We should not try to inline calli. - - // Make the call its own tree (spill the stack if needed). - // Do not consume the debug info here. This is particularly - // important if we give up on the inline, in which case the - // call will typically end up in the statement that contains - // the GT_RET_EXPR that we leave on the stack. - impAppendTree(call, CHECK_SPILL_ALL, impCurStmtDI, false); - - // TODO: Still using the widened type. - GenTree* retExpr = gtNewInlineCandidateReturnExpr(call, genActualType(callRetTyp), compCurBB->bbFlags); - - // Link the retExpr to the call so if necessary we can manipulate it later. - origCall->gtInlineCandidateInfo->retExpr = retExpr; - - // Propagate retExpr as the placeholder for the call. - call = retExpr; - } - else - { - // If the call is virtual, and has a generics context, and is not going to have a class probe, - // record the context for possible use during late devirt. - // - // If we ever want to devirt at Tier0, and/or see issues where OSR methods under PGO lose - // important devirtualizations, we'll want to allow both a class probe and a captured context. - // - if (origCall->IsVirtual() && (origCall->gtCallType != CT_INDIRECT) && (exactContextHnd != nullptr) && - (origCall->gtHandleHistogramProfileCandidateInfo == nullptr)) - { - JITDUMP("\nSaving context %p for call [%06u]\n", exactContextHnd, dspTreeID(origCall)); - origCall->gtCallMoreFlags |= GTF_CALL_M_HAS_LATE_DEVIRT_INFO; - LateDevirtualizationInfo* const info = new (this, CMK_Inlining) LateDevirtualizationInfo; - info->exactContextHnd = exactContextHnd; - origCall->gtLateDevirtualizationInfo = info; - } - - if (isFatPointerCandidate) - { - // fatPointer candidates should be in statements of the form call() or var = call(). - // Such form allows to find statements with fat calls without walking through whole trees - // and removes problems with cutting trees. - assert(!bIntrinsicImported); - assert(IsTargetAbi(CORINFO_NATIVEAOT_ABI)); - if (call->OperGet() != GT_LCL_VAR) // can be already converted by impFixupCallStructReturn. - { - unsigned calliSlot = lvaGrabTemp(true DEBUGARG("calli")); - LclVarDsc* varDsc = lvaGetDesc(calliSlot); - - impAssignTempGen(calliSlot, call, tiRetVal.GetClassHandle(), CHECK_SPILL_NONE); - // impAssignTempGen can change src arg list and return type for call that returns struct. - var_types type = genActualType(lvaTable[calliSlot].TypeGet()); - call = gtNewLclvNode(calliSlot, type); - } - } - - // For non-candidates we must also spill, since we - // might have locals live on the eval stack that this - // call can modify. - // - // Suppress this for certain well-known call targets - // that we know won't modify locals, eg calls that are - // recognized in gtCanOptimizeTypeEquality. Otherwise - // we may break key fragile pattern matches later on. - bool spillStack = true; - if (call->IsCall()) - { - GenTreeCall* callNode = call->AsCall(); - if ((callNode->gtCallType == CT_HELPER) && (gtIsTypeHandleToRuntimeTypeHelper(callNode) || - gtIsTypeHandleToRuntimeTypeHandleHelper(callNode))) - { - spillStack = false; - } - else if ((callNode->gtCallMoreFlags & GTF_CALL_M_SPECIAL_INTRINSIC) != 0) - { - spillStack = false; - } - } - - if (spillStack) - { - impSpillSideEffects(true, CHECK_SPILL_ALL DEBUGARG("non-inline candidate call")); - } - } - } - - if (!bIntrinsicImported) - { - //------------------------------------------------------------------------- - // - /* If the call is of a small type and the callee is managed, the callee will normalize the result - before returning. - However, we need to normalize small type values returned by unmanaged - functions (pinvoke). The pinvoke stub does the normalization, but we need to do it here - if we use the shorter inlined pinvoke stub. */ - - if (checkForSmallType && varTypeIsIntegral(callRetTyp) && genTypeSize(callRetTyp) < genTypeSize(TYP_INT)) - { - call = gtNewCastNode(genActualType(callRetTyp), call, false, callRetTyp); - } - } - - impPushOnStack(call, tiRetVal); - } - - // VSD functions get a new call target each time we getCallInfo, so clear the cache. - // Also, the call info cache for CALLI instructions is largely incomplete, so clear it out. - // if ( (opcode == CEE_CALLI) || (callInfoCache.fetchCallInfo().kind == CORINFO_VIRTUALCALL_STUB)) - // callInfoCache.uncacheCallInfo(); - - return callRetTyp; -} -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - -#ifdef DEBUG -// -var_types Compiler::impImportJitTestLabelMark(int numArgs) -{ - TestLabelAndNum tlAndN; - if (numArgs == 2) - { - tlAndN.m_num = 0; - StackEntry se = impPopStack(); - assert(se.seTypeInfo.GetType() == TI_INT); - GenTree* val = se.val; - assert(val->IsCnsIntOrI()); - tlAndN.m_tl = (TestLabel)val->AsIntConCommon()->IconValue(); - } - else if (numArgs == 3) - { - StackEntry se = impPopStack(); - assert(se.seTypeInfo.GetType() == TI_INT); - GenTree* val = se.val; - assert(val->IsCnsIntOrI()); - tlAndN.m_num = val->AsIntConCommon()->IconValue(); - se = impPopStack(); - assert(se.seTypeInfo.GetType() == TI_INT); - val = se.val; - assert(val->IsCnsIntOrI()); - tlAndN.m_tl = (TestLabel)val->AsIntConCommon()->IconValue(); - } - else - { - assert(false); - } - - StackEntry expSe = impPopStack(); - GenTree* node = expSe.val; - - // There are a small number of special cases, where we actually put the annotation on a subnode. - if (tlAndN.m_tl == TL_LoopHoist && tlAndN.m_num >= 100) - { - // A loop hoist annotation with value >= 100 means that the expression should be a static field access, - // a GT_IND of a static field address, which should be the sum of a (hoistable) helper call and possibly some - // offset within the static field block whose address is returned by the helper call. - // The annotation is saying that this address calculation, but not the entire access, should be hoisted. - assert(node->OperGet() == GT_IND); - tlAndN.m_num -= 100; - GetNodeTestData()->Set(node->AsOp()->gtOp1, tlAndN); - GetNodeTestData()->Remove(node); - } - else - { - GetNodeTestData()->Set(node, tlAndN); - } - - impPushOnStack(node, expSe.seTypeInfo); - return node->TypeGet(); -} -#endif // DEBUG - -//----------------------------------------------------------------------------------- -// impFixupCallStructReturn: For a call node that returns a struct do one of the following: -// - set the flag to indicate struct return via retbuf arg; -// - adjust the return type to a SIMD type if it is returned in 1 reg; -// - spill call result into a temp if it is returned into 2 registers or more and not tail call or inline candidate. -// -// Arguments: -// call - GT_CALL GenTree node -// retClsHnd - Class handle of return type of the call -// -// Return Value: -// Returns new GenTree node after fixing struct return of call node -// -GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HANDLE retClsHnd) -{ - if (!varTypeIsStruct(call)) - { - return call; - } - - call->gtRetClsHnd = retClsHnd; - -#if FEATURE_MULTIREG_RET - call->InitializeStructReturnType(this, retClsHnd, call->GetUnmanagedCallConv()); - const ReturnTypeDesc* retTypeDesc = call->GetReturnTypeDesc(); - const unsigned retRegCount = retTypeDesc->GetReturnRegCount(); -#else // !FEATURE_MULTIREG_RET - const unsigned retRegCount = 1; -#endif // !FEATURE_MULTIREG_RET - - structPassingKind howToReturnStruct; - var_types returnType = getReturnTypeForStruct(retClsHnd, call->GetUnmanagedCallConv(), &howToReturnStruct); - - if (howToReturnStruct == SPK_ByReference) - { - assert(returnType == TYP_UNKNOWN); - call->gtCallMoreFlags |= GTF_CALL_M_RETBUFFARG; - - if (call->IsUnmanaged()) - { - // Native ABIs do not allow retbufs to alias anything. - // This is allowed by the managed ABI and impAssignStructPtr will - // never introduce copies due to this. - unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Retbuf for unmanaged call")); - impAssignTempGen(tmpNum, call, retClsHnd, CHECK_SPILL_ALL); - return gtNewLclvNode(tmpNum, lvaGetDesc(tmpNum)->TypeGet()); - } - - return call; - } - - // Recognize SIMD types as we do for LCL_VARs, - // note it could be not the ABI specific type, for example, on x64 we can set 'TYP_SIMD8` - // for `System.Numerics.Vector2` here but lower will change it to long as ABI dictates. - var_types simdReturnType = impNormStructType(call->gtRetClsHnd); - if (simdReturnType != call->TypeGet()) - { - assert(varTypeIsSIMD(simdReturnType)); - JITDUMP("changing the type of a call [%06u] from %s to %s\n", dspTreeID(call), varTypeName(call->TypeGet()), - varTypeName(simdReturnType)); - call->ChangeType(simdReturnType); - } - - if (retRegCount == 1) - { - return call; - } - -#if FEATURE_MULTIREG_RET - assert(varTypeIsStruct(call)); // It could be a SIMD returned in several regs. - assert(returnType == TYP_STRUCT); - assert((howToReturnStruct == SPK_ByValueAsHfa) || (howToReturnStruct == SPK_ByValue)); - -#ifdef UNIX_AMD64_ABI - // must be a struct returned in two registers - assert(retRegCount == 2); -#else // not UNIX_AMD64_ABI - assert(retRegCount >= 2); -#endif // not UNIX_AMD64_ABI - - if (!call->CanTailCall() && !call->IsInlineCandidate()) - { - // Force a call returning multi-reg struct to be always of the IR form - // tmp = call - // - // No need to assign a multi-reg struct to a local var if: - // - It is a tail call or - // - The call is marked for in-lining later - return impAssignMultiRegTypeToVar(call, retClsHnd DEBUGARG(call->GetUnmanagedCallConv())); - } - return call; -#endif // FEATURE_MULTIREG_RET -} - /***************************************************************************** For struct return values, re-type the operand in the case where the ABI does not use a struct return buffer From 8a2368eb459611a963f78f7004bc4409d8904111 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 16:00:42 +0100 Subject: [PATCH 32/50] Fix bad merge --- .../CorInfoImpl_generated.cs.orig | 3100 ----------------- 1 file changed, 3100 deletions(-) delete mode 100644 src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig deleted file mode 100644 index cadf59f72de57..0000000000000 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs.orig +++ /dev/null @@ -1,3100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// DO NOT EDIT THIS FILE! IT IS AUTOGENERATED -// To regenerate run the gen script in src/coreclr/tools/Common/JitInterface/ThunkGenerator -// and follow the instructions in docs/project/updating-jitinterface.md - -using System; -using System.Runtime.InteropServices; - -namespace Internal.JitInterface -{ - internal unsafe partial class CorInfoImpl - { - [UnmanagedCallersOnly] - private static byte _isIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) - { - var _this = GetThis(thisHandle); - try - { - return _this.isIntrinsic(ftn) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodAttribs(ftn); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _setMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CorInfoMethodRuntimeFlags attribs) - { - var _this = GetThis(thisHandle); - try - { - _this.setMethodAttribs(ftn, attribs); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getMethodSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_SIG_INFO* sig, CORINFO_CLASS_STRUCT_* memberParent) - { - var _this = GetThis(thisHandle); - try - { - _this.getMethodSig(ftn, sig, memberParent); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _getMethodInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_METHOD_INFO* info) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodInfo(ftn, info) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoInline _canInline(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd) - { - var _this = GetThis(thisHandle); - try - { - return _this.canInline(callerHnd, calleeHnd); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _beginInlining(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd) - { - var _this = GetThis(thisHandle); - try - { - _this.beginInlining(inlinerHnd, inlineeHnd); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _reportInliningDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd, CorInfoInline inlineResult, byte* reason) - { - var _this = GetThis(thisHandle); - try - { - _this.reportInliningDecision(inlinerHnd, inlineeHnd, inlineResult, reason); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _canTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* declaredCalleeHnd, CORINFO_METHOD_STRUCT_* exactCalleeHnd, byte fIsTailPrefix) - { - var _this = GetThis(thisHandle); - try - { - return _this.canTailCall(callerHnd, declaredCalleeHnd, exactCalleeHnd, fIsTailPrefix != 0) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _reportTailCallDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd, byte fIsTailPrefix, CorInfoTailCall tailCallResult, byte* reason) - { - var _this = GetThis(thisHandle); - try - { - _this.reportTailCallDecision(callerHnd, calleeHnd, fIsTailPrefix != 0, tailCallResult, reason); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint EHnumber, CORINFO_EH_CLAUSE* clause) - { - var _this = GetThis(thisHandle); - try - { - _this.getEHinfo(ftn, EHnumber, ref *clause); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getMethodClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodClass(method); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_MODULE_STRUCT_* _getMethodModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodModule(method); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, uint* offsetOfIndirection, uint* offsetAfterIndirection, bool* isRelative) - { - var _this = GetThis(thisHandle); - try - { - _this.getMethodVTableOffset(method, ref *offsetOfIndirection, ref *offsetAfterIndirection, ref *isRelative); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_DEVIRTUALIZATION_INFO* info) - { - var _this = GetThis(thisHandle); - try - { - return _this.resolveVirtualMethod(info) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_METHOD_STRUCT_* _getUnboxedEntry(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, bool* requiresInstMethodTableArg) - { - var _this = GetThis(thisHandle); - try - { - return _this.getUnboxedEntry(ftn, ref *requiresInstMethodTableArg); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getDefaultComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) - { - var _this = GetThis(thisHandle); - try - { - return _this.getDefaultComparerClass(elemType); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getDefaultEqualityComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) - { - var _this = GetThis(thisHandle); - try - { - return _this.getDefaultEqualityComparerClass(elemType); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _expandRawHandleIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) - { - var _this = GetThis(thisHandle); - try - { - _this.expandRawHandleIntrinsic(ref *pResolvedToken, ref *pResult); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _isIntrinsicType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd) - { - var _this = GetThis(thisHandle); - try - { - return _this.isIntrinsicType(classHnd) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoCallConvExtension _getUnmanagedCallConv(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig, bool* pSuppressGCTransition) - { - var _this = GetThis(thisHandle); - try - { - return _this.getUnmanagedCallConv(method, callSiteSig, ref *pSuppressGCTransition); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _pInvokeMarshalingRequired(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig) - { - var _this = GetThis(thisHandle); - try - { - return _this.pInvokeMarshalingRequired(method, callSiteSig) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _satisfiesMethodConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* parent, CORINFO_METHOD_STRUCT_* method) - { - var _this = GetThis(thisHandle); - try - { - return _this.satisfiesMethodConstraints(parent, method) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isCompatibleDelegate(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* objCls, CORINFO_CLASS_STRUCT_* methodParentCls, CORINFO_METHOD_STRUCT_* method, CORINFO_CLASS_STRUCT_* delegateCls, bool* pfIsOpenDelegate) - { - var _this = GetThis(thisHandle); - try - { - return _this.isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, ref *pfIsOpenDelegate) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _methodMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) - { - var _this = GetThis(thisHandle); - try - { - _this.methodMustBeLoadedBeforeCodeIsRun(method); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static CORINFO_METHOD_STRUCT_* _mapMethodDeclToMethodImpl(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) - { - var _this = GetThis(thisHandle); - try - { - return _this.mapMethodDeclToMethodImpl(method); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getGSCookie(IntPtr thisHandle, IntPtr* ppException, IntPtr* pCookieVal, IntPtr** ppCookieVal) - { - var _this = GetThis(thisHandle); - try - { - _this.getGSCookie(pCookieVal, ppCookieVal); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _setPatchpointInfo(IntPtr thisHandle, IntPtr* ppException, PatchpointInfo* patchpointInfo) - { - var _this = GetThis(thisHandle); - try - { - _this.setPatchpointInfo(patchpointInfo); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static PatchpointInfo* _getOSRInfo(IntPtr thisHandle, IntPtr* ppException, uint* ilOffset) - { - var _this = GetThis(thisHandle); - try - { - return _this.getOSRInfo(ref *ilOffset); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) - { - var _this = GetThis(thisHandle); - try - { - _this.resolveToken(ref *pResolvedToken); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _tryResolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) - { - var _this = GetThis(thisHandle); - try - { - return _this.tryResolveToken(ref *pResolvedToken) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _findSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint sigTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) - { - var _this = GetThis(thisHandle); - try - { - _this.findSig(module, sigTOK, context, sig); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _findCallSiteSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint methTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) - { - var _this = GetThis(thisHandle); - try - { - _this.findCallSiteSig(module, methTOK, context, sig); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getTokenTypeAsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) - { - var _this = GetThis(thisHandle); - try - { - return _this.getTokenTypeAsHandle(ref *pResolvedToken); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isValidToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) - { - var _this = GetThis(thisHandle); - try - { - return _this.isValidToken(module, metaTOK) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isValidStringRef(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) - { - var _this = GetThis(thisHandle); - try - { - return _this.isValidStringRef(module, metaTOK) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static int _getStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK, char* buffer, int bufferSize, int startIndex) - { - var _this = GetThis(thisHandle); - try - { - return _this.getStringLiteral(module, metaTOK, buffer, bufferSize, startIndex); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static UIntPtr _printObjectDescription(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* handle, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) - { - var _this = GetThis(thisHandle); - try - { - return _this.printObjectDescription(handle, buffer, bufferSize, pRequiredBufferSize); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.asCorInfoType(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte* _getClassNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte** namespaceName) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassNameFromMetadata(cls, namespaceName); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getTypeInstantiationArgument(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, uint index) - { - var _this = GetThis(thisHandle); - try - { - return _this.getTypeInstantiationArgument(cls, index); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static UIntPtr _printClassName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) - { - var _this = GetThis(thisHandle); - try - { - return _this.printClassName(cls, buffer, bufferSize, pRequiredBufferSize); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.isValueClass(cls) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoInlineTypeCheck _canInlineTypeCheck(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CorInfoInlineTypeCheckSource source) - { - var _this = GetThis(thisHandle); - try - { - return _this.canInlineTypeCheck(cls, source); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassAttribs(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_MODULE_STRUCT_* _getClassModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassModule(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_ASSEMBLY_STRUCT_* _getModuleAssembly(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* mod) - { - var _this = GetThis(thisHandle); - try - { - return _this.getModuleAssembly(mod); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte* _getAssemblyName(IntPtr thisHandle, IntPtr* ppException, CORINFO_ASSEMBLY_STRUCT_* assem) - { - var _this = GetThis(thisHandle); - try - { - return _this.getAssemblyName(assem); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void* _LongLifetimeMalloc(IntPtr thisHandle, IntPtr* ppException, UIntPtr sz) - { - var _this = GetThis(thisHandle); - try - { - return _this.LongLifetimeMalloc(sz); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _LongLifetimeFree(IntPtr thisHandle, IntPtr* ppException, void* obj) - { - var _this = GetThis(thisHandle); - try - { - _this.LongLifetimeFree(obj); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static UIntPtr _getClassModuleIdForStatics(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CORINFO_MODULE_STRUCT_** pModule, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassModuleIdForStatics(cls, pModule, ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassSize(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getHeapClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getHeapClassSize(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _canAllocateOnStack(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.canAllocateOnStack(cls) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getClassAlignmentRequirement(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte fDoubleAlignHint) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassAlignmentRequirement(cls, fDoubleAlignHint != 0); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getClassGClayout(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* gcPtrs) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassGClayout(cls, gcPtrs); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getClassNumInstanceFields(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassNumInstanceFields(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_FIELD_STRUCT_* _getFieldInClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, int num) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldInClass(clsHnd, num); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _checkMethodModifier(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod, byte* modifier, byte fOptional) - { - var _this = GetThis(thisHandle); - try - { - return _this.checkMethodModifier(hMethod, modifier, fOptional != 0) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getNewHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, bool* pHasSideEffects) - { - var _this = GetThis(thisHandle); - try - { - return _this.getNewHelper(ref *pResolvedToken, callerHandle, ref *pHasSideEffects); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getNewArrHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* arrayCls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getNewArrHelper(arrayCls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getCastingHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fThrowing) - { - var _this = GetThis(thisHandle); - try - { - return _this.getCastingHelper(ref *pResolvedToken, fThrowing != 0); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getSharedCCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd) - { - var _this = GetThis(thisHandle); - try - { - return _this.getSharedCCtorHelper(clsHnd); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getTypeForBox(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getTypeForBox(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getBoxHelper(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getUnBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getUnBoxHelper(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_OBJECT_STRUCT_* _getRuntimeTypePointer(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getRuntimeTypePointer(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isObjectImmutable(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* objPtr) - { - var _this = GetThis(thisHandle); - try - { - return _this.isObjectImmutable(objPtr) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getObjectType(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* objPtr) - { - var _this = GetThis(thisHandle); - try - { - return _this.getObjectType(objPtr); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup) - { - var _this = GetThis(thisHandle); - try - { - return _this.getReadyToRunHelper(ref *pResolvedToken, ref *pGenericLookupKind, id, ref *pLookup) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pTargetMethod, mdToken targetConstraint, CORINFO_CLASS_STRUCT_* delegateType, CORINFO_LOOKUP* pLookup) - { - var _this = GetThis(thisHandle); - try - { - _this.getReadyToRunDelegateCtorHelper(ref *pTargetMethod, targetConstraint, delegateType, ref *pLookup); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte* _getHelperName(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc helpFunc) - { - var _this = GetThis(thisHandle); - try - { - return _this.getHelperName(helpFunc); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoInitClassResult _initClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_METHOD_STRUCT_* method, CORINFO_CONTEXT_STRUCT* context) - { - var _this = GetThis(thisHandle); - try - { - return _this.initClass(field, method, context); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _classMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - _this.classMustBeLoadedBeforeCodeIsRun(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getBuiltinClass(IntPtr thisHandle, IntPtr* ppException, CorInfoClassId classId) - { - var _this = GetThis(thisHandle); - try - { - return _this.getBuiltinClass(classId); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoType _getTypeForPrimitiveValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getTypeForPrimitiveValueClass(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoType _getTypeForPrimitiveNumericClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getTypeForPrimitiveNumericClass(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _canCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* child, CORINFO_CLASS_STRUCT_* parent) - { - var _this = GetThis(thisHandle); - try - { - return _this.canCast(child, parent) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _areTypesEquivalent(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) - { - var _this = GetThis(thisHandle); - try - { - return _this.areTypesEquivalent(cls1, cls2) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static TypeCompareState _compareTypesForCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* fromClass, CORINFO_CLASS_STRUCT_* toClass) - { - var _this = GetThis(thisHandle); - try - { - return _this.compareTypesForCast(fromClass, toClass); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static TypeCompareState _compareTypesForEquality(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) - { - var _this = GetThis(thisHandle); - try - { - return _this.compareTypesForEquality(cls1, cls2); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _mergeClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) - { - var _this = GetThis(thisHandle); - try - { - return _this.mergeClasses(cls1, cls2); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isMoreSpecificType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) - { - var _this = GetThis(thisHandle); - try - { - return _this.isMoreSpecificType(cls1, cls2) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static TypeCompareState _isEnum(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CORINFO_CLASS_STRUCT_** underlyingType) - { - var _this = GetThis(thisHandle); - try - { - return _this.isEnum(cls, underlyingType); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getParentType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getParentType(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoType _getChildType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_CLASS_STRUCT_** clsRet) - { - var _this = GetThis(thisHandle); - try - { - return _this.getChildType(clsHnd, clsRet); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _satisfiesClassConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.satisfiesClassConstraints(cls) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isSDArray(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.isSDArray(cls) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getArrayRank(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArrayRank(cls); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoArrayIntrinsic _getArrayIntrinsicID(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArrayIntrinsicID(ftn); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void* _getArrayInitializationData(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, uint size) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArrayInitializationData(field, size); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_HELPER_DESC* pAccessHelper) - { - var _this = GetThis(thisHandle); - try - { - return _this.canAccessClass(ref *pResolvedToken, callerHandle, ref *pAccessHelper); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static UIntPtr _printFieldName(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) - { - var _this = GetThis(thisHandle); - try - { - return _this.printFieldName(field, buffer, bufferSize, pRequiredBufferSize); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getFieldClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldClass(field); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoType _getFieldType(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_CLASS_STRUCT_** structType, CORINFO_CLASS_STRUCT_* memberParent) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldType(field, structType, memberParent); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getFieldOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldOffset(field); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getFieldInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult) - { - var _this = GetThis(thisHandle); - try - { - _this.getFieldInfo(ref *pResolvedToken, callerHandle, flags, pResult); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _isFieldStatic(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* fldHnd) - { - var _this = GetThis(thisHandle); - try - { - return _this.isFieldStatic(fldHnd) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static int _getArrayOrStringLength(IntPtr thisHandle, IntPtr* ppException, CORINFO_OBJECT_STRUCT_* objHnd) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArrayOrStringLength(objHnd); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cILOffsets, uint** pILOffsets, BoundaryTypes* implicitBoundaries) - { - var _this = GetThis(thisHandle); - try - { - _this.getBoundaries(ftn, ref *cILOffsets, ref *pILOffsets, implicitBoundaries); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _setBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping* pMap) - { - var _this = GetThis(thisHandle); - try - { - _this.setBoundaries(ftn, cMap, pMap); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cVars, ILVarInfo** vars, bool* extendOthers) - { - var _this = GetThis(thisHandle); - try - { - _this.getVars(ftn, ref *cVars, vars, ref *extendOthers); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _setVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cVars, NativeVarInfo* vars) - { - var _this = GetThis(thisHandle); - try - { - _this.setVars(ftn, cVars, vars); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _reportRichMappings(IntPtr thisHandle, IntPtr* ppException, InlineTreeNode* inlineTreeNodes, uint numInlineTreeNodes, RichOffsetMapping* mappings, uint numMappings) - { - var _this = GetThis(thisHandle); - try - { - _this.reportRichMappings(inlineTreeNodes, numInlineTreeNodes, mappings, numMappings); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void* _allocateArray(IntPtr thisHandle, IntPtr* ppException, UIntPtr cBytes) - { - var _this = GetThis(thisHandle); - try - { - return _this.allocateArray(cBytes); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _freeArray(IntPtr thisHandle, IntPtr* ppException, void* array) - { - var _this = GetThis(thisHandle); - try - { - _this.freeArray(array); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static CORINFO_ARG_LIST_STRUCT_* _getArgNext(IntPtr thisHandle, IntPtr* ppException, CORINFO_ARG_LIST_STRUCT_* args) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArgNext(args); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoTypeWithMod _getArgType(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args, CORINFO_CLASS_STRUCT_** vcTypeRet) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArgType(sig, args, vcTypeRet); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static int _getExactClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* baseType, int maxExactClasses, CORINFO_CLASS_STRUCT_** exactClsRet) - { - var _this = GetThis(thisHandle); - try - { - return _this.getExactClasses(baseType, maxExactClasses, exactClsRet); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getArgClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args) - { - var _this = GetThis(thisHandle); - try - { - return _this.getArgClass(sig, args); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHFAElemType _getHFAType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* hClass) - { - var _this = GetThis(thisHandle); - try - { - return _this.getHFAType(hClass); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static HRESULT _GetErrorHRESULT(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) - { - var _this = GetThis(thisHandle); - try - { - return _this.GetErrorHRESULT(pExceptionPointers); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _GetErrorMessage(IntPtr thisHandle, IntPtr* ppException, char* buffer, uint bufferLength) - { - var _this = GetThis(thisHandle); - try - { - return _this.GetErrorMessage(buffer, bufferLength); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static int _FilterException(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) - { - var _this = GetThis(thisHandle); - try - { - return _this.FilterException(pExceptionPointers); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _ThrowExceptionForJitResult(IntPtr thisHandle, IntPtr* ppException, HRESULT result) - { - var _this = GetThis(thisHandle); - try - { - _this.ThrowExceptionForJitResult(result); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _ThrowExceptionForHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_HELPER_DESC* throwHelper) - { - var _this = GetThis(thisHandle); - try - { - _this.ThrowExceptionForHelper(ref *throwHelper); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _runWithErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) - { - var _this = GetThis(thisHandle); - try - { - return _this.runWithErrorTrap(function, parameter) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _runWithSPMIErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) - { - var _this = GetThis(thisHandle); - try - { - return _this.runWithSPMIErrorTrap(function, parameter) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getEEInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_EE_INFO* pEEInfoOut) - { - var _this = GetThis(thisHandle); - try - { - _this.getEEInfo(ref *pEEInfoOut); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static char* _getJitTimeLogFilename(IntPtr thisHandle, IntPtr* ppException) - { - var _this = GetThis(thisHandle); - try - { - return _this.getJitTimeLogFilename(); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodDefFromMethod(hMethod); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static UIntPtr _printMethodName(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte* buffer, UIntPtr bufferSize, UIntPtr* pRequiredBufferSize) - { - var _this = GetThis(thisHandle); - try - { - return _this.printMethodName(ftn, buffer, bufferSize, pRequiredBufferSize); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte* _getMethodNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** className, byte** namespaceName, byte** enclosingClassName) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodNameFromMetadata(ftn, className, namespaceName, enclosingClassName); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getMethodHash(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodHash(ftn); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static UIntPtr _findNameOfToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleHandle, mdToken token, byte* szFQName, UIntPtr FQNameCapacity) - { - var _this = GetThis(thisHandle); - try - { - return _this.findNameOfToken(moduleHandle, token, szFQName, FQNameCapacity); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _getSystemVAmd64PassStructInRegisterDescriptor(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd, SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr) - { - var _this = GetThis(thisHandle); - try - { - return _this.getSystemVAmd64PassStructInRegisterDescriptor(structHnd, structPassInRegDescPtr) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getLoongArch64PassStructInRegisterFlags(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd) - { - var _this = GetThis(thisHandle); - try - { - return _this.getLoongArch64PassStructInRegisterFlags(structHnd); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getThreadTLSIndex(ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void* _getInlinedCallFrameVptr(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getInlinedCallFrameVptr(ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static int* _getAddrOfCaptureThreadGlobal(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getAddrOfCaptureThreadGlobal(ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void* _getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getHelperFtn(ftnNum, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _getFunctionEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_CONST_LOOKUP* pResult, CORINFO_ACCESS_FLAGS accessFlags) - { - var _this = GetThis(thisHandle); - try - { - _this.getFunctionEntryPoint(ftn, ref *pResult, accessFlags); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP* pResult) - { - var _this = GetThis(thisHandle); - try - { - _this.getFunctionFixedEntryPoint(ftn, isUnsafeFunctionPointer != 0, ref *pResult); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void* _getMethodSync(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodSync(ftn, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle) - { - var _this = GetThis(thisHandle); - try - { - return _this.getLazyStringLiteralHelper(handle); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_MODULE_STRUCT_* _embedModuleHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.embedModuleHandle(handle, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _embedClassHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* handle, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.embedClassHandle(handle, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_METHOD_STRUCT_* _embedMethodHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* handle, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.embedMethodHandle(handle, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_FIELD_STRUCT_* _embedFieldHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* handle, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.embedFieldHandle(handle, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _embedGenericHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fEmbedParent, CORINFO_GENERICHANDLE_RESULT* pResult) - { - var _this = GetThis(thisHandle); - try - { - _this.embedGenericHandle(ref *pResolvedToken, fEmbedParent != 0, ref *pResult); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getLocationOfThisType(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* context, CORINFO_LOOKUP_KIND* pLookupKind) - { - var _this = GetThis(thisHandle); - try - { - _this.getLocationOfThisType(context, ref *pLookupKind); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getAddressOfPInvokeTarget(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_CONST_LOOKUP* pLookup) - { - var _this = GetThis(thisHandle); - try - { - _this.getAddressOfPInvokeTarget(method, ref *pLookup); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void* _GetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.GetCookieForPInvokeCalliSig(szMetaSig, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _canGetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig) - { - var _this = GetThis(thisHandle); - try - { - return _this.canGetCookieForPInvokeCalliSig(szMetaSig) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_JUST_MY_CODE_HANDLE_* _getJustMyCodeHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_JUST_MY_CODE_HANDLE_** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getJustMyCodeHandle(method, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _GetProfilingHandle(IntPtr thisHandle, IntPtr* ppException, bool* pbHookFunction, void** pProfilerHandle, bool* pbIndirectedHandles) - { - var _this = GetThis(thisHandle); - try - { - _this.GetProfilingHandle(ref *pbHookFunction, ref *pProfilerHandle, ref *pbIndirectedHandles); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _getCallInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, CORINFO_CALL_INFO* pResult) - { - var _this = GetThis(thisHandle); - try - { - _this.getCallInfo(ref *pResolvedToken, pConstrainedResolvedToken, callerHandle, flags, pResult); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _canAccessFamily(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hCaller, CORINFO_CLASS_STRUCT_* hInstanceType) - { - var _this = GetThis(thisHandle); - try - { - return _this.canAccessFamily(hCaller, hInstanceType) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _isRIDClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.isRIDClassDomainID(cls) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getClassDomainID(cls, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void* _getFieldAddress(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldAddress(field, ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _getReadonlyStaticFieldValue(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* buffer, int bufferSize, byte ignoreMovableObjects) - { - var _this = GetThis(thisHandle); - try - { - return _this.getReadonlyStaticFieldValue(field, buffer, bufferSize, ignoreMovableObjects != 0) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static CORINFO_CLASS_STRUCT_* _getStaticFieldCurrentClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* pIsSpeculative) - { - var _this = GetThis(thisHandle); - try - { - return _this.getStaticFieldCurrentClass(field, pIsSpeculative); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static IntPtr _getVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getVarArgsHandle(pSig, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _canGetVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig) - { - var _this = GetThis(thisHandle); - try - { - return _this.canGetVarArgsHandle(pSig) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static InfoAccessType _constructStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, mdToken metaTok, void** ppValue) - { - var _this = GetThis(thisHandle); - try - { - return _this.constructStringLiteral(module, metaTok, ref *ppValue); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static InfoAccessType _emptyStringLiteral(IntPtr thisHandle, IntPtr* ppException, void** ppValue) - { - var _this = GetThis(thisHandle); - try - { - return _this.emptyStringLiteral(ref *ppValue); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getFieldThreadLocalStoreID(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldThreadLocalStoreID(field, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _addActiveDependency(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleFrom, CORINFO_MODULE_STRUCT_* moduleTo) - { - var _this = GetThis(thisHandle); - try - { - _this.addActiveDependency(moduleFrom, moduleTo); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static CORINFO_METHOD_STRUCT_* _GetDelegateCtor(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_METHOD_STRUCT_* targetMethodHnd, DelegateCtorArgs* pCtorData) - { - var _this = GetThis(thisHandle); - try - { - return _this.GetDelegateCtor(methHnd, clsHnd, targetMethodHnd, ref *pCtorData); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _MethodCompileComplete(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd) - { - var _this = GetThis(thisHandle); - try - { - _this.MethodCompileComplete(methHnd); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _getTailCallHelpers(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, CORINFO_TAILCALL_HELPERS* pResult) - { - var _this = GetThis(thisHandle); - try - { - return _this.getTailCallHelpers(ref *callToken, sig, flags, ref *pResult) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _convertPInvokeCalliToCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte mustConvert) - { - var _this = GetThis(thisHandle); - try - { - return _this.convertPInvokeCalliToCall(ref *pResolvedToken, mustConvert != 0) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static byte _notifyInstructionSetUsage(IntPtr thisHandle, IntPtr* ppException, InstructionSet instructionSet, byte supportEnabled) - { - var _this = GetThis(thisHandle); - try - { - return _this.notifyInstructionSetUsage(instructionSet, supportEnabled != 0) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _updateEntryPointForTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_CONST_LOOKUP* entryPoint) - { - var _this = GetThis(thisHandle); - try - { - _this.updateEntryPointForTailCall(ref *entryPoint); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _allocMem(IntPtr thisHandle, IntPtr* ppException, AllocMemArgs* pArgs) - { - var _this = GetThis(thisHandle); - try - { - _this.allocMem(ref *pArgs); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _reserveUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte isFunclet, byte isColdCode, uint unwindSize) - { - var _this = GetThis(thisHandle); - try - { - _this.reserveUnwindInfo(isFunclet != 0, isColdCode != 0, unwindSize); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _allocUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte* pHotCode, byte* pColdCode, uint startOffset, uint endOffset, uint unwindSize, byte* pUnwindBlock, CorJitFuncKind funcKind) - { - var _this = GetThis(thisHandle); - try - { - _this.allocUnwindInfo(pHotCode, pColdCode, startOffset, endOffset, unwindSize, pUnwindBlock, funcKind); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void* _allocGCInfo(IntPtr thisHandle, IntPtr* ppException, UIntPtr size) - { - var _this = GetThis(thisHandle); - try - { - return _this.allocGCInfo(size); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _setEHcount(IntPtr thisHandle, IntPtr* ppException, uint cEH) - { - var _this = GetThis(thisHandle); - try - { - _this.setEHcount(cEH); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _setEHinfo(IntPtr thisHandle, IntPtr* ppException, uint EHnumber, CORINFO_EH_CLAUSE* clause) - { - var _this = GetThis(thisHandle); - try - { - _this.setEHinfo(EHnumber, ref *clause); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static byte _logMsg(IntPtr thisHandle, IntPtr* ppException, uint level, byte* fmt, IntPtr args) - { - var _this = GetThis(thisHandle); - try - { - return _this.logMsg(level, fmt, args) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static int _doAssert(IntPtr thisHandle, IntPtr* ppException, byte* szFile, int iLine, byte* szExpr) - { - var _this = GetThis(thisHandle); - try - { - return _this.doAssert(szFile, iLine, szExpr); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _reportFatalError(IntPtr thisHandle, IntPtr* ppException, CorJitResult result) - { - var _this = GetThis(thisHandle); - try - { - _this.reportFatalError(result); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static HRESULT _getPgoInstrumentationResults(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema** pSchema, uint* pCountSchemaItems, byte** pInstrumentationData, PgoSource* pgoSource) - { - var _this = GetThis(thisHandle); - try - { - return _this.getPgoInstrumentationResults(ftnHnd, ref *pSchema, ref *pCountSchemaItems, pInstrumentationData, ref *pgoSource); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static HRESULT _allocPgoInstrumentationBySchema(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema* pSchema, uint countSchemaItems, byte** pInstrumentationData) - { - var _this = GetThis(thisHandle); - try - { - return _this.allocPgoInstrumentationBySchema(ftnHnd, pSchema, countSchemaItems, pInstrumentationData); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_STRUCT_* methodHandle) - { - var _this = GetThis(thisHandle); - try - { - _this.recordCallSite(instrOffset, callSig, methodHandle); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta) - { - var _this = GetThis(thisHandle); - try - { - _this.recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - } - } - - [UnmanagedCallersOnly] - private static ushort _getRelocTypeHint(IntPtr thisHandle, IntPtr* ppException, void* target) - { - var _this = GetThis(thisHandle); - try - { - return _this.getRelocTypeHint(target); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getExpectedTargetArchitecture(IntPtr thisHandle, IntPtr* ppException) - { - var _this = GetThis(thisHandle); - try - { - return _this.getExpectedTargetArchitecture(); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - [UnmanagedCallersOnly] - private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_FLAGS* flags, uint sizeInBytes) - { - var _this = GetThis(thisHandle); - try - { - return _this.getJitFlags(ref *flags, sizeInBytes); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - - - private static IntPtr GetUnmanagedCallbacks() - { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 181); - - callbacks[0] = (delegate* unmanaged)&_isIntrinsic; - callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; - callbacks[2] = (delegate* unmanaged)&_setMethodAttribs; - callbacks[3] = (delegate* unmanaged)&_getMethodSig; - callbacks[4] = (delegate* unmanaged)&_getMethodInfo; - callbacks[5] = (delegate* unmanaged)&_canInline; - callbacks[6] = (delegate* unmanaged)&_beginInlining; - callbacks[7] = (delegate* unmanaged)&_reportInliningDecision; - callbacks[8] = (delegate* unmanaged)&_canTailCall; - callbacks[9] = (delegate* unmanaged)&_reportTailCallDecision; - callbacks[10] = (delegate* unmanaged)&_getEHinfo; - callbacks[11] = (delegate* unmanaged)&_getMethodClass; - callbacks[12] = (delegate* unmanaged)&_getMethodModule; - callbacks[13] = (delegate* unmanaged)&_getMethodVTableOffset; - callbacks[14] = (delegate* unmanaged)&_resolveVirtualMethod; - callbacks[15] = (delegate* unmanaged)&_getUnboxedEntry; - callbacks[16] = (delegate* unmanaged)&_getDefaultComparerClass; - callbacks[17] = (delegate* unmanaged)&_getDefaultEqualityComparerClass; - callbacks[18] = (delegate* unmanaged)&_expandRawHandleIntrinsic; - callbacks[19] = (delegate* unmanaged)&_isIntrinsicType; - callbacks[20] = (delegate* unmanaged)&_getUnmanagedCallConv; - callbacks[21] = (delegate* unmanaged)&_pInvokeMarshalingRequired; - callbacks[22] = (delegate* unmanaged)&_satisfiesMethodConstraints; - callbacks[23] = (delegate* unmanaged)&_isCompatibleDelegate; - callbacks[24] = (delegate* unmanaged)&_methodMustBeLoadedBeforeCodeIsRun; - callbacks[25] = (delegate* unmanaged)&_mapMethodDeclToMethodImpl; - callbacks[26] = (delegate* unmanaged)&_getGSCookie; - callbacks[27] = (delegate* unmanaged)&_setPatchpointInfo; - callbacks[28] = (delegate* unmanaged)&_getOSRInfo; - callbacks[29] = (delegate* unmanaged)&_resolveToken; - callbacks[30] = (delegate* unmanaged)&_tryResolveToken; - callbacks[31] = (delegate* unmanaged)&_findSig; - callbacks[32] = (delegate* unmanaged)&_findCallSiteSig; - callbacks[33] = (delegate* unmanaged)&_getTokenTypeAsHandle; - callbacks[34] = (delegate* unmanaged)&_isValidToken; - callbacks[35] = (delegate* unmanaged)&_isValidStringRef; - callbacks[36] = (delegate* unmanaged)&_getStringLiteral; - callbacks[37] = (delegate* unmanaged)&_printObjectDescription; - callbacks[38] = (delegate* unmanaged)&_asCorInfoType; - callbacks[39] = (delegate* unmanaged)&_getClassNameFromMetadata; - callbacks[40] = (delegate* unmanaged)&_getTypeInstantiationArgument; - callbacks[41] = (delegate* unmanaged)&_printClassName; - callbacks[42] = (delegate* unmanaged)&_isValueClass; - callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; - callbacks[44] = (delegate* unmanaged)&_getClassAttribs; - callbacks[45] = (delegate* unmanaged)&_getClassModule; - callbacks[46] = (delegate* unmanaged)&_getModuleAssembly; - callbacks[47] = (delegate* unmanaged)&_getAssemblyName; - callbacks[48] = (delegate* unmanaged)&_LongLifetimeMalloc; - callbacks[49] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[50] = (delegate* unmanaged)&_getClassModuleIdForStatics; - callbacks[51] = (delegate* unmanaged)&_getClassSize; - callbacks[52] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[53] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[54] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[55] = (delegate* unmanaged)&_getClassGClayout; - callbacks[56] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[57] = (delegate* unmanaged)&_getFieldInClass; - callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[59] = (delegate* unmanaged)&_getNewHelper; - callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[61] = (delegate* unmanaged)&_getCastingHelper; - callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[63] = (delegate* unmanaged)&_getTypeForBox; - callbacks[64] = (delegate* unmanaged)&_getBoxHelper; - callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; -<<<<<<< HEAD:src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs - callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[67] = (delegate* unmanaged)&_isObjectImmutable; - callbacks[68] = (delegate* unmanaged)&_getObjectType; - callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[71] = (delegate* unmanaged)&_getHelperName; - callbacks[72] = (delegate* unmanaged)&_initClass; - callbacks[73] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[74] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[77] = (delegate* unmanaged)&_canCast; - callbacks[78] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[79] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[80] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[81] = (delegate* unmanaged)&_mergeClasses; - callbacks[82] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[83] = (delegate* unmanaged)&_isEnum; - callbacks[84] = (delegate* unmanaged)&_getParentType; - callbacks[85] = (delegate* unmanaged)&_getChildType; - callbacks[86] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[87] = (delegate* unmanaged)&_isSDArray; - callbacks[88] = (delegate* unmanaged)&_getArrayRank; - callbacks[89] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[90] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[91] = (delegate* unmanaged)&_canAccessClass; - callbacks[92] = (delegate* unmanaged)&_getFieldName; - callbacks[93] = (delegate* unmanaged)&_getFieldClass; - callbacks[94] = (delegate* unmanaged)&_getFieldType; - callbacks[95] = (delegate* unmanaged)&_getFieldOffset; - callbacks[96] = (delegate* unmanaged)&_getFieldInfo; - callbacks[97] = (delegate* unmanaged)&_isFieldStatic; - callbacks[98] = (delegate* unmanaged)&_getArrayOrStringLength; - callbacks[99] = (delegate* unmanaged)&_getBoundaries; - callbacks[100] = (delegate* unmanaged)&_setBoundaries; - callbacks[101] = (delegate* unmanaged)&_getVars; - callbacks[102] = (delegate* unmanaged)&_setVars; - callbacks[103] = (delegate* unmanaged)&_reportRichMappings; - callbacks[104] = (delegate* unmanaged)&_allocateArray; - callbacks[105] = (delegate* unmanaged)&_freeArray; - callbacks[106] = (delegate* unmanaged)&_getArgNext; - callbacks[107] = (delegate* unmanaged)&_getArgType; - callbacks[108] = (delegate* unmanaged)&_getExactClasses; - callbacks[109] = (delegate* unmanaged)&_getArgClass; - callbacks[110] = (delegate* unmanaged)&_getHFAType; - callbacks[111] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[112] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[113] = (delegate* unmanaged)&_FilterException; - callbacks[114] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[115] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[116] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[117] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[118] = (delegate* unmanaged)&_getEEInfo; - callbacks[119] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[120] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[121] = (delegate* unmanaged)&_getMethodName; - callbacks[122] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[123] = (delegate* unmanaged)&_getMethodHash; - callbacks[124] = (delegate* unmanaged)&_findNameOfToken; - callbacks[125] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[126] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[128] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[129] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[130] = (delegate* unmanaged)&_getHelperFtn; - callbacks[131] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[132] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[133] = (delegate* unmanaged)&_getMethodSync; - callbacks[134] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[135] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[136] = (delegate* unmanaged)&_embedClassHandle; - callbacks[137] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[138] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[139] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[140] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[141] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[142] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[143] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[144] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[145] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[146] = (delegate* unmanaged)&_getCallInfo; - callbacks[147] = (delegate* unmanaged)&_canAccessFamily; - callbacks[148] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[149] = (delegate* unmanaged)&_getClassDomainID; - callbacks[150] = (delegate* unmanaged)&_getFieldAddress; - callbacks[151] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; - callbacks[152] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[153] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[154] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[155] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[156] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[157] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[158] = (delegate* unmanaged)&_addActiveDependency; - callbacks[159] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[160] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[161] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[162] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[163] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[164] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[165] = (delegate* unmanaged)&_allocMem; - callbacks[166] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[167] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[168] = (delegate* unmanaged)&_allocGCInfo; - callbacks[169] = (delegate* unmanaged)&_setEHcount; - callbacks[170] = (delegate* unmanaged)&_setEHinfo; - callbacks[171] = (delegate* unmanaged)&_logMsg; - callbacks[172] = (delegate* unmanaged)&_doAssert; - callbacks[173] = (delegate* unmanaged)&_reportFatalError; - callbacks[174] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[175] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[176] = (delegate* unmanaged)&_recordCallSite; - callbacks[177] = (delegate* unmanaged)&_recordRelocation; - callbacks[178] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[179] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[180] = (delegate* unmanaged)&_getJitFlags; -||||||| parent of 35ee62dcc42 (Work on switching getMethodName and getFieldName to print):src/coreclr/tools/Common/JitInterface/CorInfoBase.cs - callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[67] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[68] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[69] = (delegate* unmanaged)&_getHelperName; - callbacks[70] = (delegate* unmanaged)&_initClass; - callbacks[71] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[72] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[75] = (delegate* unmanaged)&_canCast; - callbacks[76] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[79] = (delegate* unmanaged)&_mergeClasses; - callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[81] = (delegate* unmanaged)&_getParentType; - callbacks[82] = (delegate* unmanaged)&_getChildType; - callbacks[83] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[84] = (delegate* unmanaged)&_isSDArray; - callbacks[85] = (delegate* unmanaged)&_getArrayRank; - callbacks[86] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[87] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[88] = (delegate* unmanaged)&_canAccessClass; - callbacks[89] = (delegate* unmanaged)&_getFieldName; - callbacks[90] = (delegate* unmanaged)&_getFieldClass; - callbacks[91] = (delegate* unmanaged)&_getFieldType; - callbacks[92] = (delegate* unmanaged)&_getFieldOffset; - callbacks[93] = (delegate* unmanaged)&_getFieldInfo; - callbacks[94] = (delegate* unmanaged)&_isFieldStatic; - callbacks[95] = (delegate* unmanaged)&_getBoundaries; - callbacks[96] = (delegate* unmanaged)&_setBoundaries; - callbacks[97] = (delegate* unmanaged)&_getVars; - callbacks[98] = (delegate* unmanaged)&_setVars; - callbacks[99] = (delegate* unmanaged)&_reportRichMappings; - callbacks[100] = (delegate* unmanaged)&_allocateArray; - callbacks[101] = (delegate* unmanaged)&_freeArray; - callbacks[102] = (delegate* unmanaged)&_getArgNext; - callbacks[103] = (delegate* unmanaged)&_getArgType; - callbacks[104] = (delegate* unmanaged)&_getExactClasses; - callbacks[105] = (delegate* unmanaged)&_getArgClass; - callbacks[106] = (delegate* unmanaged)&_getHFAType; - callbacks[107] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[108] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[109] = (delegate* unmanaged)&_FilterException; - callbacks[110] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[111] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[112] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[113] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[114] = (delegate* unmanaged)&_getEEInfo; - callbacks[115] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[116] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[117] = (delegate* unmanaged)&_getMethodName; - callbacks[118] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[119] = (delegate* unmanaged)&_getMethodHash; - callbacks[120] = (delegate* unmanaged)&_findNameOfToken; - callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[122] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[123] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[124] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[125] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[126] = (delegate* unmanaged)&_getHelperFtn; - callbacks[127] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[128] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[129] = (delegate* unmanaged)&_getMethodSync; - callbacks[130] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[131] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[132] = (delegate* unmanaged)&_embedClassHandle; - callbacks[133] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[134] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[135] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[136] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[137] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[138] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[139] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[140] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[141] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[142] = (delegate* unmanaged)&_getCallInfo; - callbacks[143] = (delegate* unmanaged)&_canAccessFamily; - callbacks[144] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[145] = (delegate* unmanaged)&_getClassDomainID; - callbacks[146] = (delegate* unmanaged)&_getFieldAddress; - callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[148] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[149] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[150] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[151] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[152] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[153] = (delegate* unmanaged)&_addActiveDependency; - callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[160] = (delegate* unmanaged)&_allocMem; - callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[163] = (delegate* unmanaged)&_allocGCInfo; - callbacks[164] = (delegate* unmanaged)&_setEHcount; - callbacks[165] = (delegate* unmanaged)&_setEHinfo; - callbacks[166] = (delegate* unmanaged)&_logMsg; - callbacks[167] = (delegate* unmanaged)&_doAssert; - callbacks[168] = (delegate* unmanaged)&_reportFatalError; - callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[171] = (delegate* unmanaged)&_recordCallSite; - callbacks[172] = (delegate* unmanaged)&_recordRelocation; - callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[175] = (delegate* unmanaged)&_getJitFlags; -======= - callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[67] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[68] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[69] = (delegate* unmanaged)&_getHelperName; - callbacks[70] = (delegate* unmanaged)&_initClass; - callbacks[71] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[72] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[75] = (delegate* unmanaged)&_canCast; - callbacks[76] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[79] = (delegate* unmanaged)&_mergeClasses; - callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[81] = (delegate* unmanaged)&_getParentType; - callbacks[82] = (delegate* unmanaged)&_getChildType; - callbacks[83] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[84] = (delegate* unmanaged)&_isSDArray; - callbacks[85] = (delegate* unmanaged)&_getArrayRank; - callbacks[86] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[87] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[88] = (delegate* unmanaged)&_canAccessClass; - callbacks[89] = (delegate* unmanaged)&_printFieldName; - callbacks[90] = (delegate* unmanaged)&_getFieldClass; - callbacks[91] = (delegate* unmanaged)&_getFieldType; - callbacks[92] = (delegate* unmanaged)&_getFieldOffset; - callbacks[93] = (delegate* unmanaged)&_getFieldInfo; - callbacks[94] = (delegate* unmanaged)&_isFieldStatic; - callbacks[95] = (delegate* unmanaged)&_getBoundaries; - callbacks[96] = (delegate* unmanaged)&_setBoundaries; - callbacks[97] = (delegate* unmanaged)&_getVars; - callbacks[98] = (delegate* unmanaged)&_setVars; - callbacks[99] = (delegate* unmanaged)&_reportRichMappings; - callbacks[100] = (delegate* unmanaged)&_allocateArray; - callbacks[101] = (delegate* unmanaged)&_freeArray; - callbacks[102] = (delegate* unmanaged)&_getArgNext; - callbacks[103] = (delegate* unmanaged)&_getArgType; - callbacks[104] = (delegate* unmanaged)&_getExactClasses; - callbacks[105] = (delegate* unmanaged)&_getArgClass; - callbacks[106] = (delegate* unmanaged)&_getHFAType; - callbacks[107] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[108] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[109] = (delegate* unmanaged)&_FilterException; - callbacks[110] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[111] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[112] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[113] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[114] = (delegate* unmanaged)&_getEEInfo; - callbacks[115] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[116] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[117] = (delegate* unmanaged)&_printMethodName; - callbacks[118] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[119] = (delegate* unmanaged)&_getMethodHash; - callbacks[120] = (delegate* unmanaged)&_findNameOfToken; - callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[122] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[123] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[124] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[125] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[126] = (delegate* unmanaged)&_getHelperFtn; - callbacks[127] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[128] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[129] = (delegate* unmanaged)&_getMethodSync; - callbacks[130] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[131] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[132] = (delegate* unmanaged)&_embedClassHandle; - callbacks[133] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[134] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[135] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[136] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[137] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[138] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[139] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[140] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[141] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[142] = (delegate* unmanaged)&_getCallInfo; - callbacks[143] = (delegate* unmanaged)&_canAccessFamily; - callbacks[144] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[145] = (delegate* unmanaged)&_getClassDomainID; - callbacks[146] = (delegate* unmanaged)&_getFieldAddress; - callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[148] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[149] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[150] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[151] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[152] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[153] = (delegate* unmanaged)&_addActiveDependency; - callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[160] = (delegate* unmanaged)&_allocMem; - callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[163] = (delegate* unmanaged)&_allocGCInfo; - callbacks[164] = (delegate* unmanaged)&_setEHcount; - callbacks[165] = (delegate* unmanaged)&_setEHinfo; - callbacks[166] = (delegate* unmanaged)&_logMsg; - callbacks[167] = (delegate* unmanaged)&_doAssert; - callbacks[168] = (delegate* unmanaged)&_reportFatalError; - callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[171] = (delegate* unmanaged)&_recordCallSite; - callbacks[172] = (delegate* unmanaged)&_recordRelocation; - callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[175] = (delegate* unmanaged)&_getJitFlags; ->>>>>>> 35ee62dcc42 (Work on switching getMethodName and getFieldName to print):src/coreclr/tools/Common/JitInterface/CorInfoBase.cs - - return (IntPtr)callbacks; - } - } -} - From d0c4b9fe4d1750ee4e7676368f4d4c385eff8799 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 17:55:30 +0100 Subject: [PATCH 33/50] Update for consistency, builds again --- src/coreclr/jit/codegencommon.cpp | 8 +- src/coreclr/jit/compiler.h | 44 +++--- src/coreclr/jit/compiler.hpp | 27 ---- src/coreclr/jit/ee_il_dll.cpp | 230 ++-------------------------- src/coreclr/jit/eeinterface.cpp | 240 ++++++++++++++++++++++++++++-- src/coreclr/jit/emit.cpp | 15 +- src/coreclr/jit/emitxarch.cpp | 4 +- src/coreclr/jit/gentree.cpp | 78 +++++----- src/coreclr/jit/importercalls.cpp | 9 +- src/coreclr/jit/lclvars.cpp | 13 +- src/coreclr/jit/morph.cpp | 2 +- src/coreclr/jit/valuenum.cpp | 14 +- 12 files changed, 342 insertions(+), 342 deletions(-) diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index 0c65564e5effa..5e82a3992e35b 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -7548,8 +7548,12 @@ void CodeGen::genReportRichDebugInfoInlineTreeToFile(FILE* file, InlineContext* fprintf(file, "\"ILOffset\":%u,", context->GetLocation().GetOffset()); fprintf(file, "\"LocationFlags\":%u,", (uint32_t)context->GetLocation().EncodeSourceTypes()); fprintf(file, "\"ExactILOffset\":%u,", context->GetActualCallOffset()); - const char* methodName = compiler->eeGetMethodName(context->GetCallee()); - fprintf(file, "\"MethodName\":\"%s\",", methodName); + auto append = [&]() { + char buffer[256]; + const char* methodName = compiler->eeGetMethodName(context->GetCallee(), buffer, sizeof(buffer)); + fprintf(file, "\"MethodName\":\"%s\",", methodName); + }; + append(); fprintf(file, "\"Inlinees\":["); if (context->GetChild() != nullptr) { diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 2dc5983f4a561..ea267a44a3c48 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7588,6 +7588,10 @@ class Compiler var_types eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd, CORINFO_CLASS_HANDLE* pStructHnd = nullptr); + // Conventions: the "base" primitive printing functions take StringPrinter* + // and do not do any SPMI handling. There are then convenience printing + // functions exposed on top that have SPMI handling and additional buffer + // handling. Note that the strings returned are never truncated here. void eePrintJitType(class StringPrinter* printer, var_types jitType); void eePrintType(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation); void eePrintTypeOrJitAlias(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation); @@ -7601,16 +7605,32 @@ class Compiler bool includeReturnType, bool includeThisSpecifier); -#if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS) + void eePrintField(class StringPrinter* printer, CORINFO_FIELD_HANDLE fldHnd, bool includeType); + const char* eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType = true, - bool includeThisSpecifier = true); - unsigned compMethodHash(CORINFO_METHOD_HANDLE methodHandle); + bool includeThisSpecifier = true, + char* buffer = nullptr, + size_t bufferSize = 0); + + const char* eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer = nullptr, size_t bufferSize = 0); + + const char* eeGetFieldName(CORINFO_FIELD_HANDLE fldHnd, + bool includeType, + char* buffer = nullptr, + size_t bufferSize = 0); + + const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer = nullptr, size_t bufferSize = 0); - bool eeIsNativeMethod(CORINFO_METHOD_HANDLE method); - CORINFO_METHOD_HANDLE eeGetMethodHandleForNative(CORINFO_METHOD_HANDLE method); + void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle); + const char* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd); + +#if defined(DEBUG) + unsigned eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd); #endif + unsigned compMethodHash(CORINFO_METHOD_HANDLE methodHandle); + var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig, bool* isPinned); CORINFO_CLASS_HANDLE eeGetArgClass(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE list); @@ -7632,10 +7652,6 @@ class Compiler void eeGetMethodSig(CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* retSig, CORINFO_CLASS_HANDLE owner = nullptr); - // Method entry-points, instrs - - CORINFO_METHOD_HANDLE eeMarkNativeTarget(CORINFO_METHOD_HANDLE method); - CORINFO_EE_INFO eeInfo; bool eeInfoInitialized; @@ -7841,16 +7857,6 @@ class Compiler // Utility functions -#if defined(DEBUG) - void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle); - unsigned eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd); - const char* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd); -#endif - - const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer = nullptr, size_t bufferSize = 0); - const char* eeGetFieldName(CORINFO_FIELD_HANDLE fieldHnd, bool includeClass, char* buffer = nullptr, size_t bufferSize = 0); - const char* eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer = nullptr, size_t bufferSize = 0); - static CORINFO_METHOD_HANDLE eeFindHelper(unsigned helper); static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index b89ebaf08715e..ba73f5439a37a 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -3649,33 +3649,6 @@ inline bool jitStaticFldIsGlobAddr(CORINFO_FIELD_HANDLE fldHnd) return (fldHnd == FLD_GLOBAL_DS || fldHnd == FLD_GLOBAL_FS); } -#if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(FEATURE_TRACELOGGING) - -inline bool Compiler::eeIsNativeMethod(CORINFO_METHOD_HANDLE method) -{ - return ((((size_t)method) & 0x2) == 0x2); -} - -inline CORINFO_METHOD_HANDLE Compiler::eeGetMethodHandleForNative(CORINFO_METHOD_HANDLE method) -{ - assert((((size_t)method) & 0x3) == 0x2); - return (CORINFO_METHOD_HANDLE)(((size_t)method) & ~0x3); -} -#endif - -inline CORINFO_METHOD_HANDLE Compiler::eeMarkNativeTarget(CORINFO_METHOD_HANDLE method) -{ - assert((((size_t)method) & 0x3) == 0); - if (method == nullptr) - { - return method; - } - else - { - return (CORINFO_METHOD_HANDLE)(((size_t)method) | 0x2); - } -} - /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index a094965a25d34..23d991f669d85 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -120,6 +120,16 @@ extern "C" DLLEXPORT void jitStartup(ICorJitHost* jitHost) g_jitInitialized = true; } +#ifndef DEBUG +void jitprintf(const char* fmt, ...) +{ + va_list vl; + va_start(vl, fmt); + vfprintf(jitstdout, fmt, vl); + va_end(vl); +} +#endif + void jitShutdown(bool processIsTerminating) { if (!g_jitInitialized) @@ -1401,151 +1411,7 @@ bool Compiler::eeRunWithSPMIErrorTrapImp(void (*function)(void*), void* param) return info.compCompHnd->runWithSPMIErrorTrap(function, param); } -/***************************************************************************** - * - * Utility functions - */ - -#if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(FEATURE_TRACELOGGING) - -/*****************************************************************************/ - -// static helper names - constant array -const char* jitHlpFuncTable[CORINFO_HELP_COUNT] = { -#define JITHELPER(code, pfnHelper, sig) #code, -#define DYNAMICJITHELPER(code, pfnHelper, sig) #code, -#include "jithelpers.h" -}; - -/***************************************************************************** -* -* Filter wrapper to handle exception filtering. -* On Unix compilers don't support SEH. -*/ - -struct FilterSuperPMIExceptionsParam_ee_il -{ - Compiler* pThis; - Compiler::Info* pJitInfo; - CORINFO_FIELD_HANDLE field; - CORINFO_METHOD_HANDLE method; - CORINFO_CLASS_HANDLE clazz; - const char** classNamePtr; - const char* fieldOrMethodOrClassNamePtr; - char* className; - unsigned classSize; - EXCEPTION_POINTERS exceptionPointers; -}; - -template -static void eePrint(StringPrinter* sp, Compiler* comp, const char* defaultName, T handle) -{ - char buffer[256]; - size_t requiredBufferSize; - bool success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { - (comp->info.compCompHnd->*print)(handle, buffer, sizeof(buffer), &requiredBufferSize); - }); - - if (!success) - { - sp->Append(defaultName); - return; - } - - if (bufferSize >= requiredBufferSize) - { - sp->Append(buffer); - return; - } - - char* pBuffer = new (comp, CMK_DebugOnly) char[requiredBufferSize]; - success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { - (comp->info.compCompHnd->*print)(handle, pBuffer, requiredBufferSize); - }); - - if (!success) - { - sp->Append(defaultName); - return; - } - - sp->Append(pBuffer); -} - - -//------------------------------------------------------------------------ -// eeGetClassName: -// Get the name (including namespace and instantiation) of a type. -// If missing information (in SPMI), then return a placeholder string. -// -// Parameters: -// clsHnd - the handle of the class -// buffer - a buffer to use for scratch space, or null pointer to allocate a new string. -// bufferSize - the size of buffer. If the final class name is longer a new string will be allocated. -// -// Return value: -// The name string. -// -const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer, size_t bufferSize) -{ - StringPrinter printer(getAllocator(CMK_DebugOnly), buffer, bufferSize); - if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) - { - printer.Truncate(0); - printer.Append("hackishClassName"); - } - - return printer.GetBuffer(); -} - -const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE field, bool includeClass, char* buffer, size_t bufferSize) -{ - StringPrinter printer(getAllocator(CMK_DebugOnly), buffer, bufferSize); - if (includeClass) - { - if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, info.compCompHnd->getFieldClass(field), true); })) - { - printer.Append("hackishClassName"); - } - - printer.Append(':'); - } - - eePrint(&printer, this, "hackishFieldName", field); - return printer.GetBuffer(); -} - -const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method, char* buffer, size_t bufferSize) -{ - if (eeGetHelperNum(method) != CORINFO_HELP_UNDEF) - { - CorInfoHelpFunc ftnNum = eeGetHelperNum(method); - const char* name = info.compCompHnd->getHelperName(ftnNum); - - // If it's something unknown from a RET VM, or from SuperPMI, then use our own helper name table. - if ((strcmp(name, "AnyJITHelper") == 0) || (strcmp(name, "Yickish helper name") == 0)) - { - if ((unsigned)ftnNum < CORINFO_HELP_COUNT) - { - name = jitHlpFuncTable[ftnNum]; - } - } - - return name; - } - - if (eeIsNativeMethod(method)) - { - method = eeGetMethodHandleForNative(method); - } - - return eePrint(this, "hackishMethodName", method, buffer, bufferSize); -} - -#endif - #ifdef DEBUG - //------------------------------------------------------------------------ // eeTryGetClassSize: wraps getClassSize but if doing SuperPMI replay // and the value isn't found, use a bogus size. @@ -1557,78 +1423,12 @@ const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE method, char* buffer // unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) { - FilterSuperPMIExceptionsParam_ee_il param; - - param.pThis = this; - param.pJitInfo = &info; - param.clazz = clsHnd; - - bool success = eeRunWithSPMIErrorTrap( - [](FilterSuperPMIExceptionsParam_ee_il* pParam) { - pParam->classSize = pParam->pJitInfo->compCompHnd->getClassSize(pParam->clazz); - }, - ¶m); - - if (!success) - { - param.classSize = (unsigned)-1; // Use the maximum unsigned value as the size - } - return param.classSize; -} - -//------------------------------------------------------------------------ -// eeGetShortClassName: Returns class name with no instantiation. -// -// Arguments: -// clsHnd - the class handle to get the type name of -// -// Return value: -// String without instantiation. -// -const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) -{ - StringPrinter printer(getAllocator(CMK_DebugOnly)); - if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, false); })) - { - printer.Truncate(0); - printer.Append("hackishClassName"); - } + unsigned classSize = UINT_MAX; + eeRunFunctorWithSPMIErrorTrap([&]() { + classSize = info.compCompHnd->getClassSize(clsHnd); + }); - return printer.GetBuffer(); + return classSize; } -void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle) -{ - const size_t maxStrSize = 64; - char str[maxStrSize]; - size_t actualLen = 0; - - // Ignore potential SPMI failures - bool success = eeRunFunctorWithSPMIErrorTrap( - [&]() { actualLen = this->info.compCompHnd->printObjectDescription(handle, str, maxStrSize); }); - - if (!success) - { - return; - } - - for (size_t i = 0; i < actualLen; i++) - { - // Replace \n and \r symbols with whitespaces - if (str[i] == '\n' || str[i] == '\r') - { - str[i] = ' '; - } - } - - printf("%s '%s'\n", prefix, str); -} -#else // DEBUG -void jitprintf(const char* fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - vfprintf(jitstdout, fmt, vl); - va_end(vl); -} #endif // !DEBUG diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index cbe29237f60ed..4c700f2f3bbbf 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -10,9 +10,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ -// ONLY FUNCTIONS common to all variants of the JIT (EXE, DLL) should go here) -// otherwise they belong in the corresponding directory. - #include "jitpch.h" #ifdef _MSC_VER @@ -83,8 +80,6 @@ void StringPrinter::Append(char chr) m_bufferIndex++; } -#if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) - //------------------------------------------------------------------------ // eePrintJitType: // Print a JIT type. @@ -200,6 +195,12 @@ void Compiler::eePrintTypeOrJitAlias(StringPrinter* printer, CORINFO_CLASS_HANDL } } +static const char* s_jitHelperNames[CORINFO_HELP_COUNT] = { +#define JITHELPER(code, pfnHelper, sig) #code, +#define DYNAMICJITHELPER(code, pfnHelper, sig) #code, +#include "jithelpers.h" +}; + //------------------------------------------------------------------------ // eePrintMethod: // Print a method given by a method handle, its owning class handle and its @@ -226,6 +227,14 @@ void Compiler::eePrintMethod(StringPrinter* printer, bool includeReturnType, bool includeThisSpecifier) { + CorInfoHelpFunc helper = eeGetHelperNum(methHnd); + if (helper == CORINFO_HELP_UNDEF) + { + assert(helper < CORINFO_HELP_COUNT); + printer->Append(s_jitHelperNames[helper]); + return; + } + if (clsHnd != NO_CLASS_HANDLE) { eePrintType(printer, clsHnd, includeClassInstantiation); @@ -333,6 +342,39 @@ void Compiler::eePrintMethod(StringPrinter* printer, } } +//------------------------------------------------------------------------ +// eePrintField: +// Print a field name to a StringPrinter. +// +// Arguments: +// printer - the printer +// fld - The field +// includeType - Whether to prefix the string by : +// +void Compiler::eePrintField(StringPrinter* printer, CORINFO_FIELD_HANDLE fld, bool includeType) +{ + if (includeType) + { + CORINFO_CLASS_HANDLE cls = info.compCompHnd->getFieldClass(fld); + eePrintType(printer, cls, true); + printer->Append(':'); + } + + size_t requiredBufferSize; + char buffer[256]; + info.compCompHnd->printFieldName(fld, buffer, sizeof(buffer), &requiredBufferSize); + if (sizeof(buffer) <= requiredBufferSize) + { + printer->Append(buffer); + } + else + { + char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; + info.compCompHnd->printFieldName(fld, pBuffer, requiredBufferSize); + printer->Append(pBuffer); + } +} + //------------------------------------------------------------------------ // eeGetMethodFullName: // Get a string describing a method. @@ -341,18 +383,25 @@ void Compiler::eePrintMethod(StringPrinter* printer, // hnd - the method handle // includeReturnType - Whether to include the return type in the string // includeThisSpecifier - Whether to include a specifier for whether this is an instance method. +// buffer - Preexisting buffer to use (can be nullptr to allocate on heap). +// bufferSize - Size of preexisting buffer. +// +// Remarks: +// If the final string is larger than the preexisting buffer can contain then +// the string will be jit memory allocated. // // Returns: // The string. // -const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType, bool includeThisSpecifier) +const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType, bool includeThisSpecifier, char* buffer, size_t bufferSize) { - if ((eeGetHelperNum(hnd) != CORINFO_HELP_UNDEF) || eeIsNativeMethod(hnd)) + CorInfoHelpFunc helper = eeGetHelperNum(hnd); + if (helper != CORINFO_HELP_UNDEF) { - return eeGetMethodName(hnd);; + return s_jitHelperNames[helper]; } - StringPrinter p(getAllocator(CMK_DebugOnly)); + StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); CORINFO_CLASS_HANDLE clsHnd = NO_CLASS_HANDLE; bool success = eeRunFunctorWithSPMIErrorTrap([&]() { clsHnd = info.compCompHnd->getMethodClass(hnd); @@ -407,10 +456,177 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ } p.Truncate(0); - p.Append("hackishClassName:hackishMethodName(?)"); + p.Append(""); + return p.GetBuffer(); +} + +//------------------------------------------------------------------------ +// eeGetMethodName: +// Get the name of a method. +// +// Arguments: +// hnd - the method handle +// buffer - Preexisting buffer to use (can be nullptr to allocate on heap). +// bufferSize - Size of preexisting buffer. +// +// Remarks: +// See eeGetMethodFullName for documentation about the buffer. +// +// Returns: +// The string. +// +const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer, size_t bufferSize) +{ + StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + + }); + + if (!success) + { + p.Truncate(0); + p.Append(""); + } + return p.GetBuffer(); } -#endif // defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) +//------------------------------------------------------------------------ +// eeGetFieldName: +// Get a string describing a field. +// +// Arguments: +// fldHnd - the field handle +// includeType - Whether to prefix the string with : +// buffer - Preexisting buffer to use (can be nullptr to allocate on heap). +// bufferSize - Size of preexisting buffer. +// +// Remarks: +// See eeGetMethodFullName for documentation about the buffer. +// +// Returns: +// The string. +// +const char* Compiler::eeGetFieldName( + CORINFO_FIELD_HANDLE fldHnd, + bool includeType, + char* buffer, + size_t bufferSize) +{ + StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintField(&p, fldHnd, includeType); + }); + + if (success) + { + return p.GetBuffer(); + } + + p.Truncate(0); + + if (includeType) + { + p.Append(":"); + + success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintField(&p, fldHnd, false); + }); + + if (success) + { + return p.GetBuffer(); + } + + p.Truncate(0); + } + + if (includeType) + { + p.Append(":"); + } + + p.Append(""); + return p.GetBuffer(); +} + +//------------------------------------------------------------------------ +// eeGetClassName: +// Get the name (including namespace and instantiation) of a type. +// If missing information (in SPMI), then return a placeholder string. +// +// Parameters: +// clsHnd - the handle of the class +// buffer - a buffer to use for scratch space, or null pointer to allocate a new string. +// bufferSize - the size of buffer. If the final class name is longer a new string will be allocated. +// +// Return value: +// The name string. +// +const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer, size_t bufferSize) +{ + StringPrinter printer(getAllocator(CMK_DebugOnly), buffer, bufferSize); + if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) + { + printer.Truncate(0); + printer.Append("hackishClassName"); + } + + return printer.GetBuffer(); +} + +//------------------------------------------------------------------------ +// eeGetShortClassName: Returns class name with no instantiation. +// +// Arguments: +// clsHnd - the class handle to get the type name of +// +// Return value: +// String without instantiation. +// +const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) +{ + StringPrinter printer(getAllocator(CMK_DebugOnly)); + if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, false); })) + { + printer.Truncate(0); + printer.Append("hackishClassName"); + } + + return printer.GetBuffer(); +} + +void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle) +{ + const size_t maxStrSize = 64; + char str[maxStrSize]; + size_t actualLen = 0; + + // Ignore potential SPMI failures + bool success = eeRunFunctorWithSPMIErrorTrap( + [&]() { actualLen = this->info.compCompHnd->printObjectDescription(handle, str, maxStrSize); }); + + if (!success) + { + return; + } + + for (size_t i = 0; i < actualLen; i++) + { + // Replace \n and \r symbols with whitespaces + if (str[i] == '\n' || str[i] == '\r') + { + str[i] = ' '; + } + } + + printf("%s '%s'\n", prefix, str); +} -/*****************************************************************************/ diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index 3c769f92d6d08..97e1bf1172407 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -4058,19 +4058,21 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag flag &= GTF_ICON_HDL_MASK; + char buffer[256]; + if (cookie != 0) { if (flag == GTF_ICON_FTN_ADDR) { - printf("%s code for ", commentPrefix); - emitComp->eePrintMethodName(reinterpret_cast(cookie), true); + const char* methName = emitComp->eeGetMethodFullName(reinterpret_cast(cookie), true, true, buffer, sizeof(buffer)); + printf("%s code for %s", methName); return; } if ((flag == GTF_ICON_STATIC_HDL) || (flag == GTF_ICON_STATIC_BOX_PTR)) { - printf("%s %s for ", commentPrefix, flag == GTF_ICON_STATIC_HDL ? "data" : "box"); - emitComp->eePrintFieldName(reinterpret_cast(cookie), true); + const char* fieldName = emitComp->eeGetFieldName(reinterpret_cast(cookie), true, buffer, sizeof(buffer)); + printf("%s %s for %s", commentPrefix, flag == GTF_ICON_STATIC_HDL ? "data" : "box", fieldName); return; } } @@ -4107,8 +4109,7 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag } else if (flag == GTF_ICON_FIELD_HDL) { - printf("%s ", commentPrefix); - emitComp->eePrintFieldName(reinterpret_cast(handle), true); + str = emitComp->eeGetFieldName(reinterpret_cast(handle), true, buffer, sizeof(buffer)); } else if (flag == GTF_ICON_STATIC_HDL) { @@ -4116,7 +4117,7 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag } else if (flag == GTF_ICON_METHOD_HDL) { - str = emitComp->eeGetMethodFullName(reinterpret_cast(handle)); + str = emitComp->eeGetMethodFullName(reinterpret_cast(handle), true, true, buffer, sizeof(buffer)); } else if (flag == GTF_ICON_FTN_ADDR) { diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 7ad8f8c423497..b1b3c9db17ddc 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -9516,8 +9516,8 @@ void emitter::emitDispClsVar(CORINFO_FIELD_HANDLE fldHnd, ssize_t offs, bool rel #ifdef DEBUG if (emitComp->opts.varNames && offs < 0) { - printf("'"); - emitComp->eePrintFieldName(fldHnd); + char buffer[128]; + printf("'%s", emitComp->eeGetFieldName(fldHnd, true, buffer, sizeof(buffer))); if (offs) { printf("%+Id", offs); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index a6bd5b7225612..03bb74d9c257b 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -11502,7 +11502,7 @@ void Compiler::gtDispFieldSeq(FieldSeq* fieldSeq, ssize_t offset) } char buffer[128]; - printf(" Fseq[%s", eeGetFieldName(fieldSeq->GetFieldHandle(), buffer, sizeof(buffer))); + printf(" Fseq[%s", eeGetFieldName(fieldSeq->GetFieldHandle(), false, buffer, sizeof(buffer))); if (offset != 0) { printf(", %zd", offset); @@ -11532,6 +11532,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) } bool isLclFld = false; + char buffer[256]; switch (tree->gtOper) { @@ -11583,11 +11584,11 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) { unsigned fieldLclNum = varDsc->lvFieldLclStart + index; LclVarDsc* fieldVarDsc = lvaGetDesc(fieldLclNum); - char fieldName[64]; + const char* fieldName; #if !defined(TARGET_64BIT) if (varTypeIsLong(varDsc)) { - strcpy_s(fieldName, sizeof(fieldName), (index == 0) ? "lo" : "hi"); + fieldName = index == 0 ? "lo" : "hi"; } else #endif // !defined(TARGET_64BIT) @@ -11595,7 +11596,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) CORINFO_CLASS_HANDLE typeHnd = varDsc->GetStructHnd(); CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(typeHnd, fieldVarDsc->lvFldOrdinal); - eePrintFieldNameToBuffer(fldHnd, fieldName, sizeof(fieldName)); + fieldName = eeGetFieldName(fldHnd, true, buffer, sizeof(buffer)); } printf("\n"); @@ -11632,11 +11633,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) case GT_JMP: { - const char* methodName; - const char* className; - - printf(" "); - eePrintMethodName((CORINFO_METHOD_HANDLE)tree->AsVal()->gtVal1, true); + printf(" %s", eeGetMethodFullName((CORINFO_METHOD_HANDLE)tree->AsVal()->gtVal1, true, true, buffer, sizeof(buffer))); } break; @@ -11649,11 +11646,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) case GT_FTN_ADDR: { - const char* methodName; - const char* className; - - methodName = eeGetMethodName((CORINFO_METHOD_HANDLE)tree->AsFptrVal()->gtFptrMethod, &className); - printf(" %s.%s\n", className, methodName); + printf(" %s\n", eeGetMethodFullName((CORINFO_METHOD_HANDLE)tree->AsFptrVal()->gtFptrMethod, true, true, buffer, sizeof(buffer))); } break; @@ -11914,20 +11907,20 @@ void Compiler::gtDispTree(GenTree* tree, { switch (putArg->gtPutArgStkKind) { - case GenTreePutArgStk::Kind::RepInstr: - printf(" (RepInstr)"); - break; - case GenTreePutArgStk::Kind::PartialRepInstr: - printf(" (PartialRepInstr)"); - break; - case GenTreePutArgStk::Kind::Unroll: - printf(" (Unroll)"); - break; - case GenTreePutArgStk::Kind::Push: - printf(" (Push)"); - break; - default: - unreached(); + case GenTreePutArgStk::Kind::RepInstr: + printf(" (RepInstr)"); + break; + case GenTreePutArgStk::Kind::PartialRepInstr: + printf(" (PartialRepInstr)"); + break; + case GenTreePutArgStk::Kind::Unroll: + printf(" (Unroll)"); + break; + case GenTreePutArgStk::Kind::Push: + printf(" (Push)"); + break; + default: + unreached(); } } } @@ -11942,8 +11935,11 @@ void Compiler::gtDispTree(GenTree* tree, if (tree->OperIs(GT_FIELD, GT_FIELD_ADDR)) { - char buffer[128]; - printf(" %s", eeGetFieldName(tree->AsField()->gtFldHnd, buffer, sizeof(buffer))); + auto disp = [&]() { + char buffer[256]; + printf(" %s", eeGetFieldName(tree->AsField()->gtFldHnd, true, buffer, sizeof(buffer))); + }; + disp(); } if (tree->gtOper == GT_INTRINSIC) @@ -12148,12 +12144,11 @@ void Compiler::gtDispTree(GenTree* tree, if (call->gtCallType != CT_INDIRECT) { - const char* methodName; - const char* className; - - methodName = eeGetMethodName(call->gtCallMethHnd, &className); - - printf(" %s.%s", className, methodName); + auto disp = [&]() { + char buffer[256]; + printf(" %s", eeGetMethodFullName(call->gtCallMethHnd, true, true, buffer, sizeof(buffer))); + }; + disp(); } if ((call->gtFlags & GTF_CALL_UNMANAGED) && (call->gtCallMoreFlags & GTF_CALL_M_FRAME_VAR_DEATH)) @@ -18305,9 +18300,9 @@ CORINFO_CLASS_HANDLE Compiler::gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldH if (queryForCurrentClass) { #if DEBUG - JITDUMP("Querying runtime about current class of field "); - eePrintFieldName(fieldHnd, true); - printf(" (declared as %s)\n", eeGetClassName(fieldClass)); + char buffer[128]; + JITDUMP("Querying runtime about current class of field %s (declared as %s)\n", + eeGetFieldName(fieldHnd, true, buffer, sizeof(buffer))); #endif // DEBUG // Is this a fully initialized init-only static field? @@ -18321,8 +18316,11 @@ CORINFO_CLASS_HANDLE Compiler::gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldH fieldClass = currentClass; *pIsExact = true; *pIsNonNull = true; +#ifdef DEBUG + char buffer[128]; JITDUMP("Runtime reports field is init-only and initialized and has class %s\n", - eeGetClassName(fieldClass)); + eeGetClassName(fieldClass, buffer, sizeof(buffer))); +#endif } else { diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index a0f8c0c2143a1..84ff03e0593c2 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -5018,9 +5018,12 @@ void Compiler::considerGuardedDevirtualization(GenTreeCall* call, } } +#ifdef DEBUG + char buffer[256]; JITDUMP("%s call would invoke method %s\n", isInterface ? "interface" : call->IsDelegateInvoke() ? "delegate" : "virtual", - eeGetMethodName(likelyMethod, nullptr)); + eeGetMethodFullName(likelyMethod, true, true, buffer, sizeof(buffer))); +#endif // Add this as a potential candidate. // @@ -5777,7 +5780,7 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, objClassNote = isExact ? " [exact]" : objClassIsFinal ? " [final]" : ""; objClassName = eeGetClassName(objClass); baseClassName = eeGetClassName(baseClass); - baseMethodName = eeGetMethodName(baseMethod, nullptr); + baseMethodName = eeGetMethodName(baseMethod); if (verbose) { @@ -5883,7 +5886,7 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, if (verbose || doPrint) { - derivedMethodName = eeGetMethodName(derivedMethod, nullptr); + derivedMethodName = eeGetMethodName(derivedMethod); derivedClassName = eeGetClassName(derivedClass); if (verbose) { diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index e39c91a5dc997..90cdc5f6eb4c7 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -2415,12 +2415,10 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum) // Now grab the temp for the field local. #ifdef DEBUG - char fieldName[64]; - compiler->eePrintFieldNameToBuffer(pFieldInfo->fldHnd, fieldName, sizeof(fieldName)); - + char fieldNameBuffer[64]; + const char* fieldName = compiler->eeGetFieldName(pFieldInfo->fldHnd, false, fieldNameBuffer, sizeof(fieldNameBuffer)); char buf[200]; - sprintf_s(buf, sizeof(buf), "%s V%02u.%s (fldOffset=0x%x)", "field", lclNum, - fieldName, pFieldInfo->fldOffset); + sprintf_s(buf, sizeof(buf), "field V%02u.%s (fldOffset=0x%x)", lclNum, fieldName, pFieldInfo->fldOffset); // We need to copy 'buf' as lvaGrabTemp() below caches a copy to its argument. size_t len = strlen(buf) + 1; @@ -7833,9 +7831,8 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r CORINFO_CLASS_HANDLE typeHnd = parentvarDsc->GetStructHnd(); CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(typeHnd, varDsc->lvFldOrdinal); - printf(" V%02u.", varDsc->lvParentLcl); - eePrintFieldName(fldHnd); - printf("(offs=0x%02x)", varDsc->lvFldOffset); + char buffer[128]; + printf(" V%02u.%s(offs=0x%02x)", varDsc->lvParentLcl, eeGetFieldName(fldHnd, false, buffer, sizeof(buffer)), varDsc->lvFldOffset); lvaPromotionType promotionType = lvaGetPromotionType(parentvarDsc); switch (promotionType) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 2ea9f1225e341..1bfa32023bb77 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -5458,7 +5458,7 @@ GenTree* Compiler::fgMorphExpandStaticField(GenTree* tree) } else if (isStaticReadOnlyInited) { - JITDUMP("Marking initialized static read-only field '%s' as invariant.\n", eeGetFieldName(fieldHandle)); + JITDUMP("Marking initialized static read-only field '%s' as invariant.\n", eeGetFieldName(fieldHandle, false)); // Static readonly field is not null at this point (see getStaticFieldCurrentClass impl). tree->gtFlags |= (GTF_IND_INVARIANT | GTF_IND_NONFAULTING | GTF_IND_NONNULL); diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 64550d2cf8369..d824dbecec4cd 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -2974,9 +2974,11 @@ ValueNum ValueNumStore::VNForFieldSelector(CORINFO_FIELD_HANDLE fieldHnd, var_ty #ifdef DEBUG if (m_pComp->verbose) { - printf(" VNForHandle("); - m_pComp->eePrintFieldName(fieldHnd); - printf(") is " FMT_VN ", fieldType is %s", fldHndVN, varTypeName(fieldType)); + char buffer[128]; + const char* fldName = m_pComp->eeGetFieldName(fieldHnd, false, buffer, sizeof(buffer)); + + printf(" VNForHandle(%s) is " FMT_VN ", fieldType is %s", + fldName, fldHndVN, varTypeName(fieldType)); if (size != 0) { @@ -8042,9 +8044,9 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, #ifdef DEBUG if (verbose) { - printf(" VNForHandle("); - eePrintFieldName(fldHnd); - printf(") is " FMT_VN "\n", fldHndVN); + char buffer[128]; + const char* fldName = eeGetFieldName(fldHnd, false, buffer, sizeof(buffer)); + printf(" VNForHandle(%s) is " FMT_VN "\n", fldName, fldHndVN); } #endif // DEBUG From fea3eece18975db97d2841106dd893ef9fadee7d Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 17:55:44 +0100 Subject: [PATCH 34/50] Run jit-format --- src/coreclr/jit/codegencommon.cpp | 2 +- src/coreclr/jit/compiler.h | 3 +-- src/coreclr/jit/ee_il_dll.cpp | 4 +--- src/coreclr/jit/eeinterface.cpp | 26 ++++++++-------------- src/coreclr/jit/emit.cpp | 9 +++++--- src/coreclr/jit/gentree.cpp | 36 ++++++++++++++++--------------- src/coreclr/jit/importercalls.cpp | 6 +++--- src/coreclr/jit/lclvars.cpp | 8 ++++--- src/coreclr/jit/valuenum.cpp | 7 +++--- 9 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index 5e82a3992e35b..e0dc50a0e83e0 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -7549,7 +7549,7 @@ void CodeGen::genReportRichDebugInfoInlineTreeToFile(FILE* file, InlineContext* fprintf(file, "\"LocationFlags\":%u,", (uint32_t)context->GetLocation().EncodeSourceTypes()); fprintf(file, "\"ExactILOffset\":%u,", context->GetActualCallOffset()); auto append = [&]() { - char buffer[256]; + char buffer[256]; const char* methodName = compiler->eeGetMethodName(context->GetCallee(), buffer, sizeof(buffer)); fprintf(file, "\"MethodName\":\"%s\",", methodName); }; diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index ea267a44a3c48..9c2c25af10a5a 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7617,7 +7617,7 @@ class Compiler const char* eeGetFieldName(CORINFO_FIELD_HANDLE fldHnd, bool includeType, - char* buffer = nullptr, + char* buffer = nullptr, size_t bufferSize = 0); const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer = nullptr, size_t bufferSize = 0); @@ -7856,7 +7856,6 @@ class Compiler // Utility functions - static CORINFO_METHOD_HANDLE eeFindHelper(unsigned helper); static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 23d991f669d85..c9528a9585ebd 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -1424,9 +1424,7 @@ bool Compiler::eeRunWithSPMIErrorTrapImp(void (*function)(void*), void* param) unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) { unsigned classSize = UINT_MAX; - eeRunFunctorWithSPMIErrorTrap([&]() { - classSize = info.compCompHnd->getClassSize(clsHnd); - }); + eeRunFunctorWithSPMIErrorTrap([&]() { classSize = info.compCompHnd->getClassSize(clsHnd); }); return classSize; } diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 4c700f2f3bbbf..5bf0c102b5bb6 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -242,7 +242,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, } size_t requiredBufferSize; - char buffer[256]; + char buffer[256]; info.compCompHnd->printMethodName(methHnd, buffer, sizeof(buffer), &requiredBufferSize); if (sizeof(buffer) <= requiredBufferSize) { @@ -361,7 +361,7 @@ void Compiler::eePrintField(StringPrinter* printer, CORINFO_FIELD_HANDLE fld, bo } size_t requiredBufferSize; - char buffer[256]; + char buffer[256]; info.compCompHnd->printFieldName(fld, buffer, sizeof(buffer), &requiredBufferSize); if (sizeof(buffer) <= requiredBufferSize) { @@ -393,7 +393,8 @@ void Compiler::eePrintField(StringPrinter* printer, CORINFO_FIELD_HANDLE fld, bo // Returns: // The string. // -const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includeReturnType, bool includeThisSpecifier, char* buffer, size_t bufferSize) +const char* Compiler::eeGetMethodFullName( + CORINFO_METHOD_HANDLE hnd, bool includeReturnType, bool includeThisSpecifier, char* buffer, size_t bufferSize) { CorInfoHelpFunc helper = eeGetHelperNum(hnd); if (helper != CORINFO_HELP_UNDEF) @@ -477,8 +478,8 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd, bool includ // const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer, size_t bufferSize) { - StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, /* sig */ nullptr, /* includeClassInstantiation */ false, @@ -514,16 +515,10 @@ const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffe // Returns: // The string. // -const char* Compiler::eeGetFieldName( - CORINFO_FIELD_HANDLE fldHnd, - bool includeType, - char* buffer, - size_t bufferSize) +const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE fldHnd, bool includeType, char* buffer, size_t bufferSize) { StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { - eePrintField(&p, fldHnd, includeType); - }); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintField(&p, fldHnd, includeType); }); if (success) { @@ -536,9 +531,7 @@ const char* Compiler::eeGetFieldName( { p.Append(":"); - success = eeRunFunctorWithSPMIErrorTrap([&]() { - eePrintField(&p, fldHnd, false); - }); + success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintField(&p, fldHnd, false); }); if (success) { @@ -629,4 +622,3 @@ void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDL printf("%s '%s'\n", prefix, str); } - diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index 97e1bf1172407..dfea35387abe2 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -4064,14 +4064,16 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag { if (flag == GTF_ICON_FTN_ADDR) { - const char* methName = emitComp->eeGetMethodFullName(reinterpret_cast(cookie), true, true, buffer, sizeof(buffer)); + const char* methName = emitComp->eeGetMethodFullName(reinterpret_cast(cookie), true, + true, buffer, sizeof(buffer)); printf("%s code for %s", methName); return; } if ((flag == GTF_ICON_STATIC_HDL) || (flag == GTF_ICON_STATIC_BOX_PTR)) { - const char* fieldName = emitComp->eeGetFieldName(reinterpret_cast(cookie), true, buffer, sizeof(buffer)); + const char* fieldName = + emitComp->eeGetFieldName(reinterpret_cast(cookie), true, buffer, sizeof(buffer)); printf("%s %s for %s", commentPrefix, flag == GTF_ICON_STATIC_HDL ? "data" : "box", fieldName); return; } @@ -4117,7 +4119,8 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag } else if (flag == GTF_ICON_METHOD_HDL) { - str = emitComp->eeGetMethodFullName(reinterpret_cast(handle), true, true, buffer, sizeof(buffer)); + str = emitComp->eeGetMethodFullName(reinterpret_cast(handle), true, true, buffer, + sizeof(buffer)); } else if (flag == GTF_ICON_FTN_ADDR) { diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 03bb74d9c257b..065082dcb7716 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -11633,7 +11633,8 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) case GT_JMP: { - printf(" %s", eeGetMethodFullName((CORINFO_METHOD_HANDLE)tree->AsVal()->gtVal1, true, true, buffer, sizeof(buffer))); + printf(" %s", eeGetMethodFullName((CORINFO_METHOD_HANDLE)tree->AsVal()->gtVal1, true, true, buffer, + sizeof(buffer))); } break; @@ -11646,7 +11647,8 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) case GT_FTN_ADDR: { - printf(" %s\n", eeGetMethodFullName((CORINFO_METHOD_HANDLE)tree->AsFptrVal()->gtFptrMethod, true, true, buffer, sizeof(buffer))); + printf(" %s\n", eeGetMethodFullName((CORINFO_METHOD_HANDLE)tree->AsFptrVal()->gtFptrMethod, true, true, + buffer, sizeof(buffer))); } break; @@ -11907,20 +11909,20 @@ void Compiler::gtDispTree(GenTree* tree, { switch (putArg->gtPutArgStkKind) { - case GenTreePutArgStk::Kind::RepInstr: - printf(" (RepInstr)"); - break; - case GenTreePutArgStk::Kind::PartialRepInstr: - printf(" (PartialRepInstr)"); - break; - case GenTreePutArgStk::Kind::Unroll: - printf(" (Unroll)"); - break; - case GenTreePutArgStk::Kind::Push: - printf(" (Push)"); - break; - default: - unreached(); + case GenTreePutArgStk::Kind::RepInstr: + printf(" (RepInstr)"); + break; + case GenTreePutArgStk::Kind::PartialRepInstr: + printf(" (PartialRepInstr)"); + break; + case GenTreePutArgStk::Kind::Unroll: + printf(" (Unroll)"); + break; + case GenTreePutArgStk::Kind::Push: + printf(" (Push)"); + break; + default: + unreached(); } } } @@ -18302,7 +18304,7 @@ CORINFO_CLASS_HANDLE Compiler::gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldH #if DEBUG char buffer[128]; JITDUMP("Querying runtime about current class of field %s (declared as %s)\n", - eeGetFieldName(fieldHnd, true, buffer, sizeof(buffer))); + eeGetFieldName(fieldHnd, true, buffer, sizeof(buffer))); #endif // DEBUG // Is this a fully initialized init-only static field? diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 84ff03e0593c2..03658cde25b29 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -211,10 +211,10 @@ var_types Compiler::impImportCall(OPCODE opcode, // These should be in corelib.h, and available through a JIT/EE interface call. const char* namespaceName; const char* className; - const char* methodName = info.compCompHnd->getMethodNameFromMetadata(methHnd, &className, &namespaceName, nullptr); + const char* methodName = + info.compCompHnd->getMethodNameFromMetadata(methHnd, &className, &namespaceName, nullptr); if ((strcmp(namespaceName, "System.Runtime.CompilerServices") == 0) && - (strcmp(className, "JitTestLabel") == 0) && - (strcmp(methodName, "Mark") == 0)) + (strcmp(className, "JitTestLabel") == 0) && (strcmp(methodName, "Mark") == 0)) { return impImportJitTestLabelMark(sig->numArgs); } diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 90cdc5f6eb4c7..6baf04dc2f043 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -2415,8 +2415,9 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum) // Now grab the temp for the field local. #ifdef DEBUG - char fieldNameBuffer[64]; - const char* fieldName = compiler->eeGetFieldName(pFieldInfo->fldHnd, false, fieldNameBuffer, sizeof(fieldNameBuffer)); + char fieldNameBuffer[64]; + const char* fieldName = + compiler->eeGetFieldName(pFieldInfo->fldHnd, false, fieldNameBuffer, sizeof(fieldNameBuffer)); char buf[200]; sprintf_s(buf, sizeof(buf), "field V%02u.%s (fldOffset=0x%x)", lclNum, fieldName, pFieldInfo->fldOffset); @@ -7832,7 +7833,8 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(typeHnd, varDsc->lvFldOrdinal); char buffer[128]; - printf(" V%02u.%s(offs=0x%02x)", varDsc->lvParentLcl, eeGetFieldName(fldHnd, false, buffer, sizeof(buffer)), varDsc->lvFldOffset); + printf(" V%02u.%s(offs=0x%02x)", varDsc->lvParentLcl, eeGetFieldName(fldHnd, false, buffer, sizeof(buffer)), + varDsc->lvFldOffset); lvaPromotionType promotionType = lvaGetPromotionType(parentvarDsc); switch (promotionType) diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index d824dbecec4cd..f6362b04bcac8 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -2974,11 +2974,10 @@ ValueNum ValueNumStore::VNForFieldSelector(CORINFO_FIELD_HANDLE fieldHnd, var_ty #ifdef DEBUG if (m_pComp->verbose) { - char buffer[128]; + char buffer[128]; const char* fldName = m_pComp->eeGetFieldName(fieldHnd, false, buffer, sizeof(buffer)); - printf(" VNForHandle(%s) is " FMT_VN ", fieldType is %s", - fldName, fldHndVN, varTypeName(fieldType)); + printf(" VNForHandle(%s) is " FMT_VN ", fieldType is %s", fldName, fldHndVN, varTypeName(fieldType)); if (size != 0) { @@ -8044,7 +8043,7 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, #ifdef DEBUG if (verbose) { - char buffer[128]; + char buffer[128]; const char* fldName = eeGetFieldName(fldHnd, false, buffer, sizeof(buffer)); printf(" VNForHandle(%s) is " FMT_VN "\n", fldName, fldHndVN); } From 8b9d37113278359a254e05398082558fdd872669 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 18:39:04 +0100 Subject: [PATCH 35/50] SPMI related fixes --- .../tools/Common/JitInterface/CorInfoImpl.cs | 29 +- .../tools/superpmi/mcs/verbdumpmap.cpp | 4 +- src/coreclr/tools/superpmi/mcs/verbildump.cpp | 6 +- .../tools/superpmi/superpmi-shared/agnostic.h | 2 +- .../superpmi/superpmi-shared/asmdumper.cpp | 5 +- .../superpmi/superpmi-shared/callutils.cpp | 57 +-- .../superpmi/superpmi-shared/callutils.h | 3 - .../tools/superpmi/superpmi-shared/lwmlist.h | 8 +- .../superpmi-shared/methodcontext.cpp | 401 +++++++----------- .../superpmi/superpmi-shared/methodcontext.h | 73 ++-- .../icorjitcompiler.cpp | 19 +- 11 files changed, 250 insertions(+), 357 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 4e228944e7993..6e2ea0012dd00 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2843,19 +2843,10 @@ private CorInfoIsAccessAllowedResult canAccessClass(ref CORINFO_RESOLVED_TOKEN p return CorInfoIsAccessAllowedResult.CORINFO_ACCESS_ALLOWED; } - private byte* getFieldName(CORINFO_FIELD_STRUCT_* ftn, byte** moduleName) + private nuint printFieldName(CORINFO_FIELD_STRUCT_* fld, byte* buffer, nuint bufferSize, nuint* requiredBufferSize) { - var field = HandleToObject(ftn); - if (moduleName != null) - { - MetadataType typeDef = field.OwningType.GetTypeDefinition() as MetadataType; - if (typeDef != null) - *moduleName = (byte*)GetPin(StringToUTF8(typeDef.GetFullName())); - else - *moduleName = (byte*)GetPin(StringToUTF8("unknown")); - } - - return (byte*)GetPin(StringToUTF8(field.Name)); + FieldDesc field = HandleToObject(fld); + return PrintFromUtf16(field.Name, buffer, bufferSize, requiredBufferSize); } private CORINFO_CLASS_STRUCT_* getFieldClass(CORINFO_FIELD_STRUCT_* field) @@ -3139,20 +3130,10 @@ private static byte[] StringToUTF8(string s) return bytes; } - private byte* getMethodName(CORINFO_METHOD_STRUCT_* ftn, byte** moduleName) + private nuint printMethodName(CORINFO_METHOD_STRUCT_* ftn, byte* buffer, nuint bufferSize, nuint* requiredBufferSize) { MethodDesc method = HandleToObject(ftn); - - if (moduleName != null) - { - MetadataType typeDef = method.OwningType.GetTypeDefinition() as MetadataType; - if (typeDef != null) - *moduleName = (byte*)GetPin(StringToUTF8(typeDef.GetFullName())); - else - *moduleName = (byte*)GetPin(StringToUTF8("unknown")); - } - - return (byte*)GetPin(StringToUTF8(method.Name)); + return PrintFromUtf16(method.Name, buffer, bufferSize, requiredBufferSize); } private static string getMethodNameFromMetadataImpl(MethodDesc method, out string className, out string namespaceName, out string enclosingClassName) diff --git a/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp b/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp index 78de9a8b17f7e..9e4bd15f2f0ce 100644 --- a/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp +++ b/src/coreclr/tools/superpmi/mcs/verbdumpmap.cpp @@ -29,8 +29,8 @@ void DumpMap(int index, MethodContext* mc) mc->repCompileMethod(&cmi, &flags, &os); - const char* moduleName = nullptr; - const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); + char methodName[256]; + mc->repPrintMethodName(cmi.ftn, methodName, sizeof(methodName)); char className[256]; mc->repPrintClassName(mc->repGetMethodClass(cmi.ftn), className, sizeof(className)); diff --git a/src/coreclr/tools/superpmi/mcs/verbildump.cpp b/src/coreclr/tools/superpmi/mcs/verbildump.cpp index b123f3adcf815..7e1d713089a67 100644 --- a/src/coreclr/tools/superpmi/mcs/verbildump.cpp +++ b/src/coreclr/tools/superpmi/mcs/verbildump.cpp @@ -937,15 +937,15 @@ void DumpIL(MethodContext* mc) mc->repCompileMethod(&cmi, &flags, &os); - const char* moduleName = nullptr; - const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); + char methodName[256]; + mc->repPrintMethodName(cmi.ftn, methodName, sizeof(methodName)); char className[256]; mc->repPrintClassName(mc->repGetMethodClass(cmi.ftn), className, sizeof(className)); printf("// ProcessName - '%s'\n", mc->cr->repProcessName()); printf(".assembly extern mscorlib{}\n"); - printf(".assembly %s{}\n", moduleName); + printf(".assembly dumped_asm\n"); printf(".class %s\n", className); printf("{\n"); printf(" .method "); diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index 87fb3bb166f56..75b5ba3239552 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -773,7 +773,7 @@ struct Agnostic_RecordCallSite DWORDLONG methodHandle; }; -struct Agnostic_PrintEntityResult +struct Agnostic_PrintResult { // Required size of a buffer to contain everything including null terminator. // UINT_MAX if it was not determined during recording. diff --git a/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp b/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp index b524addc2d383..d0602431e52a9 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp @@ -19,8 +19,11 @@ void ASMDumper::DumpToFile(HANDLE hFile, MethodContext* mc, CompileResult* cr) ZeroMemory(buff, bufflen * sizeof(char)); buff_offset += sprintf_s(&buff[buff_offset], bufflen - buff_offset, ";;Generated from SuperPMI on original input '%s'", cr->repProcessName()); + + char methodName[256]; + mc->repPrintMethodName(info.ftn, methodName, sizeof(methodName)); buff_offset += sprintf_s(&buff[buff_offset], bufflen - buff_offset, "\r\n Method Name \"%s\"", - mc->repGetMethodName(info.ftn, nullptr)); + methodName); WriteFile(hFile, buff, buff_offset * sizeof(char), &bytesWritten, nullptr); ULONG hotCodeSize; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp b/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp index 75bbf2a55c76e..aaad597f9b575 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp @@ -215,28 +215,6 @@ CallType CallUtils::GetDirectCallSiteInfo(MethodContext* mc, // SuperPMI's method context replaying instead of directly making calls into the JIT/EE interface. //------------------------------------------------------------------------------------------------- -// Originally from src/jit/ee_il_dll.cpp -const char* CallUtils::GetMethodName(MethodContext* mc, CORINFO_METHOD_HANDLE method, const char** classNamePtr) -{ - if (GetHelperNum(method)) - { - if (classNamePtr != nullptr) - *classNamePtr = "HELPER"; - - // The JIT version uses the getHelperName JIT/EE interface call, but this is easier for us - return kHelperName[GetHelperNum(method)]; - } - - if (IsNativeMethod(method)) - { - if (classNamePtr != nullptr) - *classNamePtr = "NATIVE"; - method = GetMethodHandleForNative(method); - } - - return (mc->repGetMethodName(method, classNamePtr)); -} - // Originally from src/jit/eeinterface.cpp // If `ignoreMethodName` is `true`, we construct the function signature with a dummy method name that will be the // same for all methods. @@ -244,11 +222,24 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL { const char* returnType = NULL; - const char* className = ignoreMethodName ? "CLASS" : nullptr; - const char* methodName = ignoreMethodName ? "METHOD" : GetMethodName(mc, hnd, &className); - if ((GetHelperNum(hnd) != CORINFO_HELP_UNDEF) || IsNativeMethod(hnd)) + if ((GetHelperNum(hnd) != CORINFO_HELP_UNDEF)) { - return methodName; + return kHelperName[GetHelperNum(hnd)]; + } + + char classNameBuffer[256]; + char methodNameBuffer[256]; + + const char* className = "CLASS"; + const char* methodName = "METHOD"; + + if (!ignoreMethodName) + { + mc->repPrintClassName(mc->repGetMethodClass(hnd), classNameBuffer, sizeof(classNameBuffer)); + mc->repPrintMethodName(hnd, methodNameBuffer, sizeof(methodNameBuffer)); + + className = classNameBuffer; + methodName = methodNameBuffer; } size_t length = 0; @@ -376,17 +367,3 @@ inline CorInfoHelpFunc CallUtils::GetHelperNum(CORINFO_METHOD_HANDLE method) return (CORINFO_HELP_UNDEF); return ((CorInfoHelpFunc)(((size_t)method) >> 2)); } - -// Originally from jit/compiler.hpp -inline bool CallUtils::IsNativeMethod(CORINFO_METHOD_HANDLE method) -{ - return ((((size_t)method) & 0x2) == 0x2); -} - -// Originally from jit/compiler.hpp -inline CORINFO_METHOD_HANDLE CallUtils::GetMethodHandleForNative(CORINFO_METHOD_HANDLE method) -{ - // Tweaked to avoid using CRT assertions - Assert((((size_t)method) & 0x3) == 0x2); - return (CORINFO_METHOD_HANDLE)(((size_t)method) & ~0x3); -} diff --git a/src/coreclr/tools/superpmi/superpmi-shared/callutils.h b/src/coreclr/tools/superpmi/superpmi-shared/callutils.h index b0b04cb59bb4d..7d29de3d0b789 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/callutils.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/callutils.h @@ -29,9 +29,6 @@ class CallUtils /*out*/ CORINFO_SIG_INFO* outSigInfo, /*out*/ char** outCallTargetSymbol); static CorInfoHelpFunc GetHelperNum(CORINFO_METHOD_HANDLE method); - static bool IsNativeMethod(CORINFO_METHOD_HANDLE method); - static CORINFO_METHOD_HANDLE GetMethodHandleForNative(CORINFO_METHOD_HANDLE method); - static const char* GetMethodName(MethodContext* mc, CORINFO_METHOD_HANDLE method, const char** classNamePtr); static const char* GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDLE hnd, CORINFO_SIG_INFO sig, bool ignoreMethodName = false); }; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index 25ac3926489cc..b171c1ad8e573 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -18,7 +18,6 @@ LWM(AllocPgoInstrumentationBySchema, DWORDLONG, Agnostic_AllocPgoInstrumentationBySchema) LWM(GetPgoInstrumentationResults, DWORDLONG, Agnostic_GetPgoInstrumentationResults) -LWM(PrintClassName, DWORDLONG, Agnostic_PrintEntityResult) LWM(AreTypesEquivalent, DLDL, DWORD) LWM(AsCorInfoType, DWORDLONG, DWORD) LWM(CanAccessClass, Agnostic_CanAccessClassIn, Agnostic_CanAccessClassOut) @@ -84,7 +83,6 @@ LWM(GetStaticFieldCurrentClass, DWORDLONG, Agnostic_GetStaticFieldCurrentClass) LWM(GetFieldClass, DWORDLONG, DWORDLONG) LWM(GetFieldInClass, DLD, DWORDLONG) LWM(GetFieldInfo, Agnostic_GetFieldInfo, Agnostic_CORINFO_FIELD_INFO) -LWM(GetFieldName, DWORDLONG, DD) LWM(GetFieldOffset, DWORDLONG, DWORD) LWM(GetFieldThreadLocalStoreID, DWORDLONG, DLD) LWM(GetFieldType, DLDL, DLD) @@ -111,7 +109,6 @@ LWM(GetMethodModule, DWORDLONG, DWORDLONG) LWM(GetMethodDefFromMethod, DWORDLONG, DWORD) LWM(GetMethodHash, DWORDLONG, DWORD) LWM(GetMethodInfo, DWORDLONG, Agnostic_GetMethodInfo) -LWM(GetMethodName, DLD, DD) LWM(GetMethodNameFromMetadata, Agnostic_CORINFO_METHODNAME_TOKENin, Agnostic_CORINFO_METHODNAME_TOKENout) LWM(GetMethodSig, DLDL, Agnostic_CORINFO_SIG_INFO) LWM(GetMethodSync, DWORDLONG, DLDL) @@ -153,7 +150,10 @@ LWM(IsIntrinsicType, DWORDLONG, DWORD) LWM(IsSDArray, DWORDLONG, DWORD) LWM(IsValidStringRef, DLD, DWORD) LWM(GetStringLiteral, DLDDD, DD) -LWM(PrintObjectDescription, DWORDLONG, Agnostic_PrintEntityResult) +LWM(PrintObjectDescription, DWORDLONG, Agnostic_PrintResult) +LWM(PrintClassName, DWORDLONG, Agnostic_PrintResult) +LWM(PrintFieldName, DWORDLONG, Agnostic_PrintResult) +LWM(PrintMethodName, DWORDLONG, Agnostic_PrintResult) LWM(IsValidToken, DLD, DWORD) LWM(IsValueClass, DWORDLONG, DWORD) LWM(MergeClasses, DLDL, DWORDLONG) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 9d92cd76d8e97..ea4b80e3579ad 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -1063,65 +1063,6 @@ CorInfoInitClassResult MethodContext::repInitClass(CORINFO_FIELD_HANDLE field, return result; } -void MethodContext::recGetMethodName(CORINFO_METHOD_HANDLE ftn, char* methodname, const char** moduleName) -{ - if (GetMethodName == nullptr) - GetMethodName = new LightWeightMap(); - DD value; - DLD key; - key.A = CastHandle(ftn); - key.B = (moduleName != nullptr); - - if (methodname != nullptr) - value.A = GetMethodName->AddBuffer((unsigned char*)methodname, (DWORD)strlen(methodname) + 1); - else - value.A = (DWORD)-1; - - if ((moduleName != nullptr) && (*moduleName != nullptr)) - value.B = GetMethodName->AddBuffer((unsigned char*)*moduleName, (DWORD)strlen(*moduleName) + 1); - else - value.B = (DWORD)-1; - - GetMethodName->Add(key, value); - DEBUG_REC(dmpGetMethodName(key, value)); -} -void MethodContext::dmpGetMethodName(DLD key, DD value) -{ - unsigned char* methodName = (unsigned char*)GetMethodName->GetBuffer(value.A); - unsigned char* moduleName = (unsigned char*)GetMethodName->GetBuffer(value.B); - printf("GetMethodName key - ftn-%016llX modNonNull-%u, value meth-'%s', mod-'%s'", key.A, key.B, methodName, - moduleName); - GetMethodName->Unlock(); -} - -const char* MethodContext::repGetMethodName(CORINFO_METHOD_HANDLE ftn, const char** moduleName) -{ - const char* result = "hackishMethodName"; - DD value; - DLD key; - key.A = CastHandle(ftn); - key.B = (moduleName != nullptr); - - int itemIndex = -1; - if (GetMethodName != nullptr) - itemIndex = GetMethodName->GetIndex(key); - if (itemIndex < 0) - { - if (moduleName != nullptr) - *moduleName = "hackishModuleName"; - } - else - { - value = GetMethodName->Get(key); - DEBUG_REP(dmpGetMethodName(key, value)); - - if (moduleName != nullptr) - *moduleName = (const char*)GetMethodName->GetBuffer(value.B); - result = (const char*)GetMethodName->GetBuffer(value.A); - } - return result; -} - void MethodContext::recGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, char* methodName, const char** className, @@ -4742,52 +4683,6 @@ CorInfoType MethodContext::repGetFieldType(CORINFO_FIELD_HANDLE field, return (CorInfoType)value.B; } -void MethodContext::recGetFieldName(CORINFO_FIELD_HANDLE ftn, const char** moduleName, const char* result) -{ - if (GetFieldName == nullptr) - GetFieldName = new LightWeightMap(); - - DD value; - - if (result != nullptr) - value.A = GetFieldName->AddBuffer((unsigned char*)result, (DWORD)strlen(result) + 1); - else - value.A = (DWORD)-1; - - if ((moduleName != nullptr) && (*moduleName != nullptr)) // protect strlen - value.B = (DWORD)GetFieldName->AddBuffer((unsigned char*)*moduleName, (DWORD)strlen(*moduleName) + 1); - else - value.B = (DWORD)-1; - - DWORDLONG key = CastHandle(ftn); - GetFieldName->Add(key, value); - DEBUG_REC(dmpGetFieldName(key, value)); -} -void MethodContext::dmpGetFieldName(DWORDLONG key, DD value) -{ - unsigned char* fieldName = (unsigned char*)GetFieldName->GetBuffer(value.A); - unsigned char* moduleName = (unsigned char*)GetFieldName->GetBuffer(value.B); - printf("GetFieldName key - ftn-%016llX, value fld-'%s', mod-'%s'", key, fieldName, moduleName); - GetFieldName->Unlock(); -} -const char* MethodContext::repGetFieldName(CORINFO_FIELD_HANDLE ftn, const char** moduleName) -{ - if (GetFieldName == nullptr) - { - if (moduleName != nullptr) - *moduleName = "hackishModuleName"; - return "hackishFieldName"; - } - - DWORDLONG key = CastHandle(ftn); - DD value = GetFieldName->Get(key); - DEBUG_REP(dmpGetFieldName(key, value)); - - if (moduleName != nullptr) - *moduleName = (const char*)GetFieldName->GetBuffer(value.B); - return (const char*)GetFieldName->GetBuffer(value.A); -} - void MethodContext::recCanInlineTypeCheck(CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source, CorInfoInlineTypeCheck result) @@ -4946,137 +4841,6 @@ int MethodContext::repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned me return srcBufferLength; } -void MethodContext::recPrintEntity( - const char* name, - LightWeightMap*& map, - DWORDLONG handle, - char* buffer, - size_t bufferSize, - size_t* pRequiredBufferSize, - size_t bytesWritten) -{ - if (map == nullptr) - map = new LightWeightMap(); - - // Required size of a buffer that contains all data and null terminator. - UINT requiredBufferSize = UINT_MAX; - if (pRequiredBufferSize != nullptr) - { - requiredBufferSize = (UINT)(*pRequiredBufferSize); - } - else if (bytesWritten + 1 < bufferSize) - { - requiredBufferSize = (UINT)(bytesWritten + 1); - } - - Agnostic_PrintEntityResult res; - int index = map->GetIndex(handle); - if (index != -1) - { - // Merge with existing entry - - res = map->GetItem(index); - - if (requiredBufferSize != UINT_MAX) - { - res.requiredBufferSize = requiredBufferSize; - } - - if (bytesWritten > res.bufferSize) - { - // Always stored without null terminator. - res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); - res.bufferSize = bytesWritten; - } - - map->Update(index, res); - - dmpPrintEntity(name, map, handle, res); - return; - } - - if (buffer != nullptr) - { - res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); - } - else - { - res.buffer = UINT_MAX; - } - - res.bufferSize = (UINT)bytesWritten; - res.requiredBufferSize = requiredBufferSize; - - map->Add(handle, res); - dmpPrintEntity(name, map, handle, res); -} - -void MethodContext::dmpPrintEntity( - const char* name, - LightWeightMapBuffer* buffer, - DWORDLONG key, - const Agnostic_PrintEntityResult& value) -{ - printf("%s key hnd-%016llX, bufferSize-%u, requiredBufferSize-%u", name, key, value.bufferSize, value.requiredBufferSize); - buffer->Unlock(); -} - -size_t MethodContext::repPrintEntity( - const char* name, - LightWeightMap*& map, - DWORDLONG handle, - char* buffer, - size_t bufferSize, - size_t* pRequiredBufferSize) -{ - AssertMapAndKeyExist(map, handle, ": map %s key %016llx", name, handle); - - Agnostic_PrintEntityResult res = map->Get(handle); - DEBUG_REP(dmpPrintEntity(name, buffer, handle, res)); - - if (pRequiredBufferSize != nullptr) - { - if (res.requiredBufferSize == UINT_MAX) - { - LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (missing requiredBufferSize for %s key %016llx)", name, handle); - } - - *pRequiredBufferSize = res.requiredBufferSize; - } - - // requiredBufferSize is with null terminator, but buffer is stored without null terminator. - // Determine if we have enough data to answer the call losslessly. - bool haveFullBuffer = (res.requiredBufferSize != UINT_MAX) && ((res.bufferSize + 1) >= res.requiredBufferSize); - if (!haveFullBuffer && (bufferSize > static_cast(res.bufferSize) + 1)) - { - LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (not enough buffer data for %s key %016llx)", name, handle); - } - - size_t bytesWritten = 0; - if ((buffer != nullptr) && (bufferSize > 0)) - { - char* storedBuffer = (char*)map->GetBuffer(res.buffer); - bytesWritten = min(bufferSize - 1, res.bufferSize); - memcpy(buffer, storedBuffer, bytesWritten); - buffer[bytesWritten] = '\0'; - } - - return bytesWritten; -} - -void MethodContext::recPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) -{ - recPrintEntity("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize, bytesWritten); -} -void MethodContext::dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintEntityResult& value) -{ - dmpPrintEntity("PrintObjectDescription", PrintObjectDescription, key, value); -} -size_t MethodContext::repPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) -{ - return repPrintEntity("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize); -} - void MethodContext::recGetHelperName(CorInfoHelpFunc funcNum, const char* result) { if (GetHelperName == nullptr) @@ -6721,17 +6485,174 @@ CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLAS return result; } +void MethodContext::recPrint( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize, + size_t bytesWritten) +{ + if (map == nullptr) + map = new LightWeightMap(); + + // Required size of a buffer that contains all data and null terminator. + UINT requiredBufferSize = UINT_MAX; + if (pRequiredBufferSize != nullptr) + { + requiredBufferSize = (UINT)(*pRequiredBufferSize); + } + else if (bytesWritten + 1 < bufferSize) + { + requiredBufferSize = (UINT)(bytesWritten + 1); + } + + Agnostic_PrintResult res; + int index = map->GetIndex(handle); + if (index != -1) + { + // Merge with existing entry + + res = map->GetItem(index); + + if (requiredBufferSize != UINT_MAX) + { + res.requiredBufferSize = requiredBufferSize; + } + + if (bytesWritten > res.bufferSize) + { + // Always stored without null terminator. + res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + res.bufferSize = (UINT)bytesWritten; + } + + map->Update(index, res); + + dmpPrint(name, map, handle, res); + return; + } + + if (buffer != nullptr) + { + res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + } + else + { + res.buffer = UINT_MAX; + } + + res.bufferSize = (UINT)bytesWritten; + res.requiredBufferSize = requiredBufferSize; + + map->Add(handle, res); + dmpPrint(name, map, handle, res); +} + +void MethodContext::dmpPrint( + const char* name, + LightWeightMapBuffer* buffer, + DWORDLONG key, + const Agnostic_PrintResult& value) +{ + printf("%s key hnd-%016llX, bufferSize-%u, requiredBufferSize-%u", name, key, value.bufferSize, value.requiredBufferSize); + buffer->Unlock(); +} + +size_t MethodContext::repPrint( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize) +{ + AssertMapAndKeyExist(map, handle, ": map %s key %016llx", name, handle); + + Agnostic_PrintResult res = map->Get(handle); + DEBUG_REP(dmpPrint(name, buffer, handle, res)); + + if (pRequiredBufferSize != nullptr) + { + if (res.requiredBufferSize == UINT_MAX) + { + LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (missing requiredBufferSize for %s key %016llx)", name, handle); + } + + *pRequiredBufferSize = res.requiredBufferSize; + } + + // requiredBufferSize is with null terminator, but buffer is stored without null terminator. + // Determine if we have enough data to answer the call losslessly. + bool haveFullBuffer = (res.requiredBufferSize != UINT_MAX) && ((res.bufferSize + 1) >= res.requiredBufferSize); + if (!haveFullBuffer && (bufferSize > static_cast(res.bufferSize) + 1)) + { + LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (not enough buffer data for %s key %016llx)", name, handle); + } + + size_t bytesWritten = 0; + if ((buffer != nullptr) && (bufferSize > 0)) + { + char* storedBuffer = (char*)map->GetBuffer(res.buffer); + bytesWritten = min(bufferSize - 1, res.bufferSize); + memcpy(buffer, storedBuffer, bytesWritten); + buffer[bytesWritten] = '\0'; + } + + return bytesWritten; +} + +void MethodContext::recPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) +{ + recPrint("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize, bytesWritten); +} +void MethodContext::dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintResult& value) +{ + dmpPrint("PrintObjectDescription", PrintObjectDescription, key, value); +} +size_t MethodContext::repPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ + return repPrint("PrintObjectDescription", PrintObjectDescription, CastHandle(handle), buffer, bufferSize, pRequiredBufferSize); +} + void MethodContext::recPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) { - recPrintEntity("PrintClassName", PrintClassName, CastHandle(cls), buffer, bufferSize, pRequiredBufferSize, bytesWritten); + recPrint("PrintClassName", PrintClassName, CastHandle(cls), buffer, bufferSize, pRequiredBufferSize, bytesWritten); } -void MethodContext::dmpPrintClassName(DWORDLONG key, const Agnostic_PrintEntityResult& value) +void MethodContext::dmpPrintClassName(DWORDLONG key, const Agnostic_PrintResult& value) { - dmpPrintEntity("PrintClassName", PrintClassName, key, value); + dmpPrint("PrintClassName", PrintClassName, key, value); } size_t MethodContext::repPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { - return repPrintEntity("PrintClassName", PrintClassName, CastHandle(cls), buffer, bufferSize, pRequiredBufferSize); + return repPrint("PrintClassName", PrintClassName, CastHandle(cls), buffer, bufferSize, pRequiredBufferSize); +} + +void MethodContext::recPrintFieldName(CORINFO_FIELD_HANDLE fld, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) +{ + recPrint("PrintFieldName", PrintFieldName, CastHandle(fld), buffer, bufferSize, pRequiredBufferSize, bytesWritten); +} +void MethodContext::dmpPrintFieldName(DWORDLONG key, const Agnostic_PrintResult& value) +{ + dmpPrint("PrintFieldName", PrintFieldName, key, value); +} +size_t MethodContext::repPrintFieldName(CORINFO_FIELD_HANDLE fld, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ + return repPrint("PrintFieldName", PrintFieldName, CastHandle(fld), buffer, bufferSize, pRequiredBufferSize); +} + +void MethodContext::recPrintMethodName(CORINFO_METHOD_HANDLE meth, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten) +{ + recPrint("PrintMethodName", PrintMethodName, CastHandle(meth), buffer, bufferSize, pRequiredBufferSize, bytesWritten); +} +void MethodContext::dmpPrintMethodName(DWORDLONG key, const Agnostic_PrintResult& value) +{ + dmpPrint("PrintMethodName", PrintMethodName, key, value); +} +size_t MethodContext::repPrintMethodName(CORINFO_METHOD_HANDLE meth, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) +{ + return repPrint("PrintMethodName", PrintMethodName, CastHandle(meth), buffer, bufferSize, pRequiredBufferSize); } void MethodContext::recGetTailCallHelpers( diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 69e8636c47eb5..e9d7c43f31a0b 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -175,10 +175,6 @@ class MethodContext CORINFO_METHOD_HANDLE method, CORINFO_CONTEXT_HANDLE context); - void recGetMethodName(CORINFO_METHOD_HANDLE ftn, char* methodname, const char** moduleName); - void dmpGetMethodName(DLD key, DD value); - const char* repGetMethodName(CORINFO_METHOD_HANDLE ftn, const char** moduleName); - void recGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, char* methodname, const char** moduleName, @@ -616,10 +612,6 @@ class MethodContext CORINFO_CLASS_HANDLE* structType, CORINFO_CLASS_HANDLE memberParent); - void recGetFieldName(CORINFO_FIELD_HANDLE ftn, const char** moduleName, const char* result); - void dmpGetFieldName(DWORDLONG key, DD value); - const char* repGetFieldName(CORINFO_FIELD_HANDLE ftn, const char** moduleName); - void recCanInlineTypeCheck(CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source, CorInfoInlineTypeCheck result); @@ -638,31 +630,6 @@ class MethodContext void dmpGetStringLiteral(DLDDD key, DD value); int repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, char16_t* buffer, int bufferSize, int startIndex); - void recPrintEntity( - const char* name, - LightWeightMap*& map, - DWORDLONG handle, - char* buffer, - size_t bufferSize, - size_t* pRequiredBufferSize, - size_t bytesWritten); - void dmpPrintEntity( - const char* name, - LightWeightMapBuffer* buffer, - DWORDLONG key, - const Agnostic_PrintEntityResult& value); - size_t repPrintEntity( - const char* name, - LightWeightMap*& map, - DWORDLONG handle, - char* buffer, - size_t bufferSize, - size_t* pRequiredBufferSize); - - void recPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); - void dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintEntityResult& value); - size_t repPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); - void recGetHelperName(CorInfoHelpFunc funcNum, const char* result); void dmpGetHelperName(DWORD key, DWORD value); const char* repGetHelperName(CorInfoHelpFunc funcNum); @@ -846,10 +813,43 @@ class MethodContext void dmpGetTypeInstantiationArgument(DLD key, DWORDLONG value); CORINFO_CLASS_HANDLE repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index); + void recPrint( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize, + size_t bytesWritten); + void dmpPrint( + const char* name, + LightWeightMapBuffer* buffer, + DWORDLONG key, + const Agnostic_PrintResult& value); + size_t repPrint( + const char* name, + LightWeightMap*& map, + DWORDLONG handle, + char* buffer, + size_t bufferSize, + size_t* pRequiredBufferSize); + + void recPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); + void dmpPrintObjectDescription(DWORDLONG key, const Agnostic_PrintResult& value); + size_t repPrintObjectDescription(CORINFO_OBJECT_HANDLE handle, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize); + void recPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); - void dmpPrintClassName(DWORDLONG cls, const Agnostic_PrintEntityResult& value); + void dmpPrintClassName(DWORDLONG cls, const Agnostic_PrintResult& value); size_t repPrintClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize = nullptr); + void recPrintFieldName(CORINFO_FIELD_HANDLE fld, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); + void dmpPrintFieldName(DWORDLONG fld, const Agnostic_PrintResult& value); + size_t repPrintFieldName(CORINFO_FIELD_HANDLE fld, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize = nullptr); + + void recPrintMethodName(CORINFO_METHOD_HANDLE meth, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize, size_t bytesWritten); + void dmpPrintMethodName(DWORDLONG meth, const Agnostic_PrintResult& value); + size_t repPrintMethodName(CORINFO_METHOD_HANDLE meth, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize = nullptr); + void recGetTailCallHelpers( CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, @@ -969,10 +969,11 @@ enum mcPackets Packet_CanAccessClass = 3, Packet_CanAccessFamily = 4, Packet_CanCast = 5, + Packet_PrintMethodName = 6, Packet_CanGetCookieForPInvokeCalliSig = 7, Packet_CanGetVarArgsHandle = 8, Packet_CanInline = 9, - //Packet_CanInlineTypeCheckWithObjectVTable = 10, + Packet_PrintFieldName = 10, //Packet_CanSkipMethodVerification = 11, Packet_CanTailCall = 12, //Retired4 = 13, @@ -1018,7 +1019,6 @@ enum mcPackets Packet_GetFieldClass = 53, Packet_GetFieldInClass = 54, Packet_GetFieldInfo = 55, - Packet_GetFieldName = 56, Packet_GetFieldOffset = 57, Packet_GetFieldThreadLocalStoreID = 58, Packet_GetFieldType = 59, @@ -1037,7 +1037,6 @@ enum mcPackets Packet_GetMethodDefFromMethod = 72, Packet_GetMethodHash = 73, Packet_GetMethodInfo = 74, - Packet_GetMethodName = 75, Packet_GetMethodSig = 76, Packet_GetMethodSync = 77, Packet_GetMethodVTableOffset = 78, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp index 5f7fb2d19ef01..c6b7d0ae36e72 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp @@ -29,6 +29,21 @@ void interceptor_ICJC::finalizeAndCommitCollection(MethodContext* mc, CorJitResu mc->saveToFile(hFile); } +template +static void printInFull(TPrinter print) +{ + size_t requiredSize; + char buffer[256]; + print(buffer, sizeof(buffer), &requiredSize); + + if (requiredSize > sizeof(buffer)) + { + char* alloced = new char[requiredSize]; + print(alloced, requiredSize, nullptr); + delete[] alloced; + } +} + CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp, /* IN */ struct CORINFO_METHOD_INFO* info, /* IN */ unsigned /* code:CorJitFlag */ flags, /* IN */ @@ -75,8 +90,8 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp, our_ICorJitInfo.isValueClass(ourClass); our_ICorJitInfo.asCorInfoType(ourClass); - const char* className = nullptr; - our_ICorJitInfo.getMethodName(info->ftn, &className); + printInFull([&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { our_ICorJitInfo.printClassName(ourClass, buffer, bufferSize, requiredBufferSize); }); + printInFull([&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { our_ICorJitInfo.printMethodName(info->ftn, buffer, bufferSize, requiredBufferSize); }); #endif // Record data from the global context, if any From 0ca9cde87b03e254aeb85b3c59b71b425f93cb56 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 18:49:50 +0100 Subject: [PATCH 36/50] Unnecessary diff --- src/coreclr/vm/typeparse.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/vm/typeparse.cpp b/src/coreclr/vm/typeparse.cpp index 04dde98b5f66d..996d794385e57 100644 --- a/src/coreclr/vm/typeparse.cpp +++ b/src/coreclr/vm/typeparse.cpp @@ -1387,6 +1387,7 @@ TypeName::GetTypeHaveAssemblyHelper( } // TypeName::GetTypeHaveAssemblyHelper + DomainAssembly * LoadDomainAssembly( SString * psszAssemblySpec, Assembly * pRequestingAssembly, From 5e53677448d80392bd397fcecab014dbc1080be5 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 19:49:21 +0100 Subject: [PATCH 37/50] Run jit-format --- src/coreclr/jit/importercalls.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 03658cde25b29..eb2408c604ff0 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -213,7 +213,8 @@ var_types Compiler::impImportCall(OPCODE opcode, const char* className; const char* methodName = info.compCompHnd->getMethodNameFromMetadata(methHnd, &className, &namespaceName, nullptr); - if ((strcmp(namespaceName, "System.Runtime.CompilerServices") == 0) && + if ((namespaceName != nullptr) && (className != nullptr) && (methodName != nullptr) && + (strcmp(namespaceName, "System.Runtime.CompilerServices") == 0) && (strcmp(className, "JitTestLabel") == 0) && (strcmp(methodName, "Mark") == 0)) { return impImportJitTestLabelMark(sig->numArgs); From a5b7986951b9587017b8bca50d43344a85f95190 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 19:57:15 +0100 Subject: [PATCH 38/50] Avoid unnecessary diff 2 --- src/coreclr/vm/typeparse.cpp | 1 - src/coreclr/vm/typeparse.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/typeparse.cpp b/src/coreclr/vm/typeparse.cpp index 996d794385e57..04dde98b5f66d 100644 --- a/src/coreclr/vm/typeparse.cpp +++ b/src/coreclr/vm/typeparse.cpp @@ -1387,7 +1387,6 @@ TypeName::GetTypeHaveAssemblyHelper( } // TypeName::GetTypeHaveAssemblyHelper - DomainAssembly * LoadDomainAssembly( SString * psszAssemblySpec, Assembly * pRequestingAssembly, diff --git a/src/coreclr/vm/typeparse.h b/src/coreclr/vm/typeparse.h index e5cf7408ac076..8491e0deeb992 100644 --- a/src/coreclr/vm/typeparse.h +++ b/src/coreclr/vm/typeparse.h @@ -37,6 +37,7 @@ bool inline IsTypeNameReservedChar(WCHAR ch) } } + DomainAssembly * LoadDomainAssembly( SString * psszAssemblySpec, Assembly * pRequestingAssembly, From 2f93dcbca3ff44c633218a78d5024b3f2884b6af Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 20:04:14 +0100 Subject: [PATCH 39/50] Minor clean up for isEnum --- .../tools/superpmi/superpmi-shared/methodcontext.cpp | 7 ++----- src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h | 2 +- .../tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index ea4b80e3579ad..e65db072fe7a4 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -5748,7 +5748,7 @@ bool MethodContext::repIsMoreSpecificType(CORINFO_CLASS_HANDLE cls1, CORINFO_CLA return value != 0; } -void MethodContext::recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType, TypeCompareState result) +void MethodContext::recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE underlyingType, TypeCompareState result) { if (IsEnum == nullptr) IsEnum = new LightWeightMap(); @@ -5757,10 +5757,7 @@ void MethodContext::recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* un DLD value; ZeroMemory(&value, sizeof(value)); - if (underlyingType != nullptr) - value.A = CastHandle(*underlyingType); - else - value.A = 0; + value.A = CastHandle(underlyingType); value.B = (DWORD)result; IsEnum->Add(key, value); diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index e9d7c43f31a0b..be8dbc8f6898e 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -732,7 +732,7 @@ class MethodContext void dmpIsMoreSpecificType(DLDL key, DWORD value); bool repIsMoreSpecificType(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2); - void recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType, TypeCompareState result); + void recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE underlyingType, TypeCompareState result); void dmpIsEnum(DWORDLONG key, DLD value); TypeCompareState repIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index ba3bde9e949a5..1c9ca30ba3cfb 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -935,7 +935,7 @@ TypeCompareState interceptor_ICJI::isEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLAS mc->cr->AddCall("isEnum"); CORINFO_CLASS_HANDLE tempUnderlyingType = nullptr; TypeCompareState temp = original_ICorJitInfo->isEnum(cls, &tempUnderlyingType); - mc->recIsEnum(cls, &tempUnderlyingType, temp); + mc->recIsEnum(cls, tempUnderlyingType, temp); if (underlyingType != nullptr) { *underlyingType = tempUnderlyingType; From f8bac91d4f73b2ece8b0d4e247ca5930648c5b5b Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 20:05:45 +0100 Subject: [PATCH 40/50] Avoid another diff --- src/coreclr/jit/gentree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 065082dcb7716..1a0394ea69a44 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -11588,7 +11588,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) #if !defined(TARGET_64BIT) if (varTypeIsLong(varDsc)) { - fieldName = index == 0 ? "lo" : "hi"; + fieldName = (index == 0) ? "lo" : "hi"; } else #endif // !defined(TARGET_64BIT) From 2f215cb8072cf807fbe82a20ac60807f5c4cab23 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 20:07:43 +0100 Subject: [PATCH 41/50] Remove a couple more hackishX in favor of --- src/coreclr/jit/eeinterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 5bf0c102b5bb6..890a15ada45f5 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -569,7 +569,7 @@ const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer, if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) { printer.Truncate(0); - printer.Append("hackishClassName"); + printer.Append(""); } return printer.GetBuffer(); @@ -590,7 +590,7 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, false); })) { printer.Truncate(0); - printer.Append("hackishClassName"); + printer.Append(""); } return printer.GetBuffer(); From 79ed341ae014c197da1e5c9db93717d11457a9ef Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 20:09:00 +0100 Subject: [PATCH 42/50] More consistent buffer size --- src/coreclr/jit/lclvars.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 6baf04dc2f043..3f0809e782ebb 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -2415,7 +2415,7 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum) // Now grab the temp for the field local. #ifdef DEBUG - char fieldNameBuffer[64]; + char fieldNameBuffer[128]; const char* fieldName = compiler->eeGetFieldName(pFieldInfo->fldHnd, false, fieldNameBuffer, sizeof(fieldNameBuffer)); char buf[200]; From d88c2355e18b4ad1fe43b759ca9dc62e243748d2 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 20:12:52 +0100 Subject: [PATCH 43/50] GC_NOTRIGGER --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 7ebaf9b25b170..3dbff59b17a64 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -6367,7 +6367,7 @@ size_t CEEInfo::printMethodName(CORINFO_METHOD_HANDLE ftnHnd, char* buffer, size { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; MODE_PREEMPTIVE; } CONTRACTL_END; From 486a4fcc58cfc804cd140d94905a0df4a8038d8d Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 20:29:40 +0100 Subject: [PATCH 44/50] Remove getHelperName --- src/coreclr/inc/corinfo.h | 4 - src/coreclr/inc/icorjitinfoimpl_generated.h | 3 - src/coreclr/jit/ICorJitInfo_names_generated.h | 1 - .../jit/ICorJitInfo_wrapper_generated.hpp | 9 - .../tools/Common/JitInterface/CorInfoImpl.cs | 5 - .../JitInterface/CorInfoImpl_generated.cs | 236 ++++++++---------- .../ThunkGenerator/ThunkInput.txt | 1 - .../aot/jitinterface/jitinterface_generated.h | 10 - .../tools/superpmi/superpmi-shared/lwmlist.h | 1 - .../superpmi-shared/methodcontext.cpp | 39 --- .../superpmi/superpmi-shared/methodcontext.h | 5 - .../superpmi-shim-collector/icorjitinfo.cpp | 8 - .../icorjitinfo_generated.cpp | 7 - .../icorjitinfo_generated.cpp | 6 - .../tools/superpmi/superpmi/icorjitinfo.cpp | 6 - src/coreclr/vm/jitinterface.cpp | 25 -- 16 files changed, 110 insertions(+), 256 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 500b7cbd49408..9b0ad2b0c1826 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2514,10 +2514,6 @@ class ICorStaticInfo CORINFO_LOOKUP * pLookup ) = 0; - virtual const char* getHelperName( - CorInfoHelpFunc - ) = 0; - // This function tries to initialize the class (run the class constructor). // this function returns whether the JIT must insert helper calls before // accessing static field or method. diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index eda13303a780f..c912ee69d4c85 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -303,9 +303,6 @@ void getReadyToRunDelegateCtorHelper( CORINFO_CLASS_HANDLE delegateType, CORINFO_LOOKUP* pLookup) override; -const char* getHelperName( - CorInfoHelpFunc helpFunc) override; - CorInfoInitClassResult initClass( CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, diff --git a/src/coreclr/jit/ICorJitInfo_names_generated.h b/src/coreclr/jit/ICorJitInfo_names_generated.h index 79684bce3c013..1a6f869ba7052 100644 --- a/src/coreclr/jit/ICorJitInfo_names_generated.h +++ b/src/coreclr/jit/ICorJitInfo_names_generated.h @@ -75,7 +75,6 @@ DEF_CLR_API(isObjectImmutable) DEF_CLR_API(getObjectType) DEF_CLR_API(getReadyToRunHelper) DEF_CLR_API(getReadyToRunDelegateCtorHelper) -DEF_CLR_API(getHelperName) DEF_CLR_API(initClass) DEF_CLR_API(classMustBeLoadedBeforeCodeIsRun) DEF_CLR_API(getBuiltinClass) diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index 14935b6915adf..7bf0eb277a009 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -704,15 +704,6 @@ void WrapICorJitInfo::getReadyToRunDelegateCtorHelper( API_LEAVE(getReadyToRunDelegateCtorHelper); } -const char* WrapICorJitInfo::getHelperName( - CorInfoHelpFunc helpFunc) -{ - API_ENTER(getHelperName); - const char* temp = wrapHnd->getHelperName(helpFunc); - API_LEAVE(getHelperName); - return temp; -} - CorInfoInitClassResult WrapICorJitInfo::initClass( CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 6e2ea0012dd00..679eb13030bb0 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2360,11 +2360,6 @@ private CorInfoHelpFunc getUnBoxHelper(CORINFO_CLASS_STRUCT_* cls) return type.IsNullable ? CorInfoHelpFunc.CORINFO_HELP_UNBOX_NULLABLE : CorInfoHelpFunc.CORINFO_HELP_UNBOX; } - private byte* getHelperName(CorInfoHelpFunc helpFunc) - { - return (byte*)GetPin(StringToUTF8(helpFunc.ToString())); - } - private CorInfoInitClassResult initClass(CORINFO_FIELD_STRUCT_* field, CORINFO_METHOD_STRUCT_* method, CORINFO_CONTEXT_STRUCT* context) { FieldDesc fd = field == null ? null : HandleToObject(field); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index 26e52540226ba..65c17d7017293 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -1061,21 +1061,6 @@ private static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* } } - [UnmanagedCallersOnly] - private static byte* _getHelperName(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc helpFunc) - { - var _this = GetThis(thisHandle); - try - { - return _this.getHelperName(helpFunc); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - [UnmanagedCallersOnly] private static CorInfoInitClassResult _initClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_METHOD_STRUCT_* method, CORINFO_CONTEXT_STRUCT* context) { @@ -2685,7 +2670,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 181); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 180); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; @@ -2758,116 +2743,115 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[68] = (delegate* unmanaged)&_getObjectType; callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper; callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[71] = (delegate* unmanaged)&_getHelperName; - callbacks[72] = (delegate* unmanaged)&_initClass; - callbacks[73] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[74] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[77] = (delegate* unmanaged)&_canCast; - callbacks[78] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[79] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[80] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[81] = (delegate* unmanaged)&_mergeClasses; - callbacks[82] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[83] = (delegate* unmanaged)&_isEnum; - callbacks[84] = (delegate* unmanaged)&_getParentType; - callbacks[85] = (delegate* unmanaged)&_getChildType; - callbacks[86] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[87] = (delegate* unmanaged)&_isSDArray; - callbacks[88] = (delegate* unmanaged)&_getArrayRank; - callbacks[89] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[90] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[91] = (delegate* unmanaged)&_canAccessClass; - callbacks[92] = (delegate* unmanaged)&_printFieldName; - callbacks[93] = (delegate* unmanaged)&_getFieldClass; - callbacks[94] = (delegate* unmanaged)&_getFieldType; - callbacks[95] = (delegate* unmanaged)&_getFieldOffset; - callbacks[96] = (delegate* unmanaged)&_getFieldInfo; - callbacks[97] = (delegate* unmanaged)&_isFieldStatic; - callbacks[98] = (delegate* unmanaged)&_getArrayOrStringLength; - callbacks[99] = (delegate* unmanaged)&_getBoundaries; - callbacks[100] = (delegate* unmanaged)&_setBoundaries; - callbacks[101] = (delegate* unmanaged)&_getVars; - callbacks[102] = (delegate* unmanaged)&_setVars; - callbacks[103] = (delegate* unmanaged)&_reportRichMappings; - callbacks[104] = (delegate* unmanaged)&_allocateArray; - callbacks[105] = (delegate* unmanaged)&_freeArray; - callbacks[106] = (delegate* unmanaged)&_getArgNext; - callbacks[107] = (delegate* unmanaged)&_getArgType; - callbacks[108] = (delegate* unmanaged)&_getExactClasses; - callbacks[109] = (delegate* unmanaged)&_getArgClass; - callbacks[110] = (delegate* unmanaged)&_getHFAType; - callbacks[111] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[112] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[113] = (delegate* unmanaged)&_FilterException; - callbacks[114] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[115] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[116] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[117] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[118] = (delegate* unmanaged)&_getEEInfo; - callbacks[119] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[120] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[121] = (delegate* unmanaged)&_printMethodName; - callbacks[122] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[123] = (delegate* unmanaged)&_getMethodHash; - callbacks[124] = (delegate* unmanaged)&_findNameOfToken; - callbacks[125] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[126] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[128] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[129] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[130] = (delegate* unmanaged)&_getHelperFtn; - callbacks[131] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[132] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[133] = (delegate* unmanaged)&_getMethodSync; - callbacks[134] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[135] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[136] = (delegate* unmanaged)&_embedClassHandle; - callbacks[137] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[138] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[139] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[140] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[141] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[142] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[143] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[144] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[145] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[146] = (delegate* unmanaged)&_getCallInfo; - callbacks[147] = (delegate* unmanaged)&_canAccessFamily; - callbacks[148] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[149] = (delegate* unmanaged)&_getClassDomainID; - callbacks[150] = (delegate* unmanaged)&_getFieldAddress; - callbacks[151] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; - callbacks[152] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[153] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[154] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[155] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[156] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[157] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[158] = (delegate* unmanaged)&_addActiveDependency; - callbacks[159] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[160] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[161] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[162] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[163] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[164] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[165] = (delegate* unmanaged)&_allocMem; - callbacks[166] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[167] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[168] = (delegate* unmanaged)&_allocGCInfo; - callbacks[169] = (delegate* unmanaged)&_setEHcount; - callbacks[170] = (delegate* unmanaged)&_setEHinfo; - callbacks[171] = (delegate* unmanaged)&_logMsg; - callbacks[172] = (delegate* unmanaged)&_doAssert; - callbacks[173] = (delegate* unmanaged)&_reportFatalError; - callbacks[174] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[175] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[176] = (delegate* unmanaged)&_recordCallSite; - callbacks[177] = (delegate* unmanaged)&_recordRelocation; - callbacks[178] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[179] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[180] = (delegate* unmanaged)&_getJitFlags; + callbacks[71] = (delegate* unmanaged)&_initClass; + callbacks[72] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[73] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[76] = (delegate* unmanaged)&_canCast; + callbacks[77] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[78] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[79] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[80] = (delegate* unmanaged)&_mergeClasses; + callbacks[81] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[82] = (delegate* unmanaged)&_isEnum; + callbacks[83] = (delegate* unmanaged)&_getParentType; + callbacks[84] = (delegate* unmanaged)&_getChildType; + callbacks[85] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[86] = (delegate* unmanaged)&_isSDArray; + callbacks[87] = (delegate* unmanaged)&_getArrayRank; + callbacks[88] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[89] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[90] = (delegate* unmanaged)&_canAccessClass; + callbacks[91] = (delegate* unmanaged)&_printFieldName; + callbacks[92] = (delegate* unmanaged)&_getFieldClass; + callbacks[93] = (delegate* unmanaged)&_getFieldType; + callbacks[94] = (delegate* unmanaged)&_getFieldOffset; + callbacks[95] = (delegate* unmanaged)&_getFieldInfo; + callbacks[96] = (delegate* unmanaged)&_isFieldStatic; + callbacks[97] = (delegate* unmanaged)&_getArrayOrStringLength; + callbacks[98] = (delegate* unmanaged)&_getBoundaries; + callbacks[99] = (delegate* unmanaged)&_setBoundaries; + callbacks[100] = (delegate* unmanaged)&_getVars; + callbacks[101] = (delegate* unmanaged)&_setVars; + callbacks[102] = (delegate* unmanaged)&_reportRichMappings; + callbacks[103] = (delegate* unmanaged)&_allocateArray; + callbacks[104] = (delegate* unmanaged)&_freeArray; + callbacks[105] = (delegate* unmanaged)&_getArgNext; + callbacks[106] = (delegate* unmanaged)&_getArgType; + callbacks[107] = (delegate* unmanaged)&_getExactClasses; + callbacks[108] = (delegate* unmanaged)&_getArgClass; + callbacks[109] = (delegate* unmanaged)&_getHFAType; + callbacks[110] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[111] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[112] = (delegate* unmanaged)&_FilterException; + callbacks[113] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[114] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[115] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[116] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[117] = (delegate* unmanaged)&_getEEInfo; + callbacks[118] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[119] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[120] = (delegate* unmanaged)&_printMethodName; + callbacks[121] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[122] = (delegate* unmanaged)&_getMethodHash; + callbacks[123] = (delegate* unmanaged)&_findNameOfToken; + callbacks[124] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[125] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[126] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[127] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[128] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[129] = (delegate* unmanaged)&_getHelperFtn; + callbacks[130] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[131] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[132] = (delegate* unmanaged)&_getMethodSync; + callbacks[133] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[134] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[135] = (delegate* unmanaged)&_embedClassHandle; + callbacks[136] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[137] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[138] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[139] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[140] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[141] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[142] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[143] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[144] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[145] = (delegate* unmanaged)&_getCallInfo; + callbacks[146] = (delegate* unmanaged)&_canAccessFamily; + callbacks[147] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[148] = (delegate* unmanaged)&_getClassDomainID; + callbacks[149] = (delegate* unmanaged)&_getFieldAddress; + callbacks[150] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; + callbacks[151] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[152] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[153] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[154] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[155] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[156] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[157] = (delegate* unmanaged)&_addActiveDependency; + callbacks[158] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[159] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[160] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[161] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[162] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[163] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[164] = (delegate* unmanaged)&_allocMem; + callbacks[165] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[166] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[167] = (delegate* unmanaged)&_allocGCInfo; + callbacks[168] = (delegate* unmanaged)&_setEHcount; + callbacks[169] = (delegate* unmanaged)&_setEHinfo; + callbacks[170] = (delegate* unmanaged)&_logMsg; + callbacks[171] = (delegate* unmanaged)&_doAssert; + callbacks[172] = (delegate* unmanaged)&_reportFatalError; + callbacks[173] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[174] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[175] = (delegate* unmanaged)&_recordCallSite; + callbacks[176] = (delegate* unmanaged)&_recordRelocation; + callbacks[177] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[178] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[179] = (delegate* unmanaged)&_getJitFlags; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 78eecc913ca28..f8ec02914b2eb 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -227,7 +227,6 @@ FUNCTIONS CORINFO_CLASS_HANDLE getObjectType(CORINFO_OBJECT_HANDLE objPtr) bool getReadyToRunHelper(CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_LOOKUP_KIND * pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP *pLookup) void getReadyToRunDelegateCtorHelper(CORINFO_RESOLVED_TOKEN * pTargetMethod, mdToken targetConstraint, CORINFO_CLASS_HANDLE delegateType, CORINFO_LOOKUP *pLookup) - const char* getHelperName(CorInfoHelpFunc helpFunc) CorInfoInitClassResult initClass(CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, CORINFO_CONTEXT_HANDLE context) void classMustBeLoadedBeforeCodeIsRun(CORINFO_CLASS_HANDLE cls) CORINFO_CLASS_HANDLE getBuiltinClass(CorInfoClassId classId) diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index 068c7e298acc1..0688b6a9fa282 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -82,7 +82,6 @@ struct JitInterfaceCallbacks CORINFO_CLASS_HANDLE (* getObjectType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_OBJECT_HANDLE objPtr); bool (* getReadyToRunHelper)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup); void (* getReadyToRunDelegateCtorHelper)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pTargetMethod, unsigned int targetConstraint, CORINFO_CLASS_HANDLE delegateType, CORINFO_LOOKUP* pLookup); - const char* (* getHelperName)(void * thisHandle, CorInfoExceptionClass** ppException, CorInfoHelpFunc helpFunc); CorInfoInitClassResult (* initClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, CORINFO_CONTEXT_HANDLE context); void (* classMustBeLoadedBeforeCodeIsRun)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); CORINFO_CLASS_HANDLE (* getBuiltinClass)(void * thisHandle, CorInfoExceptionClass** ppException, CorInfoClassId classId); @@ -899,15 +898,6 @@ class JitInterfaceWrapper : public ICorJitInfo if (pException != nullptr) throw pException; } - virtual const char* getHelperName( - CorInfoHelpFunc helpFunc) -{ - CorInfoExceptionClass* pException = nullptr; - const char* temp = _callbacks->getHelperName(_thisHandle, &pException, helpFunc); - if (pException != nullptr) throw pException; - return temp; -} - virtual CorInfoInitClassResult initClass( CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index b171c1ad8e573..70361a38b29c5 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -90,7 +90,6 @@ LWM(GetFunctionEntryPoint, DLD, DLD) LWM(GetFunctionFixedEntryPoint, DWORDLONG, Agnostic_CORINFO_CONST_LOOKUP) LWM(GetGSCookie, DWORD, DLDL) LWM(GetHelperFtn, DWORD, DLDL) -LWM(GetHelperName, DWORD, DWORD) LWM(GetHFAType, DWORDLONG, DWORD) LWM(GetInlinedCallFrameVptr, DWORD, DLDL) LWM(GetIntConfigValue, Agnostic_ConfigIntInfo, DWORD) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index e65db072fe7a4..2702a33fd2b8f 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -4841,45 +4841,6 @@ int MethodContext::repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned me return srcBufferLength; } -void MethodContext::recGetHelperName(CorInfoHelpFunc funcNum, const char* result) -{ - if (GetHelperName == nullptr) - GetHelperName = new LightWeightMap(); - - DWORD value = (DWORD)-1; - if (result != nullptr) - value = (DWORD)GetHelperName->AddBuffer((unsigned char*)result, (DWORD)strlen(result) + 1); - - DWORD key = (DWORD)funcNum; - GetHelperName->Add(key, value); - DEBUG_REC(dmpGetHelperName(key, value)); -} -void MethodContext::dmpGetHelperName(DWORD key, DWORD value) -{ - printf("GetHelperName key ftn-%u, value '%s'", key, (const char*)GetHelperName->GetBuffer(value)); - GetHelperName->Unlock(); -} -const char* MethodContext::repGetHelperName(CorInfoHelpFunc funcNum) -{ - if (GetHelperName == nullptr) - return "Yickish helper name"; - - DWORD key = (DWORD)funcNum; - - int itemIndex = GetHelperName->GetIndex(key); - if (itemIndex < 0) - { - return "hackishHelperName"; - } - else - { - DWORD value = GetHelperName->Get(key); - DEBUG_REP(dmpGetHelperName(key, value)); - unsigned int buffIndex = (unsigned int)value; - return (const char*)GetHelperName->GetBuffer(buffIndex); - } -} - void MethodContext::recCanCast(CORINFO_CLASS_HANDLE child, CORINFO_CLASS_HANDLE parent, bool result) { if (CanCast == nullptr) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index be8dbc8f6898e..be1621f08dd53 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -630,10 +630,6 @@ class MethodContext void dmpGetStringLiteral(DLDDD key, DD value); int repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, char16_t* buffer, int bufferSize, int startIndex); - void recGetHelperName(CorInfoHelpFunc funcNum, const char* result); - void dmpGetHelperName(DWORD key, DWORD value); - const char* repGetHelperName(CorInfoHelpFunc funcNum); - void recCanCast(CORINFO_CLASS_HANDLE child, CORINFO_CLASS_HANDLE parent, bool result); void dmpCanCast(DLDL key, DWORD value); bool repCanCast(CORINFO_CLASS_HANDLE child, CORINFO_CLASS_HANDLE parent); @@ -1026,7 +1022,6 @@ enum mcPackets Packet_GetFunctionFixedEntryPoint = 61, Packet_GetGSCookie = 62, Packet_GetHelperFtn = 63, - Packet_GetHelperName = 64, Packet_GetInlinedCallFrameVptr = 65, Packet_GetArrayIntrinsicID = 66, Packet_GetJitTimeLogFilename = 67, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 1c9ca30ba3cfb..36933a56d3e6e 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -795,14 +795,6 @@ void interceptor_ICJI::getReadyToRunDelegateCtorHelper(CORINFO_RESOLVED_TOKEN* p mc->recGetReadyToRunDelegateCtorHelper(pTargetMethod, targetConstraint, delegateType, pLookup); } -const char* interceptor_ICJI::getHelperName(CorInfoHelpFunc funcNum) -{ - mc->cr->AddCall("getHelperName"); - const char* temp = original_ICorJitInfo->getHelperName(funcNum); - mc->recGetHelperName(funcNum, temp); - return temp; -} - // This function tries to initialize the class (run the class constructor). // this function returns whether the JIT must insert helper calls before // accessing static field or method. diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp index cc101731caa42..bdd5272db2017 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -578,13 +578,6 @@ void interceptor_ICJI::getReadyToRunDelegateCtorHelper( original_ICorJitInfo->getReadyToRunDelegateCtorHelper(pTargetMethod, targetConstraint, delegateType, pLookup); } -const char* interceptor_ICJI::getHelperName( - CorInfoHelpFunc helpFunc) -{ - mcs->AddCall("getHelperName"); - return original_ICorJitInfo->getHelperName(helpFunc); -} - CorInfoInitClassResult interceptor_ICJI::initClass( CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp index 7040aba565405..babddef2739ca 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -507,12 +507,6 @@ void interceptor_ICJI::getReadyToRunDelegateCtorHelper( original_ICorJitInfo->getReadyToRunDelegateCtorHelper(pTargetMethod, targetConstraint, delegateType, pLookup); } -const char* interceptor_ICJI::getHelperName( - CorInfoHelpFunc helpFunc) -{ - return original_ICorJitInfo->getHelperName(helpFunc); -} - CorInfoInitClassResult interceptor_ICJI::initClass( CORINFO_FIELD_HANDLE field, CORINFO_METHOD_HANDLE method, diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 16e1aa1448655..67f57d0c73c5f 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -672,12 +672,6 @@ void MyICJI::getReadyToRunDelegateCtorHelper(CORINFO_RESOLVED_TOKEN* pTargetMeth jitInstance->mc->repGetReadyToRunDelegateCtorHelper(pTargetMethod, targetConstraint, delegateType, pLookup); } -const char* MyICJI::getHelperName(CorInfoHelpFunc funcNum) -{ - jitInstance->mc->cr->AddCall("getHelperName"); - return jitInstance->mc->repGetHelperName(funcNum); -} - // This function tries to initialize the class (run the class constructor). // this function returns whether the JIT must insert helper calls before // accessing static field or method. diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 3dbff59b17a64..7159be1f1b13c 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3417,31 +3417,6 @@ void CEEInfo::ComputeRuntimeLookupForSharedGenericToken(DictionaryEntryKind entr } } -/***********************************************************************/ -const char* CEEInfo::getHelperName (CorInfoHelpFunc ftnNum) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - MODE_PREEMPTIVE; - PRECONDITION(ftnNum >= 0 && ftnNum < CORINFO_HELP_COUNT); - } CONTRACTL_END; - - const char* result = NULL; - - JIT_TO_EE_TRANSITION_LEAF(); - -#ifdef _DEBUG - result = hlpFuncTable[ftnNum].name; -#else - result = "AnyJITHelper"; -#endif - - EE_TO_JIT_TRANSITION_LEAF(); - - return result; -} - /*********************************************************************/ size_t CEEInfo::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize) { From b45f7dd421fbb7c4fff0bf020d4964b51131b832 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Sun, 13 Nov 2022 21:21:29 +0100 Subject: [PATCH 45/50] Few fixes --- src/coreclr/jit/eeinterface.cpp | 2 +- src/coreclr/jit/emit.cpp | 2 +- src/coreclr/jit/gentree.cpp | 6 ++++-- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 890a15ada45f5..92db15bb2380e 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -228,7 +228,7 @@ void Compiler::eePrintMethod(StringPrinter* printer, bool includeThisSpecifier) { CorInfoHelpFunc helper = eeGetHelperNum(methHnd); - if (helper == CORINFO_HELP_UNDEF) + if (helper != CORINFO_HELP_UNDEF) { assert(helper < CORINFO_HELP_COUNT); printer->Append(s_jitHelperNames[helper]); diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index dfea35387abe2..13dec732941d0 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -4066,7 +4066,7 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag { const char* methName = emitComp->eeGetMethodFullName(reinterpret_cast(cookie), true, true, buffer, sizeof(buffer)); - printf("%s code for %s", methName); + printf("%s code for %s", commentPrefix, methName); return; } diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 1a0394ea69a44..1a256129dc557 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -18302,9 +18302,11 @@ CORINFO_CLASS_HANDLE Compiler::gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldH if (queryForCurrentClass) { #if DEBUG - char buffer[128]; + char fieldNameBuffer[128]; + char classNameBuffer[128]; JITDUMP("Querying runtime about current class of field %s (declared as %s)\n", - eeGetFieldName(fieldHnd, true, buffer, sizeof(buffer))); + eeGetFieldName(fieldHnd, true, fieldNameBuffer, sizeof(fieldNameBuffer)), + eeGetClassName(fieldClass, classNameBuffer, sizeof(classNameBuffer))); #endif // DEBUG // Is this a fully initialized init-only static field? diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 679eb13030bb0..90e65c1cd0728 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1929,7 +1929,7 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) private nuint printClassName(CORINFO_CLASS_STRUCT_* cls, byte* buffer, nuint bufferSize, nuint* pRequiredBufferSize) { - var type = HandleToObject(cls); + TypeDesc type = HandleToObject(cls); string name = JitTypeNameFormatter.Instance.FormatName(type); return PrintFromUtf16(name, buffer, bufferSize, pRequiredBufferSize); } From a8d8be123f3062a2a361033473d8a5c78e5fbee8 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 14 Nov 2022 13:25:13 +0100 Subject: [PATCH 46/50] Handle a few more cases in JitTypeNameFormatter --- .../JitInterface/JitTypeNameFormatter.cs | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs index 8e1e66ecc1621..aa4a01615953b 100644 --- a/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs +++ b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs @@ -9,54 +9,70 @@ namespace Internal.JitInterface { // This is a very rough equivalent of typestring.cpp in the CLR used with - // FormatNamespace|FormatNoInst. This is currently only used for - // printClassName in the JIT-EE interface that is used for the various - // method set JIT variables (JitDisasm for example). The JIT handles - // formatting of most type names on its own so we only need the basics - // here. + // FormatNamespace|FormatNoInst, with some adjustments related to generic + // instantiations. This is currently only used for printClassName in the + // JIT-EE interface that is used for the various method set JIT variables + // (JitDisasm for example). internal sealed class JitTypeNameFormatter : TypeNameFormatter { public static JitTypeNameFormatter Instance { get; } = new JitTypeNameFormatter(); public override void AppendName(StringBuilder sb, PointerType type) { - Debug.Fail("Unexpected pointer type in JitTypeNameFormatter"); + AppendName(sb, type.ParameterType); + sb.Append('*'); } public override void AppendName(StringBuilder sb, GenericParameterDesc type) { - Debug.Fail("Unexpected generic parameter in JitTypeNameFormatter"); + Debug.Fail("Unexpected generic parameter type in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, SignatureTypeVariable type) { - Debug.Fail("Unexpected TVar in JitTypeNameFormatter"); + Debug.Fail("Unexpected signature type variable in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, SignatureMethodVariable type) { - Debug.Fail("Unexpected MVar in JitTypeNameFormatter"); + Debug.Fail("Unexpected signature method variable in JitTypeNameFormatter"); } public override void AppendName(StringBuilder sb, FunctionPointerType type) { - Debug.Fail("Unexpected function pointer type in JitTypeNameFormatter"); + MethodSignature signature = type.Signature; + + AppendName(sb, signature.ReturnType); + + sb.Append(" ("); + for (int i = 0; i < signature.Length; i++) + { + if (i > 0) + sb.Append(", "); + AppendName(sb, signature[i]); + } + + sb.Append(')'); } public override void AppendName(StringBuilder sb, ByRefType type) { - Debug.Fail("Unexpected ByRef type in JitTypeNameFormatter"); + AppendName(sb, type.ParameterType); + sb.Append('&'); } public override void AppendName(StringBuilder sb, ArrayType type) { - Debug.Fail("Unexpected array type in JitTypeNameFormatter"); + AppendName(sb, type.ElementType); + sb.Append('['); + sb.Append(',', type.Rank - 1); + sb.Append(']'); } protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType type) { AppendName(sb, type.GetTypeDefinition()); - // Instantiation itself is handled by JIT. + // Type name intentionally excludes instantiations. } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) From 2b7e2aea490e25cfd623c00ac3b0789495e6fb13 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 14 Nov 2022 19:16:17 +0100 Subject: [PATCH 47/50] Update src/coreclr/vm/jitinterface.cpp --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 7159be1f1b13c..3c7576a8478d2 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3512,7 +3512,7 @@ size_t CEEInfo::printClassName(CORINFO_CLASS_HANDLE cls, char* buffer, size_t bu if (pRequiredBufferSize != nullptr) { - *pRequiredBufferSize = requiredBufferSize; + *pRequiredBufferSize = requiredBufferSize + 1; } EE_TO_JIT_TRANSITION(); From 8c7a16c521737b636009c396ba35426a7fb07f7f Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Wed, 16 Nov 2022 11:47:00 +0100 Subject: [PATCH 48/50] Address feedback, remove outdated comment I forgot to remove in previous PR --- src/coreclr/inc/corinfo.h | 21 +++++++--- src/coreclr/jit/fginline.cpp | 7 ---- src/coreclr/tools/superpmi/mcs/verbildump.cpp | 10 +---- .../tools/superpmi/superpmi-shared/agnostic.h | 7 +++- .../superpmi/superpmi-shared/asmdumper.cpp | 4 +- .../superpmi/superpmi-shared/asmdumper.h | 1 + .../superpmi/superpmi-shared/callutils.cpp | 40 ++++-------------- .../superpmi-shared/methodcontext.cpp | 41 +++++++++++-------- .../superpmi/superpmi-shared/spmiutil.cpp | 35 ++++++++++++++++ .../tools/superpmi/superpmi-shared/spmiutil.h | 3 ++ .../icorjitcompiler.cpp | 5 +-- 11 files changed, 98 insertions(+), 76 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 9b0ad2b0c1826..37d33c9bb474e 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2275,14 +2275,23 @@ class ICorStaticInfo // // Arguments: // handle - Direct object handle - // buffer - Pointer to buffer - // bufferSize - Buffer size - // pRequiredBufferSize - Full length of the textual UTF8 representation, can be used to call this - // API again with a bigger buffer to get the full string if the first buffer - // from that first attempt was not big enough. + // buffer - Pointer to buffer. Can be nullptr. + // bufferSize - Buffer size (in bytes). + // pRequiredBufferSize - Full length of the textual UTF8 representation, in bytes. + // Includes the null terminator, so the value is always at least 1, + // where 1 indicates an empty string. + // Can be used to call this API again with a bigger buffer to get the full + // string. // // Return Value: - // Bytes written to the given buffer excluding the null terminator. The range is [0..bufferSize). + // Bytes written to the buffer, excluding the null terminator. The range is [0..bufferSize). + // If bufferSize is 0, returns 0. + // + // Remarks: + // buffer and bufferSize can be respectively nullptr and 0 to query just the required buffer size. + // + // If the return value is less than bufferSize - 1 then the full string was written. In this case + // it is guaranteed that return value == *pRequiredBufferSize - 1. // virtual size_t printObjectDescription ( CORINFO_OBJECT_HANDLE handle, /* IN */ diff --git a/src/coreclr/jit/fginline.cpp b/src/coreclr/jit/fginline.cpp index 9922e2cec437c..762f0c66c97e6 100644 --- a/src/coreclr/jit/fginline.cpp +++ b/src/coreclr/jit/fginline.cpp @@ -240,13 +240,6 @@ class SubstitutePlaceholdersAndDevirtualizeWalker : public GenTreeVisitorrepCompileMethod(&cmi, &flags, &os); - char methodName[256]; - mc->repPrintMethodName(cmi.ftn, methodName, sizeof(methodName)); - - char className[256]; - mc->repPrintClassName(mc->repGetMethodClass(cmi.ftn), className, sizeof(className)); - printf("// ProcessName - '%s'\n", mc->cr->repProcessName()); printf(".assembly extern mscorlib{}\n"); printf(".assembly dumped_asm\n"); - printf(".class %s\n", className); + printf(".class %s\n", getClassName(mc, mc->repGetMethodClass(cmi.ftn)).c_str()); printf("{\n"); printf(" .method "); DumpAttributeToConsoleBare(mc->repGetMethodAttribs(cmi.ftn)); DumpPrimToConsoleBare(mc, cmi.args.retType, CastHandle(cmi.args.retTypeClass)); - printf(" %s(", methodName); + printf(" %s(", getMethodName(mc, cmi.ftn).c_str()); DumpSigToConsoleBare(mc, &cmi.args); printf(")\n"); printf(" {\n"); diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index 75b5ba3239552..dd66096a5eded 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -778,8 +778,11 @@ struct Agnostic_PrintResult // Required size of a buffer to contain everything including null terminator. // UINT_MAX if it was not determined during recording. DWORD requiredBufferSize; - DWORD buffer; - DWORD bufferSize; + // Index of stored string buffer. We always store this without null terminator. + // May be UINT_MAX if no buffer was stored. + DWORD stringBuffer; + // The size of the buffer stored by stringBuffer. + DWORD stringBufferSize; }; #pragma pack(pop) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp b/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp index d0602431e52a9..9f7c5d8485c30 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.cpp @@ -20,10 +20,8 @@ void ASMDumper::DumpToFile(HANDLE hFile, MethodContext* mc, CompileResult* cr) buff_offset += sprintf_s(&buff[buff_offset], bufflen - buff_offset, ";;Generated from SuperPMI on original input '%s'", cr->repProcessName()); - char methodName[256]; - mc->repPrintMethodName(info.ftn, methodName, sizeof(methodName)); buff_offset += sprintf_s(&buff[buff_offset], bufflen - buff_offset, "\r\n Method Name \"%s\"", - methodName); + getMethodName(mc, info.ftn).c_str()); WriteFile(hFile, buff, buff_offset * sizeof(char), &bytesWritten, nullptr); ULONG hotCodeSize; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.h b/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.h index e1f6cd0952276..90af3ef16febf 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/asmdumper.h @@ -6,6 +6,7 @@ #include "methodcontext.h" #include "compileresult.h" +#include "spmiutil.h" class ASMDumper { diff --git a/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp b/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp index aaad597f9b575..2f026c54cff72 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp @@ -227,22 +227,16 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL return kHelperName[GetHelperNum(hnd)]; } - char classNameBuffer[256]; - char methodNameBuffer[256]; - - const char* className = "CLASS"; - const char* methodName = "METHOD"; + std::string className = "CLASS"; + std::string methodName = "METHOD"; if (!ignoreMethodName) { - mc->repPrintClassName(mc->repGetMethodClass(hnd), classNameBuffer, sizeof(classNameBuffer)); - mc->repPrintMethodName(hnd, methodNameBuffer, sizeof(methodNameBuffer)); - - className = classNameBuffer; - methodName = methodNameBuffer; + className = getClassName(mc, mc->repGetMethodClass(hnd)); + methodName = getMethodName(mc, hnd); } - size_t length = 0; + size_t length = className.size(); unsigned i; /* Generating the full signature is a two-pass process. First we have to walk @@ -254,17 +248,8 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL /* initialize length with length of className and '.' */ - if (className != nullptr) - length = strlen(className) + 1; - else - { - // Tweaked to avoid using CRT assertions - Assert(strlen(".") == 7); - length = 7; - } - /* add length of methodName and opening bracket */ - length += strlen(methodName) + 1; + length += methodName.size() + 1; CORINFO_ARG_LIST_HANDLE argList = sig.args; @@ -308,17 +293,10 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL /* Now generate the full signature string in the allocated buffer */ - if (className) - { - strcpy_s(retName, length, className); - strcat_s(retName, length, ":"); - } - else - { - strcpy_s(retName, length, "."); - } + strcpy_s(retName, length, className.c_str()); + strcat_s(retName, length, ":"); - strcat_s(retName, length, methodName); + strcat_s(retName, length, methodName.c_str()); // append the signature strcat_s(retName, length, "("); diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 2702a33fd2b8f..e3267b4d0257c 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -6479,33 +6479,33 @@ void MethodContext::recPrint( res.requiredBufferSize = requiredBufferSize; } - if (bytesWritten > res.bufferSize) + if (bytesWritten > res.stringBufferSize) { // Always stored without null terminator. - res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); - res.bufferSize = (UINT)bytesWritten; + res.stringBuffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + res.stringBufferSize = (UINT)bytesWritten; } map->Update(index, res); - dmpPrint(name, map, handle, res); + DEBUG_REC(dmpPrint(name, map, handle, res)); return; } if (buffer != nullptr) { - res.buffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); + res.stringBuffer = map->AddBuffer((unsigned char*)buffer, static_cast(bytesWritten)); } else { - res.buffer = UINT_MAX; + res.stringBuffer = UINT_MAX; } - res.bufferSize = (UINT)bytesWritten; + res.stringBufferSize = (UINT)bytesWritten; res.requiredBufferSize = requiredBufferSize; map->Add(handle, res); - dmpPrint(name, map, handle, res); + DEBUG_REC(dmpPrint(name, map, handle, res)); } void MethodContext::dmpPrint( @@ -6514,7 +6514,7 @@ void MethodContext::dmpPrint( DWORDLONG key, const Agnostic_PrintResult& value) { - printf("%s key hnd-%016llX, bufferSize-%u, requiredBufferSize-%u", name, key, value.bufferSize, value.requiredBufferSize); + printf("%s key hnd-%016llX, stringBufferSize-%u, requiredBufferSize-%u", name, key, value.stringBufferSize, value.requiredBufferSize); buffer->Unlock(); } @@ -6541,10 +6541,13 @@ size_t MethodContext::repPrint( *pRequiredBufferSize = res.requiredBufferSize; } - // requiredBufferSize is with null terminator, but buffer is stored without null terminator. - // Determine if we have enough data to answer the call losslessly. - bool haveFullBuffer = (res.requiredBufferSize != UINT_MAX) && ((res.bufferSize + 1) >= res.requiredBufferSize); - if (!haveFullBuffer && (bufferSize > static_cast(res.bufferSize) + 1)) + // requiredBufferSize is with null terminator, but buffer is stored without + // null terminator. Determine if we have enough data to answer the query + // losslessly. + // Note that requiredBufferSize is always set by recording side if we had + // enough information to determine it. + bool haveFullBuffer = (res.requiredBufferSize != UINT_MAX) && ((res.stringBufferSize + 1) >= res.requiredBufferSize); + if (!haveFullBuffer && (bufferSize > static_cast(res.stringBufferSize) + 1)) { LogException(EXCEPTIONCODE_MC, "SuperPMI assertion failed (not enough buffer data for %s key %016llx)", name, handle); } @@ -6552,9 +6555,15 @@ size_t MethodContext::repPrint( size_t bytesWritten = 0; if ((buffer != nullptr) && (bufferSize > 0)) { - char* storedBuffer = (char*)map->GetBuffer(res.buffer); - bytesWritten = min(bufferSize - 1, res.bufferSize); - memcpy(buffer, storedBuffer, bytesWritten); + bytesWritten = min(bufferSize - 1, res.stringBufferSize); + if (bytesWritten > 0) + { + // The "full buffer" check above ensures this given that + // res.stringBuffer == UINT_MAX implies res.stringBufferSize == 0. + Assert(res.stringBuffer != UINT_MAX); + char* storedBuffer = (char*)map->GetBuffer(res.stringBuffer); + memcpy(buffer, storedBuffer, bytesWritten); + } buffer[bytesWritten] = '\0'; } diff --git a/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.cpp b/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.cpp index 034e309634ebd..f80956305e2c3 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.cpp @@ -378,3 +378,38 @@ void PutArm64MovkConstant(UINT32* p, unsigned con) { *p = (*p & ~(0xffff << 5)) | ((con & 0xffff) << 5); } + +template +static std::string getFromPrinter(TPrint print) +{ + char buffer[256]; + + size_t requiredBufferSize; + print(buffer, sizeof(buffer), &requiredBufferSize); + + if (requiredBufferSize <= sizeof(buffer)) + { + return std::string(buffer); + } + else + { + std::vector vec(requiredBufferSize); + size_t printed = print(vec.data(), requiredBufferSize, nullptr); + assert(printed == requiredBufferSize - 1); + return std::string(vec.data()); + } +} + +std::string getMethodName(MethodContext* mc, CORINFO_METHOD_HANDLE methHnd) +{ + return getFromPrinter([&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return mc->repPrintMethodName(methHnd, buffer, bufferSize, requiredBufferSize); + }); +} + +std::string getClassName(MethodContext* mc, CORINFO_CLASS_HANDLE clsHnd) +{ + return getFromPrinter([&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return mc->repPrintClassName(clsHnd, buffer, bufferSize, requiredBufferSize); + }); +} diff --git a/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.h b/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.h index f414e9be3623c..a8ea81c21c527 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/spmiutil.h @@ -93,4 +93,7 @@ inline constexpr unsigned ArrLen(T (&)[size]) return size; } +std::string getMethodName(MethodContext* mc, CORINFO_METHOD_HANDLE methHnd); +std::string getClassName(MethodContext* mc, CORINFO_CLASS_HANDLE clsHnd); + #endif // !_SPMIUtil diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp index c6b7d0ae36e72..0ef956bd62787 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp @@ -38,9 +38,8 @@ static void printInFull(TPrinter print) if (requiredSize > sizeof(buffer)) { - char* alloced = new char[requiredSize]; - print(alloced, requiredSize, nullptr); - delete[] alloced; + std::vector vec(requiredSize); + print(vec.data(), requiredSize, nullptr); } } From 65c06f742841083c4c0615133f40284bd38428c3 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Wed, 16 Nov 2022 12:01:33 +0100 Subject: [PATCH 49/50] Address some more feedback --- src/coreclr/jit/compiler.h | 2 + src/coreclr/jit/eeinterface.cpp | 80 +++++++++++++++------------------ 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 9c2c25af10a5a..8e2b4f55712d3 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7588,6 +7588,8 @@ class Compiler var_types eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd, CORINFO_CLASS_HANDLE* pStructHnd = nullptr); + template + void eeAppendPrint(class StringPrinter* printer, TPrint print); // Conventions: the "base" primitive printing functions take StringPrinter* // and do not do any SPMI handling. There are then convenience printing // functions exposed on top that have SPMI handling and additional buffer diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 92db15bb2380e..d9852afb9e537 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -93,6 +93,34 @@ void Compiler::eePrintJitType(StringPrinter* printer, var_types jitType) printer->Append(varTypeName(jitType)); } +//------------------------------------------------------------------------ +// eeAppendPrint: +// Append the output of one of the JIT-EE 'print' functions to a StringPrinter. +// +// Arguments: +// printer - the printer +// print - A functor to print the string that follows the conventions of the JIT-EE print* functions. +// +template +void Compiler::eeAppendPrint(StringPrinter* printer, TPrint print) +{ + size_t requiredBufferSize; + char buffer[256]; + size_t printed = print(buffer, sizeof(buffer), &requiredBufferSize); + if (requiredBufferSize <= sizeof(buffer)) + { + assert(printed == requiredBufferSize - 1); + printer->Append(buffer); + } + else + { + char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; + printed = print(pBuffer, requiredBufferSize, nullptr); + assert(printed == requiredBufferSize - 1); + printer->Append(pBuffer); + } +} + //------------------------------------------------------------------------ // eePrintType: // Print a type given by a class handle. @@ -128,23 +156,9 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, return; } - size_t requiredBufferSize; - char buffer[256]; - size_t writtenBytes = info.compCompHnd->printClassName(clsHnd, buffer, sizeof(buffer), &requiredBufferSize); - if (writtenBytes <= 0) - { - printer->Append(""); - } - else if (requiredBufferSize <= sizeof(buffer)) - { - printer->Append(buffer); - } - else - { - char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; - info.compCompHnd->printClassName(clsHnd, pBuffer, requiredBufferSize); - printer->Append(pBuffer); - } + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return info.compCompHnd->printClassName(clsHnd, buffer, bufferSize, requiredBufferSize); + }); if (!includeInstantiation) { @@ -241,19 +255,9 @@ void Compiler::eePrintMethod(StringPrinter* printer, printer->Append(':'); } - size_t requiredBufferSize; - char buffer[256]; - info.compCompHnd->printMethodName(methHnd, buffer, sizeof(buffer), &requiredBufferSize); - if (sizeof(buffer) <= requiredBufferSize) - { - printer->Append(buffer); - } - else - { - char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; - info.compCompHnd->printMethodName(methHnd, pBuffer, requiredBufferSize); - printer->Append(pBuffer); - } + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return info.compCompHnd->printMethodName(methHnd, buffer, bufferSize, requiredBufferSize); + }); if (includeMethodInstantiation && (sig->sigInst.methInstCount > 0)) { @@ -360,19 +364,9 @@ void Compiler::eePrintField(StringPrinter* printer, CORINFO_FIELD_HANDLE fld, bo printer->Append(':'); } - size_t requiredBufferSize; - char buffer[256]; - info.compCompHnd->printFieldName(fld, buffer, sizeof(buffer), &requiredBufferSize); - if (sizeof(buffer) <= requiredBufferSize) - { - printer->Append(buffer); - } - else - { - char* pBuffer = new (this, CMK_DebugOnly) char[requiredBufferSize]; - info.compCompHnd->printFieldName(fld, pBuffer, requiredBufferSize); - printer->Append(pBuffer); - } + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return info.compCompHnd->printFieldName(fld, buffer, bufferSize, requiredBufferSize); + }); } //------------------------------------------------------------------------ From 9aa933c605cb206de15a5e10606144eba0a0a82a Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Wed, 16 Nov 2022 16:34:09 +0100 Subject: [PATCH 50/50] Small fix --- src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp b/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp index 2f026c54cff72..79778bf508493 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/callutils.cpp @@ -236,7 +236,8 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL methodName = getMethodName(mc, hnd); } - size_t length = className.size(); + // Class name and colon + size_t length = className.size() + 1; unsigned i; /* Generating the full signature is a two-pass process. First we have to walk