[Top][All Lists]
[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-289-gd66b74d |
Date: |
Wed, 09 Sep 2009 17:28:58 +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=d66b74dce74c2824726746e82a8a413463cb80fd
The branch, boehm-demers-weiser-gc has been updated
via d66b74dce74c2824726746e82a8a413463cb80fd (commit)
via f07c349eb38d6c7b160b8980fc4007fb502e3433 (commit)
from 56273dea4bc44b798f6b661e4fca953437f512f7 (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 d66b74dce74c2824726746e82a8a413463cb80fd
Author: Ludovic Courtès <address@hidden>
Date: Wed Sep 9 19:27:42 2009 +0200
Avoid unneeded `scm_dynwind_free ()'.
* libguile/array-map.c (indices_gc_hint): New variable.
(scm_ramapc, scm_array_index_map_x): Avoid `scm_dynwind_free ()' using
`scm_gc_malloc_pointerless ()'.
commit f07c349eb38d6c7b160b8980fc4007fb502e3433
Author: Ludovic Courtès <address@hidden>
Date: Wed Sep 9 19:14:04 2009 +0200
Update doc of `scm_gc_protect_object ()' and SMOB mark/free.
* doc/ref/api-memory.texi (Garbage Collection
Functions)[scm_gc_protect_object]: Explain that it's equivalent to
storing in a global variable.
* doc/ref/api-smobs.texi (Smobs)[scm_set_smob_free]: Expand on the
relationship with `scm_gc_malloc ()'.
[scm_set_smob_mark]: Explain that it's usually not needed.
-----------------------------------------------------------------------
Summary of changes:
doc/ref/api-memory.texi | 5 ++++
doc/ref/api-smobs.texi | 57 +++++++++++++++++++++++++++++++++--------------
libguile/array-map.c | 18 +++++---------
3 files changed, 52 insertions(+), 28 deletions(-)
diff --git a/doc/ref/api-memory.texi b/doc/ref/api-memory.texi
index 48cce0c..2bf7f10 100644
--- a/doc/ref/api-memory.texi
+++ b/doc/ref/api-memory.texi
@@ -41,6 +41,11 @@ otherwise might be. When you are done with the object, call
the object remains protected until it has been unprotected as many times
as it was protected. It is an error to unprotect an object more times
than it has been protected. Returns the SCM object it was passed.
+
+Note that storing @var{obj} in a C global variable has the same
address@hidden Guile up to version 1.8, C global variables were not
+scanned by the garbage collector; hence, @code{scm_gc_protect_object}
+was the only way in C to prevent a Scheme object from being freed.}.
@end deftypefn
@deftypefn {C Function} SCM scm_gc_unprotect_object (SCM @var{obj})
diff --git a/doc/ref/api-smobs.texi b/doc/ref/api-smobs.texi
index df000d8..cc7f08b 100644
--- a/doc/ref/api-smobs.texi
+++ b/doc/ref/api-smobs.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -8,6 +8,8 @@
@node Smobs
@section Smobs
address@hidden smob
+
This chapter contains reference information related to defining and
working with smobs. See @ref{Defining New Types (Smobs)} for a
tutorial-like introduction to smobs.
@@ -33,10 +35,47 @@ immediately followed by calls to one or several of
@code{scm_set_smob_print}, and/or @code{scm_set_smob_equalp}.
@end deftypefun
address@hidden finalizer
address@hidden finalization
+
address@hidden {C Function} void scm_set_smob_free (scm_t_bits tc, size_t
(*free) (SCM obj))
+This function sets the smob freeing procedure (sometimes referred to as
+a @dfn{finalizer}) for the smob type specified by the tag
address@hidden @var{tc} is the tag returned by @code{scm_make_smob_type}.
+
+The @var{free} procedure must deallocate all resources that are
+directly associated with the smob instance @var{OBJ}. It must assume
+that all @code{SCM} values that it references have already been freed
+and are thus invalid.
+
+It must also not call any libguile function or macro except
address@hidden, @code{SCM_SMOB_FLAGS}, @code{SCM_SMOB_DATA},
address@hidden, and @code{SCM_SMOB_DATA_3}.
+
+The @var{free} procedure must return 0.
+
+Note that defining a freeing procedure is not necessary if the resources
+associated with @var{obj} consists only of memory allocated with
address@hidden or @code{scm_gc_malloc_pointerless} because this
+memory is automatically reclaimed by the garbage collector when it is no
+longer needed (@pxref{Memory Blocks, @code{scm_gc_malloc}}).
address@hidden deftypefn
+
address@hidden precise marking
+
@deftypefn {C Function} void scm_set_smob_mark (scm_t_bits tc, SCM (*mark)
(SCM obj))
This function sets the smob marking procedure for the smob type specified by
the tag @var{tc}. @var{tc} is the tag returned by @code{scm_make_smob_type}.
+Defining a marking procedure should rarely be necessary because all the
+process' memory (with the exception of @code{scm_gc_malloc_pointerless}
+or read-only regions) is scanned for live address@hidden,
+in Guile up to the 1.8 series, the marking procedure was required. The
+reason is that Guile's GC would only look for pointers in the memory
+area used for built-in types (the @dfn{cell heap}), not in
+user-allocated or statically allocated memory. This approach is often
+referred to as @dfn{precise marking}.}.
+
The @var{mark} procedure must cause @code{scm_gc_mark} to be called
for every @code{SCM} value that is directly referenced by the smob
instance @var{obj}. One of these @code{SCM} values can be returned
@@ -49,22 +88,6 @@ It must not call any libguile function or macro except
@code{SCM_SMOB_DATA_2}, and @code{SCM_SMOB_DATA_3}.
@end deftypefn
address@hidden {C Function} void scm_set_smob_free (scm_t_bits tc, size_t
(*free) (SCM obj))
-This function sets the smob freeing procedure for the smob type
-specified by the tag @var{tc}. @var{tc} is the tag returned by
address@hidden
-
-The @var{free} procedure must deallocate all resources that are
-directly associated with the smob instance @var{OBJ}. It must assume
-that all @code{SCM} values that it references have already been freed
-and are thus invalid.
-
-It must also not call any libguile function or macro except
address@hidden, @code{SCM_SMOB_FLAGS}, @code{SCM_SMOB_DATA},
address@hidden, and @code{SCM_SMOB_DATA_3}.
-
-The @var{free} procedure must return 0.
address@hidden deftypefn
@deftypefn {C Function} void scm_set_smob_print (scm_t_bits tc, int (*print)
(SCM obj, SCM port, scm_print_state* pstate))
This function sets the smob printing procedure for the smob type
diff --git a/libguile/array-map.c b/libguile/array-map.c
index fb9ceea..eaac54a 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -37,7 +37,6 @@
#include "libguile/vectors.h"
#include "libguile/bitvectors.h"
#include "libguile/srfi-4.h"
-#include "libguile/dynwind.h"
#include "libguile/generalized-arrays.h"
#include "libguile/generalized-vectors.h"
@@ -78,6 +77,9 @@ static ra_iproc ra_asubrs[] =
{0, 0, 0}
};
+/* The WHAT argument for `scm_gc_malloc ()' et al. */
+static const char indices_gc_hint[] = "array-indices";
+
#define GVREF scm_c_generalized_vector_ref
#define GVSET scm_c_generalized_vector_set_x
@@ -311,10 +313,8 @@ scm_ramapc (int (*cproc)(), SCM data, SCM ra0, SCM lra,
const char *what)
plvra = SCM_CDRLOC (*plvra);
}
- scm_dynwind_begin (0);
-
- vinds = scm_malloc (sizeof(long) * SCM_I_ARRAY_NDIM (ra0));
- scm_dynwind_free (vinds);
+ vinds = scm_gc_malloc_pointerless (sizeof(long) * SCM_I_ARRAY_NDIM (ra0),
+ indices_gc_hint);
for (k = 0; k <= kmax; k++)
vinds[k] = SCM_I_ARRAY_DIMS (ra0)[k].lbnd;
@@ -343,7 +343,6 @@ scm_ramapc (int (*cproc)(), SCM data, SCM ra0, SCM lra,
const char *what)
}
while (k >= 0);
- scm_dynwind_end ();
return 1;
}
}
@@ -1015,10 +1014,8 @@ SCM_DEFINE (scm_array_index_map_x, "array-index-map!",
2, 0, 0,
if (kmax < 0)
return scm_array_set_x (ra, scm_call_0 (proc), SCM_EOL);
- scm_dynwind_begin (0);
-
- vinds = scm_malloc (sizeof(long) * SCM_I_ARRAY_NDIM (ra));
- scm_dynwind_free (vinds);
+ vinds = scm_gc_malloc_pointerless (sizeof(long) * SCM_I_ARRAY_NDIM (ra),
+ indices_gc_hint);
for (k = 0; k <= kmax; k++)
vinds[k] = SCM_I_ARRAY_DIMS (ra)[k].lbnd;
@@ -1050,7 +1047,6 @@ SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2,
0, 0,
}
while (k >= 0);
- scm_dynwind_end ();
return SCM_UNSPECIFIED;
}
else if (scm_is_generalized_vector (ra))
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, boehm-demers-weiser-gc, updated. release_1-9-2-289-gd66b74d,
Ludovic Courtès <=