diff options
-rw-r--r-- | libguile/ChangeLog | 5 | ||||
-rw-r--r-- | libguile/gc-card.c | 9 | ||||
-rw-r--r-- | libguile/gc-malloc.c | 6 | ||||
-rw-r--r-- | libguile/gc-segment.c | 13 | ||||
-rw-r--r-- | libguile/gc.c | 15 | ||||
-rw-r--r-- | libguile/struct.c | 4 | ||||
-rw-r--r-- | libguile/struct.h | 2 |
7 files changed, 40 insertions, 14 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 8d984443f..d8eb34c4d 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,10 @@ 2002-09-05 Han-Wen Nienhuys <hanwen@cs.uu.nl> + * struct.h: change scm_structs_to_free to scm_i_structs_to_free + + * 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. diff --git a/libguile/gc-card.c b/libguile/gc-card.c index f9c9c7d7d..61bf5b2ad 100644 --- a/libguile/gc-card.c +++ b/libguile/gc-card.c @@ -68,6 +68,11 @@ long int scm_i_deprecated_memory_return; +/* During collection, this accumulates structures which are to be freed. + */ +SCM scm_i_structs_to_free; + + /* Init all the free cells in CARD, prepending to *FREE_LIST. @@ -109,8 +114,8 @@ scm_i_sweep_card (scm_t_cell * p, SCM *free_list, scm_t_heap_segment*seg) /* Structs need to be freed in a special order. * This is handled by GC C hooks in struct.c. */ - SCM_SET_STRUCT_GC_CHAIN (p, scm_structs_to_free); - scm_structs_to_free = scmptr; + SCM_SET_STRUCT_GC_CHAIN (p, scm_i_structs_to_free); + scm_i_structs_to_free = scmptr; } continue; diff --git a/libguile/gc-malloc.c b/libguile/gc-malloc.c index 7bf366b0d..2f39db0da 100644 --- a/libguile/gc-malloc.c +++ b/libguile/gc-malloc.c @@ -200,13 +200,15 @@ scm_gc_register_collectable_memory (void *mem, size_t size, const char *what) */ if (scm_mallocated > scm_mtrigger) { - long prev_alloced = scm_mallocated; + unsigned long prev_alloced = scm_mallocated; float yield; scm_igc (what); scm_i_sweep_all_segments("mtrigger"); - yield = (prev_alloced - scm_mallocated) / (float) prev_alloced; + yield = ((float)prev_alloced - (float) scm_mallocated) + / (float) prev_alloced; + scm_gc_malloc_yield_percentage = (int) (100 * yield); #ifdef DEBUGINFO diff --git a/libguile/gc-segment.c b/libguile/gc-segment.c index 2cdbef2aa..ec0c2cf80 100644 --- a/libguile/gc-segment.c +++ b/libguile/gc-segment.c @@ -296,7 +296,7 @@ scm_i_insert_segment (scm_t_heap_segment * seg) highest_cell = SCM_MAX (highest_cell, seg->bounds[1]); } - + { int i = 0; int j = 0; @@ -304,6 +304,17 @@ scm_i_insert_segment (scm_t_heap_segment * seg) while (i < scm_i_heap_segment_table_size && scm_i_heap_segment_table[i]->bounds[0] <= seg->bounds[0]) i++; + + /* + We insert a new entry; if that happens to be before the + "current" segment of a freelist, we must move the freelist index + as well. + */ + if (scm_i_master_freelist.heap_segment_idx >= i) + scm_i_master_freelist.heap_segment_idx ++; + if (scm_i_master_freelist2.heap_segment_idx >= i) + scm_i_master_freelist2.heap_segment_idx ++; + for (j = scm_i_heap_segment_table_size; j > i; --j) scm_i_heap_segment_table[j] = scm_i_heap_segment_table[j - 1]; diff --git a/libguile/gc.c b/libguile/gc.c index fdc390e79..d5baf3cca 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -120,8 +120,6 @@ int scm_i_cell_validation_already_running ; periods. */ - - void scm_i_expensive_validation_check (SCM cell) { @@ -277,10 +275,6 @@ int scm_block_gc = 1; */ SCM scm_weak_vectors; -/* During collection, this accumulates structures which are to be freed. - */ -SCM scm_structs_to_free; - /* GC Statistics Keeping */ unsigned long scm_cells_allocated = 0; @@ -608,10 +602,19 @@ scm_igc (const char *what) scm_gc_sweep (); + + /* + TODO: this hook should probably be moved to just before the mark, + since that's where the sweep is finished in lazy sweeping. + */ scm_c_hook_run (&scm_after_sweep_c_hook, 0); gc_end_stats (); SCM_CRITICAL_SECTION_END; + + /* + See above. + */ scm_c_hook_run (&scm_after_gc_c_hook, 0); --scm_gc_running_p; diff --git a/libguile/struct.c b/libguile/struct.c index 308af78e7..c4f810260 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -360,7 +360,7 @@ scm_struct_gc_init (void *dummy1 SCM_UNUSED, void *dummy2 SCM_UNUSED, void *dummy3 SCM_UNUSED) { - scm_structs_to_free = SCM_EOL; + scm_i_structs_to_free = SCM_EOL; return 0; } @@ -369,7 +369,7 @@ scm_free_structs (void *dummy1 SCM_UNUSED, void *dummy2 SCM_UNUSED, void *dummy3 SCM_UNUSED) { - SCM newchain = scm_structs_to_free; + SCM newchain = scm_i_structs_to_free; do { /* Mark vtables in GC chain. GC mark set means delay freeing. */ diff --git a/libguile/struct.h b/libguile/struct.h index 7c784b14d..5e4df9152 100644 --- a/libguile/struct.h +++ b/libguile/struct.h @@ -103,7 +103,7 @@ SCM_API SCM scm_struct_table; #define SCM_STRUCT_GC_CHAIN(X) SCM_CELL_OBJECT_3 (X) #define SCM_SET_STRUCT_GC_CHAIN(X, Y) SCM_SET_CELL_OBJECT_3 (X, Y) -SCM_API SCM scm_structs_to_free; +SCM_API SCM scm_i_structs_to_free; |