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

407 commits

Author SHA1 Message Date
Ludovic Courtès
4a4849dbe0 Merge commit '0329137392' into boehm-demers-weiser-gc
Conflicts:
	libguile/gc.c
	libguile/srcprop.c
	libguile/srcprop.h
2008-09-10 22:33:40 +02:00
Ludovic Court`es
3ec17f28b8 Reverted inappropriate merge in `gc.c'.
git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-53
2008-09-10 22:28:17 +02:00
Ludovic Courtès
35a9197ccc Merge commit 'f30e1bdf97' into boehm-demers-weiser-gc
Conflicts:
	libguile/Makefile.am
	libguile/coop-pthreads.c
	libguile/gc-freelist.c
	libguile/gc-segment.c
	libguile/gc.c
	libguile/private-gc.h
	test-suite/tests/environments.nottest
2008-09-10 22:27:30 +02:00
Ludovic Courtes
e7bca22779 Use thread-local allocation (significant perf. improvement!); added the `boehm-gc.h' header.
* libguile/Makefile.am (modinclude_HEADERS): Added `boehm-gc.h'.

* libguile/coop-defs.h: Use "libguile/boehm-gc.h" instead of <gc/gc.h>.

* libguile/coop-threads.h: Likewise.

* libguile/coop.c: Likewise.

* libguile/gc.c: Likewise.
  (scm_storage_prehistory): Invoke `GC_init ()'.

* libguile/guardians.c: Use "libguile/boehm-gc.h" instead of <gc/gc.h>.

* libguile/inline.h: Likewise.
  (scm_double_cell): Use `GC_MALLOC' instead of `GC_malloc'.

* libguile/pthread-threads.h: Use "libguile/boehm-gc.h" instead of
  <gc/gc.h>.

* libguile/smob.c: Likewise.

* libguile/smob.h: Likewise.

* libguile/struct.c: Likewise.

* libguile/threads.c: Likewise.

* libguile/weaks.c: Likewise.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-51
2008-09-10 22:19:49 +02:00
Ludovic Courtes
8e7b3e9807 Removed scm_gc_registered_roots' and scm_permobjs'.
* libguile/gc.c (scm_permanent_object): Use `scm_gc_protect_object ()'.
  (scm_gc_register_root): Do nothing.
  (scm_init_storage): Removed initialization of `scm_permobjs' and
  `scm_gc_register_roots'.

* libguile/root.h (scm_permobjs): Removed.
  (scm_gc_registered_roots): Removed.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-50
2008-09-10 22:19:30 +02:00
Ludovic Courtes
fdab75a144 Expand heap size at startup time.
* libguile/gc.c (scm_storage_prehistory): Invoke `GC_expand_hp ()'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-49
2008-09-10 22:19:22 +02:00
Ludovic Courtes
184327a68d Turn "all interior pointers" off (slight performance gain).
* libguile/gc.c (scm_storage_prehistory): Set `GC_all_interior_pointers'
  to 0.  Register `scm_tc3_cons' and `scm_tc3_closure' as valid
  displacements.

* libguile/struct.c (scm_alloc_struct): Register additional
  displacements.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-48
