[ARM/Linux] Fix incorrect return marshaling in PInvoke stub (#5010)
authorJonghyun Park <parjong@gmail.com>
Wed, 25 May 2016 02:23:51 +0000 (11:23 +0900)
committerJan Kotas <jkotas@microsoft.com>
Wed, 25 May 2016 02:23:51 +0000 (19:23 -0700)
* Revises compMethodReturnsMultiRegRetType for ARM

For ARM, the current implementation of 'compMethodReturnsMultiRegRetType'
always returns false.

Unfortunately, this behavior is inconsistent with JIT importer. JIT impoter
attempts to merge various return statements as one statement via inserting
an assignment statement just before each return statement if there are more
than 4 returns.

If the method of interest has a return value, then JIT importer
introduces a local temporary variable, and use it to return value.

Due to the above implementation, JIT importer never generates a return
variable, which results in assertion violation insider JIT morph, which
is discussed in #5009.

This commit attempts to fix #5009 via implementing 'compMethodReturnsMultiRegRetType'
for ARM.

* Uses compRetNativeType instead of compRetType

* Fix typo '_TARGET_ARM' as '_TARGET_ARM_'

src/jit/compiler.h
src/vm/ilmarshalers.h

index edcc951..6ae8741 100644 (file)
@@ -7904,7 +7904,7 @@ public :
     bool                compMethodReturnsMultiRegRetType() 
     {       
 #if FEATURE_MULTIREG_RET
-#ifdef FEATURE_UNIX_AMD64_STRUCT_PASSING
+#if defined(FEATURE_UNIX_AMD64_STRUCT_PASSING) || defined(_TARGET_ARM_)
         // Methods returning a struct in two registers is considered having a return value of TYP_STRUCT.
         // Such method's compRetNativeType is TYP_STRUCT without a hidden RetBufArg
         return varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM);
index 3ed74b4..1730eab 100644 (file)
@@ -600,7 +600,7 @@ public:
                 nativeSize = wNativeSize;
             }
 
-#if !defined(_TARGET_ARM) && !(defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING))
+#if !defined(_TARGET_ARM_) && !(defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING))
             switch (nativeSize)
             {
                 case 1: typ = ELEMENT_TYPE_U1; break;