Skip to content

Commit

Permalink
Fix handle dumping for AOT scenarios (#98728)
Browse files Browse the repository at this point in the history
Revert #97573 to previous behavior (not dumping handle strings) for
NativeAOT and R2R compiles; those require more work to find the
handle to use.
  • Loading branch information
BruceForstall authored Feb 21, 2024
1 parent cefd1a7 commit 96bee8d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
19 changes: 17 additions & 2 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,27 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse
if (curAssertion->op1.kind == O1K_EXACT_TYPE)
{
ssize_t iconVal = curAssertion->op2.u1.iconVal;
printf("Exact Type MT(0x%p %s)", dspPtr(iconVal), eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
{
printf("Exact Type MT(0x%p)", dspPtr(iconVal));
}
else
{
printf("Exact Type MT(0x%p %s)", dspPtr(iconVal),
eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
}
}
else if (curAssertion->op1.kind == O1K_SUBTYPE)
{
ssize_t iconVal = curAssertion->op2.u1.iconVal;
printf("MT(0x%p %s)", dspPtr(iconVal), eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
{
printf("MT(0x%p)", dspPtr(iconVal));
}
else
{
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
27 changes: 24 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12172,13 +12172,34 @@ void Compiler::gtDispConst(GenTree* tree)
printf(" scope");
break;
case GTF_ICON_CLASS_HDL:
printf(" class %s", eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
{
printf(" class");
}
else
{
printf(" class %s", eeGetClassName((CORINFO_CLASS_HANDLE)iconVal));
}
break;
case GTF_ICON_METHOD_HDL:
printf(" method %s", eeGetMethodFullName((CORINFO_METHOD_HANDLE)iconVal));
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
{
printf(" method");
}
else
{
printf(" method %s", eeGetMethodFullName((CORINFO_METHOD_HANDLE)iconVal));
}
break;
case GTF_ICON_FIELD_HDL:
printf(" field %s", eeGetFieldName((CORINFO_FIELD_HANDLE)iconVal, true));
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
{
printf(" field");
}
else
{
printf(" field %s", eeGetFieldName((CORINFO_FIELD_HANDLE)iconVal, true));
}
break;
case GTF_ICON_STATIC_HDL:
printf(" static");
Expand Down
27 changes: 15 additions & 12 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9082,19 +9082,22 @@ 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)
if (!comp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) && !comp->opts.IsReadyToRun())
{
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;
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 96bee8d

Please sign in to comment.