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

[LoongArch64] JIT/EE interface for getting ABI-info #62893

Merged
merged 29 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
47d106f
Merge pull request #1 from dotnet/main
shushanhf Apr 27, 2021
411b59e
Merge branch 'dotnet:main' into master
shushanhf Oct 25, 2021
7eed4eb
Merge branch 'dotnet:main' into master
shushanhf Dec 6, 2021
0d7c9e4
Merge branch 'dotnet:main' into master
shushanhf Dec 10, 2021
2c534c5
Merge branch 'dotnet:main' into master
shushanhf Dec 14, 2021
6e14d76
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
359875d
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
192b095
Merge branch 'dotnet:main' into main
shushanhf Dec 16, 2021
485a681
[LoongArch64] add ToolBox directory about jitinterace for getting ABI…
shushanhf Dec 16, 2021
42667b3
[LoongArch64] add new interace for getting ABI-info. (#59561)
shushanhf Dec 17, 2021
7e518a8
[LoongArch64] add the linking page for LoongArch64 ABI-info. (#59561)
Dec 17, 2021
db97aa7
[LoongArch64] moved ThunkInput.txt to #62885.
Dec 20, 2021
4e3eeb2
[LoongArch64] moved vm/jitinterface.cpp to #62885.
Dec 20, 2021
f722a3b
remove the JIT/EE interface back from #62885..
Dec 24, 2021
c896413
Merge branch 'main' into main_loongarch64_3a
shushanhf Jan 12, 2022
948a822
[LoongArch64] Fix the compiling error after merge.
shushanhf Jan 12, 2022
a723e85
[LoongArch64] add comments for the returned value of `getFieldTypeByH…
Jan 13, 2022
adb9570
[LoongArch64] rename getFieldTypeByHnd to getFieldSizeClassificationB…
shushanhf Jan 13, 2022
02ff4bf
[LoongArch64] Delete the interface `getArgType2`.
shushanhf Jan 14, 2022
f28774a
[LoongArch64] delete `GetArgType` within `ToolBox/superpmi`.
shushanhf Jan 14, 2022
73d158a
[LoongArch64] rename `getFieldSizeClassificationByHnd` to
shushanhf Jan 14, 2022
7d5d052
[LoongArch64] amend the floating-ABI for native-struct.
shushanhf Jan 17, 2022
b8534b2
[LoongArch64] update all related `GetFieldSizeClassificationByHnd`
Jan 19, 2022
47c81cc
Merge branch 'main' into main_loongarch64_3a
Jan 19, 2022
a3688bf
[LoongArch64] replace `LookupApproxFieldTypeHandle()`
shushanhf Feb 15, 2022
b05a2b9
[LoongArch64] implements the crossgen2 for LoongArch64.
shushanhf Feb 15, 2022
6a179ff
Revert "[LoongArch64] implements the crossgen2 for LoongArch64."
Feb 16, 2022
a6cbbcc
[LoongArch64] update the `GUID JITEEVersionIdentifier`.
Feb 18, 2022
a5d6bcd
Merge branch 'main' into main_loongarch64_3a
Feb 18, 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
5 changes: 5 additions & 0 deletions src/coreclr/ToolBox/superpmi/mcs/verbildump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ void DumpSigToConsoleBare(MethodContext* mc, CORINFO_SIG_INFO* pSig)
for (int i = 0; i < (int)pSig->numArgs; i++)
{
DWORDLONG dl;
#if defined(TARGET_LOONGARCH64)
int flags;
CorInfoTypeWithMod type = mc->repGetArgType(pSig, currentItem, (CORINFO_CLASS_HANDLE*)&dl, &flags, &exceptionCode);
Copy link
Member

Choose a reason for hiding this comment

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

This and number and number of other changes were for getArgType2. They are not necessary anymore.

Copy link
Contributor Author

@shushanhf shushanhf Jan 14, 2022

Choose a reason for hiding this comment

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

OK, Thanks for your review.
I will delete them.

#else
CorInfoTypeWithMod type = mc->repGetArgType(pSig, currentItem, (CORINFO_CLASS_HANDLE*)&dl, &exceptionCode);
#endif
CorInfoType cit = strip(type);
if (cit == CORINFO_TYPE_CLASS)
dl = CastHandle(mc->repGetArgClass(pSig, currentItem, &exceptionCode));
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/agnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ struct Agnostic_GetArgType_Value
{
DWORDLONG vcTypeRet;
DWORD result;
#if defined(TARGET_LOONGARCH64)
int flags;
#endif
DWORD exceptionCode;
};

Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/callutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL
// Tweaked to use EE types instead of JIT-specific types
CORINFO_CLASS_HANDLE typeHandle;
DWORD exception;
#if defined(TARGET_LOONGARCH64)
int flags;
CorInfoType type = strip(mc->repGetArgType(&sig, argList, &typeHandle, &flags, &exception));
#else
CorInfoType type = strip(mc->repGetArgType(&sig, argList, &typeHandle, &exception));
#endif

length += strlen(TypeUtils::GetCorInfoTypeName(type));
argList = mc->repGetArgNext(argList);
Expand Down Expand Up @@ -339,7 +344,12 @@ const char* CallUtils::GetMethodFullName(MethodContext* mc, CORINFO_METHOD_HANDL
// Tweaked to use EE types instead of JIT-specific types
CORINFO_CLASS_HANDLE typeHandle;
DWORD exception;
#if defined(TARGET_LOONGARCH64)
int flags;
CorInfoType type = strip(mc->repGetArgType(&sig, argList, &typeHandle, &flags, &exception));
#else
CorInfoType type = strip(mc->repGetArgType(&sig, argList, &typeHandle, &exception));
#endif
strcat_s(retName, length, TypeUtils::GetCorInfoTypeName(type));

argList = mc->repGetArgNext(argList);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ LWM(GetAddrOfCaptureThreadGlobal, DWORD, DLDL)
LWM(GetArgClass, Agnostic_GetArgClass_Key, Agnostic_GetArgClass_Value)
LWM(GetArgNext, DWORDLONG, DWORDLONG)
LWM(GetArgType, Agnostic_GetArgType_Key, Agnostic_GetArgType_Value)
LWM(GetFieldTypeByHnd, DWORDLONG, DWORD)
LWM(GetArrayInitializationData, DLD, DWORDLONG)
LWM(GetArrayRank, DWORDLONG, DWORD)
LWM(GetArrayIntrinsicID, DWORDLONG, DWORD)
Expand Down
34 changes: 34 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,9 @@ void MethodContext::recGetArgType(CORINFO_SIG_INFO* sig,
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet,
CorInfoTypeWithMod result,
#if defined(TARGET_LOONGARCH64)
int flags,
#endif
DWORD exceptionCode)
{
if (GetArgType == nullptr)
Expand All @@ -2664,6 +2667,9 @@ void MethodContext::recGetArgType(CORINFO_SIG_INFO* sig,
Agnostic_GetArgType_Value value;
value.vcTypeRet = CastHandle(*vcTypeRet);
value.result = (DWORD)result;
#if defined(TARGET_LOONGARCH64)
value.flags = flags;
#endif
value.exceptionCode = (DWORD)exceptionCode;

GetArgType->Add(key, value);
Expand All @@ -2681,6 +2687,9 @@ void MethodContext::dmpGetArgType(const Agnostic_GetArgType_Key& key, const Agno
CorInfoTypeWithMod MethodContext::repGetArgType(CORINFO_SIG_INFO* sig,
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet,
#if defined(TARGET_LOONGARCH64)
int *flags,
#endif
DWORD* exceptionCode)
{
AssertMapExists(GetArgType, ": key %016llX %016llX", CastHandle(sig->scope), CastHandle(args));
Expand All @@ -2701,6 +2710,10 @@ CorInfoTypeWithMod MethodContext::repGetArgType(CORINFO_SIG_INFO* sig,
AssertKeyExists(GetArgType, key, ": key %016llX %016llX", key.scope, key.args);

Agnostic_GetArgType_Value value = GetArgType->Get(key);
#if defined(TARGET_LOONGARCH64)
if (flags)
*flags = value.flags;
#endif
DEBUG_REP(dmpGetArgType(key, value));

*vcTypeRet = (CORINFO_CLASS_HANDLE)value.vcTypeRet;
Expand All @@ -2709,6 +2722,27 @@ CorInfoTypeWithMod MethodContext::repGetArgType(CORINFO_SIG_INFO* sig,
return temp;
}

void MethodContext::recGetFieldTypeByHnd(CORINFO_CLASS_HANDLE cls, DWORD value)
{
if (GetFieldTypeByHnd == nullptr)
GetFieldTypeByHnd = new LightWeightMap<DWORDLONG, DWORD>();

DWORDLONG key = (DWORDLONG)cls;

GetFieldTypeByHnd->Add((DWORDLONG)cls, value);
//DEBUG_REC(dmpGetArgType(key, value));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//DEBUG_REC(dmpGetArgType(key, value));
DEBUG_REC(dmpGetLoongArch64PassStructInRegisterFlags(key, value));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks

}

void MethodContext::dmpGetFieldTypeByHnd(DWORDLONG key, DWORD value)
{
printf("GetFieldTypeByHnd key %08X value-%X", key, value);
}

DWORD MethodContext::repGetFieldTypeByHnd(CORINFO_CLASS_HANDLE cls)
{
return GetFieldTypeByHnd->Get((DWORDLONG)cls);
}

void MethodContext::recGetArgNext(CORINFO_ARG_LIST_HANDLE args, CORINFO_ARG_LIST_HANDLE result)
{
if (GetArgNext == nullptr)
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,23 @@ class MethodContext
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet,
CorInfoTypeWithMod result,
#if defined(TARGET_LOONGARCH64)
int flags,
#endif
DWORD exception);
void dmpGetArgType(const Agnostic_GetArgType_Key& key, const Agnostic_GetArgType_Value& value);
CorInfoTypeWithMod repGetArgType(CORINFO_SIG_INFO* sig,
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet,
#if defined(TARGET_LOONGARCH64)
int *flags,
#endif
DWORD* exception);

void recGetFieldTypeByHnd(CORINFO_CLASS_HANDLE cls, DWORD value);
void dmpGetFieldTypeByHnd(DWORDLONG key, DWORD value);
DWORD repGetFieldTypeByHnd(CORINFO_CLASS_HANDLE cls);

void recGetArgNext(CORINFO_ARG_LIST_HANDLE args, CORINFO_ARG_LIST_HANDLE result);
void dmpGetArgNext(DWORDLONG key, DWORDLONG value);
CORINFO_ARG_LIST_HANDLE repGetArgNext(CORINFO_ARG_LIST_HANDLE args);
Expand Down Expand Up @@ -1097,6 +1107,7 @@ enum mcPackets
Packet_GetAssemblyName = 191,
Packet_IsIntrinsic = 192,
Packet_UpdateEntryPointForTailCall = 193,
Packet_GetFieldTypeByHnd = 194,
};

void SetDebugDumpVariables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,9 @@ CORINFO_ARG_LIST_HANDLE interceptor_ICJI::getArgNext(CORINFO_ARG_LIST_HANDLE arg
CorInfoTypeWithMod interceptor_ICJI::getArgType(CORINFO_SIG_INFO* sig, /* IN */
CORINFO_ARG_LIST_HANDLE args, /* IN */
CORINFO_CLASS_HANDLE* vcTypeRet /* OUT */
#if defined(TARGET_LOONGARCH64)
,int *flags
#endif
)
{
CorInfoTypeWithMod temp = (CorInfoTypeWithMod)CORINFO_TYPE_UNDEF;
Expand All @@ -1195,15 +1198,42 @@ CorInfoTypeWithMod interceptor_ICJI::getArgType(CORINFO_SIG_INFO* sig,
{
mc->cr->AddCall("getArgType");
temp =
#if defined(TARGET_LOONGARCH64)
original_ICorJitInfo->getArgType(sig, args, vcTypeRet, flags);
#else
original_ICorJitInfo->getArgType(sig, args, vcTypeRet);
#endif

#ifdef fatMC
CORINFO_CLASS_HANDLE temp3 = getArgClass(sig, args);
#endif
},
[&](DWORD exceptionCode)
{

#if defined(TARGET_LOONGARCH64)
this->mc->recGetArgType(sig, args, vcTypeRet, temp, flags ? *flags : 0, exceptionCode);
#else
this->mc->recGetArgType(sig, args, vcTypeRet, temp, exceptionCode);
#endif
});

return temp;
}

uint32_t interceptor_ICJI::getFieldTypeByHnd(CORINFO_CLASS_HANDLE cls)
{

uint32_t temp = 0;
RunWithErrorExceptionCodeCaptureAndContinue(
[&]()
{
mc->cr->AddCall("getFieldTypeByHnd");
temp = original_ICorJitInfo->getFieldTypeByHnd(cls);
},
[&](DWORD exceptionCode)
{
this->mc->recGetFieldTypeByHnd(cls, temp);
});

return temp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,24 @@ CORINFO_ARG_LIST_HANDLE interceptor_ICJI::getArgNext(
CorInfoTypeWithMod interceptor_ICJI::getArgType(
CORINFO_SIG_INFO* sig,
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet)
CORINFO_CLASS_HANDLE* vcTypeRet
#if defined(TARGET_LOONGARCH64)
,int *flags
#endif
)
{
mcs->AddCall("getArgType");
#if defined(TARGET_LOONGARCH64)
return original_ICorJitInfo->getArgType(sig, args, vcTypeRet, flags);
#else
return original_ICorJitInfo->getArgType(sig, args, vcTypeRet);
#endif
}

uint32_t interceptor_ICJI::getFieldTypeByHnd(CORINFO_CLASS_HANDLE cls)
{
mcs->AddCall("getFieldTypeByHnd");
return original_ICorJitInfo->getFieldTypeByHnd(cls);
}

CORINFO_CLASS_HANDLE interceptor_ICJI::getArgClass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,23 @@ CORINFO_ARG_LIST_HANDLE interceptor_ICJI::getArgNext(
CorInfoTypeWithMod interceptor_ICJI::getArgType(
CORINFO_SIG_INFO* sig,
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet)
CORINFO_CLASS_HANDLE* vcTypeRet
#if defined(TARGET_LOONGARCH64)
,int *flags
#endif
)
{

#if defined(TARGET_LOONGARCH64)
return original_ICorJitInfo->getArgType(sig, args, vcTypeRet, flags);
#else
return original_ICorJitInfo->getArgType(sig, args, vcTypeRet);
#endif
}

uint32_t interceptor_ICJI::getFieldTypeByHnd(CORINFO_CLASS_HANDLE cls)
{
return original_ICorJitInfo->getFieldTypeByHnd(cls);
}

CORINFO_CLASS_HANDLE interceptor_ICJI::getArgClass(
Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,16 +1050,29 @@ CORINFO_ARG_LIST_HANDLE MyICJI::getArgNext(CORINFO_ARG_LIST_HANDLE args /* IN */
CorInfoTypeWithMod MyICJI::getArgType(CORINFO_SIG_INFO* sig, /* IN */
CORINFO_ARG_LIST_HANDLE args, /* IN */
CORINFO_CLASS_HANDLE* vcTypeRet /* OUT */
#if defined(TARGET_LOONGARCH64)
,int *flags
#endif
)
{
DWORD exceptionCode = 0;
jitInstance->mc->cr->AddCall("getArgType");
#if defined(TARGET_LOONGARCH64)
CorInfoTypeWithMod value = jitInstance->mc->repGetArgType(sig, args, vcTypeRet, flags, &exceptionCode);
#else
CorInfoTypeWithMod value = jitInstance->mc->repGetArgType(sig, args, vcTypeRet, &exceptionCode);
#endif
if (exceptionCode != 0)
ThrowException(exceptionCode);
return value;
}

uint32_t MyICJI::getFieldTypeByHnd(CORINFO_CLASS_HANDLE cls)
{
jitInstance->mc->cr->AddCall("getFieldTypeByHnd");
shushanhf marked this conversation as resolved.
Show resolved Hide resolved
return 0;//jitInstance->mc->repGetFieldTypeByHnd(cls);
}

// If the Arg is a CORINFO_TYPE_CLASS fetch the class handle associated with it
CORINFO_CLASS_HANDLE MyICJI::getArgClass(CORINFO_SIG_INFO* sig, /* IN */
CORINFO_ARG_LIST_HANDLE args /* IN */
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,13 @@ CORINFO_ARG_LIST_HANDLE getArgNext(
CorInfoTypeWithMod getArgType(
CORINFO_SIG_INFO* sig,
CORINFO_ARG_LIST_HANDLE args,
CORINFO_CLASS_HANDLE* vcTypeRet) override;
CORINFO_CLASS_HANDLE* vcTypeRet
#if defined(TARGET_LOONGARCH64)
,int *flags = NULL
#endif
shushanhf marked this conversation as resolved.
Show resolved Hide resolved
) override;

uint32_t getFieldTypeByHnd(CORINFO_CLASS_HANDLE cls) override;
shushanhf marked this conversation as resolved.
Show resolved Hide resolved

CORINFO_CLASS_HANDLE getArgClass(
CORINFO_SIG_INFO* sig,
Expand Down
Loading