diff options
author | Jeremy Koritzinsky <jkoritzinsky@gmail.com> | 2019-04-05 12:52:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 12:52:00 -0700 |
commit | 04f97c9923156b0c695f5fe441ffd14624de8076 (patch) | |
tree | 39dabb413ee77c1fc50b6b5f22f392a9f7d0e362 /src/vm/dllimport.cpp | |
parent | 8d51f4253996baf64fca1c57c421fb42ac5762cd (diff) | |
download | coreclr-04f97c9923156b0c695f5fe441ffd14624de8076.tar.gz coreclr-04f97c9923156b0c695f5fe441ffd14624de8076.tar.bz2 coreclr-04f97c9923156b0c695f5fe441ffd14624de8076.zip |
Enable return buffers on Windows ARM64 for struct-returning member functions (#23625)
* Enable return buffers on Windows ARM64 for struct-returning member functions. Fixes #23577.
* Update comment to match new condition.
* Enable byref return on all Windows (excluding arm64 HFA. Add more test cases for ThisCall.
* On x86, if we have a normalized return value in an instance method, get back the actual type so that we correctly marshal it via a return buffer.
* Fix param ordering.
* Clean up based on PR feedback.
* Fix accidental variable shadowing.
Diffstat (limited to 'src/vm/dllimport.cpp')
-rw-r--r-- | src/vm/dllimport.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/vm/dllimport.cpp b/src/vm/dllimport.cpp index 252ec56a3c..924a50fe9d 100644 --- a/src/vm/dllimport.cpp +++ b/src/vm/dllimport.cpp @@ -3579,7 +3579,7 @@ static MarshalInfo::MarshalType DoMarshalReturnValue(MetaSig& msig, CorNativeLinkFlags nlFlags, UINT argidx, // this is used for reverse pinvoke hresult swapping StubState* pss, - BOOL fThisCall, + BOOL isInstanceMethod, int argOffset, DWORD dwStubFlags, MethodDesc *pMD, @@ -3647,6 +3647,7 @@ static MarshalInfo::MarshalType DoMarshalReturnValue(MetaSig& msig, SF_IsBestFit(dwStubFlags), SF_IsThrowOnUnmappableChar(dwStubFlags), TRUE, + isInstanceMethod, pMD, TRUE DEBUG_ARG(pDebugName) @@ -3955,6 +3956,7 @@ static void CreateNDirectStubWorker(StubState* pss, BOOL fMarshalReturnValueFirst = FALSE; BOOL fReverseWithReturnBufferArg = FALSE; + bool isInstanceMethod = fStubNeedsCOM || fThisCall; // We can only change fMarshalReturnValueFirst to true when we are NOT doing HRESULT-swapping! // When we are HRESULT-swapping, the managed return type is actually the type of the last parameter and not the return type. @@ -3963,7 +3965,6 @@ static void CreateNDirectStubWorker(StubState* pss, // to make sure we match the native signature correctly (when marshalling parameters, we add them to the native stub signature). if (!SF_IsHRESULTSwapping(dwStubFlags)) { - bool isInstanceMethod = fStubNeedsCOM || fThisCall; // We cannot just use pSig.GetReturnType() here since it will return ELEMENT_TYPE_VALUETYPE for enums. bool isReturnTypeValueType = msig.GetRetTypeHandleThrowing().GetVerifierCorElementType() == ELEMENT_TYPE_VALUETYPE; #if defined(_TARGET_X86_) || defined(_TARGET_ARM_) @@ -3983,7 +3984,7 @@ static void CreateNDirectStubWorker(StubState* pss, // On Windows-X86, the native signature might need a return buffer when the managed doesn't (specifically when the native signature is a member function). fMarshalReturnValueFirst = HasRetBuffArg(&msig) || (isInstanceMethod && isReturnTypeValueType); #endif // UNIX_X86_ABI -#elif defined(_TARGET_AMD64_) +#elif defined(_TARGET_AMD64_) || defined (_TARGET_ARM64_) fMarshalReturnValueFirst = isInstanceMethod && isReturnTypeValueType; #endif // defined(_TARGET_X86_) || defined(_TARGET_ARM_) #ifdef _WIN32 @@ -4036,6 +4037,7 @@ static void CreateNDirectStubWorker(StubState* pss, SF_IsBestFit(dwStubFlags), SF_IsThrowOnUnmappableChar(dwStubFlags), TRUE, + isInstanceMethod ? TRUE : FALSE, pMD, TRUE DEBUG_ARG(pSigDesc->m_pDebugName) @@ -4092,7 +4094,7 @@ static void CreateNDirectStubWorker(StubState* pss, nlFlags, 0, pss, - fThisCall, + isInstanceMethod, argOffset, dwStubFlags, pMD, @@ -4205,7 +4207,7 @@ static void CreateNDirectStubWorker(StubState* pss, nlFlags, argidx, pss, - fThisCall, + isInstanceMethod, argOffset, dwStubFlags, pMD, |