1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 06:41:13 +02:00

* Fixed the changelog entry regarding re-introduction of struct member

properties (I continuously talked of member 'documentation' instead)
* Replace calls to scm_remember with calls to scm_remember_upto_here_1.
This commit is contained in:
Dirk Herrmann 2000-12-28 16:49:09 +00:00
parent fcba9b58c6
commit 5d2b97cd07
8 changed files with 84 additions and 13 deletions

10
NEWS
View file

@ -276,6 +276,16 @@ behaviour is undefined - it may even crash or loop endlessly. Further, for
the case that the object is not found in the list, scm_c_memq returns #f which the case that the object is not found in the list, scm_c_memq returns #f which
is similar to scm_memq, but different from scm_sloppy_memq's behaviour. is similar to scm_memq, but different from scm_sloppy_memq's behaviour.
** New functions: scm_remember_upto_here_1, scm_remember_upto_here_2,
scm_remember_upto_here
These functions replace the function scm_remember.
** Deprecated function: scm_remember
Use one of the new functions scm_remember_upto_here_1,
scm_remember_upto_here_2 or scm_remember_upto_here instead.
** New global variable scm_gc_running_p introduced. ** New global variable scm_gc_running_p introduced.
Use this variable to find out if garbage collection is being executed. Up to Use this variable to find out if garbage collection is being executed. Up to

View file

@ -41,6 +41,7 @@ In release 1.6:
eval.c: scm_eval2, scm_eval_3 eval.c: scm_eval2, scm_eval_3
load.c: scm_read_and_eval_x load.c: scm_read_and_eval_x
smob.c: scm_make_smob_type_mfpe, scm_set_smob_mfpe smob.c: scm_make_smob_type_mfpe, scm_set_smob_mfpe
gc.c: scm_remember
- remove deprecated procedures: - remove deprecated procedures:
boot-9.scm:eval-in-module boot-9.scm:eval-in-module
- remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL, - remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,

View file

@ -1,3 +1,15 @@
2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eval.c (check_map_args), gh_data.c (gh_set_substr,
gh_scm2newstr, gh_get_substr, gh_symbol2newstr), print.c
(scm_iprin1): Use scm_remember_upto_here_1 instead of
scm_remember.
* gc.[ch] (scm_remember_upto_here_1, scm_remember_upto_here_2,
scm_remember_upto_here): New functions.
(scm_remember): Deprecated.
2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de> 2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de>
* continuations.c (scm_make_continuation): Make variable cont * continuations.c (scm_make_continuation): Make variable cont
@ -7,15 +19,15 @@
2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de> 2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de>
This patch re-introduces the unused member "documentation" of This patch re-introduces the unused member "properties" of
struct scm_subr_entry as requested by Mikael Djurfeldt. struct scm_subr_entry as requested by Mikael Djurfeldt.
* procs.h (scm_subr_entry): Re-introduced member "documentation". * procs.h (scm_subr_entry): Re-introduced member "properties".
(SCM_SUBR_DOC): Un-deprecated. (SCM_SUBR_PROPS): Un-deprecated.
* procs.c (scm_make_subr_opt, scm_mark_subr_table): Struct * procs.c (scm_make_subr_opt, scm_mark_subr_table): Struct
scm_subr_entry has a member "documentation" again. scm_subr_entry has a member "properties" again.
2000-12-28 Michael Livshin <mlivshin@bigfoot.com> 2000-12-28 Michael Livshin <mlivshin@bigfoot.com>

View file

@ -3550,7 +3550,7 @@ check_map_args (SCM argv,
scm_out_of_range (who, ve[i]); scm_out_of_range (who, ve[i]);
} }
scm_remember (&argv); scm_remember_upto_here_1 (argv);
} }

View file

