diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2008-09-10 00:11:02 -0300 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@lilypond.org> | 2008-09-11 12:10:58 -0300 |
commit | b71c8ec90ac5328ce437cf91ef2b4886ca25f9ba (patch) | |
tree | 5eae8c2b9ccb8a9b7a2345caa4e31d00534fb9b6 | |
parent | b48efb55b0ce22d05f82cc93f55a6090d912af1e (diff) | |
download | guile-b71c8ec90ac5328ce437cf91ef2b4886ca25f9ba.tar.gz |
Revise GC asserts.
* libguile/gc.c (scm_i_gc): Change assert into printed warning.
* libguile/private-gc.h (nil): introduce scm_i_last_marked_cell_count,
as a private mechanism for maintaining cell counts. Remove variable
scm_cells_allocated.
-rw-r--r-- | libguile/gc.c | 20 | ||||
-rw-r--r-- | libguile/gc.h | 1 | ||||
-rw-r--r-- | libguile/private-gc.h | 5 |
3 files changed, 17 insertions, 9 deletions
diff --git a/libguile/gc.c b/libguile/gc.c index f3ef585a9..a970eef0b 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -416,7 +416,7 @@ gc_end_stats () scm_gc_cells_allocated_acc += (double) scm_i_gc_sweep_stats.collected; - scm_gc_cells_marked_acc += (double) scm_cells_allocated; + scm_gc_cells_marked_acc += (double) scm_i_last_marked_cell_count; scm_gc_cells_marked_conservatively_acc += (double) scm_i_find_heap_calls; scm_gc_cells_swept_acc += (double) scm_i_gc_sweep_stats.swept; @@ -558,6 +558,8 @@ scm_check_deprecated_memory_return () scm_i_deprecated_memory_return = 0; } +long int scm_i_last_marked_cell_count; + /* Must be called while holding scm_i_sweep_mutex. This function is fairly long, but it touches various global @@ -598,16 +600,22 @@ scm_i_gc (const char *what) scm_i_sweep_all_segments ("GC", &scm_i_gc_sweep_stats); scm_check_deprecated_memory_return (); -#if (SCM_DEBUG_CELL_ACCESSES == 0 && SCM_SIZEOF_UNSIGNED_LONG ==4) +#if (SCM_DEBUG_CELL_ACCESSES == 0 && SCM_SIZEOF_UNSIGNED_LONG == 4) /* Sanity check our numbers. */ /* TODO(hanwen): figure out why the stats are off on x64_64. */ /* If this was not true, someone touched mark bits outside of the mark phase. */ - assert (scm_cells_allocated == scm_i_marked_count ()); + if (scm_i_last_marked_cell_count != scm_i_marked_count ()) + { + static char msg[] = + "The number of marked objects changed since the last GC: %d vs %d."; + /* At some point, we should probably use a deprecation warning. */ + fprintf(stderr, msg, scm_i_last_marked_cell_count, scm_i_marked_count ()); + } assert (scm_i_gc_sweep_stats.swept == (scm_i_master_freelist.heap_total_cells + scm_i_master_freelist2.heap_total_cells)); - assert (scm_i_gc_sweep_stats.collected + scm_cells_allocated + assert (scm_i_gc_sweep_stats.collected + scm_i_last_marked_cell_count == scm_i_gc_sweep_stats.swept); #endif /* SCM_DEBUG_CELL_ACCESSES */ @@ -617,8 +625,8 @@ scm_i_gc (const char *what) scm_mark_all (); scm_gc_mark_time_taken += (scm_c_get_internal_run_time () - t_before_gc); - scm_cells_allocated = scm_i_marked_count (); - + scm_i_last_marked_cell_count = scm_cells_allocated = scm_i_marked_count (); + /* Sweep TODO: the after_sweep hook should probably be moved to just before diff --git a/libguile/gc.h b/libguile/gc.h index fbd971036..58ac77241 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -287,7 +287,6 @@ SCM_API struct scm_t_cell_type_statistics scm_i_master_freelist; SCM_API struct scm_t_cell_type_statistics scm_i_master_freelist2; SCM_API unsigned long scm_gc_malloc_collected; -SCM_API unsigned long scm_cells_allocated; SCM_API int scm_gc_malloc_yield_percentage; SCM_API unsigned long scm_mallocated; SCM_API unsigned long scm_mtrigger; diff --git a/libguile/private-gc.h b/libguile/private-gc.h index 93503ceb1..f5331ab1e 100644 --- a/libguile/private-gc.h +++ b/libguile/private-gc.h @@ -273,8 +273,9 @@ SCM_INTERNAL void scm_i_sweep_all_segments (char const *reason, SCM_INTERNAL SCM scm_i_all_segments_statistics (SCM hashtab); SCM_INTERNAL unsigned long *scm_i_segment_table_info(int *size); -extern long int scm_i_deprecated_memory_return; -extern long int scm_i_find_heap_calls; +SCM_INTERNAL long int scm_i_deprecated_memory_return; +SCM_INTERNAL long int scm_i_find_heap_calls; +SCM_INTERNAL long int scm_i_last_marked_cell_count; /* global init funcs. |