]> granicus.if.org Git - gc/commitdiff
Fix DATASTART (and other minor improvements) for NaCl target
authorElijah Taylor <elijahtaylor@google.com>
Tue, 9 Aug 2011 20:03:46 +0000 (22:03 +0200)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 4 Mar 2012 15:11:39 +0000 (19:11 +0400)
* 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
pthread_stop_world.c

index 9bb2944840073fe8fde0be467ae8875b955aa5cd..5b5929ae8912d5704fbaab5508e055e86e5cc10e 100644 (file)
 #   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
index ae915d32135d5ccfec69eb12dac0dd0b772e743b..a299f7543aeb4f002d834ad42fff2d3d1700189f 100644 (file)
@@ -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));