From bcc8495653c03b8ba4bb61fbd4828cac90789c4e Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Wed, 25 May 2016 11:23:51 +0900 Subject: [PATCH] [ARM/Linux] Fix incorrect return marshaling in PInvoke stub (#5010) * 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 | 2 +- src/vm/ilmarshalers.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jit/compiler.h b/src/jit/compiler.h index edcc951..6ae8741 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -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); diff --git a/src/vm/ilmarshalers.h b/src/vm/ilmarshalers.h index 3ed74b4..1730eab 100644 --- a/src/vm/ilmarshalers.h +++ b/src/vm/ilmarshalers.h @@ -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; -- 2.7.4