1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-23 04:50:28 +02:00

* gc-segment.c (scm_i_make_initial_segment): check user settings

for sanity.

* gc-malloc.c (scm_gc_init_malloc): check user settings for
sanity.
(scm_gc_register_collectable_memory): prevent overflow of memory
counts.

* gc-freelist.c (scm_init_freelist): check user settings for sanity.

* gc-malloc.c (scm_gc_register_collectable_memory): use floats;
these won't ever wrap around with high memory usage.

* gc-freelist.c: include <stdio.h>

* gc-malloc.c: add DEBUGINFO for mtrigger GCs.
This commit is contained in:
Han-Wen Nienhuys 2002-09-05 21:55:33 +00:00
parent ffd724008b
commit dac04e9fb9
5 changed files with 42 additions and 11 deletions

View file

@ -1,5 +1,15 @@
2002-09-05 Han-Wen Nienhuys <hanwen@cs.uu.nl> 2002-09-05 Han-Wen Nienhuys <hanwen@cs.uu.nl>
* gc-segment.c (scm_i_make_initial_segment): check user settings
for sanity.
* gc-malloc.c (scm_gc_init_malloc): check user settings for
sanity.
(scm_gc_register_collectable_memory): prevent overflow of memory
counts.
* gc-freelist.c (scm_init_freelist): check user settings for sanity.
* struct.h: change scm_structs_to_free to scm_i_structs_to_free * struct.h: change scm_structs_to_free to scm_i_structs_to_free
* gc-malloc.c (scm_gc_register_collectable_memory): use floats; * gc-malloc.c (scm_gc_register_collectable_memory): use floats;

View file