2008-09-10 22:19:11 +02:00
Ludovic Courtes
915b3f9f9a Implemented gc-stats' using libgc' information.
* libguile/gc.c (protected_obj_count): Made `static'.
  (scm_heap_size): Mapped to `heap-size' rather than `cell-heap-size'.
  (scm_heap_free_size): New.
  (scm_heap_total_allocated): New.
  (scm_gc_stats): Rewritten.  Return the (little) information available
  from `libgc'.
  (scm_gc_disable): New.
  (scm_gc_enable): New.
  (scm_storage_prehistory): Don't call `GC_add_roots ()' with
  SCM_SYS_PROTECTS.  Use `GC_is_visible ()' to check whether
  SCM_SYS_PROTECTS is visible.

* libguile/gc.h (scm_gc_enable): New declaration.
  (scm_gc_disable): New declaration.
  (scm_gc_for_alloc): Removed.
  (scm_gc_for_newcell): Removed.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-46
2008-09-10 20:28:41 +02:00
Han-Wen Nienhuys
7ddb9baf80 Cleanup mark-during-GC debug checks.
* libguile/__scm.h (SCM_DEBUG): add SCM_DEBUG_MARKING_API

* libguile/gc.h (SCM_SET_GC_MARK): depending on
SCM_DEBUG_MARKING_API crash if someone is touching markbits
outside regular hours.

Rename ensure_marking() to scm_i_ensure_marking().

* libguile/inline.h (scm_double_cell, scm_cell): only set mark bits
for debugging if SCM_DEBUG_MARKING_API is unset

* libguile/gc-mark.c: Issue deprecation warning if we are marking
outside of the GC mark phase.
2008-09-09 23:08:16 -03:00
Ludovic Courtes
10fb3386dd Fixed use of finalizers for guardians and SMOBs (undoes patches 23-24).
* libguile/gc.c (finalizer_trampoline): Removed.
  (scm_gc_register_finalizer): Removed (undoes patches 23 and 24).

* libguile/gc.h (scm_gc_register_finalizer): Removed.

* libguile/guardians.c (finalize_guarded): Undid patch 23.  Added support
  for "proxied finalizers".
  (scm_i_guard): Likewise.

* libguile/smob.c (scm_i_finalize_smob): Adapted to
  `GC_finalization_proc'.

* libguile/smob.h: Include <gc/gc.h>.
  (SCM_NEWSMOB): Use `GC_REGISTER_FINALIZER_NO_ORDER' instead of
  `scm_gc_register_finalizer ()'.
  (SCM_NEWSMOB3): Likewise.
  (scm_i_finalize_smob): Updated.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-29
2008-09-05 09:34:35 +02:00
Ludovic Courtes
53cc0209fa Fixed `scm_gc_register_finalizer ()' to avoid bootstrap problem.
* libguile/gc.c (finalizer_trampoline): Don't use `scm_call_2 ()' to
  invoke the finalizer: directly call the C function instead.
  (scm_gc_register_finalizer): Don't create a real subr with
  `scm_c_make_gsubr ()': simply convert the C function pointer to an
  `SCM' object instead.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-24
2008-09-05 09:33:38 +02:00
Ludovic Courtes
febd2677c9 Generalized BGC's finalizer mechanism. Use it in `guardians.c'.
* libguile/gc.c (finalizer_trampoline): New.
  (scm_gc_register_finalizer): New.

* libguile/gc.h (scm_gc_register_finalizer): New declaration.

* libguile/guardians.c (finalize_guarded): Updated to the new prototype.
  (scm_i_guard): Use `scm_gc_register_finalizer ()' instead of
  `GC_REGISTER_FINALIZER_NO_ORDER ()'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-23
2008-09-05 09:33:29 +02:00
Ludovic Courtes
378f262561 Added support for SMOB custom mark procedures.
* libguile/gc.c (scm_gc_mark): Removed.
  (scm_gc_mark_dependencies): Removed.
  (scm_mark_locations): Removed.

* libguile/gc.h (scm_gc_mark_dependencies): Removed.
  (scm_mark_locations): Removed.

* libguile/inline.h (scm_cell): Use `GC_MALLOC ()' instead of `GC_malloc ()'.

* libguile/smob.c (smob_freelist): New.
  (smob_gc_kind): New.
  (smob_mark): New.
  (scm_gc_mark): New.
  (scm_i_new_smob_with_mark_proc): New.
  (scm_smob_prehistory): Initialize `smob_freelist' and `smob_gc_kind'.

* libguile/smob.h (scm_i_new_smob_with_mark_proc): New declaration.
  (SCM_NEWSMOB): Use it if a mark procedure is available.
  (SCM_NEWSMOB2): Likewise.
  (SCM_NEWSMOB3): Likewise.

