From a96bde9730e4c2244536ce5f4250e5e4f4e6780a Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Thu, 18 Aug 2022 14:08:46 +0300 Subject: [PATCH] Backport fixes for sharing wrappers when type attributes are involved (#21537) * [wasm] Fix the handling of i8/u8 in get_wrapper_shared_type_full (). (#19859) Previously, these were returned verbatim, which caused sharing issues when the type had attributes. Fixes https://github.com/mono/mono/issues/19841. * [aot] Fix the handling of r4/r8 parameter types with attributes during generic sharing. (#20217) The attributes need to be ignored as with the other types, otherwise gsharedvt wrappers for signatures with parameters like double f = default will not be found. Fixes https://github.com/mono/mono/issues/20195. Co-authored-by: Zoltan Varga --- mono/mini/mini-generic-sharing.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/mono/mini/mini-generic-sharing.c b/mono/mini/mini-generic-sharing.c index 90b19017a5b..28100d7d4d4 100644 --- a/mono/mini/mini-generic-sharing.c +++ b/mono/mini/mini-generic-sharing.c @@ -1254,6 +1254,31 @@ get_wrapper_shared_type_full (MonoType *t, gboolean is_field) return mono_get_int32_type (); case MONO_TYPE_U4: return m_class_get_byval_arg (mono_defaults.uint32_class); + case MONO_TYPE_I8: +#if TARGET_SIZEOF_VOID_P == 8 + /* Use native int as its already used for byref */ + return m_class_get_byval_arg (mono_defaults.int_class); +#else + return m_class_get_byval_arg (mono_defaults.int64_class); +#endif + case MONO_TYPE_U8: + return m_class_get_byval_arg (mono_defaults.uint64_class); + case MONO_TYPE_I: +#if TARGET_SIZEOF_VOID_P == 8 + return m_class_get_byval_arg (mono_defaults.int_class); +#else + return m_class_get_byval_arg (mono_defaults.int32_class); +#endif + case MONO_TYPE_U: +#if TARGET_SIZEOF_VOID_P == 8 + return m_class_get_byval_arg (mono_defaults.uint64_class); +#else + return m_class_get_byval_arg (mono_defaults.uint32_class); +#endif + case MONO_TYPE_R4: + return m_class_get_byval_arg (mono_defaults.single_class); + case MONO_TYPE_R8: + return m_class_get_byval_arg (mono_defaults.double_class); case MONO_TYPE_OBJECT: case MONO_TYPE_CLASS: case MONO_TYPE_SZARRAY: @@ -1310,16 +1335,6 @@ get_wrapper_shared_type_full (MonoType *t, gboolean is_field) t = shared_type; return t; } -#if TARGET_SIZEOF_VOID_P == 8 - case MONO_TYPE_I8: - return mono_get_int_type (); -#endif -#if TARGET_SIZEOF_VOID_P == 4 - case MONO_TYPE_I: - return mono_get_int32_type (); - case MONO_TYPE_U: - return m_class_get_byval_arg (mono_defaults.uint32_class); -#endif default: break; } -- 2.11.4.GIT