Use thread-local allocation (significant perf. improvement!); added the `boehm-gc...
authorLudovic Courtes <ludovic.courtes@laas.fr>
Sun, 3 Dec 2006 21:59:02 +0000 (21:59 +0000)
committerLudovic Courtès <ludo@gnu.org>
Wed, 10 Sep 2008 20:19:49 +0000 (22:19 +0200)
* libguile/Makefile.am (modinclude_HEADERS): Added `boehm-gc.h'.

* libguile/coop-defs.h: Use "libguile/boehm-gc.h" instead of <gc/gc.h>.

* libguile/coop-threads.h: Likewise.

* libguile/coop.c: Likewise.

* libguile/gc.c: Likewise.
  (scm_storage_prehistory): Invoke `GC_init ()'.

* libguile/guardians.c: Use "libguile/boehm-gc.h" instead of <gc/gc.h>.

* libguile/inline.h: Likewise.
  (scm_double_cell): Use `GC_MALLOC' instead of `GC_malloc'.

* libguile/pthread-threads.h: Use "libguile/boehm-gc.h" instead of
  <gc/gc.h>.

* libguile/smob.c: Likewise.

* libguile/smob.h: Likewise.

* libguile/struct.c: Likewise.

* libguile/threads.c: Likewise.

* libguile/weaks.c: Likewise.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-51

15 files changed:
libguile/Makefile.am
libguile/boehm-gc.h [new file with mode: 0644]
libguile/coop-defs.h
libguile/coop-pthreads.h
libguile/coop.c
libguile/gc.c
libguile/guardians.c
libguile/inline.h
libguile/pthread-threads.h
libguile/smob.c
libguile/smob.h
libguile/struct.c
libguile/threads.c
libguile/vectors.c
libguile/weaks.c

index 5313901..34b7473 100644 (file)
@@ -183,6 +183,7 @@ pkginclude_HEADERS = gh.h
 # These are headers visible as <libguile/mumble.h>.
 modincludedir = $(includedir)/libguile
 modinclude_HEADERS = __scm.h alist.h arbiters.h async.h backtrace.h    \
+    boehm-gc.h                                                         \
     boolean.h chars.h continuations.h convert.h debug.h debug-malloc.h \
     deprecation.h deprecated.h discouraged.h dynl.h dynwind.h          \
     environments.h eq.h error.h eval.h evalext.h extensions.h          \
diff --git a/libguile/boehm-gc.h b/libguile/boehm-gc.h
new file mode 100644 (file)
index 0000000..49a3695
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef SCM_BOEHM_GC_H
+#define SCM_BOEHM_GC_H
+
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* Correct header inclusion.  */
+
+#include "libguile/gen-scmconfig.h"
+
+#ifdef SCM_I_GSC_USE_PTHREAD_THREADS
+
+/* When pthreads are used, let `libgc' know about it and redirect allocation
+   calls such as `GC_MALLOC ()' to (contention-free, faster) thread-local
+   allocation.  */
+
+# define GC_THREADS 1
+# define GC_REDIRECT_TO_LOCAL 1
+
+#endif
+
+#include <gc/gc.h>
+#include <gc/gc_local_alloc.h>
+
+#endif /* SCM_BOEHM_GC_H */
index 7b06cce..9ce8035 100644 (file)
 
 #ifdef GUILE_PTHREAD_COMPAT
 # include <pthread.h>
-
-# define GC_THREADS 1
-# include <gc/gc.h>
 #endif
 
+#include "libguile/boehm-gc.h"
+
 /* This file is included by threads.h, which, in turn, is included by
    libguile.h while coop-threads.h only is included by
    coop-threads.c. */
index a82f124..57b53ed 100644 (file)
@@ -29,8 +29,7 @@
 
 #include <pthread.h>
 
-#define GC_THREADS 1
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 #include "libguile/iselect.h"
 
index 133c3d4..a8dca12 100644 (file)
@@ -511,6 +511,8 @@ coop_condition_variable_destroy (coop_c *c)
 
 #ifdef GUILE_PTHREAD_COMPAT
 
+#include "libguile/boehm-gc.h"
+
 /* 1K room for the cond wait routine */
 #if SCM_STACK_GROWS_UP
 # define COOP_STACK_ROOM (256)
index 142fd0b..d8b27d2 100644 (file)
@@ -23,6 +23,8 @@
 #  include <config.h>
 #endif
 
+#include "libguile/gen-scmconfig.h"
+
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
@@ -55,7 +57,7 @@ extern unsigned long * __libc_ia64_register_backing_store_base;
 #include "libguile/gc.h"
 #include "libguile/dynwind.h"
 
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 #ifdef GUILE_DEBUG_MALLOC
 #include "libguile/debug-malloc.h"
@@ -641,6 +643,13 @@ scm_storage_prehistory ()
   GC_all_interior_pointers = 0;
 
   GC_INIT ();
+
+#ifdef SCM_I_GSC_USE_PTHREAD_THREADS
+  /* When using GC 6.8, this call is required to initialize thread-local
+     freelists (shouldn't be necessary with GC 7.0).  */
+  GC_init ();
+#endif
+
   GC_expand_hp (SCM_DEFAULT_INIT_HEAP_SIZE_2);
 
   /* We only need to register a displacement for those types for which the
index 7ca11c4..879462a 100644 (file)
@@ -55,7 +55,7 @@
 #include "libguile/eval.h"
 
 #include "libguile/guardians.h"
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 
 
index 8d6c417..75a7cc9 100644 (file)
@@ -38,7 +38,7 @@
 #include "libguile/pairs.h"
 
 
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 
 SCM_API SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
@@ -98,7 +98,7 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr,
 {
   SCM z;
 
-  z = SCM_PACK ((scm_t_bits) (GC_malloc (2 * sizeof (scm_t_cell))));
+  z = SCM_PACK ((scm_t_bits) (GC_MALLOC (2 * sizeof (scm_t_cell))));
   /* Initialize the type slot last so that the cell is ignored by the
      GC until it is completely initialized.  This is only relevant
      when the GC can actually run during this code, which it can't
index e2ee7b2..64b56e1 100644 (file)
@@ -29,8 +29,7 @@
 #include <sched.h>
 
 /* `libgc' intercepts pthread calls by defining wrapping macros.  */
-#define GC_THREADS 1
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 /* Threads 
 */
index 901942c..7184422 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "libguile/smob.h"
 
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 #include <gc/gc_mark.h>
 
 
index 0561793..2bf508e 100644 (file)
@@ -25,7 +25,7 @@
 #include "libguile/__scm.h"
 #include "libguile/print.h"
 
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 
 \f
index 38331dd..181b3d3 100644 (file)
@@ -39,7 +39,7 @@
 #include <string.h>
 #endif
 
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 
 \f
 
index ec13605..5f52180 100644 (file)
@@ -20,6 +20,7 @@
 
 #define _GNU_SOURCE
 
+#include "libguile/boehm-gc.h"
 #include "libguile/_scm.h"
 
 #if HAVE_UNISTD_H
index afc74b7..4bc5ce6 100644 (file)
@@ -34,7 +34,7 @@
 #include "libguile/dynwind.h"
 #include "libguile/deprecation.h"
 
-#include <gc/gc.h> /* disappearing links (aka. weak pointers) */
+#include "libguile/boehm-gc.h"
 
 
 \f
index efb2d13..5883dec 100644 (file)
@@ -52,7 +52,7 @@
 #include "libguile/validate.h"
 #include "libguile/weaks.h"
 
-#include <gc/gc.h>
+#include "libguile/boehm-gc.h"
 #include <gc/gc_typed.h>