Author: miguel
Date: 2005-04-28 15:42:31 -0400 (Thu, 28 Apr 2005)
New Revision: 43741

Modified:
   branches/mono-1-1-6/mcs/class/corlib/System.Threading/Thread.cs
   branches/mono-1-1-6/mono/mono/metadata/object-internals.h
   branches/mono-1-1-6/mono/mono/metadata/threads.c
   branches/mono-1-1-6/mono/mono/mini/mini-amd64.c
Log:
Revert the Exit patches as they introduce 16 regressions alone, add amd64 fix

Modified: branches/mono-1-1-6/mcs/class/corlib/System.Threading/Thread.cs
===================================================================
--- branches/mono-1-1-6/mcs/class/corlib/System.Threading/Thread.cs     
2005-04-28 19:32:28 UTC (rev 43740)
+++ branches/mono-1-1-6/mcs/class/corlib/System.Threading/Thread.cs     
2005-04-28 19:42:31 UTC (rev 43741)
@@ -82,7 +82,6 @@
                private IntPtr appdomain_refs;
                private bool interruption_requested;
                private IntPtr suspend_event;
-               private IntPtr suspended_event;
                private IntPtr resume_event;
                private object synch_lock = new Object();
                private IntPtr serialized_culture_info;

Modified: branches/mono-1-1-6/mono/mono/metadata/object-internals.h
===================================================================
--- branches/mono-1-1-6/mono/mono/metadata/object-internals.h   2005-04-28 
19:32:28 UTC (rev 43740)
+++ branches/mono-1-1-6/mono/mono/metadata/object-internals.h   2005-04-28 
19:42:31 UTC (rev 43741)
@@ -239,7 +239,6 @@
        GSList *appdomain_refs;
        MonoBoolean interruption_requested;
        gpointer suspend_event;
-       gpointer suspended_event;
        gpointer resume_event;
        MonoObject *synch_lock;
        guint8* serialized_culture_info;

Modified: branches/mono-1-1-6/mono/mono/metadata/threads.c
===================================================================
--- branches/mono-1-1-6/mono/mono/metadata/threads.c    2005-04-28 19:32:28 UTC 
(rev 43740)
+++ branches/mono-1-1-6/mono/mono/metadata/threads.c    2005-04-28 19:42:31 UTC 
(rev 43741)
@@ -1798,22 +1798,13 @@
        LeaveCriticalSection (&threads_mutex);
 }
 
