summaryrefslogtreecommitdiff
path: root/libguile/hashtab.c
AgeCommit message (Collapse)AuthorFilesLines
2008-09-05procs/weaks/hashtab: Removed a bit of useless mark/free code.Ludovic Courtes1-38/+0
* libguile/hashtab.c (UNMARKED_CELL_P): Removed. (scm_i_scan_weak_hashtables): Removed. * libguile/hashtab.h (scm_i_scan_weak_hashtables): Removed. * libguile/procs.c (scm_mark_subr_table): Removed. * libguile/procs.h (scm_mark_subr_table): Removed. * libguile/weaks.c (UNMARKED_CELL_P): Removed. (scm_i_remove_weaks): Removed. (scm_i_remove_weaks_from_weak_vectors): Removed. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-18
2008-09-05Fixes in weak hash tables handling, notably in `hash-fold'.Ludovic Courtes1-9/+49
* libguile/hashtab.c (scm_i_rehash): Return immediately if TABLE is weak. (scm_hash_fn_create_handle_x): Explicitly mention that we don't support weak alist vectors. (scm_internal_hash_fold): Handle weak pairs within buckets. * libguile/modules.c (scm_module_reverse_lookup): Handle weak alists (currently, don't do anything if a NULL pair is met). git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-16
2008-09-05Fixed `scm_fixup_weak_alist ()'; update weak hash table size as needed.Ludovic Courtes1-40/+69
* libguile/hashtab.c (scm_fixup_weak_alist): Added a REMOVED_ITEMS parameter. Fixed a bug in the case where PREV is `SCM_EOL'. (IS_WEAK_THING): New macro. (START_WEAK_BUCKET_FIXUP): New macro. (END_WEAK_BUCKET_FIXUP): New macro. (scm_hash_fn_get_handle)[buckets]: New variable. Use the above macros. (scm_hash_fn_create_handle_x): Likewise. (scm_hash_fn_remove_x): Likewise. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-9
2008-09-05Fixed the weak cell implementation (for weak hash tables).Ludovic Courtes1-11/+78
* libguile/hashtab.c (wcar_cell_descr): New. (wcdr_cell_descr): New. (scm_weak_car_cell): Use `GC_malloc_explicitly_typed ()' instead of `scm_gc_malloc_pointerless ()'. (scm_weak_cdr_cell): Likewise. (SCM_WEAK_CELL_WORD_DELETED_P): Use `SCM_CELL_OBJECT' instead of `SCM_CELL_WORD'. (scm_hash_fn_get_handle): Call `GC_disable ()' before calling `scm_fixup_weak_alist ()' and `GC_enable ()' afterwards. (scm_hash_fn_create_handle_x): Likewise. (scm_hash_fn_remove_x): Likewise. (scm_hashtab_prehistory): Initialize WCAR_CELL_DESCR and WCDR_CELL_DESCR. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-8
2008-09-05First stab at implementing weak hash tables and vectors. Unable to run the ↵Ludovic Courtes1-19/+172
REPL. * libguile/hashtab.c (scm_weak_car_cell): New. (scm_weak_cdr_cell): New. (scm_doubly_weak_cell): New. (SCM_WEAK_CELL_WORD_DELETED_P): New. (SCM_WEAK_CELL_WORD): New. (scm_fixup_weak_alist): New. (make_hash_table): Always use non-weak vectors. Allocate `scm_t_hashtable' objects as pointerless. (scm_i_rehash): Always make NEW_BUCKETS a non-weak vector. (scm_hash_fn_get_handle): Call `scm_fixup_weak_alist ()' on weak buckets before calling ASSOC_FN. (scm_hash_fn_remove_x): Likewise. (scm_hash_fn_create_handle_x): Likewise. Also, use `scm_.*weak.*cell ()' for HANDLE when needed. * libguile/symbols.c (lookup_interned_symbol): Check for nullified pairs. * libguile/vectors.c (scm_vector_elements): Abort on weak vectors. (scm_vector_writable_elements): Likewise. (scm_c_vector_ref): Check whether the referenced element has been nullified. (scm_c_vector_set_x): Use `GC_GENERAL_REGISTER_DISAPPEARING_LINK ()'. (scm_i_allocate_weak_vector): Use `scm_gc_malloc_pointerless ()' instead of `scm_gc_malloc ()' when allocating room for the vector itself. * libguile/weaks.c (scm_make_weak_key_alist_vector): Use `scm_make_vector ()' instead of `scm_i_allocate_weak_vector ()'. (scm_make_weak_value_alist_vector): Likewise. (scm_make_doubly_weak_alist_vector): Likewise. (weak_vectors): Removed. (scm_i_init_weak_vectors_for_gc): Removed. (scm_i_mark_weak_vector): Removed. (scm_i_mark_weak_vector_non_weaks): Removed. (scm_i_mark_weak_vectors_non_weaks): Removed. (scm_i_remove_weaks_from_weak_vectors): Commented out. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-7
2008-09-05Merge from lcourtes@laas.fr--2005-mobileLudovic Courtes1-1/+4
Patches applied: * lcourtes@laas.fr--2005-mobile/guile-core--boehm-gc--1.9 (base, patch 1) - tag of lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--base-0 - Initial hack for Boehm's GC support: nothing works. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-1
2008-08-16Remove unused macro UNMARKED_CELL_P()Han-Wen Nienhuys1-2/+0
2008-02-15Release stuff: missing NEWS and 2007/2008 copyrights.Neil Jerram1-1/+1
2008-01-18* hashtab.c (scm_hash_fn_create_handle_x): If supplied assoc_fnNeil Jerram1-1/+3
returns neither a pair nor #f, signal a wrong-type-arg error. (Thanks to Gregory Marton for reporting this.) * tests/hash.test: New "hashx" test supplied by Gregory Marton; prior to today's fix in libguile/hashtab.c, this caused a segmentation fault.
2006-04-17merge from 1.8 branchKevin Ryde1-1/+1
2005-07-31* gc-mark.c (scm_mark_all): Do not rely on hooks to run the weakMarius Vollmer1-52/+17
hashtable and guardian machinery but call the relevant functions directly. * guardians.h, guardians.c, deprecated.h, deprecated.c (scm_destroy_guardian_x, scm_guardian_greedy_p, scm_guardian_destroyed_p, scm_guard, scm_get_one_zombie): Deprecated and moved into deprecated.[ch]. * guardians.h, guardians.c: Mostly rewritten. (scm_i_init_guardians_for_gc, scm_i_identify_inaccessible_guardeds, scm_i_mark_inaccessible_guardeds): New. * weaks.h, weaks.c (SCM_I_WVECT_TYPE, SCM_I_SET_WVECT_TYPE): New. (SCM_I_WVECT_N_ITEMS, SCM_I_SET_WVECT_N_ITEMS): New. (SCM_WVECTF_NOSCAN, SCM_WVECT_NOSCAN_P): Removed. (scm_weaks_prehistory): Removed. (scm_i_init_weak_vectors_for_gc, scm_i_mark_weak_vector, scm_i_mark_weak_vectors_non_weaks, scm_i_remove_weaks_from_weak_vectors, scm_i_remove_weaks): New. (scm_weak_vector_gc_init, scm_mark_weak_vector_spines, scm_scan_weak_vectors): Removed. * hashtab.h (scm_i_scan_weak_hashtables): New. * hashtab.c (make_hash_table, scm_i_rehash): Do not use SCM_WVECTF_NOSCAN. (hashtable_print): Use SCM_HASHTABLE_N_ITEMS instead of t->n_items. (scan_weak_hashtables, scm_i_scan_weak_hashtables): Renamed former to latter. Do not scan the alists themselves, this is done by the weak vector code now. Just update the element count. * vectors.h (SCM_I_WVECT_TYPE, SCM_I_WVECT_EXTRA): Renamed former to latter. The type is now only part of the cell word. (SCM_I_SET_WVECT_TYPE, SCM_I_SET_WVECT_EXTRA): Likewise. * init.c (scm_i_init_guile): Do not call scm_weaks_prehistory.
2005-07-18* gc.c (scm_gc_stats): Bugfix: Measure size of the type we areMikael Djurfeldt1-1/+1
mallocating for (unsigned long *bounds). * hashtab.c (scm_i_rehash): Cast SCM_HASHTABLE_FLAGS (table) to scm_t_bits before storing them in the type word. * gc.c (tag_table_to_type_alist): Modified type of c_tag from scm_t_bits to int.
2005-05-23The FSF has a new address.Marius Vollmer1-1/+1
2005-04-22(scm_hashx_remove_x): Need to pass "closure" to scm_hash_fn_remove_x.Kevin Ryde1-1/+2
2005-04-04(scm_t_hashtable): Removed 'closure' field. TheMarius Vollmer1-10/+20
closure can not be stored since it is no longer valid at GC time. (make_hash_table): Initialize 'hash_fn' field. (scm_i_rehash): Only store hash_fn in hash table when closre is NULL. (rehash_after_gc): Only call scm_i_rehash when 'hash_fn' is non-NULL. Always use a NULL closure. (scm_hash_fn_create_handle_x): Also rehash when table contains too few entries.
2005-03-29(scm_hash_fx_remove_x): Removed delete_fnMarius Vollmer1-42/+35
argument; always use scm_delq_x. The delete_fn function works on the handle, not the key, and it therefore makes no sense to make it configurable. Changed all callers. (scm_hashx_remove_x): Likewise. Also, exported to Scheme. (scm_hash_clear): Accept plain vectors as hashtables. (scm_delx_x): Removed.
2005-03-02(scm_hash_fn_create_handle_x, scm_hash_fn_remove_x): Use "!scm_is_eq"Marius Vollmer1-2/+2
instead of "!=".
2005-02-25(scm_i_rehash): Remove elements from old bucket vectorMarius Vollmer1-2/+13
so that no two weak alist vectors share a spine. (scm_hash_fn_create_handle_x): Deal with a possible rehashing during GC before inserting the new alist cell.
2005-02-25(scm_i_rehash): Remove elements from old bucket vector so that no twoMarius Vollmer1-3/+4
weak alist vectors share a spine.
2005-02-23* hashtab.c (scm_i_rehash): Cope with the case that a GC modifiesMarius Vollmer1-11/+29
the hashtable. (scm_hash_fn_create_handle_x): Likewise. * vectors.h (SCM_I_SET_WVECT_TYPE): New, for use in scm_i_rehash.
2005-01-24Reverted changed from 2005/01/24 19:14:54, which was a commit to theMarius Vollmer1-22/+1
wrong branch. Sorry.
2005-01-24Threading changes.Marius Vollmer1-1/+22
2005-01-20(hashtable_size, HASHTABLE_SIZE_N): Restrict hashtable sizes to beMarius Vollmer1-5/+8
smaller than the maximum lengths of vectors.
2005-01-07(SCM_HASHTAB_BUCKET_LOC): Removed.Marius Vollmer1-13/+18
(scan_weak_hashtables): Rewrote its use with SCM_HASHTAB_BUCKET and SCM_SET_HASHTAB_BUCKET.
2005-01-02(SCM_HASHTABLE_BUCKETS): Removed.Marius Vollmer1-31/+35
(SCM_HASHTABLE_BUCKET, SCM_HASHTABLE_BUCKET_LOC): New. Replaced all uses of SCM_HASHTABLE_BUCKETS with SCM_HASHTABLE_BUCKET.
2004-10-22* variable.c, threads.c, struct.c, stackchk.c, smob.c, root.c,Marius Vollmer1-3/+2
print.c, ports.c, mallocs.c, hooks.c, hashtab.c, fports.c, guardians.c, filesys.c, coop-pthreads.c, continuations.c: Use scm_uintprint to print unsigned integers, raw heap words, and adresses, using a cast to scm_t_bits to turn pointers into integers.
2004-09-22*** empty log message ***Marius Vollmer1-12/+12
2004-08-02* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,Marius Vollmer1-7/+5
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num, scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long): Discouraged by moving to discouraged.h and discouraged.c and reimplementing in terms of scm_from_* and scm_to_*. Changed all uses to the new scm_from_* and scm_to_* functions.
2004-07-23* deprecated.h, deprecated.c, numbers.h (SCM_INUMP, SCM_NINUMP,Marius Vollmer1-2/+2
SCM_INUM): Deprecated by reenaming them to SCM_I_INUMP, SCM_I_NINUMP and SCM_I_INUM, respectively and adding deprecated versions to deprecated.h and deprecated.c. Changed all uses to either use the SCM_I_ variants or scm_is_*, scm_to_*, or scm_from_*, as appropriate.
2004-07-10* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,Marius Vollmer1-17/+7
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN, SCM_VALIDATE_INUM_MIN_COPY, SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF, SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE, SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the fixnum/bignum distinction visible. Changed all uses to scm_to_size_t or similar.
2004-07-08* numbers.h (SCM_MAKINUM, SCM_I_MAKINUM): Renamed SCM_MAKINUM toMarius Vollmer1-2/+2
SCM_I_MAKINUM and changed all uses.
2004-07-06* deprecated.h, boolean.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOL,Marius Vollmer1-6/+6
SCM_NEGATE_BOOL, SCM_BOOLP): Deprecated by moving into "deprecated.h". Replaced all uses with scm_is_false, scm_is_true, scm_from_bool, and scm_is_bool, respectively.
2004-05-18(rehash_after_gc): Bug fix: properly link the processed hashtablesMarius Vollmer1-2/+3
back into the weak_hashtables list. Thanks to Bill Schottstaedt!
2004-02-13* unif.c (scm_make_uve): Removed local variable and simplifiedMikael Djurfeldt1-32/+84
code in order to avoid compiler used uninitialized warnings. * hashtab.c, hashtab.h (scm_hash_map_to_list): Renamed from scm_hash_map. (scm_hash_fold): Use scm_call_3 directly in the call to scm_internal_hash_fold instead of going via fold_proc (which is now removed). (scm_hash_for_each): Use a trampoline + scm_internal_hash_for_each_handle. (scm_internal_hash_for_each_handle, scm_hash_for_each_handle): New functions.
2003-04-05* hashtab.c (rehash_after_gc): Clear to_rehash list beforeMikael Djurfeldt1-1/+3
processing it in order to avoid an infinite loop. * print.c (scm_prin1): Remember old state of pstate->writingp.
2003-04-05Changed license terms to the plain LGPL thru-out.Marius Vollmer1-36/+12
2003-02-19Fix of previous changeMikael Djurfeldt1-1/+2
2003-02-19Fix of last change.Mikael Djurfeldt1-7/+5
2003-02-19* hooks.c (scm_c_hook_add): Fixed bug in append mode.Mikael Djurfeldt1-129/+390
* environments.c (obarray_enter, obarray_retrieve, obarray_remove, leaf_environment_fold, obarray_remove_all): Use hashtable accessors. * gc.c (scm_init_storage): Moved hook initialization to scm_storage_prehistory. (scm_storage_prehistory): New function. (scm_igc): Added commentary about placement of scm_after_sweep_c_hook. * gc-mark.c (scm_mark_all): Use hashtable accessors. (scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and SCM_WVECT_WEAK_VALUE_P. * hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New functions. (scm_vector_to_hash_table, scm_c_make_resizing_hash_table): Removed. (scm_make_weak_key_hash_table, scm_make_weak_value_hash_table, scm_make_doubly_weak_hash_table): Moved here from weaks.c. * init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added calls to scm_storage_prehistory and scm_hashtab_prehistory. * modules.c (module-reverse-lookup): Use hashtable accessors. * symbols.c, symbols.h (scm_i_hash_symbol): New function. * weaks.c, weaks.h (scm_make_weak_key_alist_vector, scm_make_weak_value_alist_vector, scm_make_doubly_weak_alist_vector): New functions. * weaks.c (scm_init_weaks_builtins): New function. * weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE, SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P, SCM_WVECT_NOSCAN_P): New macros. * weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P and SCM_WVECT_WEAK_VALUE_P. * weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from allocate_weak_vector and exported. * Makefile.am (ice9_sources): Added weak-vector.scm. * weak-vector.scm: New file. * boot-9.scm (module-clear!): Use hash-clear!. (module-for-each): Use hash-for-each. (module-map): Use hash-map.
2003-02-13* hashtab.c: Undid thread safety. (We decided that it's better toMikael Djurfeldt1-96/+52
let the user explicitly protect the tables (or not) according what is suitable for the application.)
2003-02-12* hashtab.c (scm_hash_fn_remove_x, scm_internal_hash_fold): MadeMikael Djurfeldt1-47/+88
thread safe and handle resizing tables. (scm_ihashx, scm_sloppy_assx, scm_delx_x): Removed SCM_DEFER/ALLOW_INTS.
2003-02-11* hashtab.c (scm_vector_to_hash_table,Mikael Djurfeldt1-15/+243
scm_c_make_resizing_hash_table, scm_make_hash_table): New functions. (scm_hash_fn_get_handle, scm_hash_fn_create_handle_x): Made thread safe and handle resizing tables. * weaks.c (scm_make_weak_key_hash_table, scm_make_weak_value_hash_table, scm_make_doubly_weak_hash_table): Size argument made optional. Return resizable table if not specified. * boot-9.scm (make-hash-table): Turned primitive.
2002-07-202002-07-20 Han-Wen <hanwen@cs.uu.nl>Han-Wen Nienhuys1-13/+13
* *.c: add space after commas everywhere. * *.c: use SCM_VECTOR_SET everywhere, where a vector is written. Document cases where SCM_WRITABLE_VELTS() is used. * vectors.h (SCM_VELTS): prepare for write barrier, and let SCM_VELTS() return a const pointer (SCM_VECTOR_SET): add macro. * autogen.sh (mscripts): find and check version number of autoconf. Complain if 2.53 is not found.
2002-03-14Retire inclusion guard macro SCM_MAGIC_SNARFER.Thien-Thi Nguyen1-2/+0
2001-11-13* Miscellaneous small doc updates and fixes.Neil Jerram1-1/+1
2001-11-11* Documentation work.Neil Jerram1-1/+1
2001-10-08* hashtab.c (scm_hash_fn_create_handle_x): The result of assoc_fnDirk Herrmann1-10/+11
is known to be #f if no entry is found. Thus, use !SCM_FALSEP instead of SCM_NIMP to test for that case. * strings.h (SCM_SET_STRING_LENGTH): Cast the length to scm_t_bits instead of long.
2001-07-09Remove "face-lift" comment.Thien-Thi Nguyen1-2/+0
2001-06-26 * eval.c (scm_call_0, scm_call_1, scm_call_2, scm_call_3,Keisuke Nishida1-10/+5
scm_apply_0, scm_apply_1, scm_apply_2, scm_apply_3): New functions.
2001-06-14replace "scm_*_t" with "scm_t_*".Marius Vollmer1-10/+10