1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-02 10:16:19 +02:00

Have source properties only use regular GC mechanisms.

* libguile/srcprop.c: Include "libguile/gc.h".
  (srcprops_chunklist): Removed.
  (srcprops_freelist): Removed.
  (srcprops_free): Removed.
  (scm_make_srcprops): Use `scm_gc_malloc ()' rather than
  SRCPROPS_FREELIST et al.
  (scm_init_srcprop): Don't call `scm_set_smob_free ()'.
  (scm_finish_srcprop): Do nothing.

* libguile/srcprop.h (SRCPROPS_CHUNKSIZE): Removed.
  (scm_t_srcprops_chunk): Removed.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-45
This commit is contained in:
Ludovic Courtes 2006-06-25 22:44:00 +00:00 committed by Ludovic Courtès
parent 488b10b5a5
commit 42e6668b5e
2 changed files with 6 additions and 51 deletions

View file

@ -30,6 +30,7 @@
#include "libguile/ports.h" #include "libguile/ports.h"
#include "libguile/root.h" #include "libguile/root.h"
#include "libguile/weaks.h" #include "libguile/weaks.h"
#include "libguile/gc.h"
#include "libguile/validate.h" #include "libguile/validate.h"
#include "libguile/srcprop.h" #include "libguile/srcprop.h"
@ -56,18 +57,6 @@ SCM_GLOBAL_SYMBOL (scm_sym_column, "column");
SCM_GLOBAL_SYMBOL (scm_sym_breakpoint, "breakpoint"); SCM_GLOBAL_SYMBOL (scm_sym_breakpoint, "breakpoint");
scm_t_bits scm_tc16_srcprops; scm_t_bits scm_tc16_srcprops;
static scm_t_srcprops_chunk *srcprops_chunklist = 0;
static scm_t_srcprops *srcprops_freelist = 0;
static size_t
srcprops_free (SCM obj)
{
*((scm_t_srcprops **) SCM_SMOB_DATA (obj)) = srcprops_freelist;
srcprops_freelist = (scm_t_srcprops *) SCM_SMOB_DATA (obj);
return 0; /* srcprops_chunks are not freed until leaving guile */
}
static int static int
@ -95,32 +84,14 @@ SCM
scm_make_srcprops (long line, int col, SCM filename, SCM copy, SCM plist) scm_make_srcprops (long line, int col, SCM filename, SCM copy, SCM plist)
{ {
register scm_t_srcprops *ptr; register scm_t_srcprops *ptr;
SCM_CRITICAL_SECTION_START;
if ((ptr = srcprops_freelist) != NULL)
srcprops_freelist = *(scm_t_srcprops **)ptr;
else
{
size_t i;
scm_t_srcprops_chunk *mem;
size_t n = sizeof (scm_t_srcprops_chunk)
+ sizeof (scm_t_srcprops) * (SRCPROPS_CHUNKSIZE - 1);
mem = scm_gc_malloc (n, "srcprops");
if (mem == NULL)
scm_memory_error ("srcprops");
mem->next = srcprops_chunklist; ptr = scm_gc_malloc (sizeof (*ptr), "srcprop");
srcprops_chunklist = mem;
ptr = &mem->srcprops[0];
for (i = 1; i < SRCPROPS_CHUNKSIZE - 1; ++i)
*(scm_t_srcprops **)&ptr[i] = &ptr[i + 1];
*(scm_t_srcprops **)&ptr[SRCPROPS_CHUNKSIZE - 1] = 0;
srcprops_freelist = (scm_t_srcprops *) &ptr[1];
}
ptr->pos = SRCPROPMAKPOS (line, col); ptr->pos = SRCPROPMAKPOS (line, col);
ptr->fname = filename; ptr->fname = filename;
ptr->copy = copy; ptr->copy = copy;
ptr->plist = plist; ptr->plist = plist;
SCM_CRITICAL_SECTION_END;
SCM_RETURN_NEWSMOB (scm_tc16_srcprops, ptr); SCM_RETURN_NEWSMOB (scm_tc16_srcprops, ptr);
} }
@ -174,7 +145,7 @@ SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
else if (!scm_is_pair (obj)) else if (!scm_is_pair (obj))
SCM_WRONG_TYPE_ARG(1, obj); SCM_WRONG_TYPE_ARG(1, obj);
handle = scm_hashq_create_handle_x (scm_source_whash, obj, plist); handle = scm_hashq_create_handle_x (scm_source_whash, obj, plist);
SCM_SETCDR (handle, plist);
return plist; return plist;
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -298,7 +269,6 @@ void
scm_init_srcprop () scm_init_srcprop ()
{ {
scm_tc16_srcprops = scm_make_smob_type ("srcprops", 0); scm_tc16_srcprops = scm_make_smob_type ("srcprops", 0);
scm_set_smob_free (scm_tc16_srcprops, srcprops_free);
scm_set_smob_print (scm_tc16_srcprops, srcprops_print); scm_set_smob_print (scm_tc16_srcprops, srcprops_print);
scm_source_whash = scm_make_weak_key_hash_table (scm_from_int (2047)); scm_source_whash = scm_make_weak_key_hash_table (scm_from_int (2047));
@ -310,16 +280,7 @@ scm_init_srcprop ()
void void
scm_finish_srcprop () scm_finish_srcprop ()
{ {
register scm_t_srcprops_chunk *ptr = srcprops_chunklist, *next; /* Nothing to do. */
size_t n= sizeof (scm_t_srcprops_chunk)
+ sizeof (scm_t_srcprops) * (SRCPROPS_CHUNKSIZE - 1);
while (ptr)
{
next = ptr->next;
scm_gc_unregister_collectable_memory (ptr, n, "srcprops");
free ((char *) ptr);
ptr = next;
}
} }
/* /*

View file

@ -60,12 +60,6 @@ typedef struct scm_t_srcprops
SCM plist; SCM plist;
} scm_t_srcprops; } scm_t_srcprops;
#define SRCPROPS_CHUNKSIZE 2047 /* Number of srcprops per chunk */
typedef struct scm_t_srcprops_chunk
{
struct scm_t_srcprops_chunk *next;
scm_t_srcprops srcprops[1];
} scm_t_srcprops_chunk;
#define SCM_SOURCE_PROPERTY_FLAG_BREAK 1 #define SCM_SOURCE_PROPERTY_FLAG_BREAK 1