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

JIT: enable GDV when static class deduction fails. #55660

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Changes from all commits
Commits
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
28 changes: 20 additions & 8 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20935,25 +20935,37 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
return;
}

// Fetch information about the class that introduced the virtual method.
CORINFO_CLASS_HANDLE baseClass = info.compCompHnd->getMethodClass(baseMethod);
const DWORD baseClassAttribs = info.compCompHnd->getClassAttribs(baseClass);

// Is the call an interface call?
const bool isInterface = (baseClassAttribs & CORINFO_FLG_INTERFACE) != 0;

// See what we know about the type of 'this' in the call.
GenTree* thisObj = call->gtCallThisArg->GetNode()->gtEffectiveVal(false);
bool isExact = false;
bool objIsNonNull = false;
CORINFO_CLASS_HANDLE objClass = gtGetClassHandle(thisObj, &isExact, &objIsNonNull);

// Bail if we know nothing.
if (objClass == nullptr)
if (objClass == NO_CLASS_HANDLE)
{
JITDUMP("\nimpDevirtualizeCall: no type available (op=%s)\n", GenTree::OpName(thisObj->OperGet()));
return;
}

// Fetch information about the class that introduced the virtual method.
CORINFO_CLASS_HANDLE baseClass = info.compCompHnd->getMethodClass(baseMethod);
const DWORD baseClassAttribs = info.compCompHnd->getClassAttribs(baseClass);
// Don't try guarded devirtualiztion when we're doing late devirtualization.
//
if (isLateDevirtualization)
{
JITDUMP("No guarded devirt during late devirtualization\n");
return;
}

// Is the call an interface call?
const bool isInterface = (baseClassAttribs & CORINFO_FLG_INTERFACE) != 0;
considerGuardedDevirtualization(call, ilOffset, isInterface, baseMethod, baseClass,
pContextHandle DEBUGARG(objClass) DEBUGARG("unknown"));

return;
}

// If the objClass is sealed (final), then we may be able to devirtualize.
const DWORD objClassAttribs = info.compCompHnd->getClassAttribs(objClass);
Expand Down