From 28d02158193c5737c0cec31583099284c6b56b7f Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 13 Nov 2019 08:55:52 -0800 Subject: [PATCH] Remove handles from ves_icall_System_Array_CanChangePrimitive. (mono/mono#17708) Remove handles from ves_icall_System_Array_CanChangePrimitive. Commit migrated from https://github.com/mono/mono/commit/73431403c7e7525122526eae016f80e9d9398d3e --- src/mono/configure.ac | 2 +- src/mono/mono/metadata/icall-decl.h | 1 + src/mono/mono/metadata/icall-def-netcore.h | 2 +- src/mono/mono/metadata/icall.c | 9 ++++++--- src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs | 6 +++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index d8d7029..2ac3609 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -63,7 +63,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3` # This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets. # It should remain in the format they expect. # -MONO_CORLIB_VERSION=3EAB4D03-8026-4D77-B1AE-AC96DF737E67 +MONO_CORLIB_VERSION=4519505b-4021-473c-867a-ee387a584821 # # Put a quoted #define in config.h. diff --git a/src/mono/mono/metadata/icall-decl.h b/src/mono/mono/metadata/icall-decl.h index 5dc70d3..a85cdfd 100644 --- a/src/mono/mono/metadata/icall-decl.h +++ b/src/mono/mono/metadata/icall-decl.h @@ -222,5 +222,6 @@ ICALL_EXPORT void ves_icall_Mono_Runtime_DisableMicrosoftTelemetry (void); ICALL_EXPORT int ves_icall_Mono_Runtime_CheckCrashReportingLog (const char *directory, MonoBoolean clear); ICALL_EXPORT void ves_icall_Mono_Runtime_EnableCrashReportingLog (const char *directory); ICALL_EXPORT void ves_icall_System_Array_InternalCreate (MonoArray *volatile* result, MonoType* type, gint32 rank, gint32* pLengths, gint32* pLowerBounds); +ICALL_EXPORT MonoBoolean ves_icall_System_Array_CanChangePrimitive (MonoReflectionType *volatile* ref_src_type_handle, MonoReflectionType *volatile* ref_dst_type_handle, MonoBoolean reliable); #endif // __MONO_METADATA_ICALL_H__ diff --git a/src/mono/mono/metadata/icall-def-netcore.h b/src/mono/mono/metadata/icall-def-netcore.h index b493829..c8dacd4 100644 --- a/src/mono/mono/metadata/icall-def-netcore.h +++ b/src/mono/mono/metadata/icall-def-netcore.h @@ -37,7 +37,7 @@ NOHANDLES(ICALL(ARGI_3, "IntGetNextArgWithType", ves_icall_System_ArgIterator_In NOHANDLES(ICALL(ARGI_4, "Setup", ves_icall_System_ArgIterator_Setup)) ICALL_TYPE(ARRAY, "System.Array", ARRAY_0) -HANDLES(ARRAY_0, "CanChangePrimitive", ves_icall_System_Array_CanChangePrimitive, MonoBoolean, 3, (MonoReflectionType, MonoReflectionType, MonoBoolean)) +NOHANDLES(ICALL(ARRAY_0, "CanChangePrimitive", ves_icall_System_Array_CanChangePrimitive)) HANDLES(ARRAY_4, "FastCopy", ves_icall_System_Array_FastCopy, MonoBoolean, 5, (MonoArray, int, MonoArray, int, int)) HANDLES(ARRAY_4a, "GetCorElementTypeOfElementType", ves_icall_System_Array_GetCorElementTypeOfElementType, gint32, 1, (MonoArray)) NOHANDLES(ICALL(ARRAY_5, "GetGenericValue_icall", ves_icall_System_Array_GetGenericValue_icall)) diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index dcdd8e0..d72b324 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -336,10 +336,13 @@ get_normalized_integral_array_element_type (MonoTypeEnum elementType) } MonoBoolean -ves_icall_System_Array_CanChangePrimitive (MonoReflectionTypeHandle ref_src_type, MonoReflectionTypeHandle ref_dst_type, MonoBoolean reliable, MonoError *error) +ves_icall_System_Array_CanChangePrimitive (MonoReflectionType *volatile* ref_src_type_handle, MonoReflectionType *volatile* ref_dst_type_handle, MonoBoolean reliable) { - MonoType *src_type = MONO_HANDLE_GETVAL (ref_src_type, type); - MonoType *dst_type = MONO_HANDLE_GETVAL (ref_dst_type, type); + MonoReflectionType* const ref_src_type = *ref_src_type_handle; + MonoReflectionType* const ref_dst_type = *ref_dst_type_handle; + + MonoType *src_type = ref_src_type->type; + MonoType *dst_type = ref_dst_type->type; g_assert (mono_type_is_primitive (src_type)); g_assert (mono_type_is_primitive (dst_type)); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs index 4644768..1010479 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs @@ -154,7 +154,7 @@ namespace System if (reliable) { if (!dst_type.Equals (src_type) && - !(dst_type.IsPrimitive && src_type.IsPrimitive && CanChangePrimitive(dst_type, src_type, true))) { + !(dst_type.IsPrimitive && src_type.IsPrimitive && CanChangePrimitive(ref dst_type, ref src_type, true))) { throw new ArrayTypeMismatchException (SR.ArrayTypeMismatch_CantAssignType); } } else { @@ -219,7 +219,7 @@ namespace System } else if (source.IsPrimitive && target.IsPrimitive) { // Allow primitive type widening - return CanChangePrimitive (source, target, false); + return CanChangePrimitive (ref source, ref target, false); } else if (!source.IsValueType && !source.IsPointer) { // Source is base class or interface of destination type if (target.IsPointer) @@ -486,7 +486,7 @@ namespace System extern bool IsValueOfElementType(object value); [MethodImplAttribute (MethodImplOptions.InternalCall)] - extern static bool CanChangePrimitive (Type srcType, Type dstType, bool reliable); + extern static bool CanChangePrimitive (ref Type srcType, ref Type dstType, bool reliable); [MethodImplAttribute (MethodImplOptions.InternalCall)] internal extern static bool FastCopy (Array source, int source_idx, Array dest, int dest_idx, int length); -- 2.7.4