Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JIT<->EE printing methods consistent and support nested classes when printing class names #76505

Merged
merged 53 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5c25688
Clean up JIT<->EE "get class name" methods
jakobbotsch Oct 2, 2022
a176df0
Further cleanups/fixes
jakobbotsch Oct 2, 2022
3bfb46f
Run jit-format
jakobbotsch Oct 2, 2022
e8fa31d
Revert TypeString removal
jakobbotsch Oct 2, 2022
42501aa
Use getTypeForPrimitiveNumericClass instead
jakobbotsch Oct 2, 2022
70d4370
Nit
jakobbotsch Oct 2, 2022
e7d0aa9
Fix unsupported test
jakobbotsch Oct 2, 2022
fcb4cc3
Address feedback
jakobbotsch Oct 3, 2022
0449899
Remove leftover file
jakobbotsch Oct 3, 2022
04def1f
Fix test failure
jakobbotsch Oct 3, 2022
70866d0
Optimize
jakobbotsch Oct 4, 2022
9b29a16
Remove StringPrinter::Grow
jakobbotsch Oct 4, 2022
9bc6620
Fix contract, fix compiler error on x64
jakobbotsch Oct 4, 2022
ffaf9a4
Fix escaping
jakobbotsch Oct 4, 2022
0f37c4e
Fix GCC build
jakobbotsch Oct 4, 2022
77e799a
Clarify comment
jakobbotsch Oct 4, 2022
0b58859
Avoid unnecessary eeGetMethodName call
jakobbotsch Oct 4, 2022
b987608
Nit
jakobbotsch Oct 4, 2022
17388ed
Remove StringPrinter::Printf in favor of Append
jakobbotsch Oct 4, 2022
08a63d9
Run jit-format
jakobbotsch Oct 4, 2022
c59ec3f
Merge branch 'main' of github.com:dotnet/runtime into print-nested-cl…
jakobbotsch Oct 8, 2022
37f5cfa
Fix build
jakobbotsch Oct 8, 2022
539162c
appendClassName -> printClassName
jakobbotsch Oct 8, 2022
f385851
Merge branch 'main' of github.com:dotnet/runtime into print-nested-cl…
jakobbotsch Nov 13, 2022
f1d6112
Fix build after merge
jakobbotsch Nov 13, 2022
2a76d18
Remove escaping type names complication
jakobbotsch Nov 13, 2022
b8a0573
Nit
jakobbotsch Oct 8, 2022
e753c23
Factor PrintFromUtf16
jakobbotsch Oct 8, 2022
f61fc18
Remove unnecessary function
jakobbotsch Oct 8, 2022
e16357b
Fix missing write
jakobbotsch Oct 8, 2022
62c2622
Work on switching getMethodName and getFieldName to print
jakobbotsch Oct 8, 2022
f5447b3
More work
jakobbotsch Oct 10, 2022
d9643e1
Fix bad merge
jakobbotsch Nov 13, 2022
8a2368e
Fix bad merge
jakobbotsch Nov 13, 2022
d0c4b9f
Update for consistency, builds again
jakobbotsch Nov 13, 2022
fea3eec
Run jit-format
jakobbotsch Nov 13, 2022
8b9d371
SPMI related fixes
jakobbotsch Nov 13, 2022
0ca9cde
Unnecessary diff
jakobbotsch Nov 13, 2022
5e53677
Run jit-format
jakobbotsch Nov 13, 2022
a5b7986
Avoid unnecessary diff 2
jakobbotsch Nov 13, 2022
2f93dcb
Minor clean up for isEnum
jakobbotsch Nov 13, 2022
f8bac91
Avoid another diff
jakobbotsch Nov 13, 2022
2f215cb
Remove a couple more hackishX in favor of <unknown X>
jakobbotsch Nov 13, 2022
79ed341
More consistent buffer size
jakobbotsch Nov 13, 2022
d88c235
GC_NOTRIGGER
jakobbotsch Nov 13, 2022
486a4fc
Remove getHelperName
jakobbotsch Nov 13, 2022
b45f7dd
Few fixes
jakobbotsch Nov 13, 2022
6676673
Merge branch 'main' of github.com:dotnet/runtime into print-nested-cl…
jakobbotsch Nov 14, 2022
a8d8be1
Handle a few more cases in JitTypeNameFormatter
jakobbotsch Nov 14, 2022
2b7e2ae
Update src/coreclr/vm/jitinterface.cpp
jakobbotsch Nov 14, 2022
8c7a16c
Address feedback, remove outdated comment I forgot to remove in previ…
jakobbotsch Nov 16, 2022
65c06f7
Address some more feedback
jakobbotsch Nov 16, 2022
9aa933c
Small fix
jakobbotsch Nov 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/coreclr/gcinfo/gcinfoencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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


///////////////////////////////////////////////////////////////////////
Expand Down
105 changes: 37 additions & 68 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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 */
Expand All @@ -2303,11 +2312,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 (
Expand All @@ -2322,40 +2326,14 @@ class ICorStaticInfo
unsigned index
) = 0;

// Append a (possibly truncated) textual representation of the type `cls` to a preallocated buffer.
//
// 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
// 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.
//
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
// 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 */
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.
Expand Down Expand Up @@ -2545,10 +2523,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.
Expand Down Expand Up @@ -2701,12 +2675,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
Expand Down Expand Up @@ -2962,19 +2936,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
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/inc/gcinfoencoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 13 additions & 17 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ size_t printObjectDescription(
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;
Expand All @@ -196,13 +193,11 @@ CORINFO_CLASS_HANDLE getTypeInstantiationArgument(
CORINFO_CLASS_HANDLE cls,
unsigned index) override;

int appendClassName(
char16_t** ppBuf,
int* pnBufLen,
size_t printClassName(
CORINFO_CLASS_HANDLE cls,
bool fNamespace,
bool fFullInst,
bool fAssembly) override;
char* buffer,
size_t bufferSize,
size_t* pRequiredBufferSize) override;

bool isValueClass(
CORINFO_CLASS_HANDLE cls) override;
Expand Down Expand Up @@ -308,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,
Expand Down Expand Up @@ -384,9 +376,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;
Expand Down Expand Up @@ -497,9 +491,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,
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* e3c98d96-6e67-459a-9750-ebe799cfb788 */
0xe3c98d96,
0x6e67,
0x459a,
{0x97, 0x50, 0xeb, 0xe7, 0x99, 0xcf, 0xb7, 0x88}
constexpr GUID JITEEVersionIdentifier = { /* 1e794e80-ec63-4d7a-b11f-fcda6e7fe4f4 */
0x1e794e80,
0xec63,
0x4d7a,
{0xb1, 0x1f, 0xfc, 0xda, 0x6e, 0x7f, 0xe4, 0xf4}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 3 additions & 5 deletions src/coreclr/jit/ICorJitInfo_names_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ DEF_CLR_API(isValidStringRef)
DEF_CLR_API(getStringLiteral)
DEF_CLR_API(printObjectDescription)
DEF_CLR_API(asCorInfoType)
DEF_CLR_API(getClassName)
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)
Expand Down Expand Up @@ -76,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)
Expand All @@ -97,7 +95,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)
Expand Down Expand Up @@ -126,7 +124,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)
Expand Down
Loading