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: Use metadata names for SIMD intrinsic method recognition #76786

Merged
merged 8 commits into from
Oct 22, 2022
42 changes: 21 additions & 21 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6248,12 +6248,24 @@ const char* CEEInfo::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftnHnd, con
} CONTRACTL_END;

const char* result = NULL;
const char* classResult = NULL;
const char* namespaceResult = NULL;
const char* enclosingResult = NULL;

JIT_TO_EE_TRANSITION();

if (className != NULL)
{
*className = NULL;
}

if (namespaceName != NULL)
{
*namespaceName = NULL;
}

if (enclosingClassName != NULL)
{
*enclosingClassName = NULL;
}

MethodDesc *ftn = GetMethod(ftnHnd);
mdMethodDef token = ftn->GetMemberDef();

Expand All @@ -6263,30 +6275,18 @@ const char* CEEInfo::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftnHnd, con
IMDInternalImport* pMDImport = pMT->GetMDImport();

IfFailThrow(pMDImport->GetNameOfMethodDef(token, &result));
IfFailThrow(pMDImport->GetNameOfTypeDef(pMT->GetCl(), &classResult, &namespaceResult));
if (className != NULL || namespaceName != NULL)
{
IfFailThrow(pMDImport->GetNameOfTypeDef(pMT->GetCl(), className, namespaceName));
}
// Query enclosingClassName when the method is in a nested class
// and get the namespace of enclosing classes (nested class's namespace is empty)
if (pMT->GetClass()->IsNested())
if (enclosingClassName != NULL && pMT->GetClass()->IsNested())
{
IfFailThrow(pMDImport->GetNameOfTypeDef(pMT->GetEnclosingCl(), &enclosingResult, &namespaceResult));
IfFailThrow(pMDImport->GetNameOfTypeDef(pMT->GetEnclosingCl(), enclosingClassName, namespaceName));
Copy link
Member Author

@jakobbotsch jakobbotsch Oct 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic seems a bit odd to me in terms of the namespaceResult, IIUC it will work only for one level of nesting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is designed to handle just enough for the JIT to identify intrinsics. We only need one level of nesting for that.

}
}

if (className != NULL)
{
*className = classResult;
}

if (namespaceName != NULL)
{
*namespaceName = namespaceResult;
}

if (enclosingClassName != NULL)
{
*enclosingClassName = enclosingResult;
}

EE_TO_JIT_TRANSITION();

return result;
Expand Down