* libguile/threads.c (guilify_self_1): Initialize the
  `current_mark_stack_*' fields.

* libguile/threads.h (scm_i_thread)[current_mark_stack_ptr]: New field.
  [current_mark_stack_limit]: New field.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-22
2008-09-05 09:33:20 +02:00
Ludovic Courtes
a82e795325 Fixed GC initialization and static roots.
* libguile/gc.c (scm_storage_prehistory): Call `GC_INIT ()'.  Invoke
  `GC_add_roots ()' as well.
  (scm_init_gc): Removed call to `GC_init ()'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-6
2008-09-05 00:46:46 +02:00
Ludovic Courtes
6a4be32986 Fixed garbage collection of ports: basics work (no SMOBs, no guardians, no WHT).
* libguile/gc.c (scm_init_storage): Do not initialize SCM_I_PORT_TABLE
  here: this is done in `scm_ports_prehistory ()'.  This fixes the bug
  mentioned in the previous patch log.

* libguile/ports.c (scm_new_port_table_entry): Slightly clarified the
  code.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-4
2008-09-05 00:46:22 +02:00
Ludovic Courtes
fca4388748 First `working'' Guile! Crashes in flush-all-ports' (relates to SCM_I_PORT_TABLE).
* libguile/gc.c (scm_gc_stats): Fixed so that it returns a relevant
  result instead of just `SCM_EOL'.

* libguile/ports.c: Include `assert.h'.  Don't include `malloc.h'.
  (scm_make_port_type): Use `scm_gc_realloc ()' instead of `realloc ()'.
  (scm_new_port_table_entry): Likewise.
  (scm_flush): Added an assertion on the port number.
  (scm_ports_prehistory): Use `scm_gc_malloc ()' instead of `scm_malloc ()'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-3
2008-09-05 00:46:14 +02:00
Ludovic Courtes
26224b3f5d Merge from lcourtes@laas.fr--2005-mobile
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-09-05 00:45:58 +02:00
Han-Wen Nienhuys
289cd1a720 Don't sanity check GC numbers on 64 bit platforms, while we
investigate a real fix.
2008-09-03 01:37:58 -03:00
Han-Wen Nienhuys
487b9dec2e Only sanity check numbers if SCM_DEBUG_CELL_ACCESSES is unset.
SCM_DEBUG_CELL_ACCESSES uses the mark bits for its own purposes.
2008-08-26 23:46:39 -03:00
Han-Wen Nienhuys
1f5844000e Style nitpicks: space before () in function call. 2008-08-21 23:16:20 -03:00
Ludovic Courtès
417566ebc9 Never define _GNU_SOURCE' explicitly since AC_USE_SYSTEM_EXTENSIONS'
takes care of it.

Conflicts:

	ChangeLog
	configure.in
	libguile/eval.c
	libguile/srfi-14.c
	libguile/threads.c
2008-08-20 19:31:46 +02:00
Han-Wen Nienhuys
5bfb683e12 Make marked conservatively statistic accumulative. 2008-08-16 15:34:04 -03:00
Han-Wen Nienhuys
676d9cc553 If realloc() fails in scm_realloc, then do a complete GC with complete
sweep directly.
2008-08-16 15:20:55 -03:00
Han-Wen Nienhuys
40945e5e9f Add a statistic for tracking how many cells are marked conservatively.
This allows an informed choice for deciding how many segments to
create.  After startup, ~2% of the cells are scanned conservatively.
2008-08-16 15:03:48 -03:00
Han-Wen Nienhuys
82ae1b8eb3 Garbage collection cleanup.
* New file gc-segment-table.c: hold code for the segment table.

* Remove data that might be out of date; remove
  scm_i_adjust_min_yield().  We don't store min_yields, since they
  are only accurate at one point in time (when the sweep finishes). 
  We decide the min yield at that point from min_yield_fraction and
  freelist->collected / freelist->swept

* Introduce scm_i_gc_heap_size_delta() replacing
  scm_i_gc_grow_heap_p().
  
* Remove foo_1 fields containing penultimate results.

* After GC, count mark bit vector to discover number of live
  objects. This simplifies hairy updates.

* Many formatting and layout cleanups.

* Fix in scm_i_sweep_card(): return the length of free_list returned,
  rather than number of deleted objects.

