From a5624bf9ea51ec48fcfc6eede409dc9ceda3d5d4 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 2 Mar 2017 16:06:27 -0500 Subject: [PATCH] [threads] Remove dead field cached_culture_info (#4410) --- mcs/class/corlib/System.Threading/Thread.cs | 4 +- mono/metadata/appdomain.c | 2 - mono/metadata/object-internals.h | 2 +- mono/metadata/threads-types.h | 2 - mono/metadata/threads.c | 54 --------------------- mono/sgen/sgen-debug.c | 6 --- 6 files changed, 2 insertions(+), 68 deletions(-) diff --git a/mcs/class/corlib/System.Threading/Thread.cs b/mcs/class/corlib/System.Threading/Thread.cs index 26222aca533..9145dfd158e 100644 --- a/mcs/class/corlib/System.Threading/Thread.cs +++ b/mcs/class/corlib/System.Threading/Thread.cs @@ -51,9 +51,7 @@ namespace System.Threading { // stores a thread handle IntPtr handle; IntPtr native_handle; // used only on Win32 - - /* Note this is an opaque object (an array), not a CultureInfo */ - private object cached_culture_info; + IntPtr unused3; /* accessed only from unmanaged code */ private IntPtr name; private int name_len; diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index f92cc949b6e..0a46dc5d4a6 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -2543,8 +2543,6 @@ unload_thread_main (void *arg) mono_domain_unlock (domain); mono_loader_unlock (); - mono_threads_clear_cached_culture (domain); - domain->state = MONO_APPDOMAIN_UNLOADED; /* printf ("UNLOADED %s.\n", domain->friendly_name); */ diff --git a/mono/metadata/object-internals.h b/mono/metadata/object-internals.h index e766126d255..c7ef8233bf7 100644 --- a/mono/metadata/object-internals.h +++ b/mono/metadata/object-internals.h @@ -362,7 +362,7 @@ struct _MonoInternalThread { volatile int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks. Used for appdomain_ref push/pop */ MonoThreadHandle *handle; gpointer native_handle; - MonoArray *cached_culture_info; + gpointer unused3; gunichar2 *name; guint32 name_len; guint32 state; diff --git a/mono/metadata/threads-types.h b/mono/metadata/threads-types.h index a63a741f4a9..75cef7ef363 100644 --- a/mono/metadata/threads-types.h +++ b/mono/metadata/threads-types.h @@ -211,8 +211,6 @@ void mono_thread_push_appdomain_ref (MonoDomain *domain); void mono_thread_pop_appdomain_ref (void); gboolean mono_thread_has_appdomain_ref (MonoThread *thread, MonoDomain *domain); -void mono_threads_clear_cached_culture (MonoDomain *domain); - MonoException* mono_thread_request_interruption (mono_bool running_managed); gboolean mono_thread_interruption_requested (void); MonoException* mono_thread_interruption_checkpoint (void); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 5269045c16e..1c47c444587 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -114,14 +114,6 @@ typedef struct { StaticDataFreeList *freelist; } StaticDataInfo; -/* Number of cached culture objects in the MonoThread->cached_culture_info array - * (per-type): we use the first NUM entries for CultureInfo and the last for - * UICultureInfo. So the size of the array is really NUM_CACHED_CULTURES * 2. - */ -#define NUM_CACHED_CULTURES 4 -#define CULTURES_START_IDX 0 -#define UICULTURES_START_IDX NUM_CACHED_CULTURES - /* Controls access to the 'threads' hash table */ static void mono_threads_lock (void); static void mono_threads_unlock (void); @@ -1130,17 +1122,6 @@ mono_thread_detach_internal (MonoInternalThread *thread) thread->abort_exc = NULL; thread->current_appcontext = NULL; - /* - * This is necessary because otherwise we might have - * cross-domain references which will not get cleaned up when - * the target domain is unloaded. - */ - if (thread->cached_culture_info) { - int i; - for (i = 0; i < NUM_CACHED_CULTURES * 2; ++i) - mono_array_set (thread->cached_culture_info, MonoObject*, i, NULL); - } - /* * thread->synch_cs can be NULL if this was called after * ves_icall_System_Threading_InternalThread_Thread_free_internal. @@ -1231,8 +1212,6 @@ mono_thread_detach_internal (MonoInternalThread *thread) if (thread == mono_thread_internal_current ()) mono_thread_pop_appdomain_ref (); - thread->cached_culture_info = NULL; - mono_free_static_data (thread->static_data); thread->static_data = NULL; ref_stack_destroy (thread->appdomain_refs); @@ -3934,39 +3913,6 @@ mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout) return TRUE; } -static void -clear_cached_culture (gpointer key, gpointer value, gpointer user_data) -{ - MonoInternalThread *thread = (MonoInternalThread*)value; - MonoDomain *domain = (MonoDomain*)user_data; - int i; - - /* No locking needed here */ - /* FIXME: why no locking? writes to the cache are protected with synch_cs above */ - - if (thread->cached_culture_info) { - for (i = 0; i < NUM_CACHED_CULTURES * 2; ++i) { - MonoObject *obj = mono_array_get (thread->cached_culture_info, MonoObject*, i); - if (obj && obj->vtable->domain == domain) - mono_array_set (thread->cached_culture_info, MonoObject*, i, NULL); - } - } -} - -/* - * mono_threads_clear_cached_culture: - * - * Clear the cached_current_culture from all threads if it is in the - * given appdomain. - */ -void -mono_threads_clear_cached_culture (MonoDomain *domain) -{ - mono_threads_lock (); - mono_g_hash_table_foreach (threads, clear_cached_culture, domain); - mono_threads_unlock (); -} - /* * mono_thread_get_undeniable_exception: * diff --git a/mono/sgen/sgen-debug.c b/mono/sgen/sgen-debug.c index a78fb3dad57..ae8e2ab2f20 100644 --- a/mono/sgen/sgen-debug.c +++ b/mono/sgen/sgen-debug.c @@ -958,12 +958,6 @@ is_xdomain_ref_allowed (GCObject **ptr, GCObject *obj, MonoDomain *domain) offset == G_STRUCT_OFFSET (MonoRealProxy, unwrapped_server)) return TRUE; #endif - /* Thread.cached_culture_info */ - if (!strcmp (ref->vtable->klass->name_space, "System.Globalization") && - !strcmp (ref->vtable->klass->name, "CultureInfo") && - !strcmp(o->vtable->klass->name_space, "System") && - !strcmp(o->vtable->klass->name, "Object[]")) - return TRUE; /* * at System.IO.MemoryStream.InternalConstructor (byte[],int,int,bool,bool) [0x0004d] in /home/schani/Work/novell/trunk/mcs/class/corlib/System.IO/MemoryStream.cs:121 * at System.IO.MemoryStream..ctor (byte[]) [0x00017] in /home/schani/Work/novell/trunk/mcs/class/corlib/System.IO/MemoryStream.cs:81 -- 2.25.1