From a078b5501eb11e2d89cccfeee052e0182c2b863c Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 8 Jan 2021 09:59:02 -0500 Subject: [PATCH] Remove System.Runtime.Remoting.Contexts.Context, its not used anymore on netcore. (#46691) --- src/mono/mono/metadata/domain.c | 5 +++ src/mono/mono/metadata/object-internals.h | 2 + src/mono/mono/metadata/object.c | 2 + src/mono/mono/metadata/threads.c | 6 +++ .../System.Private.CoreLib.csproj | 1 - .../System/Runtime/Remoting/Contexts/Context.cs | 44 ---------------------- .../src/System/Threading/Thread.Mono.cs | 3 -- 7 files changed, 15 insertions(+), 48 deletions(-) delete mode 100644 src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Remoting/Contexts/Context.cs diff --git a/src/mono/mono/metadata/domain.c b/src/mono/mono/metadata/domain.c index 9c6927ef..073f86d 100644 --- a/src/mono/mono/metadata/domain.c +++ b/src/mono/mono/metadata/domain.c @@ -66,8 +66,13 @@ mono_thread_info_tls_set (info, TLS_KEY_DOMAIN, (x)); \ } while (FALSE) +#ifndef ENABLE_NETCORE #define GET_APPCONTEXT() (mono_thread_internal_current ()->current_appcontext) #define SET_APPCONTEXT(x) MONO_OBJECT_SETREF_INTERNAL (mono_thread_internal_current (), current_appcontext, (x)) +#else +#define GET_APPCONTEXT() NULL +#define SET_APPCONTEXT(x) +#endif static guint16 appdomain_list_size = 0; static guint16 appdomain_next = 0; diff --git a/src/mono/mono/metadata/object-internals.h b/src/mono/mono/metadata/object-internals.h index a5d6e8a..db47b08 100644 --- a/src/mono/mono/metadata/object-internals.h +++ b/src/mono/mono/metadata/object-internals.h @@ -594,7 +594,9 @@ struct _MonoInternalThread { gsize debugger_thread; // FIXME switch to bool as soon as CI testing with corlib version bump works gpointer *static_data; struct _MonoThreadInfo *thread_info; +#ifndef ENABLE_NETCORE MonoAppContext *current_appcontext; +#endif MonoThread *root_domain_thread; MonoObject *_serialized_principal; int _serialized_principal_version; diff --git a/src/mono/mono/metadata/object.c b/src/mono/mono/metadata/object.c index bed293e..d70e3df 100644 --- a/src/mono/mono/metadata/object.c +++ b/src/mono/mono/metadata/object.c @@ -1255,10 +1255,12 @@ field_is_special_static (MonoClass *fklass, MonoClassField *field) mono_custom_attrs_free (ainfo); return SPECIAL_STATIC_THREAD; } +#ifndef ENABLE_NETCORE else if (strcmp (klass_name, "ContextStaticAttribute") == 0) { mono_custom_attrs_free (ainfo); return SPECIAL_STATIC_CONTEXT; } +#endif } } mono_custom_attrs_free (ainfo); diff --git a/src/mono/mono/metadata/threads.c b/src/mono/mono/metadata/threads.c index ad2e348..4bb0579 100644 --- a/src/mono/mono/metadata/threads.c +++ b/src/mono/mono/metadata/threads.c @@ -999,7 +999,9 @@ mono_thread_detach_internal (MonoInternalThread *thread) thread->abort_state_handle = 0; thread->abort_exc = NULL; +#ifndef ENABLE_NETCORE thread->current_appcontext = NULL; +#endif LOCK_THREAD (thread); @@ -5039,7 +5041,11 @@ mono_get_special_static_data_for_thread (MonoInternalThread *thread, guint32 off if (static_type == SPECIAL_STATIC_OFFSET_TYPE_THREAD) { return get_thread_static_data (thread, offset); } else { +#ifndef ENABLE_NETCORE return get_context_static_data (thread->current_appcontext, offset); +#else + g_assert_not_reached (); +#endif } } 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 ebdf5f5..0414110 100644 --- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -243,7 +243,6 @@ - diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Remoting/Contexts/Context.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Remoting/Contexts/Context.cs deleted file mode 100644 index 3252b4f..0000000 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Remoting/Contexts/Context.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; - -namespace System.Runtime.Remoting.Contexts -{ - - [StructLayout(LayoutKind.Sequential)] - /* FIXME: Mono: this was public in mscorlib */ - internal class Context - { -#pragma warning disable 169, 414 - #region Sync with domain-internals.h - private int domain_id; - private int context_id; - private UIntPtr static_data; /* GC-tracked */ - private UIntPtr data; - #endregion -#pragma warning restore 169, 414 - - [MethodImpl(MethodImplOptions.InternalCall)] - private static extern void RegisterContext(Context ctx); - - [MethodImpl(MethodImplOptions.InternalCall)] - private static extern void ReleaseContext(Context ctx); - - public Context() - { -#if false - domain_id = Thread.GetDomainID(); - context_id = Interlocked.Increment (ref global_count); - - RegisterContext (this); -#endif - } - - ~Context() - { - ReleaseContext(this); - } - } -} diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs index 24662e2..104995f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs @@ -34,9 +34,6 @@ namespace System.Threading private IntPtr debugger_thread; // FIXME switch to bool as soon as CI testing with corlib version bump works private UIntPtr static_data; /* GC-tracked */ private IntPtr runtime_thread_info; - /* current System.Runtime.Remoting.Contexts.Context instance - keep as an object to avoid triggering its class constructor when not needed */ - private object? current_appcontext; private object? root_domain_thread; internal byte[]? _serialized_principal; internal int _serialized_principal_version; -- 2.7.4