@ -138,6 +138,11 @@ scm_init_freelist (scm_t_cell_type_statistics *freelist,
int span, int span,
int min_yield) int min_yield)
{ {
if (min_yield < 1)
min_yield = 1;
if (min_yield > 99)
min_yield = 99;
freelist->heap_segment_idx = -1; freelist->heap_segment_idx = -1;
freelist->min_yield = 0; freelist->min_yield = 0;
freelist->min_yield_fraction = min_yield; freelist->min_yield_fraction = min_yield;
@ -158,10 +163,9 @@ scm_init_freelist (scm_t_cell_type_statistics *freelist,
void void
scm_gc_init_freelist (void) scm_gc_init_freelist (void)
{ {
size_t init_heap_size_1 int init_heap_size_1
= scm_getenv_int ("GUILE_INIT_SEGMENT_SIZE_1", SCM_DEFAULT_INIT_HEAP_SIZE_1); = scm_getenv_int ("GUILE_INIT_SEGMENT_SIZE_1", SCM_DEFAULT_INIT_HEAP_SIZE_1);
int init_heap_size_2
size_t init_heap_size_2
= scm_getenv_int ("GUILE_INIT_SEGMENT_SIZE_2", SCM_DEFAULT_INIT_HEAP_SIZE_2); = scm_getenv_int ("GUILE_INIT_SEGMENT_SIZE_2", SCM_DEFAULT_INIT_HEAP_SIZE_2);
scm_i_freelist = SCM_EOL; scm_i_freelist = SCM_EOL;
@ -172,12 +176,14 @@ scm_gc_init_freelist (void)
scm_init_freelist (&scm_i_master_freelist, 1, scm_init_freelist (&scm_i_master_freelist, 1,
scm_getenv_int ("GUILE_MIN_YIELD_1", SCM_DEFAULT_MIN_YIELD_1)); scm_getenv_int ("GUILE_MIN_YIELD_1", SCM_DEFAULT_MIN_YIELD_1));
scm_max_segment_size = scm_getenv_int ("GUILE_MAX_SEGMENT_SIZE", SCM_DEFAULT_MAX_SEGMENT_SIZE); scm_max_segment_size = scm_getenv_int ("GUILE_MAX_SEGMENT_SIZE", SCM_DEFAULT_MAX_SEGMENT_SIZE);
if (scm_max_segment_size <= 0)
scm_max_segment_size = SCM_DEFAULT_MAX_SEGMENT_SIZE;
scm_i_make_initial_segment (init_heap_size_1, &scm_i_master_freelist); scm_i_make_initial_segment (init_heap_size_1, &scm_i_master_freelist);
scm_i_make_initial_segment (init_heap_size_2, &scm_i_master_freelist2); scm_i_make_initial_segment (init_heap_size_2, &scm_i_master_freelist2);
#if (SCM_ENABLE_DEPRECATED == 1) #if (SCM_ENABLE_DEPRECATED == 1)
if ( scm_default_init_heap_size_1 || if ( scm_default_init_heap_size_1 ||

View file

@ -106,6 +106,14 @@ scm_gc_init_malloc (void)
SCM_DEFAULT_INIT_MALLOC_LIMIT); SCM_DEFAULT_INIT_MALLOC_LIMIT);
scm_i_minyield_malloc = scm_getenv_int ("GUILE_MIN_YIELD_MALLOC", scm_i_minyield_malloc = scm_getenv_int ("GUILE_MIN_YIELD_MALLOC",
SCM_DEFAULT_MALLOC_MINYIELD); SCM_DEFAULT_MALLOC_MINYIELD);
if (scm_i_minyield_malloc >= 100)
scm_i_minyield_malloc = 99;
if (scm_i_minyield_malloc < 1)
scm_i_minyield_malloc = 1;
if (scm_mtrigger < 0)
scm_mtrigger = SCM_DEFAULT_INIT_MALLOC_LIMIT;
} }
@ -226,7 +234,10 @@ scm_gc_register_collectable_memory (void *mem, size_t size, const char *what)
Instead of getting bogged down, we let the mtrigger grow Instead of getting bogged down, we let the mtrigger grow
strongly with it. strongly with it.
*/ */
scm_mtrigger = (scm_mallocated * 110) / (100 - scm_i_minyield_malloc); float no_overflow_trigger = (float)(scm_mallocated * 110);
no_overflow_trigger /= (float) (100 - scm_i_minyield_malloc);
scm_mtrigger = (unsigned long) no_overflow_trigger;
#ifdef DEBUGINFO #ifdef DEBUGINFO
fprintf (stderr, "Mtrigger sweep: ineffective. New trigger %d\n", scm_mtrigger); fprintf (stderr, "Mtrigger sweep: ineffective. New trigger %d\n", scm_mtrigger);

View file

@ -520,12 +520,15 @@ scm_i_get_new_heap_segment (scm_t_cell_type_statistics *freelist, policy_on_erro
return -1; return -1;
} }
void void
scm_i_make_initial_segment (size_t init_heap_size, scm_t_cell_type_statistics *freelist) scm_i_make_initial_segment (int init_heap_size, scm_t_cell_type_statistics *freelist)
{ {
scm_t_heap_segment * seg = scm_i_make_empty_heap_segment (freelist); scm_t_heap_segment * seg = scm_i_make_empty_heap_segment (freelist);
if (init_heap_size < 1)
{
init_heap_size = SCM_DEFAULT_INIT_HEAP_SIZE_1;
}
if (scm_i_initialize_heap_segment_data (seg, init_heap_size)) if (scm_i_initialize_heap_segment_data (seg, init_heap_size))
{ {

View file

@ -124,7 +124,8 @@ extern unsigned long scm_gc_cells_collected_1;
void scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist); void scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist);
void scm_i_gc_sweep_freelist_reset (scm_t_cell_type_statistics *freelist); void scm_i_gc_sweep_freelist_reset (scm_t_cell_type_statistics *freelist);
int scm_i_gc_grow_heap_p (scm_t_cell_type_statistics * freelist); int scm_i_gc_grow_heap_p (scm_t_cell_type_statistics * freelist);
#define SCM_HEAP_SIZE \ #define SCM_HEAP_SIZE \
(scm_i_master_freelist.heap_size + scm_i_master_freelist2.heap_size) (scm_i_master_freelist.heap_size + scm_i_master_freelist2.heap_size)
@ -228,7 +229,7 @@ void scm_i_sweep_segments (void);
SCM scm_i_sweep_some_segments (scm_t_cell_type_statistics * fl); SCM scm_i_sweep_some_segments (scm_t_cell_type_statistics * fl);
void scm_i_reset_segments (void); void scm_i_reset_segments (void);
void scm_i_sweep_all_segments (char const *reason); void scm_i_sweep_all_segments (char const *reason);
void scm_i_make_initial_segment (size_t init_heap_size, scm_t_cell_type_statistics *freelist); void scm_i_make_initial_segment (int init_heap_size, scm_t_cell_type_statistics *freelist);
extern long int scm_i_deprecated_memory_return; extern long int scm_i_deprecated_memory_return;