* For mtrigger GCs: do not also run a full sweep after the gc() call, as
  this is inconsistent with lazy sweeping.

* Remove scm_i_make_initial_segment().

* Use calloc in scm_i_make_empty_heap_segment() to save on
  initialization code.

* New function scm_i_sweep_for_freelist() which sweeps, with proper
  statistic variable updates.

* New segments are conceptually blocks with 100% reclaimable cells.

* Remove some useless constants/comments: SCM_HEAP_SIZE,
  SCM_INIT_HEAP_SIZE, SCM_EXPHEAP, SCM_HEAP_SEG_SIZE

* Do not increment scm_cells_allocated() from the
  scm_[double]cell(). This would be a race condition.

* Move some deprecation checks in separate functions to not distract
  from main code flow.
2008-08-16 13:57:23 -03:00
Han-Wen Nienhuys
01621bf62e Include min-yields in gc-stats output. 2008-08-14 02:16:41 -03:00
Han-Wen Nienhuys
2072309c1c Whitespace and formatting fixes.
Conflicts:

	libguile/gc-freelist.c
	libguile/gc-segment.c
	libguile/gc.h
2008-08-14 01:51:24 -03:00
Ludovic Courtès
bfb64eb408 Fix build issue in `gc.c' on GNU/Linux IA64. 2008-02-22 09:53:02 +00:00
Neil Jerram
5c004b6d6a * gc.c (mark_gc_async): Change "func_data" to "fn_data", to avoid
clash with AIX header file.
* hooks.c (scm_c_hook_add, scm_c_hook_remove): Same again.
* hooks.h (scm_t_c_hook_function, scm_c_hook_add,
scm_c_hook_remove): Same again.
2007-12-29 01:35:33 +00:00
Han-Wen Nienhuys
5dbc6c0679 replace port table with weak hash table. This simplifies
memory management, and fixes freed cells appearing in
port-for-each output.
2007-08-26 18:11:57 +00:00
Han-Wen Nienhuys
93632e3cfd (s_scm_gc_stats): return an entry for total-cells-allocated
too.
(gc_update_stats): update scm_gc_cells_allocated_acc too.
2007-01-03 17:26:32 +00:00
Ludovic Courtès
d9f71a0754 Changes from arch/CVS synchronization 2006-11-08 09:34:35 +00:00
Neil Jerram
9a5fa6e98a * configure.in: New check for uca lib (needed for IA64 on HP-UX).
* threads.c (SCM_MARK_BACKING_STORE): Use scm_ia64_ar_bsp() and
scm_ia64_register_backing_store_base() instead of Linux-specific
implementations.

* gc.h (scm_ia64_register_backing_store_base, scm_ia64_ar_bsp):
New declarations.

* gc.c (__libc_ia64_register_backing_store_base): Declaration
removed.
(scm_ia64_register_backing_store_base, scm_ia64_ar_bsp): New, with
implementations for Linux and HP-UX.

* coop-pthreads.c (SCM_MARK_BACKING_STORE): Use scm_ia64_ar_bsp()
and scm_ia64_register_backing_store_base() instead of
Linux-specific implementations.

* continuations.h (__libc_ia64_register_backing_store_base):
Declaration removed.
(scm_t_contregs): New "fresh" field.

* continuations.c (ia64_getcontext): Removed.
(scm_make_continuation): Use continuation fresh field instead of
interpreting getcontext return values (which isn't portable).  Use
scm_ia64_ar_bsp() and scm_ia64_register_backing_store_base()
instead of Linux-specific implementations.
(copy_stack_and_call): Use scm_ia64_register_backing_store_base()
instead of Linux-specific implementation.

* _scm.h (__ia64__): Also detect __ia64.
2006-10-25 22:37:24 +00:00
Kevin Ryde
2b829bbb3d merge from 1.8 branch 2006-04-17 00:05:42 +00:00
Han-Wen Nienhuys
4c7016dc06 Ludovic's patch for scm_t_sweep_statistics. 2006-02-14 11:38:30 +00:00
Neil Jerram
3f98874a96 * gc.c (scm_weak_vectors): Removed. 2005-11-12 08:58:51 +00:00
Mikael Djurfeldt
3e2073bd24 * gc.c (scm_gc_stats): Bugfix: Measure size of the type we are
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-07-18 13:55:44 +00:00
Han-Wen Nienhuys
8fecbb1900 * gc-card.c (scm_i_card_statistics): init tag.
* gc.c (tag_table_to_type_alist): check type of tag. Should be integer.
2005-07-01 12:34:58 +00:00
Han-Wen Nienhuys
e4da074025 *** empty log message *** 2005-06-11 01:48:19 +00:00
Han-Wen Nienhuys
8a00ba7178 (tag_table_to_type_alist): convert tag number to "tag %d"
string, so live object stats can be sorted with string<?.
2005-06-09 19:33:38 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Neil Jerram
b01532af77 * threads.c (s_scm_lock_mutex): Don't declare msg in middle of
code.

* gc.c (s_scm_gc_live_object_stats): Don't declare alist in middle
of code.

* gc-card.c (scm_i_card_statistics): Don't declare tag in middle
of code.
(scm_i_card_statistics): Add block for declarations of tag_as_scm
and current.
2005-05-11 07:41:36 +00:00
Neil Jerram
33b320ae2a Critical section review. 2005-03-30 22:11:07 +00:00
Marius Vollmer
b17e0ac397 * gc.h, gc.c (SCM_FREECELL_P): Removed for good.
(scm_block_gc, scm_gc_heap_lock): Removed.  Removed all uses.
(scm_gc_running_p): Now a macro that refers to the scm_i_thread
field.
(scm_i_sweep_mutex): Now a non-recursive mutex.  GC can not happen
recursively.
(scm_igc, scm_i_gc): Renamed former to latter.  Changed all uses.
Do not lock scm_i_sweep_mutex, which is now non-recursive, or set
scm_gc_running_p.  Do not run the scm_after_gc_c_hook.
(scm_gc): Lock scm_i_sweep_mutex, set scm_gc_running_p and run the
scm_after_gc_c_hook here.
(scm_gc_for_new_cell): Set scm_gc_running_p here and run the
scm_after_gc_c_hook when a full GC has in fact been performed.
(scm_i_expensive_validation_check): Call scm_gc, not scm_i_gc.

* gc-segment.c (scm_i_get_new_heap_segment): Do not check
scm_gc_heap_lock.

* gc-malloc.c (scm_realloc, increase_mtrigger): Set
scm_gc_running_p while the scm_i_sweep_mutex is locked.
2005-03-10 18:39:53 +00:00
Marius Vollmer
9de87eea47 See ChangeLog from 2005-03-02. 2005-03-02 20:42:01 +00:00
Han-Wen Nienhuys
73a4c24e41 * gc.c (s_scm_gc_live_object_stats): return alist, not hashtable.
(tag_table_to_type_alist): ignore unknown types.

* gc.c (s_scm_gc_live_object_stats): new GUILE callable: return
statistics on the number of live objects of each type.

* gc-card.c (scm_i_tag_name):  new function.
(scm_i_card_statistics): new function.
2005-01-27 22:44:43 +00:00
Han-Wen Nienhuys
1367aa5e91 * gc.c (s_scm_gc_live_object_stats): return alist, not hashtable.
* gc-segment.c (scm_i_all_segments_statistics): new function.
(scm_i_heap_segment_statistics): new function

* gc.c (s_scm_gc_live_object_stats): new GUILE callable: return
statistics on the number of live objects of each type.

* gc-card.c (scm_i_tag_name):  new function.
(scm_i_card_statistics): new function.
2005-01-27 22:19:49 +00:00
Marius Vollmer
76da80e788 Reverted changed from 2005/01/24 19:14:54, which was a commit to the
wrong branch.  Sorry.
2005-01-24 23:41:14 +00:00
Marius Vollmer
a54a94b397 Threading changes. 2005-01-24 19:14:54 +00:00
Han-Wen Nienhuys
07b99edbe8 (scm_igc): put scm_gc_running-- before running hooks. 2004-10-07 23:42:41 +00:00