-static void
-collect_threads (gpointer key, gpointer value, gpointer user_data)
+static void suspend_thread (gpointer key, gpointer value, gpointer user)
 {
-       MonoThread *thread = (MonoThread*)value;
-       struct wait_data *wait = (struct wait_data*)user_data;
-       HANDLE handle;
-
-       if (wait->num<MAXIMUM_WAIT_OBJECTS) {
-               handle = OpenThread (THREAD_ALL_ACCESS, TRUE, thread->tid);
-               if (handle == NULL)
-                       return;
-
-               wait->handles [wait->num] = handle;
-               wait->threads [wait->num] = thread;
-               wait->num++;
-       }
+       MonoThread *thread=(MonoThread *)value;
+       guint32 self=GPOINTER_TO_UINT (user);
+       
+       if ((thread->tid!=self) && !mono_gc_is_finalizer_thread (thread))
+               SuspendThread (thread->handle);
 }
 
 /*
@@ -1823,64 +1814,12 @@
  */
 void mono_thread_suspend_all_other_threads (void)
 {
-       struct wait_data *wait = g_new0 (struct wait_data, 1);
-       int i, waitnum;
-       guint32 self = GetCurrentThreadId ();
+       guint32 self=GetCurrentThreadId ();
 
-       do {
-               /* 
-                * Make a copy of the hashtable since we can't do anything with
-                * threads while threads_mutex is held.
-                */
-               EnterCriticalSection (&threads_mutex);
-               mono_g_hash_table_foreach (threads, collect_threads, wait);
-               LeaveCriticalSection (&threads_mutex);
-
-               waitnum = 0;
-               for (i = 0; i < wait->num; ++i) {
-                       MonoThread *thread = wait->threads [i];
-
-                       if ((thread->tid == self) || 
mono_gc_is_finalizer_thread (thread)) {
-                               //CloseHandle (wait->handles [i]);
-                               continue;
-                       }
-
-                       mono_monitor_enter (thread->synch_lock);
-
-                       if ((thread->state & ThreadState_Suspended) != 0 || 
-                               (thread->state & ThreadState_SuspendRequested) 
!= 0 ||
-                               (thread->state & ThreadState_StopRequested) != 
0 ||
-                               (thread->state & ThreadState_Stopped) != 0) {
-                               mono_monitor_exit (thread->synch_lock);
-                               CloseHandle (wait->handles [i]);
-                               continue;
-                       }
-       
-                       thread->state |= ThreadState_SuspendRequested;
-
-                       //printf ("S: %d\n", thread->state);
-                       thread->suspended_event = CreateEvent (NULL, TRUE, 
FALSE, NULL);
-
-                       mono_monitor_exit (thread->synch_lock);
-
-                       /* Signal the thread to suspend */
-                       signal_thread_state_change (thread);
-
-                       /* Wait for it to become suspended */
-                       //printf ("W1\n");
-                       WaitForSingleObject (thread->suspended_event, INFINITE);
-                       //printf ("W2\n");
-
-                       CloseHandle (thread->suspended_event);
-                       thread->suspended_event = NULL;
-
-                       CloseHandle (wait->handles [i]);
-                       
-                       waitnum ++;
-               }
-       } while (waitnum > 0);
-
-       g_free (wait);
+       EnterCriticalSection (&threads_mutex);
+       mono_g_hash_table_foreach (threads, suspend_thread,
+                                  GUINT_TO_POINTER (self));
+       LeaveCriticalSection (&threads_mutex);
 }
 
 /*
@@ -2328,8 +2267,6 @@
                thread->state &= ~ThreadState_SuspendRequested;
                thread->state |= ThreadState_Suspended;
                thread->suspend_event = CreateEvent (NULL, TRUE, FALSE, NULL);
-               if (thread->suspended_event)
-                       SetEvent (thread->suspended_event);
                mono_monitor_exit (thread->synch_lock);
                
                WaitForSingleObject (thread->suspend_event, INFINITE);
@@ -2391,7 +2328,7 @@
                
                thread->interruption_requested = TRUE;
                mono_monitor_exit (thread->synch_lock);
-
+               
                /* this will awake the thread if it is in WaitForSingleObject 
               or similar */
                QueueUserAPC (dummy_apc, thread->handle, NULL);
@@ -2420,7 +2357,7 @@
        MonoThread *thread = mono_thread_current ();
 
        /* The thread may already be stopping */
-       if (thread == NULL)
+       if (thread == NULL) 
                return;
        
        if (thread->interruption_requested && (bypass_abort_protection || 
!is_running_protected_wrapper ())) {

Modified: branches/mono-1-1-6/mono/mono/mini/mini-amd64.c
===================================================================
--- branches/mono-1-1-6/mono/mono/mini/mini-amd64.c     2005-04-28 19:32:28 UTC 
(rev 43740)
+++ branches/mono-1-1-6/mono/mono/mini/mini-amd64.c     2005-04-28 19:42:31 UTC 
(rev 43741)
@@ -1286,6 +1286,19 @@
                                        /* The callee might be an AOT method */
                                        near_call = FALSE;
                        }
+
+                       if (patch_type == MONO_PATCH_INFO_INTERNAL_METHOD) {
+                               /* 
+                                * The call might go directly to a native 
function without
+                                * the wrapper.
+                                */
+                               MonoJitICallInfo *mi = 
mono_find_jit_icall_by_name (data);
+                               if (mi) {
+                                       gconstpointer target = 
mono_icall_get_wrapper (mi);
+                                       if ((((guint64)target) >> 32) != 0)
+                                               near_call = FALSE;
+                               }
+                       }
                }
                else {
                        if (mono_find_class_init_trampoline_by_addr (data))

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to