guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, boehm-demers-weiser-gc, updated. relea


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, boehm-demers-weiser-gc, updated. release_1-9-2-147-ge3eb628
Date: Wed, 19 Aug 2009 23:57:03 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=e3eb628d889b8cb9821a274e41b72f9751b6ee0a

The branch, boehm-demers-weiser-gc has been updated
       via  e3eb628d889b8cb9821a274e41b72f9751b6ee0a (commit)
       via  75d315e1fbb0da6af8c48d17fd5b2a7a759fe849 (commit)
       via  1f7de769402cf8a9ad54b5283dc96d60e86fb5bb (commit)
       via  aec3d99bcd1dd4020e56c426909dc570d0109d91 (commit)
      from  512c35950752d1482d87c5052c8d923e0d16ad15 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e3eb628d889b8cb9821a274e41b72f9751b6ee0a
Author: Ludovic Courtès <address@hidden>
Date:   Thu Aug 20 01:56:47 2009 +0200

    Implement precise marking of the VM stack.
    
    Suggested by Andy Wingo.
    
    * libguile/vm.c (VM_ENABLE_PRECISE_STACK_GC_SCAN): New macro.
      (vm_stack_gc_kind): New variable.
      (make_vm)[VM_ENABLE_PRECISE_STACK_GC_SCAN]: Use `GC_generic_malloc ()'
      to allocate the stack.
      (vm_stack_mark): New function.
      (scm_bootstrap_vm)[VM_ENABLE_PRECISE_STACK_GC_SCAN]: Initialize
      `vm_stack_gc_kind'.

commit 75d315e1fbb0da6af8c48d17fd5b2a7a759fe849
Author: Ludovic Courtès <address@hidden>
Date:   Thu Aug 20 01:20:58 2009 +0200

    Fix bogus computation of `vm->stack_limit'.
    
    * libguile/vm.c (make_vm): Remove bogus "- 3" when computing
      `stack_size'.
    
    * libguile/vm-engine.h (CHECK_OVERFLOW): Change accordingly.

commit 1f7de769402cf8a9ad54b5283dc96d60e86fb5bb
Author: Ludovic Courtès <address@hidden>
Date:   Thu Aug 20 01:16:38 2009 +0200

    Simplify the creation of the SMOB GC "kind".
    
    * libguile/smob.c (smob_freelist): Remove.
      (scm_smob_prehistory): Adjust accordingly.

commit aec3d99bcd1dd4020e56c426909dc570d0109d91
Author: Ludovic Courtès <address@hidden>
Date:   Thu Aug 20 01:14:14 2009 +0200

    Include "scmconfig.h" in <libguile/boehm-gc.h>.
    
    * libguile/boehm-gc.h: Use "scmconfig.h".  Check for
      `SCM_USE_PTHREAD_THREADS', not `SCM_I_GSC_USE_PTHREAD_THREADS'.

-----------------------------------------------------------------------

Summary of changes:
 libguile/boehm-gc.h  |    6 ++--
 libguile/smob.c      |    9 ++----
 libguile/vm-engine.h |    2 +-
 libguile/vm.c        |   77 +++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 83 insertions(+), 11 deletions(-)

diff --git a/libguile/boehm-gc.h b/libguile/boehm-gc.h
index 708f17b..b3a8514 100644
--- a/libguile/boehm-gc.h
+++ b/libguile/boehm-gc.h
@@ -1,7 +1,7 @@
 #ifndef SCM_BOEHM_GC_H
 #define SCM_BOEHM_GC_H
 
-/* Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2008, 2009 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
@@ -20,9 +20,9 @@
 
 /* Correct header inclusion.  */
 
-#include "libguile/gen-scmconfig.h"
+#include "libguile/scmconfig.h"
 
-#ifdef SCM_I_GSC_USE_PTHREAD_THREADS
+#ifdef SCM_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
diff --git a/libguile/smob.c b/libguile/smob.c
index 0598bae..b2c083c 100644
--- a/libguile/smob.c
+++ b/libguile/smob.c
@@ -496,10 +496,8 @@ free_print (SCM exp, SCM port, scm_print_state *pstate 
SCM_UNUSED)
 /* Marking SMOBs using user-supplied mark procedures.  */
 
 
