2010-10-09 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Sat, 9 Oct 2010 06:05:29 +0000 (06:05 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:55 +0000 (21:06 +0400)
* darwin_stop_world.c (GC_mach_thread): Move from
darwin_stop_world.h.
* include/private/darwin_stop_world.h (GC_mach_thread): Remove.
* win32_threads.c (GC_start_world): Define "thread_id" local
variable only if GC_ASSERTIONS; decide whether to resume a thread
based on its "suspended" field value; assert that suspended thread
stack_base is non-zero and the thread is not our one.

ChangeLog
darwin_stop_world.c
include/private/darwin_stop_world.h
win32_threads.c

index 1a13e23..95836fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-09  Ivan Maidanski <ivmai@mail.ru>
+
+       * darwin_stop_world.c (GC_mach_thread): Move from
+       darwin_stop_world.h.
+       * include/private/darwin_stop_world.h (GC_mach_thread): Remove.
+       * win32_threads.c (GC_start_world): Define "thread_id" local
+       variable only if GC_ASSERTIONS; decide whether to resume a thread
+       based on its "suspended" field value; assert that suspended thread
+       stack_base is non-zero and the thread is not our one.
+
 2010-10-08  Ivan Maidanski <ivmai@mail.ru>
 
        * darwin_stop_world.c (GC_thread_resume): New inline function
index 7ba0133..0124dc7 100644 (file)
@@ -304,6 +304,12 @@ STATIC GC_bool GC_use_mach_handler_thread = FALSE;
 #ifndef GC_MAX_MACH_THREADS
 # define GC_MAX_MACH_THREADS THREAD_TABLE_SZ
 #endif
+
+struct GC_mach_thread {
+  thread_act_t thread;
+  GC_bool already_suspended;
+};
+
 static struct GC_mach_thread GC_mach_threads[GC_MAX_MACH_THREADS];
 STATIC int GC_mach_threads_count = 0;
 /* FIXME: it is better to implement GC_mach_threads as a hash set.  */
index f480869..787c357 100644 (file)
@@ -30,9 +30,4 @@ struct thread_stop_info {
   ptr_t stack_ptr; /* Valid only when stopped.  */
 };
 
-struct GC_mach_thread {
-  thread_act_t thread;
-  GC_bool already_suspended;
-};
-
 #endif
index 894e10f..05c7c56 100644 (file)
@@ -1067,7 +1067,9 @@ GC_INNER void GC_stop_world(void)
 
 GC_INNER void GC_start_world(void)
 {
-  DWORD thread_id = GetCurrentThreadId();
+# ifdef GC_ASSERTIONS
+    DWORD thread_id = GetCurrentThreadId();
+# endif
   int i;
 
   GC_ASSERT(I_HOLD_LOCK());
@@ -1075,8 +1077,8 @@ GC_INNER void GC_start_world(void)
     LONG my_max = GC_get_max_thread_index();
     for (i = 0; i <= my_max; i++) {
       GC_thread t = (GC_thread)(dll_thread_table + i);
-      if (t -> stack_base != 0 && t -> suspended
-          && t -> id != thread_id) {
+      if (t -> suspended) {
+        GC_ASSERT(t -> stack_base != 0 && t -> id != thread_id);
         if (ResumeThread(THREAD_HANDLE(t)) == (DWORD)-1)
           ABORT("ResumeThread failed");
         t -> suspended = FALSE;
@@ -1088,8 +1090,8 @@ GC_INNER void GC_start_world(void)
 
     for (i = 0; i < THREAD_TABLE_SZ; i++) {
       for (t = GC_threads[i]; t != 0; t = t -> tm.next) {
-        if (t -> stack_base != 0 && t -> suspended
-            && t -> id != thread_id) {
+        if (t -> suspended) {
+          GC_ASSERT(t -> stack_base != 0 && t -> id != thread_id);
           if (ResumeThread(THREAD_HANDLE(t)) == (DWORD)-1)
             ABORT("ResumeThread failed");
           UNPROTECT_THREAD(t);