[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-197-g631e4
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-197-g631e49e |
Date: |
Fri, 15 Apr 2011 16:07:19 +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=631e49ed767a877fc1776dc5b07818512fdc8c06
The branch, stable-2.0 has been updated
via 631e49ed767a877fc1776dc5b07818512fdc8c06 (commit)
via cc3546b027336c554218351d8a755866c9560948 (commit)
from 1e56cff2337d4f6b0a9f3363ea1cb3ac5287a6ed (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 631e49ed767a877fc1776dc5b07818512fdc8c06
Author: Andy Wingo <address@hidden>
Date: Fri Apr 15 18:05:23 2011 +0200
weak hash table vacuum on before-gc C hook
* libguile/hashtab.c (weak_gc_callback)
(scm_c_register_weak_gc_callback): Change implementation to use the
before-gc C hook instead of the after-gc finalizers.
commit cc3546b027336c554218351d8a755866c9560948
Author: Andy Wingo <address@hidden>
Date: Fri Apr 15 17:45:52 2011 +0200
use gc_start_callback + asyncs for after-gc-hook, instead of finalizers
* libguile/gc.c (run_before_gc_c_hook, scm_storage_prehistory)
(after_gc_async_thunk, queue_after_gc_hook, scm_init_gc): Instead of
playing our finalizer trick, connect to the GC start callback, and use
it to queue an async after-gc-hook. Seems to fix the after-gc-hook on
non-threaded builds. Though this does re-enable the before-gc C hook,
we don't wire up the Scheme hook because we're in the alloc lock; and
indeed, a before-GC scheme hook isn't a great idea...
-----------------------------------------------------------------------
Summary of changes:
libguile/gc.c | 68 +++++++++++++++++++++++++++------------------------
libguile/hashtab.c | 27 ++++++++++----------
2 files changed, 49 insertions(+), 46 deletions(-)
diff --git a/libguile/gc.c b/libguile/gc.c
index 8816a61..da530eb 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -57,6 +57,9 @@ extern unsigned long *
__libc_ia64_register_backing_store_base;
#include "libguile/bdw-gc.h"
+/* For GC_set_start_callback. */
+#include <gc/gc_mark.h>
+
#ifdef GUILE_DEBUG_MALLOC
#include "libguile/debug-malloc.h"
#endif
@@ -545,20 +548,9 @@ scm_gc_unregister_roots (SCM *b, unsigned long n)
}
static void
-scm_c_register_gc_callback (void *key, void (*func) (void *, void *),
- void *data)
-{
- if (!key)
- key = GC_MALLOC_ATOMIC (sizeof (void*));
-
- GC_REGISTER_FINALIZER_NO_ORDER (key, func, data, NULL, NULL);
-}
-
-static void
-system_gc_callback (void *key, void *data)
+run_before_gc_c_hook (void)
{
- scm_c_register_gc_callback (key, system_gc_callback, data);
- scm_c_hook_run (&scm_after_gc_c_hook, NULL);
+ scm_c_hook_run (&scm_before_gc_c_hook, NULL);
}
@@ -616,8 +608,6 @@ scm_storage_prehistory ()
scm_c_hook_init (&scm_before_sweep_c_hook, 0, SCM_C_HOOK_NORMAL);
scm_c_hook_init (&scm_after_sweep_c_hook, 0, SCM_C_HOOK_NORMAL);
scm_c_hook_init (&scm_after_gc_c_hook, 0, SCM_C_HOOK_NORMAL);
-
- scm_c_register_gc_callback (NULL, system_gc_callback, NULL);
}
scm_i_pthread_mutex_t scm_i_gc_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
@@ -646,29 +636,31 @@ scm_init_gc_protect_object ()
SCM scm_after_gc_hook;
-static SCM gc_async;
+static SCM after_gc_async_cell;
-/* The function gc_async_thunk causes the execution of the after-gc-hook. It
- * is run after the gc, as soon as the asynchronous events are handled by the
- * evaluator.
+/* The function after_gc_async_thunk causes the execution of the
+ * after-gc-hook. It is run after the gc, as soon as the asynchronous
+ * events are handled by the evaluator.
*/
static SCM
-gc_async_thunk (void)
+after_gc_async_thunk (void)
{
+ /* Fun, no? Hook-run *and* run-hook? */
+ scm_c_hook_run (&scm_after_gc_c_hook, NULL);
scm_c_run_hook (scm_after_gc_hook, SCM_EOL);
return SCM_UNSPECIFIED;
}
-/* The function mark_gc_async is run by the scm_after_gc_c_hook at the end of
- * the garbage collection. The only purpose of this function is to mark the
- * gc_async (which will eventually lead to the execution of the
- * gc_async_thunk).
+/* The function queue_after_gc_hook is run by the scm_before_gc_c_hook
+ * at the end of the garbage collection. The only purpose of this
+ * function is to mark the after_gc_async (which will eventually lead to
+ * the execution of the after_gc_async_thunk).
*/
static void *
-mark_gc_async (void * hook_data SCM_UNUSED,
- void *fn_data SCM_UNUSED,
- void *data SCM_UNUSED)
+queue_after_gc_hook (void * hook_data SCM_UNUSED,
+ void *fn_data SCM_UNUSED,
+ void *data SCM_UNUSED)
{
/* If cell access debugging is enabled, the user may choose to perform
* additional garbage collections after an arbitrary number of cell
@@ -697,10 +689,17 @@ mark_gc_async (void * hook_data SCM_UNUSED,
#if (SCM_DEBUG_CELL_ACCESSES == 1)
if (scm_debug_cells_gc_interval == 0)
- scm_system_async_mark (gc_async);
-#else
- scm_system_async_mark (gc_async);
#endif
+ {
+ scm_i_thread *t = SCM_I_CURRENT_THREAD;
+
+ if (scm_is_false (SCM_CDR (after_gc_async_cell)))
+ {
+ SCM_SETCDR (after_gc_async_cell, t->active_asyncs);
+ t->active_asyncs = after_gc_async_cell;
+ t->pending_asyncs = 1;
+ }
+ }
return NULL;
}
@@ -793,9 +792,14 @@ scm_init_gc ()
scm_after_gc_hook = scm_make_hook (SCM_INUM0);
scm_c_define ("after-gc-hook", scm_after_gc_hook);
- gc_async = scm_c_make_gsubr ("%gc-thunk", 0, 0, 0, gc_async_thunk);
+ /* When the async is to run, the cdr of the gc_async pair gets set to
+ the asyncs queue of the current thread. */
+ after_gc_async_cell = scm_cons (scm_c_make_gsubr ("%after-gc-thunk", 0, 0, 0,
+ after_gc_async_thunk),
+ SCM_BOOL_F);
- scm_c_hook_add (&scm_after_gc_c_hook, mark_gc_async, NULL, 0);
+ scm_c_hook_add (&scm_before_gc_c_hook, queue_after_gc_hook, NULL, 0);
+ GC_set_start_callback (run_before_gc_c_hook);
#include "libguile/gc.x"
}
diff --git a/libguile/hashtab.c b/libguile/hashtab.c
index a76c038..f5c86a5 100644
--- a/libguile/hashtab.c
+++ b/libguile/hashtab.c
@@ -418,32 +418,31 @@ SCM_DEFINE (scm_make_hash_table, "make-hash-table", 0, 1,
0,
}
#undef FUNC_NAME
-static void
-weak_gc_callback (void *ptr, void *data)
+static void*
+weak_gc_callback (void *hook_data, void *fn_data, void *data)
{
- void **weak = ptr;
- void *val = *weak;
+ void **weak = fn_data;
+ void *val = weak[0];
+ void (*callback) (SCM) = weak[1];
if (val)
- {
- void (*callback) (SCM) = data;
+ callback (PTR2SCM (val));
+ else
+ scm_c_hook_remove (&scm_before_gc_c_hook, weak_gc_callback, weak);
- GC_REGISTER_FINALIZER_NO_ORDER (ptr, weak_gc_callback, data, NULL, NULL);
-
- callback (PTR2SCM (val));
- }
+ return NULL;
}
static void
scm_c_register_weak_gc_callback (SCM obj, void (*callback) (SCM))
{
- void **weak = GC_MALLOC_ATOMIC (sizeof (void**));
+ void **weak = GC_MALLOC_ATOMIC (sizeof (void*) * 2);
- *weak = SCM2PTR (obj);
+ weak[0] = SCM2PTR (obj);
+ weak[1] = (void*)callback;
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM2PTR (obj));
- GC_REGISTER_FINALIZER_NO_ORDER (weak, weak_gc_callback, (void*)callback,
- NULL, NULL);
+ scm_c_hook_add (&scm_before_gc_c_hook, weak_gc_callback, weak, 0);
}
SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 0, 1, 0,
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-197-g631e49e,
Andy Wingo <=