- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.2k
Fix struct ReturnKind on SysV AMD64. #116194
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
Changes from 4 commits
3784150
              5730cd0
              9a718cb
              1760969
              ae4fdfc
              c1c609e
              a5c9613
              dbd7587
              44fa203
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -1234,8 +1234,9 @@ COR_ILMETHOD* MethodDesc::GetILHeader() | |
| #endif // !DACCESS_COMPILE | ||
| } | ||
|  | ||
| #if defined(TARGET_X86) || defined(FEATURE_COMINTEROP) | ||
| //******************************************************************************* | ||
| ReturnKind MethodDesc::ParseReturnKindFromSig(INDEBUG(bool supportStringConstructors)) | ||
| ReturnKind MethodDesc::GetReturnKind(INDEBUG(bool supportStringConstructors)) | ||
| { | ||
| CONTRACTL | ||
| { | ||
|  | @@ -1247,13 +1248,31 @@ ReturnKind MethodDesc::ParseReturnKindFromSig(INDEBUG(bool supportStringConstruc | |
|  | ||
| ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE(); | ||
|  | ||
| // For simplicity, we don't hijack in funclets, but if you ever change that, | ||
| // be sure to choose the OnHijack... callback type to match that of the FUNCLET | ||
| // not the main method (it would probably be Scalar). | ||
|  | ||
| // Mark that we are performing a stackwalker like operation on the current thread. | ||
| // This is necessary to allow the signature parsing functions to work without triggering any loads | ||
| StackWalkerWalkingThreadHolder threadStackWalking(GetThread()); | ||
|  | ||
| TypeHandle thValueType; | ||
|  | ||
| MetaSig sig(this); | ||
| CorElementType et = sig.GetReturnTypeNormalized(&thValueType); | ||
|  | ||
| switch (et) | ||
| { | ||
| #ifdef TARGET_X86 | ||
| case ELEMENT_TYPE_R4: | ||
| case ELEMENT_TYPE_R8: | ||
| // Figuring out whether the function returns FP or not is hard to do | ||
| // on-the-fly, so we use a different callback helper on x86 where this | ||
| // piece of information is needed in order to perform the right save & | ||
| // restore of the return value around the call to OnHijackScalarWorker. | ||
| return RT_Float; | ||
| #endif | ||
|  | ||
| case ELEMENT_TYPE_STRING: | ||
| case ELEMENT_TYPE_CLASS: | ||
| case ELEMENT_TYPE_SZARRAY: | ||
|  | @@ -1275,34 +1294,6 @@ ReturnKind MethodDesc::ParseReturnKindFromSig(INDEBUG(bool supportStringConstruc | |
| if (!thValueType.IsTypeDesc()) | ||
| { | ||
| MethodTable * pReturnTypeMT = thValueType.AsMethodTable(); | ||
| #ifdef UNIX_AMD64_ABI | ||
| if (pReturnTypeMT->IsRegPassedStruct()) | ||
| { | ||
| // The Multi-reg return case using the classhandle is only implemented for AMD64 SystemV ABI. | ||
| // On other platforms, multi-reg return is not supported with GcInfo v1. | ||
| // So, the relevant information must be obtained from the GcInfo tables (which requires version2). | ||
| EEClass* eeClass = pReturnTypeMT->GetClass(); | ||
| ReturnKind regKinds[2] = { RT_Unset, RT_Unset }; | ||
| int orefCount = 0; | ||
| for (int i = 0; i < 2; i++) | ||
| { | ||
| if (eeClass->GetEightByteClassification(i) == SystemVClassificationTypeIntegerReference) | ||
| { | ||
| regKinds[i] = RT_Object; | ||
| } | ||
| else if (eeClass->GetEightByteClassification(i) == SystemVClassificationTypeIntegerByRef) | ||
| { | ||
| regKinds[i] = RT_ByRef; | ||
| } | ||
| else | ||
| { | ||
| regKinds[i] = RT_Scalar; | ||
| } | ||
| } | ||
| ReturnKind structReturnKind = GetStructReturnKind(regKinds[0], regKinds[1]); | ||
| return structReturnKind; | ||
| } | ||
| #endif // UNIX_AMD64_ABI | ||
|  | ||
| if (pReturnTypeMT->ContainsGCPointers() || pReturnTypeMT->IsByRefLike()) | ||
|          | ||
| { | ||
|  | @@ -1347,32 +1338,7 @@ ReturnKind MethodDesc::ParseReturnKindFromSig(INDEBUG(bool supportStringConstruc | |
|  | ||
| return RT_Scalar; | ||
| } | ||
|  | ||
| ReturnKind MethodDesc::GetReturnKind(INDEBUG(bool supportStringConstructors)) | ||
| { | ||
| // For simplicity, we don't hijack in funclets, but if you ever change that, | ||
| // be sure to choose the OnHijack... callback type to match that of the FUNCLET | ||
| // not the main method (it would probably be Scalar). | ||
|  | ||
| ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE(); | ||
| // Mark that we are performing a stackwalker like operation on the current thread. | ||
| // This is necessary to allow the signature parsing functions to work without triggering any loads | ||
| StackWalkerWalkingThreadHolder threadStackWalking(GetThread()); | ||
|  | ||
| #ifdef TARGET_X86 | ||
| MetaSig msig(this); | ||
| if (msig.HasFPReturn()) | ||
| { | ||
| // Figuring out whether the function returns FP or not is hard to do | ||
| // on-the-fly, so we use a different callback helper on x86 where this | ||
| // piece of information is needed in order to perform the right save & | ||
| // restore of the return value around the call to OnHijackScalarWorker. | ||
| return RT_Float; | ||
| } | ||
| #endif // TARGET_X86 | ||
|  | ||
| return ParseReturnKindFromSig(INDEBUG(supportStringConstructors)); | ||
| } | ||
| #endif // TARGET_X86 || FEATURE_COMINTEROP | ||
|  | ||
| #ifdef FEATURE_COMINTEROP | ||
|  | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.