+2010-10-16 Ivan Maidanski <ivmai@mail.ru>
+
+ * darwin_stop_world.c (DARWIN_SUSPEND_GC_THREADS,
+ DARWIN_QUERY_TASK_THREADS): New macro recognized.
+ * darwin_stop_world.c (GC_query_task_threads): add STATIC;
+ initialize to false; define as macro if DARWIN_SUSPEND_GC_THREADS
+ or DARWIN_QUERY_TASK_THREADS; remove FIXME.
+ * darwin_stop_world.c (GC_use_threads_discovery): New function
+ (for setting GC_query_task_threads value).
+ * darwin_stop_world.c (GC_mach_handler_thread,
+ GC_use_mach_handler_thread, GC_mach_thread, GC_MAX_MACH_THREADS,
+ GC_mach_threads, GC_mach_threads_count, GC_suspend_thread_list,
+ GC_darwin_register_mach_handler_thread): Define only if not
+ DARWIN_SUSPEND_GC_THREADS.
+ * darwin_stop_world.c (GC_stop_world, GC_start_world): Exclude
+ the code for GC_query_task_threads case from compilation unless
+ DARWIN_SUSPEND_GC_THREADS.
+ * os_dep.c (GC_darwin_register_mach_handler_thread): Declared only
+ if Darwin threads and not DARWIN_SUSPEND_GC_THREADS.
+ * os_dep.c (GC_mprotect_thread): Call
+ GC_darwin_register_mach_handler_thread only if THREADS and not
+ DARWIN_SUSPEND_GC_THREADS.
+ * pthread_support.c (marker_mach_threads): Don't define if
+ DARWIN_SUSPEND_GC_THREADS.
+ * pthread_support.c (GC_mark_thread): Don't fill in
+ marker_mach_threads if DARWIN_SUSPEND_GC_THREADS.
+ * include/private/gc_locks.h (GC_need_to_lock): Always declare for
+ THREADS case.
+
2010-10-15 Ivan Maidanski <ivmai@mail.ru>
* darwin_stop_world.c (GC_query_task_threads): Don't define to
#endif /* !DARWIN_DONT_PARSE_STACK */
+#define DARWIN_QUERY_TASK_THREADS 1 /* FIXME: Remove this. */
+
/* GC_query_task_threads controls whether to obtain the list of */
/* the threads from the kernel or to use GC_threads table. */
- /* FIXME: use STATIC; initialize to false, add setter function. */
- GC_bool GC_query_task_threads = FALSE;
+#ifdef DARWIN_SUSPEND_GC_THREADS
+# define GC_query_task_threads FALSE
+#elif defined(DARWIN_QUERY_TASK_THREADS)
+# define GC_query_task_threads TRUE
+#else
+ STATIC GC_bool GC_query_task_threads = FALSE;
+#endif /* !DARWIN_SUSPEND_GC_THREADS */
+
+/* FIXME: add GC_API and declare in gc.h; add comment; document macros */
+void GC_CALL GC_use_threads_discovery(void)
+{
+# if defined(DARWIN_SUSPEND_GC_THREADS) || defined(DARWIN_DONT_PARSE_STACK)
+ ABORT("Darwin task-threads-based stop and push unsupported");
+# else
+ GC_ASSERT(!GC_need_to_lock);
+# ifndef DARWIN_QUERY_TASK_THREADS
+ GC_query_task_threads = TRUE;
+# endif
+ GC_init_parallel(); /* just to be consistent with Win32 one */
+# endif
+}
/* Evaluates the stack range for a given thread. Returns the lower */
/* bound and sets *phi to the upper one. */
vm_deallocate(my_task, (vm_address_t)act_list,
sizeof(thread_t) * listcount);
} else
-# endif
+# endif /* !DARWIN_DONT_PARSE_STACK */
/* else */ {
for (i = 0; i < (int)listcount; i++) {
GC_thread p;
GC_total_stacksize = total_size;
}
-STATIC mach_port_t GC_mach_handler_thread = 0;
-STATIC GC_bool GC_use_mach_handler_thread = FALSE;
+#ifndef DARWIN_SUSPEND_GC_THREADS
-#ifndef GC_MAX_MACH_THREADS
-# define GC_MAX_MACH_THREADS THREAD_TABLE_SZ
-#endif
+ STATIC mach_port_t GC_mach_handler_thread = 0;
+ STATIC GC_bool GC_use_mach_handler_thread = FALSE;
+
+ GC_INNER void GC_darwin_register_mach_handler_thread(mach_port_t thread)
+ {
+ GC_mach_handler_thread = thread;
+ GC_use_mach_handler_thread = TRUE;
+ }
-struct GC_mach_thread {
- thread_act_t thread;
- GC_bool already_suspended;
-};
+# 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;
+ };
-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. */
+ 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. */
-#ifdef PARALLEL_MARK
+# ifdef PARALLEL_MARK
GC_INNER GC_bool GC_is_mach_marker(thread_act_t thread);
-#endif
+# endif
/* returns true if there's a thread in act_list that wasn't in old_list */
STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count,
return changed;
}
+#endif /* !DARWIN_SUSPEND_GC_THREADS */
+
#ifdef MPROTECT_VDB
GC_INNER void GC_mprotect_stop(void);
GC_INNER void GC_mprotect_resume(void);
# endif /* PARALLEL_MARK */
if (GC_query_task_threads) {
+# ifndef DARWIN_SUSPEND_GC_THREADS
GC_bool changed;
thread_act_array_t act_list, prev_list;
mach_msg_type_number_t listcount, prevcount;
mach_port_deallocate(my_task, prev_list[i]);
vm_deallocate(my_task, (vm_address_t)act_list,
sizeof(thread_t) * listcount);
+# endif /* !DARWIN_SUSPEND_GC_THREADS */
} else {
for (i = 0; i < THREAD_TABLE_SZ; i++) {
# endif
if (GC_query_task_threads) {
+# ifndef DARWIN_SUSPEND_GC_THREADS
int j = GC_mach_threads_count;
kern_return_t kern_result;
thread_act_array_t act_list;
}
vm_deallocate(my_task, (vm_address_t)act_list,
sizeof(thread_t) * listcount);
+# endif /* !DARWIN_SUSPEND_GC_THREADS */
} else {
mach_port_t my_thread = mach_thread_self();
# endif
}
-GC_INNER void GC_darwin_register_mach_handler_thread(mach_port_t thread)
-{
- GC_mach_handler_thread = thread;
- GC_use_mach_handler_thread = TRUE;
-}
-
#endif /* GC_DARWIN_THREADS */