guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUILE_MAX_HEAP_SIZE


From: Ludovic Courtès
Subject: Re: GUILE_MAX_HEAP_SIZE
Date: Tue, 09 Sep 2008 22:50:17 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Hi,

address@hidden (Ludovic Courtès) writes:

> Han-Wen Nienhuys <address@hidden> writes:
>> Han-Wen Nienhuys escreveu:
>>> Ludovic Courtès escreveu:
>
>>>> +/*
>>>> +  Classic MIT Hack, see e.g. http://www.tekpool.com/?cat=9
>>>> + */
>>>> +int scm_i_uint_bit_count(unsigned int u)
>>>>
>>>> (BTW, it'd make sense to use Gnulib's `count-one-bits' module, which is
>>>> able to use GCC's `__builtin_popcount ()'.)
>>
>> Could you add the gnulib module? I'll do the rest.
>
> I asked for re-licensing:
>
>   http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/14349
>
> Once that is done, all you need is to add it to `m4/gnulib-cache.m4',
> run "gnulib-tool --update", commit the module changes and additions, and
> hack the thing.  You can post the patches before committing, too.  ;-)

I just did it (patch attached).

Thanks,
Ludo'.

>From a8db4a59c898598cc55dd3bd86a6fd8618721d10 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ludovic=20Court=C3=A8s?= <address@hidden>
Date: Tue, 9 Sep 2008 22:46:04 +0200
Subject: [PATCH] Use Gnulib's `count-one-bits' as a replacement for 
`scm_i_uint_bit_count ()'.

* libguile/gc-card.c: Include <config.h> and <count-one-bits.h>.
  (scm_i_uint_bit_count): Remove.
  (scm_i_card_marked_count): Use `count_one_bits_l ()' instead
  of `scm_i_uint_bit_count ()'.

* libguile/gc-segment.c: Include <config.h> and <count-one-bits.h>.
  (scm_i_heap_segment_marked_count): Use `count_one_bits_l ()' instead
  of `scm_i_uint_bit_count ()'.

* libguile/private-gc.h (scm_i_uint_bit_count): Remove.
---
 libguile/gc-card.c    |   23 ++++++++---------------
 libguile/gc-segment.c |   10 ++++++++--
 libguile/private-gc.h |    1 -
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/libguile/gc-card.c b/libguile/gc-card.c
index 3511533..93e271a 100644
--- a/libguile/gc-card.c
+++ b/libguile/gc-card.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2005, 2006, 
2007 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2005, 2006, 
2007, 2008 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -15,8 +15,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <assert.h>
 #include <stdio.h>
+#include <count-one-bits.h>
+
 #include <gmp.h>
 
 #include "libguile/_scm.h"
@@ -294,19 +300,6 @@ scm_i_init_card_freelist (scm_t_cell *card, SCM *free_list,
 }
 
 /*
-  Classic MIT Hack, see e.g. http://www.tekpool.com/?cat=9
- */
-int scm_i_uint_bit_count (unsigned int u)
-{
-  unsigned int u_count = u 
-    - ((u >> 1) & 033333333333) 
-    - ((u >> 2) & 011111111111);
-  return 
-    ((u_count + (u_count >> 3)) 
-     & 030707070707) % 63;
-}
-
-/*
   Amount of cells marked in this cell, measured in 1-cells.
  */
 int
@@ -318,7 +311,7 @@ scm_i_card_marked_count (scm_t_cell *card, int span)
   int count = 0;
   while (bvec < bvec_end)
     {
-      count += scm_i_uint_bit_count (*bvec);
+      count += count_one_bits_l (*bvec);
       bvec ++;
     }
   return count * span;
diff --git a/libguile/gc-segment.c b/libguile/gc-segment.c
index 4f7b6d5..f53ec96 100644
--- a/libguile/gc-segment.c
+++ b/libguile/gc-segment.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2006 Free Software 
Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2006, 2008 Free 
Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -15,10 +15,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <assert.h> 
 #include <stdio.h>
 #include <string.h>
 
+#include <count-one-bits.h>
+
 #include "libguile/_scm.h"
 #include "libguile/pairs.h"
 #include "libguile/gc.h"
@@ -109,7 +115,7 @@ scm_i_heap_segment_marked_count (scm_t_heap_segment *seg)
   int count = 0;
   while (bvec < bvec_end)
     {
-      count += scm_i_uint_bit_count (*bvec);
+      count += count_one_bits_l (*bvec);
       bvec ++;
     }
   return count * seg->span;
diff --git a/libguile/private-gc.h b/libguile/private-gc.h
index d738665..93503ce 100644
--- a/libguile/private-gc.h
+++ b/libguile/private-gc.h
@@ -78,7 +78,6 @@
 #define SCM_GC_IN_CARD_HEADERP(x) \
   (scm_t_cell *) (x) <  SCM_GC_CELL_CARD (x) + SCM_GC_CARD_N_HEADER_CELLS
 
-int scm_i_uint_bit_count (unsigned int u);
 int scm_getenv_int (const char *var, int def);
 
 
-- 
1.6.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]