-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
/* #define DEBUGINFO */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <assert.h>
+#ifdef __ia64__
+#include <ucontext.h>
+extern unsigned long * __libc_ia64_register_backing_store_base;
+#endif
+
#include "libguile/_scm.h"
#include "libguile/eval.h"
#include "libguile/stime.h"
*/
if (scm_expensive_debug_cell_accesses_p)
scm_i_expensive_validation_check (cell);
-
+#if (SCM_DEBUG_MARKING_API == 0)
if (!SCM_GC_MARK_P (cell))
{
fprintf (stderr,
(unsigned long) SCM_UNPACK (cell));
abort ();
}
-
+#endif /* SCM_DEBUG_MARKING_API */
+
scm_i_cell_validation_already_running = 0; /* re-enable */
}
}
/* GC Statistics Keeping
*/
-unsigned long scm_cells_allocated = 0;
unsigned long scm_mallocated = 0;
+unsigned long scm_gc_ports_collected = 0;
-/* Global GC sweep statistics since the last full GC. */
-static scm_t_sweep_statistics scm_i_gc_sweep_stats = { 0, 0 };
-static scm_t_sweep_statistics scm_i_gc_sweep_stats_1 = { 0, 0 };
-
-/* Total count of cells marked/swept. */
-static double scm_gc_cells_marked_acc = 0.;
-static double scm_gc_cells_swept_acc = 0.;
-
-static unsigned long scm_gc_time_taken = 0;
-static unsigned long t_before_gc;
-static unsigned long scm_gc_mark_time_taken = 0;
-
-static unsigned long scm_gc_times = 0;
-
-static int scm_gc_cell_yield_percentage = 0;
-static unsigned long protected_obj_count = 0;
-
-/* The following are accessed from `gc-malloc.c' and `gc-card.c'. */
-int scm_gc_malloc_yield_percentage = 0;
static unsigned long protected_obj_count = 0;
SCM_SYMBOL (sym_gc_mark_time_taken, "gc-mark-time-taken");
SCM_SYMBOL (sym_times, "gc-times");
SCM_SYMBOL (sym_cells_marked, "cells-marked");
+SCM_SYMBOL (sym_cells_marked_conservatively, "cells-marked-conservatively");
SCM_SYMBOL (sym_cells_swept, "cells-swept");
SCM_SYMBOL (sym_malloc_yield, "malloc-yield");
SCM_SYMBOL (sym_cell_yield, "cell-yield");
SCM_SYMBOL (sym_protected_objects, "protected-objects");
-
-
+SCM_SYMBOL (sym_total_cells_allocated, "total-cells-allocated");
/* Number of calls to SCM_NEWCELL since startup. */
scm_cons (sym_cells_swept,
scm_from_double (local_scm_gc_cells_swept)),
scm_cons (sym_malloc_yield,
- scm_from_long(local_scm_gc_malloc_yield_percentage)),
+ scm_from_long (local_scm_gc_malloc_yield_percentage)),
scm_cons (sym_cell_yield,
scm_from_long (local_scm_gc_cell_yield_percentage)),
scm_cons (sym_heap_segments, heap_segs),
#undef FUNC_NAME
+SCM_DEFINE (scm_gc_dump, "gc-dump", 0, 0, 0,
+ (void),
+ "Dump information about the garbage collector's internal data "
+ "structures and memory usage to the standard output.")
+#define FUNC_NAME s_scm_gc_dump
+{
+ GC_dump ();
+
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
SCM_DEFINE (scm_object_address, "object-address", 1, 0, 0,
#define FUNC_NAME s_scm_gc
{
scm_i_scm_pthread_mutex_lock (&scm_i_sweep_mutex);
- scm_gc_running_p = 1;
scm_i_gc ("call");
/* njrev: It looks as though other places, e.g. scm_realloc,
can call scm_i_gc without acquiring the sweep mutex. Does this
(e.g. scm_permobjs above in scm_gc_stats) by a critical section,
not by the sweep mutex. Shouldn't all the GC-relevant objects be
protected in the same way? */
- scm_gc_running_p = 0;
scm_i_pthread_mutex_unlock (&scm_i_sweep_mutex);
scm_c_hook_run (&scm_after_gc_c_hook, 0);
return SCM_UNSPECIFIED;
*/
/* Implementation note: For every object X, there is a counter which
- scm_gc_protect_object(X) increments and scm_gc_unprotect_object(X) decrements.
+ scm_gc_protect_object (X) increments and scm_gc_unprotect_object (X) decrements.
*/
scm_storage_prehistory ()
{
GC_all_interior_pointers = 0;
+ GC_set_free_space_divisor (scm_getenv_int ("GC_FREE_SPACE_DIVISOR", 3));
GC_INIT ();
-#ifdef SCM_I_GSC_USE_PTHREAD_THREADS
+#if (! ((defined GC_VERSION_MAJOR) && (GC_VERSION_MAJOR >= 7))) \
+ && (defined 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 ();
*/
static void *
mark_gc_async (void * hook_data SCM_UNUSED,
- void *func_data SCM_UNUSED,
+ void *fn_data SCM_UNUSED,
void *data SCM_UNUSED)
{
/* If cell access debugging is enabled, the user may choose to perform
#include "libguile/gc.x"
}
-#ifdef __ia64__
-# ifdef __hpux
-# include <sys/param.h>
-# include <sys/pstat.h>
-void *
-scm_ia64_register_backing_store_base (void)
-{
- struct pst_vm_status vm_status;
- int i = 0;
- while (pstat_getprocvm (&vm_status, sizeof (vm_status), 0, i++) == 1)
- if (vm_status.pst_type == PS_RSESTACK)
- return (void *) vm_status.pst_vaddr;
- abort ();
-}
-void *
-scm_ia64_ar_bsp (const void *ctx)
-{
- uint64_t bsp;
- __uc_get_ar_bsp(ctx, &bsp);
- return (void *) bsp;
-}
-# endif /* hpux */
-# ifdef linux
-# include <ucontext.h>
-void *
-scm_ia64_register_backing_store_base (void)
-{
- extern void *__libc_ia64_register_backing_store_base;
- return __libc_ia64_register_backing_store_base;
-}
-void *
-scm_ia64_ar_bsp (const void *opaque)
-{
- ucontext_t *ctx = opaque;
- return (void *) ctx->uc_mcontext.sc_ar_bsp;
-}
-# endif /* linux */
-#endif /* __ia64__ */
void
scm_gc_sweep (void)