Skip to content

Commit

Permalink
Display names of handles in dumps (#97573)
Browse files Browse the repository at this point in the history
For class/method/field handles, display their name in dumps
in addition to their handle value.

Also fixes a problem in assertion prop dumping where 64-bit class
handle constants were truncated to 32-bit in dump.
  • Loading branch information
BruceForstall authored Feb 12, 2024
1 parent bc852d7 commit b1d7ad6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,12 +856,13 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse
case O2K_IND_CNS_INT:
if (curAssertion->op1.kind == O1K_EXACT_TYPE)
{
printf("Exact Type MT(%08X)", dspPtr(curAssertion->op2.u1.iconVal));
assert(curAssertion->op2.HasIconFlag());
ssize_t iconVal = curAssertion->op2.u1.iconVal;
printf("Exact Type MT(0x%p %s)", dspPtr(iconVal), eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
}
else if (curAssertion->op1.kind == O1K_SUBTYPE)
{
printf("MT(%08X)", dspPtr(curAssertion->op2.u1.iconVal));
ssize_t iconVal = curAssertion->op2.u1.iconVal;
printf("MT(0x%p %s)", dspPtr(iconVal), eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
assert(curAssertion->op2.HasIconFlag());
}
else if ((curAssertion->op1.kind == O1K_BOUND_OPER_BND) ||
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12031,12 +12031,12 @@ void Compiler::gtDispConst(GenTree* tree)
}
else
{
ssize_t dspIconVal =
tree->IsIconHandle() ? dspPtr(tree->AsIntCon()->gtIconVal) : tree->AsIntCon()->gtIconVal;
ssize_t iconVal = tree->AsIntCon()->gtIconVal;
ssize_t dspIconVal = tree->IsIconHandle() ? dspPtr(iconVal) : iconVal;

if (tree->TypeGet() == TYP_REF)
{
if (tree->AsIntCon()->gtIconVal == 0)
if (iconVal == 0)
{
printf(" null");
}
Expand All @@ -12046,12 +12046,12 @@ void Compiler::gtDispConst(GenTree* tree)
printf(" 0x%llx", dspIconVal);
}
}
else if ((tree->AsIntCon()->gtIconVal > -1000) && (tree->AsIntCon()->gtIconVal < 1000))
else if ((iconVal > -1000) && (iconVal < 1000))
{
printf(" %ld", dspIconVal);
}
#ifdef TARGET_64BIT
else if ((tree->AsIntCon()->gtIconVal & 0xFFFFFFFF00000000LL) != 0)
else if ((iconVal & 0xFFFFFFFF00000000LL) != 0)
{
if (dspIconVal >= 0)
{
Expand Down Expand Up @@ -12083,13 +12083,13 @@ void Compiler::gtDispConst(GenTree* tree)
printf(" scope");
break;
case GTF_ICON_CLASS_HDL:
printf(" class");
printf(" class %s", eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
break;
case GTF_ICON_METHOD_HDL:
printf(" method");
printf(" method %s", eeGetMethodFullName((CORINFO_METHOD_HANDLE)iconVal));
break;
case GTF_ICON_FIELD_HDL:
printf(" field");
printf(" field %s", eeGetFieldName((CORINFO_FIELD_HANDLE)iconVal, true));
break;
case GTF_ICON_STATIC_HDL:
printf(" static");
Expand Down
14 changes: 14 additions & 0 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9006,6 +9006,20 @@ void ValueNumStore::vnDump(Compiler* comp, ValueNum vn, bool isPtr)
ssize_t val = ConstantValue<ssize_t>(vn);
const GenTreeFlags handleFlags = GetHandleFlags(vn);
printf("Hnd const: 0x%p %s", dspPtr(val), GenTree::gtGetHandleKindString(handleFlags));
switch (handleFlags & GTF_ICON_HDL_MASK)
{
case GTF_ICON_CLASS_HDL:
printf(" %s", comp->eeGetClassName((CORINFO_CLASS_HANDLE)val));
break;
case GTF_ICON_METHOD_HDL:
printf(" %s", comp->eeGetMethodFullName((CORINFO_METHOD_HANDLE)val));
break;
case GTF_ICON_FIELD_HDL:
printf(" %s", comp->eeGetFieldName((CORINFO_FIELD_HANDLE)val, true));
break;
default:
break;
}
}
else if (IsVNConstant(vn))
{
Expand Down

0 comments on commit b1d7ad6

Please sign in to comment.