]> granicus.if.org Git - gc/commitdiff
Do not set GC_lock_holder by call_with_alloc_lock if assertions disabled
authorIvan Maidanski <ivmai@mail.ru>
Mon, 15 Jul 2013 13:18:12 +0000 (17:18 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 15 Jul 2013 13:18:12 +0000 (17:18 +0400)
* include/private/gc_locks.h (GC_lock_holder): Do not declare unless
GC_ASSERTIONS (the variable is not longer used to prevent recursive
reentry in the system call wrapper).
* misc.c (GC_call_with_alloc_lock): Remove [UN]SET_LOCK_HOLDER
explicit calls since GC_lock_holder is set properly by [UN]LOCK()
(in case of GC_ASSERTIONS).
* pthread_support.c (GC_lock_holder): Do not define unless
GC_ASSERTIONS; adjust comment.
* win32_threads.c (GC_lock_holder): Likewise.

include/private/gc_locks.h
misc.c
pthread_support.c
win32_threads.c

index 4974afac21c9334c86b39993351f3a08dc976136..29e38c973e94ca510bb5efa377a834753d662dea 100644 (file)
@@ -55,9 +55,9 @@
 #    define NOSERVICE
 #    include <windows.h>
 #    define NO_THREAD (DWORD)(-1)
-     GC_EXTERN DWORD GC_lock_holder;
      GC_EXTERN CRITICAL_SECTION GC_allocate_ml;
 #    ifdef GC_ASSERTIONS
+         GC_EXTERN DWORD GC_lock_holder;
 #        define UNCOND_LOCK() \
                 { GC_ASSERT(I_DONT_HOLD_LOCK()); \
                   EnterCriticalSection(&GC_allocate_ml); \
 #    define ENTER_GC() GC_collecting = 1;
 #    define EXIT_GC() GC_collecting = 0;
      GC_INNER void GC_lock(void);
-     GC_EXTERN unsigned long GC_lock_holder;
+#    ifdef GC_ASSERTIONS
+       GC_EXTERN unsigned long GC_lock_holder;
+#    endif
 #  endif /* GC_PTHREADS with linux_threads.c implementation */
    GC_EXTERN GC_bool GC_need_to_lock;
 
diff --git a/misc.c b/misc.c
index f0e4480f3d94381736d62d57805195b6bd3b8aaf..366603c2730a2805073a51fa27aceceabe4ad902 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1808,14 +1808,9 @@ GC_API void * GC_CALL GC_call_with_alloc_lock(GC_fn_type fn, void *client_data)
 
 #   ifdef THREADS
       LOCK();
-      /* FIXME - This looks wrong!! */
-      SET_LOCK_HOLDER();
 #   endif
     result = (*fn)(client_data);
 #   ifdef THREADS
-#     ifndef GC_ASSERTIONS
-        UNSET_LOCK_HOLDER();
-#     endif /* o.w. UNLOCK() does it implicitly */
       UNLOCK();
 #   endif
     return(result);
index e851907fbe61ec6b55585ba9ed1609c9da5e4843..994a2edf35f02cb0f9b867627476f8233281315f 100644 (file)
 #if !defined(USE_SPIN_LOCK)
   GC_INNER pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
 #endif
-GC_INNER unsigned long GC_lock_holder = NO_THREAD;
-                /* Used only for assertions, and to prevent      */
-                /* recursive reentry in the system call wrapper. */
+
+#ifdef GC_ASSERTIONS
+  GC_INNER unsigned long GC_lock_holder = NO_THREAD;
+                /* Used only for assertions.    */
+#endif
 
 #if defined(GC_DGUX386_THREADS)
 # include <sys/dg_sys_info.h>
index 4fd1d92807ca74d34c4ef5e46d2eb1bb70fd72af..c16946b756cee4df1b6af31f1cc1120eea739bc5 100644 (file)
 /* Allocation lock declarations.        */
 #if !defined(USE_PTHREAD_LOCKS)
   GC_INNER CRITICAL_SECTION GC_allocate_ml;
-  GC_INNER DWORD GC_lock_holder = NO_THREAD;
+# ifdef GC_ASSERTIONS
+    GC_INNER DWORD GC_lock_holder = NO_THREAD;
         /* Thread id for current holder of allocation lock */
+# endif
 #else
   GC_INNER pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
-  GC_INNER unsigned long GC_lock_holder = NO_THREAD;
+# ifdef GC_ASSERTIONS
+    GC_INNER unsigned long GC_lock_holder = NO_THREAD;
+# endif
 #endif
 
 #undef CreateThread