+2010-10-05 Ivan Maidanski <ivmai@mail.ru>
+
+ * finalize.c (GC_check_finalizer_nested): Change return type to
+ char pointer (instead of int pointer); use explicit cast for
+ GC_finalizer_nested assignment.
+ * pthread_support.c (GC_check_finalizer_nested): Ditto.
+ * win32_threads.c (GC_check_finalizer_nested): Ditto.
+ * finalize.c (GC_finalizer_nested): Change type to unsigned char.
+ * finalize.c (GC_notify_or_invoke_finalizers): Change type of
+ "pnested" local variable to char pointer.
+ * pthread_support.c (GC_do_blocking_inner,
+ GC_call_with_gc_active): Use explicit cast for "thread_blocked"
+ field assignment.
+ * win32_threads.c (GC_lookup_pthread): Use explicit cast for
+ "suspended" field assignment.
+ * win32_threads.c (GC_Thread_Rep): Use short type for
+ finalizer_skipped; use char type for finalizer_nested and flags
+ fields and reorder some fields (to minimize GC_Thread_Rep
+ structure size).
+ * include/private/pthread_support.h (GC_Thread_Rep): Ditto.
+ * win32_threads.c (GC_Thread_Rep): Use char type for suspended
+ field (instead of GC_bool).
+ * include/private/pthread_support.h (GC_Thread_Rep): Use char type
+ for thread_blocked field (instead of short).
+
2010-09-30 Ivan Maidanski <ivmai@mail.ru>
* darwin_stop_world.c (GC_query_task_threads): New variable (or
/* Defined in pthread_support.c or win32_threads.c. Called with the */
/* allocation lock held. */
GC_INNER void GC_reset_finalizer_nested(void);
- GC_INNER unsigned *GC_check_finalizer_nested(void);
+ GC_INNER unsigned char *GC_check_finalizer_nested(void);
#else
/* Global variables to minimize the level of recursion when a client */
/* finalizer allocates memory. */
- STATIC unsigned GC_finalizer_nested = 0;
+ STATIC unsigned char GC_finalizer_nested = 0;
STATIC unsigned GC_finalizer_skipped = 0;
/* Checks and updates the level of finalizers recursion. */
/* Returns NULL if GC_invoke_finalizers() should not be called by the */
/* collector (to minimize the risk of a deep finalizers recursion), */
/* otherwise returns a pointer to GC_finalizer_nested. */
- STATIC unsigned *GC_check_finalizer_nested(void)
+ STATIC unsigned char *GC_check_finalizer_nested(void)
{
unsigned nesting_level = GC_finalizer_nested;
if (nesting_level) {
if (++GC_finalizer_skipped < (1U << nesting_level)) return NULL;
GC_finalizer_skipped = 0;
}
- GC_finalizer_nested = nesting_level + 1;
+ GC_finalizer_nested = (unsigned char)(nesting_level + 1);
return &GC_finalizer_nested;
}
#endif /* THREADS */
}
if (!GC_finalize_on_demand) {
- unsigned *pnested = GC_check_finalizer_nested();
+ unsigned char *pnested = GC_check_finalizer_nested();
UNLOCK();
/* Skip GC_invoke_finalizers() if nested */
if (pnested != NULL) {
/* Extra bookkeeping information the stopping code uses */
struct thread_stop_info stop_info;
- short flags;
+ unsigned char flags;
# define FINISHED 1 /* Thread has exited. */
# define DETACHED 2 /* Thread is treated as detached. */
/* Thread may really be detached, or */
# define DISABLED_GC 8 /* Collections are disabled while the */
/* thread is exiting. */
- short thread_blocked; /* Protected by GC lock. */
+ unsigned char thread_blocked;
+ /* Protected by GC lock. */
/* Treated as a boolean value. If set, */
/* thread will acquire GC lock before */
/* doing any pointer manipulations, and */
/* has set its sp value. Thus it does */
/* not need to be sent a signal to stop */
/* it. */
+
+ unsigned short finalizer_skipped;
+ unsigned char finalizer_nested;
+ /* Used by GC_check_finalizer_nested() */
+ /* to minimize the level of recursion */
+ /* when a client finalizer allocates */
+ /* memory (initially both are 0). */
+
ptr_t stack_end; /* Cold end of the stack (except for */
/* main thread). */
# ifdef IA64
/* reason we need to intercept join */
/* and detach. */
- unsigned finalizer_nested;
- unsigned finalizer_skipped; /* Used by GC_check_finalizer_nested() */
- /* to minimize the level of recursion */
- /* when a client finalizer allocates */
- /* memory (initially both are 0). */
-
# ifdef THREAD_LOCAL_ALLOC
struct thread_local_freelists tlfs;
# endif
/* collector (to minimize the risk of a deep finalizers recursion), */
/* otherwise returns a pointer to the thread-local finalizer_nested. */
/* Called by GC_notify_or_invoke_finalizers() only (the lock is held). */
-GC_INNER unsigned *GC_check_finalizer_nested(void)
+GC_INNER unsigned char *GC_check_finalizer_nested(void)
{
GC_thread me = GC_lookup_thread(pthread_self());
unsigned nesting_level = me->finalizer_nested;
if (++me->finalizer_skipped < (1U << nesting_level)) return NULL;
me->finalizer_skipped = 0;
}
- me->finalizer_nested = nesting_level + 1;
+ me->finalizer_nested = (unsigned char)(nesting_level + 1);
return &me->finalizer_nested;
}
# ifdef IA64
me -> backing_store_ptr = GC_save_regs_in_stack();
# endif
- me -> thread_blocked = TRUE;
+ me -> thread_blocked = (unsigned char)TRUE;
/* Save context here if we want to support precise stack marking */
UNLOCK();
d -> client_data = (d -> fn)(d -> client_data);
GC_stackbottom = (ptr_t)(&stacksect);
}
- if (me -> thread_blocked == FALSE) {
+ if (!me->thread_blocked) {
/* We are not inside GC_do_blocking() - do nothing more. */
UNLOCK();
return fn(client_data);
# ifdef IA64
me -> backing_store_ptr = stacksect.saved_backing_store_ptr;
# endif
- me -> thread_blocked = TRUE;
+ me -> thread_blocked = (unsigned char)TRUE;
me -> stop_info.stack_ptr = stacksect.saved_stack_ptr;
UNLOCK();
/* GC_call_with_gc_active() of this */
/* thread. May be NULL. */
- unsigned finalizer_nested;
- unsigned finalizer_skipped; /* Used by GC_check_finalizer_nested() */
+ unsigned short finalizer_skipped;
+ unsigned char finalizer_nested;
+ /* Used by GC_check_finalizer_nested() */
/* to minimize the level of recursion */
/* when a client finalizer allocates */
/* memory (initially both are 0). */
- GC_bool suspended;
+ unsigned char suspended; /* really of GC_bool type */
# ifdef GC_PTHREADS
- void *status; /* hold exit value until join in case it's a pointer */
- pthread_t pthread_id;
- short flags; /* Protected by GC lock. */
+ unsigned char flags; /* Protected by GC lock. */
# define FINISHED 1 /* Thread has exited. */
# define DETACHED 2 /* Thread is intended to be detached. */
# define KNOWN_FINISHED(t) (((t) -> flags) & FINISHED)
+ pthread_t pthread_id;
+ void *status; /* hold exit value until join in case it's a pointer */
# else
# define KNOWN_FINISHED(t) 0
# endif
+
# ifdef THREAD_LOCAL_ALLOC
struct thread_local_freelists tlfs;
# endif
/* otherwise returns a pointer to the thread-local finalizer_nested. */
/* Called by GC_notify_or_invoke_finalizers() only (the lock is held). */
/* GC_check_finalizer_nested() is the same as in pthread_support.c. */
-GC_INNER unsigned *GC_check_finalizer_nested(void)
+GC_INNER unsigned char *GC_check_finalizer_nested(void)
{
GC_thread me = GC_lookup_thread_inner(GetCurrentThreadId());
unsigned nesting_level = me->finalizer_nested;
if (++me->finalizer_skipped < (1U << nesting_level)) return NULL;
me->finalizer_skipped = 0;
}
- me->finalizer_nested = nesting_level + 1;
+ me->finalizer_nested = (unsigned char)(nesting_level + 1);
return &me->finalizer_nested;
}
if (SuspendThread(t -> handle) == (DWORD)-1)
ABORT("SuspendThread failed");
# endif /* !MSWINCE */
- t -> suspended = TRUE;
+ t -> suspended = (unsigned char)TRUE;
# if defined(MPROTECT_VDB)
AO_CLEAR(&GC_fault_handler_lock);
# endif