From 14f2760d584c18fc8a1f305f5ed0a6d13ff5918a Mon Sep 17 00:00:00 2001 From: Elijah Taylor Date: Tue, 9 Aug 2011 22:03:46 +0200 Subject: [PATCH] Fix DATASTART (and other minor improvements) for NaCl target * include/private/gcconfig.h (DATASTART): Define to a fixed address for NaCl. * pthread_stop_world.c (GC_suspend_all): Issue GC warning if it appears stalled waiting for some threads to park (NaCl only). * pthread_stop_world.c (nacl_register_gc_hooks): Declare external function (available from NaCl runtime). * pthread_stop_world.c (GC_nacl_initialize_gc_thread): Invoke nacl_register_gc_hooks registring nacl_pre_syscall_hook and nacl_post_syscall_hook (NaCl only). --- include/private/gcconfig.h | 3 ++- pthread_stop_world.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 9bb29448..5b5929ae 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -1196,7 +1196,8 @@ # ifdef NACL # define OS_TYPE "NACL" extern int etext[]; -# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) +/* #define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) */ +# define DATASTART ((ptr_t)0x10000000) extern int _end[]; # define DATAEND (_end) # undef STACK_GRAN diff --git a/pthread_stop_world.c b/pthread_stop_world.c index ae915d32..a299f754 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -478,6 +478,9 @@ STATIC int GC_suspend_all(void) # ifndef NACL_PARK_WAIT_NANOSECONDS # define NACL_PARK_WAIT_NANOSECONDS (100 * 1000) # endif +# define NANOS_PER_SECOND (1000UL * 1000 * 1000) + unsigned long num_sleeps = 0; + # ifdef DEBUG_THREADS GC_log_printf("pthread_stop_world: num_threads %d\n", GC_nacl_num_gc_threads - 1); @@ -515,6 +518,12 @@ STATIC int GC_suspend_all(void) # endif /* This requires _POSIX_TIMERS feature. */ nanosleep(&ts, 0); + if (++num_sleeps > NANOS_PER_SECOND / NACL_PARK_WAIT_NANOSECONDS) { + WARN("GC appears stalled waiting for %" WARN_PRIdPTR + " threads to park...\n", + GC_nacl_num_gc_threads - num_threads_parked - 1); + num_sleeps = 0; + } } # endif /* NACL */ return n_live_threads; @@ -694,9 +703,12 @@ GC_INNER void GC_stop_world(void) STATIC GC_bool GC_nacl_thread_parking_inited = FALSE; STATIC pthread_mutex_t GC_nacl_thread_alloc_lock = PTHREAD_MUTEX_INITIALIZER; + extern void nacl_register_gc_hooks(void (*pre)(void), void (*post)(void)); + GC_INNER void GC_nacl_initialize_gc_thread(void) { int i; + nacl_register_gc_hooks(nacl_pre_syscall_hook, nacl_post_syscall_hook); pthread_mutex_lock(&GC_nacl_thread_alloc_lock); if (!EXPECT(GC_nacl_thread_parking_inited, TRUE)) { BZERO(GC_nacl_thread_parked, sizeof(GC_nacl_thread_parked)); -- 2.40.0