-/* The freelist and GC kind used for SMOB types that provide a custom mark
-   procedure.  */
-static void **smob_freelist = NULL;
-static int    smob_gc_kind = 0;
+/* The GC kind used for SMOB types that provide a custom mark procedure.  */
+static int smob_gc_kind;
 
 
 /* The generic SMOB mark procedure that gets called for SMOBs allocated with
@@ -636,8 +634,7 @@ scm_smob_prehistory ()
   long i;
   scm_t_bits tc;
 
-  smob_freelist = GC_new_free_list ();
-  smob_gc_kind = GC_new_kind ((void **)smob_freelist,
+  smob_gc_kind = GC_new_kind (GC_new_free_list (),
                              GC_MAKE_PROC (GC_new_proc (smob_mark), 0),
                              0,
                              /* Clear new objects.  As of version 7.1, libgc
diff --git a/libguile/vm-engine.h b/libguile/vm-engine.h
index 240969c..b819b90 100644
--- a/libguile/vm-engine.h
+++ b/libguile/vm-engine.h
@@ -252,7 +252,7 @@
 #endif
 
 #define CHECK_OVERFLOW()                       \
-  if (sp > stack_limit)                                \
+  if (sp >= stack_limit)                       \
     goto vm_error_stack_overflow
 
 #define CHECK_UNDERFLOW()                       \
diff --git a/libguile/vm.c b/libguile/vm.c
index df1ad88..2920924 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -23,6 +23,11 @@
 #include <stdlib.h>
 #include <alloca.h>
 #include <string.h>
+#include <assert.h>
+
+#include "libguile/boehm-gc.h"
+#include <gc/gc_mark.h>
+
 #include "_scm.h"
 #include "vm-bootstrap.h"
 #include "frames.h"
@@ -56,6 +61,13 @@
 #define VM_ENABLE_ASSERTIONS
 #endif
 
+/* When defined, arrange so that the GC doesn't scan the VM stack beyond its
+   current SP.  This should help avoid excess data retention.  See
+   
http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/3001
+   for a discussion.  */
+#define VM_ENABLE_PRECISE_STACK_GC_SCAN
+
+
 
 /*
  * VM Continuation
@@ -281,6 +293,13 @@ static const scm_t_vm_engine vm_engines[] =
 
 scm_t_bits scm_tc16_vm;
 
+#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
+
+/* The GC "kind" for the VM stack.  */
+static int vm_stack_gc_kind;
+
+#endif
+
 static SCM
 make_vm (void)
 #define FUNC_NAME "make_vm"
@@ -293,12 +312,25 @@ make_vm (void)
   struct scm_vm *vp = scm_gc_malloc (sizeof (struct scm_vm), "vm");
 
   vp->stack_size  = VM_DEFAULT_STACK_SIZE;
+
+#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
+  vp->stack_base = GC_generic_malloc (vp->stack_size * sizeof (SCM),
+                                     vm_stack_gc_kind);
+
+  /* Keep a pointer to VP so that `vm_stack_mark ()' can know what the stack
+     top is.  */
+  *vp->stack_base = PTR2SCM (vp);
+  vp->stack_base++;
+  vp->stack_size--;
+#else
   vp->stack_base  = scm_gc_malloc (vp->stack_size * sizeof (SCM),
                                   "stack-base");
+#endif
+
 #ifdef VM_ENABLE_STACK_NULLING
   memset (vp->stack_base, 0, vp->stack_size * sizeof (SCM));
 #endif
-  vp->stack_limit = vp->stack_base + vp->stack_size - 3;
+  vp->stack_limit = vp->stack_base + vp->stack_size;
   vp->ip         = NULL;
   vp->sp         = vp->stack_base - 1;
   vp->fp         = NULL;
@@ -313,6 +345,41 @@ make_vm (void)
 }
 #undef FUNC_NAME
 
+#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
+
+/* Mark the VM stack region between its base and its current top.  */
+static struct GC_ms_entry *
+vm_stack_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
+              struct GC_ms_entry *mark_stack_limit, GC_word env)
+{
+  GC_word *word;
+  const struct scm_vm *vm;
+
+  /* The first word of the VM stack should contain a pointer to the
+     corresponding VM.  */
+  vm = * ((struct scm_vm **) addr);
+
+  if (vm->stack_base == NULL)
+    /* ADDR must be a pointer to a free-list element, which we must ignore
+       (see warning in <gc/gc_mark.h>).  */
+    return mark_stack_ptr;
+
+  /* Sanity checks.  */
+  assert ((SCM *) addr == vm->stack_base - 1);
+  assert (vm->sp >= (SCM *) addr);
+  assert (vm->stack_limit - vm->stack_base == vm->stack_size);
+
+  for (word = (GC_word *) vm->stack_base; word <= (GC_word *) vm->sp; word++)
+    mark_stack_ptr = GC_MARK_AND_PUSH ((* (GC_word **) word),
+                                      mark_stack_ptr, mark_stack_limit,
+                                      NULL);
+
+  return mark_stack_ptr;
+}
+
+#endif /* VM_ENABLE_PRECISE_STACK_GC_SCAN */
+
+
 SCM
 scm_c_vm_run (SCM vm, SCM program, SCM *argv, int nargs)
 {
@@ -595,6 +662,14 @@ scm_bootstrap_vm (void)
                             (scm_t_extension_init_func)scm_init_vm, NULL);
 
   strappage = 1;
+
+#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
+  vm_stack_gc_kind =
+    GC_new_kind (GC_new_free_list (),
+                GC_MAKE_PROC (GC_new_proc (vm_stack_mark), 0),
+                0, 1);
+
+#endif
 }
 
 void


hooks/post-receive
-- 
GNU Guile




reply via email to

[Prev in Thread] Current Thread [Next in Thread]