From bf4188e9dd2b1aed809ecf16e27e2b0a2497aab7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 22 Oct 2019 11:54:15 +0200 Subject: [PATCH] Update Mono for changes in shared CoreLib partition Commit migrated from https://github.com/mono/mono/commit/cf1a9e003371495f4fff86c690da0213fff29c85 --- src/mono/mono/metadata/icall-def-netcore.h | 10 ++-- src/mono/mono/metadata/icall.c | 53 +--------------------- src/mono/netcore/CoreFX.issues.rsp | 7 +++ .../System.Private.CoreLib.csproj | 1 - .../RuntimeHelpers.cs | 4 -- .../src/System.Runtime/RuntimeImports.cs | 32 ------------- .../System.Private.CoreLib/src/System/Buffer.cs | 20 +++++--- 7 files changed, 25 insertions(+), 102 deletions(-) delete mode 100644 src/mono/netcore/System.Private.CoreLib/src/System.Runtime/RuntimeImports.cs diff --git a/src/mono/mono/metadata/icall-def-netcore.h b/src/mono/mono/metadata/icall-def-netcore.h index d221baf..3e13bb5 100644 --- a/src/mono/mono/metadata/icall-def-netcore.h +++ b/src/mono/mono/metadata/icall-def-netcore.h @@ -54,10 +54,10 @@ HANDLES(ARRAY_13, "SetValueImpl", ves_icall_System_Array_SetValueImpl, void, 3, HANDLES(ARRAY_14, "SetValueRelaxedImpl", ves_icall_System_Array_SetValueRelaxedImpl, void, 3, (MonoArray, MonoObject, guint32)) ICALL_TYPE(BUFFER, "System.Buffer", BUFFER_0) -HANDLES(BUFFER_0, "BlockCopy", ves_icall_System_Buffer_BlockCopy, void, 5, (MonoArray, int, MonoArray, int, int)) -HANDLES(BUFFER_0a, "IsPrimitiveTypeArray", ves_icall_System_Buffer_IsPrimitiveTypeArray, MonoBoolean, 1, (MonoArray)) -HANDLES(BUFFER_1, "_ByteLength", ves_icall_System_Buffer_ByteLengthInternal, gint32, 1, (MonoArray)) +NOHANDLES(ICALL(BUFFER_0, "BulkMoveWithWriteBarrier", ves_icall_System_Runtime_RuntimeImports_RhBulkMoveWithWriteBarrier)) +HANDLES(BUFFER_1, "IsPrimitiveTypeArray", ves_icall_System_Buffer_IsPrimitiveTypeArray, MonoBoolean, 1, (MonoArray)) NOHANDLES(ICALL(BUFFER_2, "__Memmove", ves_icall_System_Runtime_RuntimeImports_Memmove)) +NOHANDLES(ICALL(BUFFER_3, "__ZeroMemory", ves_icall_System_Runtime_RuntimeImports_ZeroMemory)) ICALL_TYPE(DELEGATE, "System.Delegate", DELEGATE_1) HANDLES(DELEGATE_1, "AllocDelegateLike_internal", ves_icall_System_Delegate_AllocDelegateLike_internal, MonoMulticastDelegate, 1, (MonoDelegate)) @@ -379,10 +379,6 @@ HANDLES(ALC_2, "InternalInitializeNativeALC", ves_icall_System_Runtime_Loader_As HANDLES(ALC_1, "InternalLoadFile", ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalLoadFile, MonoReflectionAssembly, 3, (gpointer, MonoString, MonoStackCrawlMark_ptr)) HANDLES(ALC_3, "InternalLoadFromStream", ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalLoadFromStream, MonoReflectionAssembly, 5, (gpointer, gpointer, gint32, gpointer, gint32)) -ICALL_TYPE(RUNIMPORT, "System.Runtime.RuntimeImports", RUNIMPORT_1) -NOHANDLES(ICALL(RUNIMPORT_1, "RhBulkMoveWithWriteBarrier", ves_icall_System_Runtime_RuntimeImports_RhBulkMoveWithWriteBarrier)) -NOHANDLES(ICALL(RUNIMPORT_2, "ZeroMemory", ves_icall_System_Runtime_RuntimeImports_ZeroMemory)) - ICALL_TYPE(RFH, "System.RuntimeFieldHandle", RFH_1) HANDLES(RFH_1, "GetValueDirect", ves_icall_System_RuntimeFieldHandle_GetValueDirect, MonoObject, 4, (MonoReflectionField, MonoReflectionType, MonoTypedRef_ptr, MonoReflectionType)) HANDLES(RFH_1a, "SetValueDirect", ves_icall_System_RuntimeFieldHandle_SetValueDirect, void, 5, (MonoReflectionField, MonoReflectionType, MonoTypedRef_ptr, MonoObject, MonoReflectionType)) diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index b82b285..07ed114 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -7281,57 +7281,6 @@ mono_array_get_byte_length (MonoArrayHandle array) } #ifdef ENABLE_NETCORE -void -ves_icall_System_Buffer_BlockCopy (MonoArrayHandle src, int src_offset, MonoArrayHandle dst, int dst_offset, int count, MonoError *error) -{ - MONO_CHECK_ARG_NULL_HANDLE (src,); - MONO_CHECK_ARG_NULL_HANDLE (dst,); - - if (src_offset < 0) { - mono_error_set_argument_out_of_range (error, "srcOffset", "Value must be non-negative and less than or equal to Int32.MaxValue."); - return; - } - - if (dst_offset < 0) { - mono_error_set_argument_out_of_range (error, "dstOffset", "Value must be non-negative and less than or equal to Int32.MaxValue."); - return; - } - - if (count < 0) { - mono_error_set_argument_out_of_range (error, "count", "Value must be non-negative and less than or equal to Int32.MaxValue."); - return; - } - - MonoClass * const src_class = m_class_get_element_class (MONO_HANDLE_GETVAL (src, obj.vtable)->klass); - MonoClass * const dst_class = m_class_get_element_class (MONO_HANDLE_GETVAL (dst, obj.vtable)->klass); - - if (!m_class_is_primitive (src_class)) { - mono_error_set_argument (error, "src", "Object must be an array of primitives."); - return; - } - - if (!m_class_is_primitive (dst_class)) { - mono_error_set_argument (error, "dst", "Object must be an array of primitives."); - return; - } - - if ((src_offset > mono_array_get_byte_length (src) - count) || (dst_offset > mono_array_get_byte_length (dst) - count)) { - mono_error_set_argument (error, "", "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."); - return; - } - - MONO_ENTER_NO_SAFEPOINTS; - - guint8 const * const src_buf = (guint8*)MONO_HANDLE_RAW (src)->vector + src_offset; - guint8* const dst_buf = (guint8*)MONO_HANDLE_RAW (dst)->vector + dst_offset; - - memmove (dst_buf, src_buf, count); - - MONO_EXIT_NO_SAFEPOINTS; - - return; -} - MonoBoolean ves_icall_System_Buffer_IsPrimitiveTypeArray (MonoArrayHandle array, MonoError* error) { @@ -7346,13 +7295,13 @@ ves_icall_System_Buffer_ByteLengthInternal (MonoArrayHandle array, MonoError* er return mono_array_get_byte_length (array); } +#ifndef ENABLE_NETCORE void ves_icall_System_Buffer_MemcpyInternal (gpointer dest, gconstpointer src, gint32 count) { memcpy (dest, src, count); } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Buffer_BlockCopyInternal (MonoArrayHandle src, gint32 src_offset, MonoArrayHandle dest, gint32 dest_offset, gint32 count, MonoError* error) { diff --git a/src/mono/netcore/CoreFX.issues.rsp b/src/mono/netcore/CoreFX.issues.rsp index dbe18ed..0b6bc20 100644 --- a/src/mono/netcore/CoreFX.issues.rsp +++ b/src/mono/netcore/CoreFX.issues.rsp @@ -942,3 +942,10 @@ # Requires NativeLibrary implementation -nomethod System.Net.Tests.HttpWebRequestTest.ServicePoint_GetValue_ExpectedResult + +# Remove once we get https://github.com/dotnet/corefx/pull/41924 through Arcade +-nomethod System.Tests.BufferTests.BlockCopy_Invalid +# Remove once we get https://github.com/dotnet/corefx/pull/41851 through Arcade +-nomethod System.Text.Tests.DecoderConvert2.PosTest6 +# Remove once we get https://github.com/dotnet/corefx/pull/41926 through Arcade +-nomethod System.Security.Cryptography.DeriveBytesTests.PasswordDeriveBytesTests.GetBytes_ZeroLength diff --git a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj index da95014..d6dac40 100644 --- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -239,7 +239,6 @@ - diff --git a/src/mono/netcore/System.Private.CoreLib/src/System.Runtime.CompilerServices/RuntimeHelpers.cs b/src/mono/netcore/System.Private.CoreLib/src/System.Runtime.CompilerServices/RuntimeHelpers.cs index 5886d95..1fb26a1 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System.Runtime.CompilerServices/RuntimeHelpers.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System.Runtime.CompilerServices/RuntimeHelpers.cs @@ -65,10 +65,6 @@ namespace System.Runtime.CompilerServices return SufficientExecutionStack (); } - public static void ExecuteCodeWithGuaranteedCleanup (TryCode code, CleanupCode backoutCode, Object userData) - { - } - public static void PrepareDelegate (Delegate d) { } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System.Runtime/RuntimeImports.cs b/src/mono/netcore/System.Private.CoreLib/src/System.Runtime/RuntimeImports.cs deleted file mode 100644 index 816bc88..0000000 --- a/src/mono/netcore/System.Private.CoreLib/src/System.Runtime/RuntimeImports.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; - -#if BIT64 -using nuint = System.UInt64; -#else -using nuint = System.UInt32; -#endif - -namespace System.Runtime -{ - static class RuntimeImports - { - internal static unsafe void RhZeroMemory (ref byte b, nuint byteLength) - { - fixed (byte* bytePointer = &b) { - ZeroMemory (bytePointer, byteLength); - } - } - - internal static unsafe void RhZeroMemory (IntPtr p, UIntPtr byteLength) => ZeroMemory ((void*) p, (nuint) byteLength); - - [MethodImpl (MethodImplOptions.InternalCall)] - static extern unsafe void ZeroMemory (void* p, nuint byteLength); - - [MethodImpl (MethodImplOptions.InternalCall)] - internal extern static void RhBulkMoveWithWriteBarrier (ref byte dmem, ref byte smem, nuint size); - } -} diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Buffer.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Buffer.cs index 0fe168d..847a9e2 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Buffer.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Buffer.cs @@ -15,17 +15,25 @@ namespace System partial class Buffer { [MethodImpl (MethodImplOptions.InternalCall)] - public static extern void BlockCopy (Array src, int srcOffset, Array dst, int dstOffset, int count); - - [MethodImpl (MethodImplOptions.InternalCall)] - static extern int _ByteLength (Array array); - - [MethodImpl (MethodImplOptions.InternalCall)] static extern bool IsPrimitiveTypeArray (Array array); internal static unsafe void Memcpy (byte* dest, byte* src, int len) => Memmove (dest, src, (nuint) len); [MethodImpl (MethodImplOptions.InternalCall)] static extern unsafe void __Memmove (byte* dest, byte* src, nuint len); + + [MethodImpl (MethodImplOptions.InternalCall)] + static extern void BulkMoveWithWriteBarrier (ref byte dmem, ref byte smem, nuint size); + + [MethodImpl(MethodImplOptions.NoInlining)] + internal static unsafe void _ZeroMemory(ref byte b, nuint byteLength) + { + fixed (byte* bytePointer = &b) { + __ZeroMemory (bytePointer, byteLength); + } + } + + [MethodImpl (MethodImplOptions.InternalCall)] + static extern unsafe void __ZeroMemory (void* p, nuint byteLength); } } -- 2.7.4