@ -2316,12 +2316,59 @@ SCM_DEFINE (scm_unhash_name, "unhash-name", 1, 0, 0,
*/ */
/*
* If within a function you need to protect one or more scheme objects from
* garbage collection, pass them as parameters to one of the
* scm_remember_upto_here* functions below. These functions don't do
* anything, but since the compiler does not know that they are actually
* no-ops, it will generate code that calls these functions with the given
* parameters. Therefore, you can be sure that the compiler will keep those
* scheme values alive (on the stack or in a register) up to the point where
* scm_remember_upto_here* is called. In other words, place the call to
* scm_remember_upt_here* _behind_ the last code in your function, that
* depends on the scheme object to exist.
*
* Example: We want to make sure, that the string object str does not get
* garbage collected during the execution of 'some_function', because
* otherwise the characters belonging to str would be freed and
* 'some_function' might access freed memory. To make sure that the compiler
* keeps str alive on the stack or in a register such that it is visible to
* the conservative gc we add the call to scm_remember_upto_here_1 _after_ the
* call to 'some_function'. Note that this would not be necessary if str was
* used anyway after the call to 'some_function'.
* char *chars = SCM_STRING_CHARS (str);
* some_function (chars);
* scm_remember_upto_here_1 (str); // str will be alive up to this point.
*/
void
scm_remember_upto_here_1 (SCM obj)
{
/* Empty. Protects a single object from garbage collection. */
}
void
scm_remember_upto_here_2 (SCM obj1, SCM obj2)
{
/* Empty. Protects two objects from garbage collection. */
}
void
scm_remember_upto_here (SCM obj, ...)
{
/* Empty. Protects any number of objects from garbage collection. */
}
#if (SCM_DEBUG_DEPRECATED == 0)
void void
scm_remember (SCM *ptr) scm_remember (SCM *ptr)
{ {
/* empty */ /* empty */
} }
#endif /* SCM_DEBUG_DEPRECATED == 0 */
/* /*
These crazy functions prevent garbage collection These crazy functions prevent garbage collection

View file

@ -349,7 +349,9 @@ extern void * scm_must_realloc (void *where,
extern void scm_done_malloc (long size); extern void scm_done_malloc (long size);
extern void scm_done_free (long size); extern void scm_done_free (long size);
extern void scm_must_free (void *obj); extern void scm_must_free (void *obj);
extern void scm_remember (SCM * ptr); extern void scm_remember_upto_here_1 (SCM obj);
extern void scm_remember_upto_here_2 (SCM obj1, SCM obj2);
extern void scm_remember_upto_here (SCM obj1, ...);
extern SCM scm_return_first (SCM elt, ...); extern SCM scm_return_first (SCM elt, ...);
extern int scm_return_first_int (int x, ...); extern int scm_return_first_int (int x, ...);
extern SCM scm_permanent_object (SCM obj); extern SCM scm_permanent_object (SCM obj);
@ -370,6 +372,7 @@ extern void scm_init_gc (void);
#define SCM_CLRGC8MARK(x) SCM_CLRGCMARK (x) #define SCM_CLRGC8MARK(x) SCM_CLRGCMARK (x)
#define SCM_GCTYP16(x) SCM_TYP16 (x) #define SCM_GCTYP16(x) SCM_TYP16 (x)
#define SCM_GCCDR(x) SCM_CDR (x) #define SCM_GCCDR(x) SCM_CDR (x)
extern void scm_remember (SCM * ptr);
#endif /* SCM_DEBUG_DEPRECATED == 0 */ #endif /* SCM_DEBUG_DEPRECATED == 0 */

View file

@ -122,7 +122,7 @@ gh_set_substr (char *src, SCM dst, int start, int len)
effective_length = ((unsigned) len < dst_len) ? len : dst_len; effective_length = ((unsigned) len < dst_len) ? len : dst_len;
memmove (dst_ptr + start, src, effective_length); memmove (dst_ptr + start, src, effective_length);
scm_remember (&dst); scm_remember_upto_here_1 (dst);
} }
/* Return the symbol named SYMBOL_STR. */ /* Return the symbol named SYMBOL_STR. */
@ -543,8 +543,7 @@ gh_scm2newstr (SCM str, int *lenp)
"gh_scm2newstr"); "gh_scm2newstr");
/* so we copy tmp_str to ret_str, which is what we will allocate */ /* so we copy tmp_str to ret_str, which is what we will allocate */
memcpy (ret_str, SCM_STRING_CHARS (str), len); memcpy (ret_str, SCM_STRING_CHARS (str), len);
/* from now on we don't mind if str gets GC collected. */ scm_remember_upto_here_1 (str);
scm_remember (&str);
/* now make sure we null-terminate it */ /* now make sure we null-terminate it */
ret_str[len] = '\0'; ret_str[len] = '\0';
@ -575,7 +574,7 @@ gh_get_substr (SCM src, char *dst, int start, int len)
effective_length = (len < src_len) ? len : src_len; effective_length = (len < src_len) ? len : src_len;
memcpy (dst + start, SCM_STRING_CHARS (src), effective_length * sizeof (char)); memcpy (dst + start, SCM_STRING_CHARS (src), effective_length * sizeof (char));
/* FIXME: must signal an error if len > src_len */ /* FIXME: must signal an error if len > src_len */
scm_remember (&src); scm_remember_upto_here_1 (src);
} }
@ -600,8 +599,7 @@ gh_symbol2newstr (SCM sym, int *lenp)
"gh_symbol2newstr"); "gh_symbol2newstr");
/* so we copy sym to ret_str, which is what we will allocate */ /* so we copy sym to ret_str, which is what we will allocate */
memcpy (ret_str, SCM_SYMBOL_CHARS (sym), len); memcpy (ret_str, SCM_SYMBOL_CHARS (sym), len);
/* from now on we don't mind if sym gets GC collected. */ scm_remember_upto_here_1 (sym);
scm_remember (&sym);
/* now make sure we null-terminate it */ /* now make sure we null-terminate it */
ret_str[len] = '\0'; ret_str[len] = '\0';

View file

@ -578,7 +578,7 @@ taloop:
} }
if (pos < end) if (pos < end)
scm_lfwrite (str + pos, end - pos, port); scm_lfwrite (str + pos, end - pos, port);
scm_remember (&exp); scm_remember_upto_here_1 (exp);
if (weird) if (weird)
scm_lfwrite ("}#", 2, port); scm_lfwrite ("}#", 2, port);
break; break;