1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

139 commits

Author SHA1 Message Date
Andy Wingo
07e69928fc hash-set! on weak tables returns the value
* libguile/weak-table.h:
* libguile/weak-table.c (scm_weak_table_putq_x)
  (scm_weak_table_remq_x, scm_weak_table_clear_x)
  (scm_weak_table_for_each): Declare these as returning void instead of
  SCM.
* libguile/hashtab.c (scm_hashq_set_x, scm_hashq_remove_x)
  (scm_hashv_set_x, scm_hashv_remove_x)
  (scm_hash_set_x, scm_hash_remove_x)
  (scm_hashx_set_x, scm_hashx_remove_x):
  (scm_hash_for_each): For weak tables, have the set! functions return
  the values, as they used to do.  Have remove! functions return #f,
  indicating the lack of a handle.  Shim around for-each to return
  unspecified, even though that wasn't yet a problem.

* test-suite/tests/weaks.test: Add a test.
2012-03-02 18:26:56 +01:00
Andy Wingo
0858753e82 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/gc-malloc.c
	libguile/ports.c
2012-02-08 11:48:08 +01:00
Bake Timmons
b7e64f8b26 Improve the usage of variable names in C docstrings.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/generalized-arrays.c:
* libguile/hashtab.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/promises.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Make the variable names in the C docstrings more
  consistent.  Replace a few instances of @var with @code when appropriate.
2012-02-02 12:22:10 +01:00
Andy Wingo
252acfe8e7 Merge commit '3d51e57cfb'
Conflicts:
	libguile/foreign.c
	libguile/hashtab.c
	module/ice-9/psyntax-pp.scm
	module/language/tree-il/compile-glil.scm
2012-01-30 18:52:46 +01:00
Ludovic Courtès
73c080f9c0 Adjust tests that relied on the output of the hash table printer.
* libguile/hashtab.c (scm_i_hashtable_print): Use `SCM_UNPACK', not
  `SCM2PTR'.

* test-suite/tests/hash.test: Adjust tests that rely on the output of
  the printer to just check for the suffix of the hash table's external
  representation.
2012-01-23 00:44:29 +01:00
Ludovic Courtès
fb8b2a9d60 Print the address of hash tables.
* libguile/hashtab.c (scm_i_hashtable_print): Print the address of EXP.
2012-01-23 00:06:14 +01:00
Andy Wingo
0607ebbfcf locking for putc, puts
* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
  _unlocked and locked variants.  Change all callers to use the
  _unlocked versions.
2011-11-08 00:55:05 +01:00
Andy Wingo
21041372ed add SCM_{PACK,UNPACK}_POINTER
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros.
  The old SCM2PTR and PTR2SCM were defined in such a way that
  round-tripping through a pointer could lose precision, even in the
  case in which you weren't interested in actually dereferencing the
  pointer, it was simply that you needed to plumb a SCM through APIs
  that take pointers.  These new macros are more like SCM_PACK and
  SCM_UNPACK, but for pointer types.  The bit representation of the
  pointer should be the same as the scm_t_bits representation.

* libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS
  pointers.  We are going to try tagging the SCM object itself in the
  future, and I don't think that keeping this support is worth its
  cost.  It probably doesn't work anyway.

* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/symbols.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Update many sites to use the new macros.
2011-10-24 18:54:04 +02:00
Andy Wingo
54a9b981a4 reimplement hashtab.c's weak hash tables in terms of weak-table.c
* libguile/hashtab.c:
* libguile/hashtab.h: Reimplement the weak hash table implementation in
  terms of weak tables.  All is well except for the horrific hack for
  hashx tables.

* libguile/weak-table.h:
* libguile/weak-table.c (scm_make_weak_key_hash_table)
  (scm_make_weak_value_hash_table, scm_make_doubly_weak_hash_table)
  (scm_weak_key_hash_table_p, scm_weak_value_hash_table_p)
  (scm_doubly_weak_hash_table_p): Move these definitions here.
