Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2364d60

Browse files
author
Rahul Kumar
authored
Merge pull request #5978 from rahku/arm64retbuf
Fix Pinvoke IL Stubs to emit correct return type in signature of call…
2 parents f33074e + 6d5ef67 commit 2364d60

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/vm/dllimport.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4194,9 +4194,17 @@ static void CreateNDirectStubWorker(StubState* pss,
41944194
bool fHasCopyCtorArgs = false;
41954195
bool fStubNeedsCOM = SF_IsCOMStub(dwStubFlags);
41964196

4197+
#if defined(_TARGET_X86_) || defined(_TARGET_ARM_)
4198+
// JIT32 has problems in generating code for pinvoke ILStubs which do a return in return buffer.
4199+
// Therefore instead we change the signature of calli to return void and make the return buffer as first
4200+
// argument. This matches the ABI i.e. return buffer is passed as first arg. So native target will get the
4201+
// return buffer in correct register.
41974202
// The return structure secret arg comes first, however byvalue return is processed at
41984203
// the end because it could be the HRESULT-swapped argument which always comes last.
41994204
bool fMarshalReturnValueFirst = !SF_IsHRESULTSwapping(dwStubFlags) && HasRetBuffArg(&msig);
4205+
#else
4206+
bool fMarshalReturnValueFirst = false;
4207+
#endif
42004208

42014209
if (fMarshalReturnValueFirst)
42024210
{

src/vm/ilmarshalers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ class ILMarshaler
600600
nativeSize = wNativeSize;
601601
}
602602

603-
#if !defined(_TARGET_ARM_) && !(defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING))
603+
#if defined(_TARGET_X86_)
604604
switch (nativeSize)
605605
{
606606
case 1: typ = ELEMENT_TYPE_U1; break;

0 commit comments

Comments
 (0)