From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Han-Wen Nienhuys Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Revise GC asserts. Date: Wed, 10 Sep 2008 00:14:09 -0300 Message-ID: Reply-To: hanwen@xs4all.nl NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1221016572 25536 80.91.229.12 (10 Sep 2008 03:16:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Sep 2008 03:16:12 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Sep 10 05:17:08 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KdGCT-0007N9-Kx for guile-devel@m.gmane.org; Wed, 10 Sep 2008 05:17:01 +0200 Original-Received: from localhost ([127.0.0.1]:51131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdGBT-0006l2-Fw for guile-devel@m.gmane.org; Tue, 09 Sep 2008 23:15:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KdGBO-0006kn-Ki for guile-devel@gnu.org; Tue, 09 Sep 2008 23:15:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KdGBN-0006kb-4E for guile-devel@gnu.org; Tue, 09 Sep 2008 23:15:54 -0400 Original-Received: from [199.232.76.173] (port=45349 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdGBN-0006kY-1v for guile-devel@gnu.org; Tue, 09 Sep 2008 23:15:53 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:36200 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KdGBM-0007ly-K2 for guile-devel@gnu.org; Tue, 09 Sep 2008 23:15:53 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KdGBG-0004mx-QL for guile-devel@gnu.org; Wed, 10 Sep 2008 03:15:46 +0000 Original-Received: from 201.80.3.52 ([201.80.3.52]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Sep 2008 03:15:46 +0000 Original-Received: from hanwen by 201.80.3.52 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Sep 2008 03:15:46 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 83 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 201.80.3.52 User-Agent: Thunderbird 2.0.0.16 (X11/20080723) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7655 Archived-At: * libguile/gc.c (scm_i_gc): Change assert into deprecation warning. * libguile/private-gc.h (nil): introduce scm_i_last_marked_cell_count, as a private mechanism for maintaining cell counts. Previous versions incremented scm_cells_allocated in an inlined function, so loading dynamic objects of older GUILEs would break invariants. --- libguile/gc.c | 18 +++++++++++++----- libguile/private-gc.h | 5 +++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libguile/gc.c b/libguile/gc.c index f3ef585..0323f87 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 @@ -603,11 +605,17 @@ scm_i_gc (const char *what) /* 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. " + "Are you marking objects outside of the mark phase?"; + scm_c_issue_deprecation_warning(msg); + } 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/private-gc.h b/libguile/private-gc.h index 93503ce..f5331ab 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. -- 1.5.5.1