From: Ivan Maidanski Date: Mon, 15 Jul 2013 13:18:12 +0000 (+0400) Subject: Do not set GC_lock_holder by call_with_alloc_lock if assertions disabled X-Git-Tag: gc7_4_0~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad4d8f40f526e7af1334b05a9d693ea03084b4bb;p=platform%2Fupstream%2Flibgc.git Do not set GC_lock_holder by call_with_alloc_lock if assertions disabled * 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. --- diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 4974afa..29e38c9 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -55,9 +55,9 @@ # define NOSERVICE # include # 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); \ @@ -177,7 +177,9 @@ # 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 f0e4480..366603c 100644 --- 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); diff --git a/pthread_support.c b/pthread_support.c index e851907..994a2ed 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -82,9 +82,11 @@ #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 diff --git a/win32_threads.c b/win32_threads.c index 4fd1d92..c16946b 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -32,11 +32,15 @@ /* 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