[threads] Remove dead field cached_culture_info (#4410)
authorLudovic Henry <ludovic@xamarin.com>
Thu, 2 Mar 2017 21:06:27 +0000 (16:06 -0500)
committerGitHub <noreply@github.com>
Thu, 2 Mar 2017 21:06:27 +0000 (16:06 -0500)
mcs/class/corlib/System.Threading/Thread.cs
mono/metadata/appdomain.c
mono/metadata/object-internals.h
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/sgen/sgen-debug.c

index 26222aca533fc40cfcf949e47a8cdb0b9cd800c7..9145dfd158e085542eb0216c3a2570a254b8bec5 100644 (file)
@@ -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; 
index f92cc949b6ee5160c1931415f97aa874881eb5bf..0a46dc5d4a656591356cda09cc7d3b3f53e78f4a 100644 (file)
@@ -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); */
index e766126d255bb096b20daf60fdec2a23d3ebbf7e..c7ef8233bf784883c91ae60d878759d5a63c4df7 100644 (file)
@@ -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;
index a63a741f4a941e186f5b6122c7aa6efb5bbf9244..75cef7ef363b6918751e492c361fdff983e0208c 100644 (file)
@@ -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);
index 5269045c16e9452d8a3ddec6ad33386b40bffa54..1c47c4445871cb0f65d0ddbe6fe9710b52d870bd 100644 (file)
@@ -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:
  *
index a78fb3dad57e7b8d3d3d31671ba54a5d24a13f05..ae8e2ab2f20cb5498bb559cb577e9c18c37c01cf 100644 (file)
@@ -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