diff options
author | Evgeny Pavlov <lucenticus@gmail.com> | 2017-03-02 03:10:17 +0300 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2017-03-02 01:10:17 +0100 |
commit | b0213b97838c4e1efe0eb2c3c60b78fec0d0da0c (patch) | |
tree | ffd124c058b2106aea891cd0a981e6567e073afa /src/vm/dllimportcallback.cpp | |
parent | 6af7b26738149d46eaccbce631d670c949527ada (diff) | |
download | coreclr-b0213b97838c4e1efe0eb2c3c60b78fec0d0da0c.tar.gz coreclr-b0213b97838c4e1efe0eb2c3c60b78fec0d0da0c.tar.bz2 coreclr-b0213b97838c4e1efe0eb2c3c60b78fec0d0da0c.zip |
[x86/Linux] Initial fix of arguments passing in FunctionPtrTest (WIP) (#9855)
* [x86/Linux] Initial fix of incorrect arguments passing in FunctionPtrTest
Diffstat (limited to 'src/vm/dllimportcallback.cpp')
-rw-r--r-- | src/vm/dllimportcallback.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/vm/dllimportcallback.cpp b/src/vm/dllimportcallback.cpp index 92604eccd7..c53b080968 100644 --- a/src/vm/dllimportcallback.cpp +++ b/src/vm/dllimportcallback.cpp @@ -1411,13 +1411,57 @@ VOID UMThunkMarshInfo::RunTimeInit() pStubMD = GetILStubMethodDesc(pMD, &sigInfo, dwStubFlags); pFinalILStub = JitILStub(pStubMD); + } } - // // m_cbActualArgSize gets the number of arg bytes for the NATIVE signature // - m_cbActualArgSize = (pStubMD != NULL) ? pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize() : pMD->SizeOfArgStack(); + m_cbActualArgSize = + (pStubMD != NULL) ? pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize() : pMD->SizeOfArgStack(); + +#if defined(_TARGET_X86_) + MetaSig sig(pMD); + ArgIterator argit(&sig); + int numRegistersUsed = 0; + m_ecxArgOffset = -1; + m_edxArgOffset = -1; + + int offs = 0; + for (UINT i = 0 ; i < sig.NumFixedArgs(); i++) + { + TypeHandle thValueType; + CorElementType type = sig.NextArgNormalized(&thValueType); + int cbSize = sig.GetElemSize(type, thValueType); + if (ArgIterator::IsArgumentInRegister(&numRegistersUsed, type)) + { + if (numRegistersUsed == 1) + m_ecxArgOffset = offs; + else if (numRegistersUsed == 2) + m_edxArgOffset = offs; + offs += STACK_ELEM_SIZE; + } + else + { + offs += StackElemSize(cbSize); + } + } + PInvokeStaticSigInfo sigInfo; + if (pMD != NULL) + new (&sigInfo) PInvokeStaticSigInfo(pMD); + else + new (&sigInfo) PInvokeStaticSigInfo(GetSignature(), GetModule()); + if (sigInfo.GetCallConv() == pmCallConvCdecl) + { + // caller pop + m_cbRetPop = 0; + } + else + { + // callee pop + m_cbRetPop = static_cast<UINT16>(m_cbActualArgSize); + } +#endif // _TARGET_X86_ #endif // _TARGET_X86_ && !FEATURE_STUBS_AS_IL |