[x86/Linux] Fix NativeCallableTest (dotnet/coreclr#10060)
authorEvgeny Pavlov <lucenticus@gmail.com>
Thu, 16 Mar 2017 04:30:37 +0000 (07:30 +0300)
committerJan Kotas <jkotas@microsoft.com>
Thu, 16 Mar 2017 04:30:37 +0000 (21:30 -0700)
* [x86/Linux] Fix NativeCallableTest

* Move m_cbActualArgSize adjustment outside if statement

* [x86/Linux] Adjust m_cbActualArgSize in case pStubMD == NULL

* [x86/Linux] Move m_cbActualArgSize calculation to #else part of '#ifdef _TARGET_X86_'

* [x86/Linux] Remove redundant computations, add comments for m_cbActualArgSize meaning

Commit migrated from https://github.com/dotnet/coreclr/commit/6f3aa999a842cfa4bf83415e88ea7fb1650ab5bf

src/coreclr/src/vm/dllimportcallback.cpp
src/coreclr/src/vm/dllimportcallback.h

index fb96875..b72bc16 100644 (file)
@@ -1375,15 +1375,9 @@ VOID UMThunkMarshInfo::RunTimeInit()
 
         }
     }
-    //
-    // m_cbActualArgSize gets the number of arg bytes for the NATIVE signature
-    //
-    m_cbActualArgSize =
-        (pStubMD != NULL) ? pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize() : pMD->SizeOfArgStack();
 
 #if defined(_TARGET_X86_)
     MetaSig sig(pMD);
-    ArgIterator argit(&sig);
     int numRegistersUsed = 0;
 
     //
@@ -1407,11 +1401,14 @@ VOID UMThunkMarshInfo::RunTimeInit()
             m_cbStackArgSize += StackElemSize(cbSize);
         }
     }
+    m_cbActualArgSize = (pStubMD != NULL) ? pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize() : offs;
+
     PInvokeStaticSigInfo sigInfo;
     if (pMD != NULL)
         new (&sigInfo) PInvokeStaticSigInfo(pMD);
     else
         new (&sigInfo) PInvokeStaticSigInfo(GetSignature(), GetModule());
+
     if (sigInfo.GetCallConv() == pmCallConvCdecl)
     {
         // caller pop
@@ -1422,6 +1419,13 @@ VOID UMThunkMarshInfo::RunTimeInit()
         // callee pop
         m_cbRetPop = static_cast<UINT16>(m_cbActualArgSize);
     }
+#else // _TARGET_X86_
+    //
+    // m_cbActualArgSize gets the number of arg bytes for the NATIVE signature
+    //
+    m_cbActualArgSize =
+        (pStubMD != NULL) ? pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize() : pMD->SizeOfArgStack();
+
 #endif // _TARGET_X86_
 
 #endif // _TARGET_X86_ && !FEATURE_STUBS_AS_IL
index b50b917..af2a0b1 100644 (file)
@@ -220,6 +220,7 @@ private:
                                             // On x86, NULL for no-marshal signatures
                                             // On non-x86, the managed entrypoint for no-delegate no-marshal signatures
     UINT32            m_cbActualArgSize;    // caches m_pSig.SizeOfFrameArgumentArray()
+                                            // On x86/Linux we have to augment with numRegistersUsed * STACK_ELEM_SIZE
 #if defined(_TARGET_X86_)
     UINT16            m_cbRetPop;           // stack bytes popped by callee (for UpdateRegDisplay)
 #if defined(FEATURE_STUBS_AS_IL)