2011-10-24 12:48:15 +02:00
Andy Wingo
7c888dfa6e fix read beyond end of hashtable size array in hashtab.c
* libguile/hashtab.c (make_hash_table): Fix read beyond end of
  hashtable_size array.  Thanks to
  http://article.gmane.org/gmane.lisp.guile.devel/12685.
2011-07-28 19:07:53 +02:00
Andy Wingo
636c99d42d fix hash-set! on weak tables
* test-suite/tests/weaks.test: Add tests.
* libguile/hashtab.c (scm_hash_fn_set_x): Fix updates to weak-value hash
  tables to not deadlock inside the alloc lock.
2011-06-16 12:09:13 +02:00
Andy Wingo
2187975e39 fix subtle and bad scm_internal_hash_fold bug for weak tables
* libguile/hashtab.c (scm_internal_hash_fold): Don't try to unlink
  deleted weak pairs.  Our previous code was buggy (`prev' should have
  only been updated in the case of a successful traversal), but more
  than that, we're not in the alloc lock.

  Thanks very much to Michael Wells for the report, and the debugging!
2011-05-30 11:33:32 +02:00
Andy Wingo
6bb2c00a76 weak_bucket_assoc tweak
* libguile/hashtab.c (weak_bucket_assoc): Change assertion to be a check
  and abort, and so that only calls GC_is_visible if the check fails.
2011-05-13 15:31:02 +02:00
Andy Wingo
d3464bb6e2 correct use of SCM2PTR in SCM_I_REGISTER_DISAPPEARING_LINK forms
* libguile/hashtab.c (set_weak_cdr):
* libguile/vectors.c (scm_c_vector_set_x):
* libguile/weaks.c (scm_weak_car_pair, scm_weak_cdr_pair):
  (scm_doubly_weak_pair): Use SCM2PTR for the target of
  SCM_I_REGISTER_DISAPPEARING_LINK calls.
2011-05-13 15:29:26 +02:00
Andy Wingo
393baa8a44 scm_is_false instead of == SCM_BOOL_F; also is_null, is_true, etc
* libguile/deprecation.c (scm_issue_deprecation_warning)
* libguile/eval.c (CAPTURE_ENV):
* libguile/goops.c (make_dispatch_procedure, make_class_from_symbol):
  (create_smob_classes):
* libguile/guardians.c (finalize_guarded, scm_i_get_one_zombie):
* libguile/hashtab.c (scm_fixup_weak_alist, scm_internal_hash_fold):
* libguile/i18n.c (scm_nl_langinfo)
* libguile/load.c (scm_primitive_load)
* libguile/posix.c (scm_setrlimit)
* libguile/socket.c (scm_to_sockaddr):
* libguile/srcprop.c (scm_make_srcprops): Use scm_is_false / scm_is_true
  / scm_is_null instead of comparing against SCM_BOOL_F et al.
2011-05-13 15:28:41 +02:00
Andy Wingo
1d9c2e6271 disallow get-handle / create-handle! of weak hash tables
* libguile/hashtab.c (scm_hashq_get_handle, scm_hashq_create_handle_x)
  (scm_hashv_get_handle, scm_hashv_create_handle_x)
  (scm_hash_get_handle, scm_hash_create_handle_x)
  (scm_hashx_get_handle, scm_hashx_create_handle_x): Don't allow these
  functions to be called on weak hash tables, as we have no idea when
  the GC will null out fields of the handle, and set-cdr! won't register
  disappearing links, and set-car! would never work of course.
2011-05-01 23:01:14 +02:00
Andy Wingo
ecc9d1b547 fix hash-set! in weak-value table from non-immediate to immediate
* libguile/hashtab.c (set_weak_cdr, scm_hash_fn_set_x): If we have a
  weak-value hash table with a previous non-immediate value for a given
  key, and we are setting an immediate as the new value, we were not
  unregistering the disappearing link.  Fixed.
2011-05-01 18:01:42 +02:00
Andy Wingo
66b229d56e pre-GC_set_start_callback compatibility
* configure.ac: Add a check for GC_set_start_callback.

* libguile/gc.c (scm_i_gc): If we don't have GC_set_start_callback, run
  the before-gc hook manually here.
  (scm_init_gc): Otherwise set it as a start callback.

* libguile/hashtab.c (weak_gc_callback, weak_gc_hook)
  (weak_gc_finalizer, scm_c_register_weak_gc_callback): Fix to work
  either way, with or without GC_set_start_callback.
2011-04-15 18:31:06 +02:00
Andy Wingo
631e49ed76 weak hash table vacuum on before-gc C hook
* libguile/hashtab.c (weak_gc_callback)
  (scm_c_register_weak_gc_callback): Change implementation to use the
  before-gc C hook instead of the after-gc finalizers.
2011-04-15 18:05:23 +02:00
Andy Wingo
6800f86d63 make-weak-key-hash-table vacuuming
* libguile/hashtab.c (scm_make_weak_key_hash_table): Whoops, fix the
  case I actually cared about.
2011-02-25 10:48:35 +01:00
Andy Wingo
62c290e977 weak hash tables vacuum stale entries after a gc
* libguile/hashtab.c (scm_c_register_weak_gc_callback): New private
  helper, arranges for a C function to be called with a SCM as an
  argument, as long as the argument is reachable by GC.
  (scm_make_weak_key_hash_table)
  (scm_make_weak_value_hash_table)
  (scm_make_doubly_weak_hash_table): Register a weak GC callback to
  vacuum_weak_hash_table.
2011-02-24 17:01:38 +01:00
Andy Wingo
40d2a0076a GC dead links in weak hash tables before a possible rehash
* libguile/hashtab.c (vacuum_weak_hash_table): New helper, goes through
  the entirety of a weak hash table, vacuuming dead entries.
  (scm_hash_fn_create_handle_x): If when adding to a weak hash table, we
  would trigger a rehash, vacuum the table first.  The weak_bucket_assoc
  would have only caught dead entries within one bucket.

  Without this patch, the following code leaks:

  (let lp ()
    (call-with-output-string
      (lambda (port)
        (display "foo" port)))
    (lp))
2011-02-23 11:59:38 +01:00
Andy Wingo
2dd7d8ce7a fix tab completion in repl (doh)
* libguile/hashtab.c: Fix remaining vector hash table support.
* module/ice-9/session.scm (apropos-fold): Use a hash table instead of a
  vector for the completions.
2011-01-07 22:01:27 -08:00
Andy Wingo
6efbc280c5 add scm_hash_fn_get_handle_by_hash
* libguile/hashtab.h:
* libguile/hashtab.c (scm_hash_fn_get_handle_by_hash): New internal
  procedure, which should make symbol table lookup faster.
2011-01-07 09:18:37 -08:00
Andy Wingo
f0554ee74a remove vector hash table code
* libguile/hashtab.c: Remove deprecated hash-tables-as-vectors support
  code.
2011-01-07 09:18:36 -08:00
Andy Wingo
328255e4f4 hashtab cleanups
* libguile/hashtab.c: Update comments.
  (hashtable_size): Allow bigger vectors on 64-bit machines.
2011-01-07 09:18:36 -08:00
Ludovic Courtès
70249b9857 Rehash weak hash tables less frequently.
* libguile/hashtab.c (weak_bucket_assoc): Call `scm_i_rehash' only when
  REMAINING is below `SCM_HASHTABLE_LOWER (table)'.
2010-12-16 23:45:23 +01:00
Ludovic Courtès
cdd47ec7e5 Include <alloca.h> wherever `alloca' is used.
Patch provided by <carlo.bramix@libero.it> (tiny change).

* libguile/control.c, libguile/fluids.c, libguile/foreign.c,
  libguile/hashtab.c, libguile/strings.c: Include <alloca.h>.
2010-11-19 14:14:53 +01:00
Ludovic Courtès
e9bac3be61 Allow arbitrary code in ASSOC procedures for weak hash tables (bug #29616).
* libguile/hashtab.c (struct t_assoc_args, do_weak_bucket_assoc):
  Remove.
  (struct t_fixup_args): New type.
  (do_weak_bucket_fixup): New function.
  (weak_bucket_assoc): Use it.  Keep strong references to BUCKET's
  entries in STRONG_REFS.  Call ASSOC once the alloc lock has been
  released.  This fixes bug #29616.

* test-suite/tests/weaks.test ("assoc can do anything"): New test.
2010-10-11 15:38:06 +02:00
Ludovic Courtès
dff58577d8 Fix a bug in weak hash table bucket fixup.
* libguile/hashtab.c (scm_fixup_weak_alist): Keep the value of PREV
  unchanged after a nullified pair is deleted; this fixes a bug whereby
  if several successive nullified pairs were encountered, not all of them
  would be removed, and the assertion in `weak_bucket_assoc' would be
  hit.  In addition, remove the `scm_is_pair (pair)' test.
2010-10-11 15:14:55 +02:00
Ludovic Courtès
5a99a574e4 Fix weak-value hash tables.
* libguile/hashtab.c (scm_hash_fn_set_x): Register a disappearing link
  to VAL when TABLE is weak-value.

* test-suite/tests/weaks.test ("weak-hash")["weak-key dies", "weak-value
  dies", "doubly-weak dies"]: Use `hash-set!' and `hash-ref', not
  `hashq-set!' and `hashq-ref', otherwise these tests would always
  succeed because (eq? "this" "this") => #f.
  ["lives"]: Use `hash-ref' and `hash-set!' too for consistency.
2010-09-23 22:02:11 +02:00
Andy Wingo
162125af16 fix build error with Compaq C V6.3-025
* libguile/hashtab.c: Re-arrange functions to avoid the need for
  pre-declaring character arrays with no length. Fixes compilation on
  Compaq C V6.3-025. Thanks to Jay Krell for the report.
2010-06-09 23:27:33 +02:00
Andy Wingo
9ea31741da fluids are tc7 objects
If you're wondering what I'm doing, I'm trying to eventually reimplement
smobs in terms of structs, so that applicable smobs can just follow the
applicable struct dispatch path. But to do that I have to get structs
initialized before things that use smobs, which means transforming a
bunch of smobby things to tc7 things. But this transformation is good
for performance anyway, and we currently have a glut of unused tc7s,
so here we go...

* libguile/tags.h (scm_tc7_fluid, scm_tc7_dynamic_state): Fluids (and
  dynamic states) now have tc7s.

* libguile/fluids.h: Remove scm_fluids_prehistory, and add internal
  scm_i_fluid_print. Update a comment.

* libguile/fluids.c: Update for tc7 representation. Also remove the next
  pointers while we're at it, as they aren't used in the new BDW GC.

* libguile/eq.c (scm_equal_p): Remove the hashtable case. Hashtables
  could never be equal? before, I don't see why to add stubs doing the
  same thing now.

* libguile/print.c (iprin1):
* libguile/gc.c (scm_i_tag_name):
* libguile/evalext.c (scm_self_evaluating_p): Add fluid and
  dynamic_state cases.

* libguile/goops.h: Remove scm_class_hashtable; it will be static.
* libguile/goops.c: Make <hashtable> static, and add <fluid> and
  <dynamic-state> classes.

* libguile/hashtab.h:
* libguile/hashtab.c: Remove scm_i_hashtable_equal_p.

* libguile/init.c (scm_i_init_guile): Remove call to fluids_prehistory.
2009-12-05 10:52:18 +01:00
Andy Wingo
c99de5aa27 hash tables have a tc7
* libguile/tags.h (scm_tc7_hashtable): Allocate a tc7 for hashtables.

* libguile/hashtab.h: Adjust macros accordingly.
  (scm_i_hashtable_print, scm_i_hashtable_equal_p): New internal
  functions.
  (scm_hashtab_prehistory): Remove, no more need for this.

* libguile/hashtab.c (scm_hash_fn_remove_x): Fix a longstanding bug.
  (make_hash_table): Adapt to the new hash table representation.

* libguile/eq.c (scm_equal_p)
* libguile/evalext.c (scm_self_evaluating_p)
* libguile/print.c (iprin1)
* libguile/gc.c (scm_i_tag_name): Add some tc7_hashtab cases.

* libguile/init.c: Remove unused environments init functions. Remove
  call to hashtab_prehistory.

* libguile/goops.h (scm_class_hashtable)
* libguile/goops.c (scm_class_of, create_standard_classes): Have to
  make a class for hash tables manually, because they aren't smobs any
  more.
2009-12-05 10:07:07 +01:00
Andy Wingo
6c9e8a5354 remove uses of trampolines within guile itself
* libguile/eval.c (scm_map, scm_for_each)
* libguile/hashtab.c (scm_hash_for_each_handle)
* libguile/list.c (scm_filter, scm_filter_x)
* libguile/quicksort.i.c:
* libguile/sort.c (scm_restricted_vector_sort_x, scm_sorted_p)
  (scm_merge, scm_merge_list_x, scm_merge_x)
  (scm_merge_list_step, scm_sort_x, scm_sort, scm_merge_vector_x)
  (scm_merge_vector_step, scm_stable_sort_x, scm_sort_list_x)
  (scm_sort_list)nn
* libguile/srfi-13.c (scm_string_any, scm_string_every)
  (scm_string_tabulate, scm_string_trim, string_trim_right)
  (scm_string_trim_both, scm_string_index, scm_string_index_right)
  (scm_string_skip, scm_string_skip_right, scm_string_count)
  (scm_string_map, scm_string_map_x, scm_string_for_each)
  (scm_string_for_each_index, scm_string_filter, scm_string_delete):
  Remove uses of trampolines.
2009-12-01 21:00:25 +01:00
Ludovic Courtès
632299050a Hold the GC lock when traversing weak hash table buckets.
* libguile/hashtab.c (scm_fixup_weak_alist): Clarify comment.
  (struct t_assoc_args): New.
  (do_weak_bucket_assoc, weak_bucket_assoc): New.
  (START_WEAK_BUCKET_FIXUP, END_WEAK_BUCKET_FIXUP): Remove.
  (scm_hash_fn_get_handle, scm_hash_fn_create_handle_x,
  scm_hash_fn_remove_x): Use `weak_bucket_assoc ()' instead of
  `START_WEAK_BUCKET_FIXUP'/`END_WEAK_BUCKET_FIXUP'.
2009-11-05 23:15:54 +01:00
Ludovic Courtès
a07010bf18 Use proper fold/for-each function types in `hashtab.h'.
* libguile/hashtab.h (scm_t_hash_fold_fn, scm_t_hash_handle_fn): New
  types.
  (scm_internal_hash_fold, scm_internal_hash_for_each_handle): Use them.

* libguile/hashtab.c (scm_internal_hash_fold): Take an
  `scm_t_hash_fold_fn'.  Update callers.
  (scm_internal_hash_for_each_handle): Take an `scm_t_hash_handle_fn'.
  Update callers.
2009-10-27 00:24:09 +01:00
Ludovic Courtès
f044da55c5 Use proper assoc/hash function types in `hashtab.c'.
This is a followup to d587c9e8b2 ("Use
proper types for hash/assoc functions in `hashtab.h'.").

* libguile/hashtab.c (scm_i_rehash, scm_hash_fn_create_handle_x,
  scm_hash_fn_ref, scm_hash_fn_set_x, scm_hash_fn_remove_x): Use
  `scm_t_hash_fn' and `scm_t_assoc_fn' as appropriate.
2009-10-27 00:24:09 +01:00
Ludovic Courtès
d587c9e8b2 Use proper types for hash/assoc functions in `hashtab.h'.
Partly fixes bug #23681 ("Function declarators with empty parentheses
should not be used").

* libguile/goops.c (scm_wrap_component): Cast `scm_sloppy_assq'.

* libguile/hashtab.c (scm_hash_fn_get_handle): Update to take functions
  of type `scm_t_hash_fn' and `scm_t_assoc_fn'.  Update callers.
  (scm_ihashx): Change to match `scm_t_hash_fn'.
  (scm_sloppy_assx): Change to match `scm_t_assoc_fn'.

* libguile/hashtab.h (scm_t_hash_fn, scm_t_assoc_fn): New types.
  (scm_t_hashtable)[hash_fn]: Change to `scm_t_hash_fn'.
  (scm_i_rehash, scm_hash_fn_get_handle, scm_hash_fn_create_handle_x,
  scm_hash_fn_ref, scm_hash_fn_set_x, scm_hash_fn_remove_x): Change to
  take `scm_t_hash_fn' and `scm_t_assoc_fn' parameters.

* libguile/srcprop.h (scm_whash_get_handle, scm_whash_create_handle,
  scm_whash_lookup): Implement in terms of `scm_hashq_*' instead of
  `scm_hash_fn_*'.

* libguile/struct.c (scm_struct_ihashq): Change to match
  `scm_t_hash_fn'.
  (scm_struct_create_handle): Cast `scm_sloppy_assq'.

* libguile/struct.h (scm_struct_ihashq): Update, make internal.
2009-10-20 00:10:18 +02:00
Ludovic Courtès
fbb857a472 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	lib/Makefile.am
	libguile/Makefile.am
	libguile/frames.c
	libguile/gc-card.c
	libguile/gc-freelist.c
	libguile/gc-mark.c
	libguile/gc-segment.c
	libguile/gc_os_dep.c
	libguile/load.c
	libguile/macros.c
	libguile/objcodes.c
	libguile/programs.c
	libguile/strings.c
	libguile/vm.c
	m4/gnulib-cache.m4
	m4/gnulib-comp.m4
	m4/inline.m4
2009-08-18 00:06:45 +02:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Ludovic Courtès
44e268898b Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	lib/Makefile.am
	libguile/gc-card.c
	libguile/gc-freelist.c
	libguile/gc-mark.c
	libguile/gc-segment.c
	libguile/gc.c
	libguile/gc.h
	libguile/gc_os_dep.c
	libguile/private-gc.h
	m4/.cvsignore
	m4/gnulib-cache.m4
	m4/gnulib-comp.m4
2008-09-13 22:51:27 +02:00
Ludovic Courtès
dbb605f575 Include <config.h> in all C files; use #ifdef HAVE_CONFIG_H' rather than #if'. 2008-09-13 15:35:27 +02:00
Ludovic Courtès
0306509bc8 Fix broken hash-table merge.
* libguile/hashtab.c (scm_hash_fn_create_handle_x): Return IT only when
  it satisfies `scm_is_pair ()'.
2008-09-10 23:51:21 +02:00
Ludovic Courtès
6f03035fe8 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/Makefile.am
	libguile/coop-defs.h
	libguile/gc-card.c
	libguile/gc-freelist.c
	libguile/gc-malloc.c
	libguile/gc-mark.c
	libguile/gc-segment.c
	libguile/gc.c
	libguile/gc.h
	libguile/gc_os_dep.c
	libguile/hashtab.c
	libguile/hashtab.h
	libguile/inline.h
	libguile/private-gc.h
	libguile/struct.c
	libguile/struct.h
	libguile/threads.c
	libguile/threads.h
	libguile/vectors.h
	libguile/weaks.h
	test-suite/tests/gc.test
2008-09-10 23:09:30 +02:00
Ludovic Courtes
639e56a4ed Re-fixed the hash table element counting in `scm_i_rehash ()'.
* libguile/hashtab.c (scm_i_rehash): Don't invoke
  `SCM_HASHTABLE_DECREMENT ()' when a weak pair is encountered in the
  source bucket.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-43
2008-09-10 20:28:12 +02:00
Ludovic Courtes
72c9d17bf3 Minor weak hashtables fixes.
* libguile/hashtab.c (scm_fixup_weak_alist): Cosmetic change.
  (scm_i_rehash): Call `SCM_HASHTABLE_DECREMENT ()' when a deleted weak
  pair is encountered.
  (scm_internal_hash_fold): Call `SCM_HASHTABLE_DECREMENT ()' instead of
  a complicated `SCM_SET_HASHTABLE_N_ITEMS ()'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-40
2008-09-10 20:27:46 +02:00
Ludovic Courtes
986ec82209 Moved weak pair code into `weaks.[ch]'.
* libguile/hashtab.c: Don't include <gc/gc_typed.h> and <gc/gc.h>.
  Updated users of weak
  (wcar_cell_descr): Removed.
  (wcdr_cell_descr): Removed.
  (scm_weak_car_cell): Removed.
  (scm_weak_cdr_cell): Removed.
  (scm_doubly_weak_cell): Removed.
  (SCM_WEAK_CELL_*_DELETED_P): Removed.
  (SCM_WEAK_CELL_WORD): Removed.
  (SCM_WEAK_CELL_C[AD]R): Removed.
  (scm_hashtab_prehistory): Don't initialize weak pairs.

* libguile/init.c (scm_i_init_guile): Invoke `scm_weaks_prehistory ()'
  before `scm_hashtab_prehistory ()' in order to initialize weak pairs.

* libguile/weaks.c: Include <gc/gc.h> and <gc/gc_typed.h>.
  (wc[ad]r_cell_descr): New.
  (scm_weak_c[ad]r_pair): New.
  (scm_doubly_weak_pair): New.
  (scm_weaks_prehistory): New.

* libguile/weaks.h (scm_weak_c[ad]r_pair): New declaration.
  (scm_doubly_weak_pair): New declaration.
  (SCM_WEAK_PAIR_WORD_DELETED_P): New.
  (SCM_WEAK_PAIR_CAR_DELETED_P): New.
  (SCM_WEAK_PAIR_CDR_DELETED_P): New.
  (SCM_WEAK_PAIR_DELETED_P): New.
  (SCM_WEAK_PAIR_WORD): New.
  (SCM_WEAK_PAIR_CAR): New.
  (SCM_WEAK_PAIR_CDR): New.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-39
2008-09-10 20:27:34 +02:00
Ludovic Courtes
c6a35e35f7 Implemented rehashing of weak hash tables.
* libguile/hashtab.c (weak_hashtables): Removed.
  (SCM_WEAK_CELL_DELETED_P): New macro.
  (START_WEAK_BUCKET_FIXUP): Added the HASHFN argument.  Invoke
  `scm_i_rehash ()' when pairs have been removed.
  (END_WEAK_BUCKET_FIXUP): Added the HASHFN argument.
  (make_hash_table): Use `SCM_NEWSMOB2 ()' instead of `SCM_NEWSMOB3 ()'
  -- last argument used to be WEAK_HASHTABLES.
  (scm_i_rehash): Handle weak hash tables.
  (to_rehash): Removed.
  (scm_internal_hash_fold): Use `SCM_WEAK_CELL_DELETED_P ()' rather than
  hand-written equivalent code.
  (rehash_after_gc): Removed.
  (scm_hashtab_prehistory): Don't add it as an after-gc hook.

* libguile/hashtab.h (SCM_HASHTABLE_NEXT): Removed.
  (SCM_HASHTABLE_NEXTLOC): Removed.
  (SCM_SET_HASHTABLE_NEXT): Removed.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-38
2008-09-10 20:27:20 +02:00
Ludovic Courtes
a4a141f679 Removed a lot of now-useless SMOB mark/free functions.
* libguile/arbiters.c (scm_init_arbiters): Don't invoke `scm_set_smob_mark'.

* libguile/async.c (async_gc_mark): Removed.
  (scm_init_async): Don't invoke `scm_set_smob_mark'.

* libguile/coop-pthreads.c (thread_mark): Removed.
  (create_thread): Use `scm_gc_malloc' instead of `scm_malloc' when
  allocating `launch_data'.
  (mutex_mark): Removed.
  (scm_threads_init): Don't invoke `scm_set_smob_mark' and
  `scm_set_smob_free'.

* libguile/debug.c (scm_init_debug): Don't invoke `scm_set_smob_mark'.

* libguile/dynl.c (dynl_obj_mark): Removed.
  (scm_init_dynamic_linking): Don't invoke `scm_set_smob_mark'.

* libguile/dynwind.c (winder_mark): Removed.
  (scm_init_dynwind): Don't invoke `scm_set_smob_mark'.

* libguile/environments.c (environment_mark): Removed.
  (environment_free): Removed.
  (observer_mark): Removed.
  (core_environments_mark): Removed.
  (core_environments_finalize): Removed.
  (leaf_environment_mark): Removed.
  (leaf_environment_free): Removed.
  (leaf_environment_funcs): Don't refer to the above funcs.
  (eval_environment_mark): Removed.
  (eval_environment_free): Removed.
  (eval_environment_funcs): Don't refer to the above funcs.
  (import_environment_mark): Removed.
  (import_environment_free): Removed.
  (import_environment_funcs): Don't refer to the above funcs.
  (export_environment_mark): Removed.
  (export_environment_free): Removed.
  (export_environment_funcs): Don't refer to the above funcs.
  (scm_environments_prehistory): Don't invoke `scm_set_smob_mark' and
  `scm_set_smob_free'.

* libguile/environments.h (scm_environment_funcs)[mark]: Removed.
  [free]: Removed.

* libguile/eval.c (promise_mark): Removed.
  (promise_free): Removed.
  (scm_init_eval): Don't invoke `scm_set_smob_mark' and
  `scm_set_smob_free'.

* libguile/fluids.c (fluid_free): Removed.
  (scm_fluids_prehistory): Don't invoke `scm_set_smob_mark' and
  `scm_set_smob_free'.

* libguile/futures.c (future_mark): Removed.
  (scm_init_futures): Don't invoke `scm_set_smob_mark'.

* libguile/hashtab.c (hashtable_free): Removed.
  (scm_hashtab_prehistory): Don't invoke `scm_set_smob_mark' and
  `scm_set_smob_free'.

* libguile/hooks.c (scm_init_hooks): Don't invoke `scm_set_smob_mark'.

* libguile/keywords.c (scm_init_keywords): Don't invoke
  `scm_set_smob_mark'.

* libguile/macros.c (scm_init_macros): Don't invoke `scm_set_smob_mark'.

* libguile/modules.c (scm_init_modules): Don't invoke
  `scm_set_smob_mark'.

* libguile/print.c (scm_init_print): Don't invoke `scm_set_smob_mark'.

* libguile/random.c (scm_i_copy_rstate): Use `scm_gc_malloc' instead of
  `scm_malloc'.
  (scm_c_make_rstate): Likewise.
  (rstate_free): Removed.
  (scm_init_random): Don't invoke `scm_set_smob_free'.

* libguile/srcprop.c (srcprops_mark): Removed.
  (scm_init_srcprop): Don't invoke `srcprops_mark'.

* libguile/srfi-14.c (charset_free): Removed.
  (scm_init_srfi_14): Don't invoke `scm_set_smob_free'.

* libguile/srfi-4.c (uvec_mark): Removed.
  (uvec_free): Removed.
  (scm_init_srfi_4): Don't invoke `scm_set_smob_free' and
  `scm_set_smob_mark'.

* libguile/threads.c (thread_mark): Removed.
  (fat_mutex_mark): Removed.
  (fat_cond_mark): Removed.
  (scm_init_threads): Dont invoke `scm_set_smob_mark' and
  `scm_set_smob_free'.

* libguile/unif.c (bitvector_free): Removed.
  (array_mark): Removed.
  (array_free): Removed.
  (scm_init_unif): Don't invoke `scm_set_smob_free' and
  `scm_set_smob_mark'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-28
2008-09-05 09:34:23 +02:00