summaryrefslogtreecommitdiff
path: root/libguile/gc.c
Commit message (Expand)AuthorAgeFilesLines
* Make scm_gc_warn_proc() write directly to stderr...This avoids a deadlock due to the lookup of cur_warnport_fluid while an allocation is ongoing. * libguile/gc.c (scm_gc_warn_proc): Write the warning directly to stderr. Daniel Llorens2016-12-141-31/+3
* Fix --without-threads...* libguile/dynl.c: * libguile/gc.c: * libguile/keywords.c: * libguile/scmsigs.c: * libguile/stime.c: Use scm_i_dynamic_link instead of scm_dynamic_link so that things compile in without-threads configurations. Andy Wingo2016-12-071-2/+2
* Deprecate dynamic roots...* libguile/root.h: * libguile/root.c: Remove these files. * libguile/deprecated.h: * libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root) (scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate. Remove all root.h usage, which was vestigial. * module/ice-9/serialize.scm: Use (current-thread) instead of (dynamic-root). Andy Wingo2016-11-211-1/+0
* Remove SCM_DEBUG_CELL_ACCESSES==1...Since the move to BDW-GC this option has not been useful. * libguile/__scm.h (SCM_DEBUG_CELL_ACCESSES): Remove default definition. * libguile/gc.h: Add comment about cells. (SCM_VALIDATE_CELL): Remove. I did a search on the internet and I found no external users. (SCM_CELL_WORD, SCM_CELL_OBJECT, SCM_SET_CELL_WORD) (SCM_SET_CELL_OBJECT, SCM_CELL_OBJECT_LOC): Remove SCM_VALIDATE_CELL uses. * libguile/gc.c (scm_debug_cell_accesses_p) (scm_expensive_debug_cell_accesses_p) (scm_debug_cells_gc_interval, scm_i_expensive_validation_check) (scm_assert_cell_valid): Remove bindings only available when SCM_DEBUG_CELL_ACCESSES was 1. * libguile/list.c (scm_list_n): Remove SCM_VALIDATE_CELL usage. Andy Wingo2016-11-181-137/+5
* Mutex instead of critical section in gc.c...* libguile/gc.c (scm_gc_protect_object, scm_gc_unprotect_object): Use a mutex instead of a critical section. Remove dead code. Andy Wingo2016-11-011-18/+9
* Use atomics for async interrupts...* libguile/__scm.h (SCM_TICK): Always define as scm_async_tick(). * libguile/error.c (scm_syserror, scm_syserror_msg): * libguile/fports.c (fport_read, fport_write): * libguile/_scm.h (SCM_SYSCALL): Replace SCM_ASYNC_TICK with scm_async_tick (). (SCM_ASYNC_TICK, SCM_ASYNC_TICK_WITH_CODE) (SCM_ASYNC_TICK_WITH_GUARD_CODE): Remove internal definitions. We inline into vm-engine.c, the only place where it matters. * libguile/async.h: * libguile/async.c (scm_async_tick, scm_i_setup_sleep): (scm_i_reset_sleep, scm_system_async_mark_for_thread): * libguile/threads.h (struct scm_thread_wake_data): * libguile/threads.h (scm_i_thread): * libguile/threads.c (block_self, guilify_self_1, scm_std_select): Rewrite to use sequentially-consistent atomic references. * libguile/atomics-internal.h (scm_atomic_set_pointer): (scm_atomic_ref_pointer): New definitions. * libguile/finalizers.c (queue_finalizer_async): We can allocate, so just use scm_system_async_mark_for_thread instead of the set-cdr! shenanigans. * libguile/scmsigs.c (take_signal): * libguile/gc.c (queue_after_gc_hook): Adapt to new asyncs mechanism. Can't allocate but we're just manipulating the current thread when no other threads are running so we should be good. * libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Inline the async_tick business. Andy Wingo2016-10-261-5/+4
* Fix --without-threads against threaded BDW-GC...* libguile/gc.c (scm_storage_prehistory): Prevent BDW-GC from spawning marker threads if Guile was built without threading support. Andy Wingo2016-07-251-1/+7
* Use the right GC version macros....Reported by Doug Evans <xdje42@gmail.com>. * libguile/gc.c (scm_storage_prehistory): Use GC_VERSION_MICRO, not GC_ALPHA_VERSION. Ludovic Courtès2014-06-091-1/+1
* Merge branch 'stable-2.0'...Conflicts: GUILE-VERSION NEWS guile-readline/ice-9/readline.scm libguile/async.c libguile/backtrace.c libguile/deprecated.h libguile/gc-malloc.c libguile/gdbint.c libguile/init.c libguile/ioext.c libguile/mallocs.c libguile/print.c libguile/rw.c libguile/scmsigs.c libguile/script.c libguile/simpos.c libguile/snarf.h libguile/strports.c libguile/threads.c libguile/vm-i-scheme.c libguile/vm-i-system.c module/srfi/srfi-18.scm test-suite/Makefile.am test-suite/standalone/test-num2integral.c Mark H Weaver2014-04-251-2/+0
|\
| * Rely on Gnulib for <unistd.h>....* libguile/async.c: * libguile/backtrace.c: * libguile/error.c: * libguile/filesys.c: * libguile/fports.c: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/init.c: * libguile/ioext.c: * libguile/load.c: * libguile/mallocs.c: * libguile/mkstemp.c: * libguile/ports.c: * libguile/posix.c: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/rw.c: * libguile/scmsigs.c: * libguile/script.c: * libguile/simpos.c: * libguile/socket.c: * libguile/stime.c: * libguile/strports.c: * libguile/threads.c: Unconditionally include <unistd.h>. Mark H Weaver2014-02-271-3/+1
* | Set $GC_MARKERS to 1 when libgc 7.4.0 is used....* libguile/gc.c (scm_storage_prehistory) [GC_VERSION == 7.4.0]: Add 'setenv' call. Ludovic Courtès2014-04-231-0/+8
* | Out-of-memory situations raise exceptions instead of aborting...* libguile/gc.c (scm_oom_fn, scm_init_gc): Install an out-of-memory handler that raises an unwind-only out-of-memory exception. (scm_gc_warn_proc, scm_init_gc): Install a warning proc that tries to print to the current warning port, if the current warning port is a file port. (scm_gc_after_nonlocal_exit): New interface. Should be called after a nonlocal return to potentially collect memory; otherwise allocations could try to expand again when they should collect. * libguile/continuations.c (scm_i_make_continuation): * libguile/eval.c (eval): * libguile/throw.c (catch): * libguile/vm.c (scm_call_n): Call scm_gc_after_nonlocal_exit after nonlocal returns. * libguile/throw.c (abort_to_prompt, throw_without_pre_unwind): Rework to avoid allocating memory. (scm_report_out_of_memory): New interface. (scm_init_throw): Pre-allocate the arguments for stack-overflow and out-of-memory errors. * module/ice-9/boot-9.scm: Add an out-of-memory exception printer. * module/system/repl/error-handling.scm (call-with-error-handling): Add out-of-memory to the report-keys set. * libguile/gc-malloc.c (scm_realloc): Call scm_report_out_of_memory if realloc fails. * libguile/error.h: * libguile/error.c: * libguile/deprecated.h: * libguile/deprecated.c (scm_memory_error): Deprecate. * test-suite/standalone/Makefile.am: * test-suite/standalone/test-out-of-memory: New test case. Andy Wingo2014-03-221-0/+64
* | Remove code to run GC more frequently as process image size increased...* libguile/gc.c: Remove code that would try to run GC more frequently as the process image size was increasing. Before, it was often the case that the heap was the main component of image size, but with expandable stacks and statically allocated data that is no longer true. Also, once scm_gc_register_allocation was incorporated, we don't need to be so conservative any more. It seems this code was simply causing too many gc's to run. Removing it improves some micro-benchmarks; time will tell. Andy Wingo2014-02-021-147/+1
* | Remove unused function scm_i_tag_name....* libguile/gc.c (scm_i_tag_name): Remove. Tom Tromey2013-12-121-78/+0
* | Merge commit 'd364a8971828e38e8f9112b711066f4962bb400e'...Conflicts: libguile/deprecated.h libguile/gc.c Andy Wingo2013-11-281-39/+0
|\|
| * Deprecate gc-live-object-stats...* libguile/gc.h: * libguile/gc.c: * libguile/deprecated.h: * libguile/deprecated.c (scm_gc_live_object_stats): Deprecate; it hasn't worked in the whole 2.0 series. Andy Wingo2013-11-281-38/+0
* | Avoid needless GC on startup due to scm_gc_register_allocation...* libguile/gc.c (bytes_until_gc): Initialize to DEFAULT_INITIAL_HEAP_SIZE, to avoid forced GC on the first mallocation. Andy Wingo2013-11-281-1/+1
* | Remove private-gc.h...* libguile/simpos.c (scm_getenv_int): Move here, from gc.c. * libguile/private-gc.h: Remove, unused. * libguile/simpos.h: Move scm_getenv_int declaration here. * libguile/vm.c: * libguile/gc.c: Adapt scm_getenv_int users. * libguile/gc-malloc.c: * libguile/load.c: * libguile/script.c: Remove private-gc includes from non-users of scm_getenv_int. * libguile/Makefile.am: Adapt. Andy Wingo2013-11-281-20/+1
* | scm_i_tag_name internal to gc.c...* libguile/gc.c (scm_i_tag_name): Make internal to gc.c. * libguile/private-gc.h: Remove from here. Andy Wingo2013-11-281-1/+2
* | Tune initial heap size...* libguile/fluids.c (new_fluid): Don't run an explicit GC for the first fluid. * libguile/gc.c (DEFAULT_INITIAL_HEAP_SIZE, scm_storage_prehistory): Enlarge from 32 kB to 512 or 1024 kB, depending on word size. Reduces startup time by 10 or 15% by avoiding excessive GC. * libguile/private-gc.h: Remove SCM_DEFAULT_INIT_HEAP_SIZE_2 definition here. Andy Wingo2013-11-281-1/+7
* | Remove another GC 6.8 hack...* libguile/gc.c (scm_storage_prehistory): Remove hack for BDW-GC 6.8. Andy Wingo2013-11-281-7/+0
* | Remove tests and shims for pre-7.2 bdw-gc....* configure.ac: Remove checks for symbols present in bdw-gc 7.2. * libguile/finalizers.c: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/guardians.c: * libguile/scmsigs.c: * libguile/threads.c: Remove shims. Andy Wingo2013-11-221-12/+0
* | Remove scm_tc7_vm...* libguile/tags.h (scm_tc7_vm): Return to pool. * libguile/goops.c: * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): * libguile/print.c (iprin1): Remove tc7_vm things. * libguile/vm.h (scm_the_vm_fluid): Remove stray declaration. Remove SCM_VM_P. Remove SCM_VM_DATA. Remove SCM_VALIDATE_VM. * libguile/vm.c (scm_i_vm_print): Remove. Andy Wingo2013-11-211-2/+0
* | Remove stack programs, objcode, and the old VM....* libguile/Makefile.am: * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Remove the old VM files, and the rules to build the .i files. * libguile/vm-engine.c: * libguile/vm.c: Remove the old VM. Woot! * libguile/_scm.h (SCM_OBJCODE_COOKIE, SCM_OBJCODE_ENDIANNESS_OFFSET) (SCM_OBJCODE_WORD_SIZE_OFFSET): Remove. * libguile/evalext.c (scm_self_evaluating_p): Remove objcode and program cases. * libguile/frames.c (scm_frame_num_locals, scm_frame_previous): Remove program cases. * libguile/gc.c (scm_i_tag_name): Remove objcode case. * libguile/goops.c (scm_class_of, create_standard_classes): Remove objcode and program cases. * libguile/instructions.h: * libguile/instructions.c (scm_instruction_list, scm_instruction_p) (scm_instruction_length, scm_instruction_pops, scm_instruction_pushes) (scm_instruction_to_opcode, scm_opcode_to_instruction): Remove old VM code. * libguile/objcodes.h: * libguile/objcodes.c: Remove the objcode data type, and handling for objcode files. * libguile/print.c: Remove objcode and program printers. * libguile/procprop.c: Remove program cases. * libguile/procs.c: * libguile/programs.h: * libguile/programs.c: Remove old program code. * libguile/smob.c: Remove objcodes include. * libguile/snarf.h: Remove static program defines. * libguile/stacks.c: Remove program case. * libguile/tags.h: Remove program and objcode tc7s. * module/ice-9/session.scm (procedure-arguments) * module/language/tree-il/analyze.scm (validate-arity) * module/statprof.scm (get-call-data, procedure=?) * module/system/vm/frame.scm (frame-bindings) (frame-call-representation): Remove old program cases. * module/system/repl/debug.scm (frame->module): Add a FIXME. * module/system/vm/instruction.scm: Remove old exports. * module/system/vm/program.scm: Remove old program code. Andy Wingo2013-11-081-2/+0
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: configure.ac libguile/deprecated.c libguile/deprecated.h libguile/filesys.h libguile/fluids.c libguile/fports.c libguile/gc.c libguile/guile.c libguile/numbers.c libguile/objcodes.c libguile/r6rs-ports.c libguile/smob.c libguile/socket.c libguile/threads.h module/language/scheme/decompile-tree-il.scm module/language/tree-il/peval.scm test-suite/tests/syncase.test Mark H Weaver2013-03-281-1/+15
|\|
| * Use accessors instead of symbols deprecated in libgc 7.3....* configure.ac: Check for `GC_set_all_interior_pointers', `GC_get_gc_no', and `GC_set_java_finalization'. * libguile/gc.c (scm_gc_stats)[HAVE_GC_GET_GC_NO]: Use `GC_get_gc_no'. (scm_storage_prehistory)[HAVE_GC_SET_ALL_INTERIOR_POINTERS]: Use `GC_set_all_interior_pointers'. * libguile/guardians.c (scm_init_guardians)[HAVE_GC_SET_JAVA_FINALIZATION]: Use `GC_set_java_finalization'. Ludovic Courtès2013-03-011-1/+15
* | gc.c: assume gc 7.2 features are present...* libguile/gc.c: Remove shims for GC_get_heap_usage_safe, GC_get_free_space_divisor, and GC_set_finalize_on_demand. Remove code in the case in which we did not have GC_set_start_callback. Andy Wingo2013-01-201-49/+1
* | Merge remote-tracking branch 'local-2.0/stable-2.0'...Conflicts: configure.ac Andy Wingo2012-03-111-0/+8
|\|
| * more libgc 7.1 compat...* configure.ac: * libguile/gc.c (GC_set_finalize_on_demand): Check for this function, and shim if it isn't present. Andy Wingo2012-03-081-0/+8
* | Merge remote-tracking branch 'local-2.0/stable-2.0'...Conflicts: configure.ac libguile/finalizers.c libguile/finalizers.h libguile/gc.c libguile/gc.h libguile/inline.c libguile/inline.h libguile/ports.c libguile/smob.c libguile/smob.h module/ice-9/deprecated.scm module/ice-9/r4rs.scm Andy Wingo2012-03-081-0/+2
|\|
| * run finalizers asynchronously in asyncs...* libguile/finalizers.c: New excitement! We'll be running finalizers asynchronously, from asyncs. This will make it safer to allocate while holding a mutex. (GC_set_finalizer_notifier): Add back-compat shim. * libguile/init.c (scm_i_init_guile): Init the async finalizer mechanism during boot. * libguile/gc.c (scm_storage_prehistory): Tell libgc we'll be finalizing on demand. (scm_gc): Explicitly run finalizers here. * libguile/threads.c (guilify_self_2): Run finalizers here if queue_finalizer_async happened to run during guilify_self_1. * configure.ac: Add check for GC_set_finalizer_notifier. Andy Wingo2012-03-081-1/+5
* | run finalizers asynchronously (in asyncs and/or pthreads)...* libguile/finalizers.c: New excitement! We'll be running finalizers in threads, if that's available. If it's not available, during early boot, we can run finalizers in asyncs. This will make it safer to allocate while holding a mutex. * libguile/posix.c (scm_fork): Shut down the finalizer thread before forking. * libguile/init.c (scm_i_init_guile): Init the async finalizer mechanism during boot and, if available, initialialize the finalizer thread at the very end. * libguile/gc.c (scm_storage_prehistory): Tell libgc we'll be finalizing on demand. (scm_gc): Explicitly run finalizers here. If you're calling this function, you probably want synchronous GC. Andy Wingo2012-02-241-1/+3
* | Revert "install pthread_atfork handlers for guile's static mutexen"...This reverts commit 6a97b1f93aace5c7c976aef51d36b3ae9cfd5630. Andy Wingo2012-02-231-2/+1
* | install pthread_atfork handlers for guile's static mutexen...* libguile/async.c: * libguile/deprecation.c: * libguile/fluids.c: * libguile/gc.c: * libguile/instructions.c: * libguile/ports.c: * libguile/posix.c: * libguile/strings.c: * libguile/threads.c: Use the SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX mechanism to lock a number of static mutexen. Andy Wingo2012-02-171-1/+2
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: libguile/debug.h module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm module/language/tree-il/peval.scm module/language/tree-il/primitives.scm Andy Wingo2012-01-301-0/+4
|\|
| * fix hook invocation during thread guilification...* libguile/gc.c (run_before_gc_c_hook): Don't run pre-GC hooks from a thread that is in the process of guilification. Andy Wingo2012-01-301-0/+4
* | Merge commit 'f78a1ccede02ccad89d6c91a6b297f1f14a30907'Andy Wingo2012-01-101-4/+1
|\|
| * stdlib.h, not malloc.h...* configure.ac: Remove check for malloc.h. * libguile/gc-malloc.c: * libguile/gc.c: * libguile/mallocs.c: * libguile/smob.c: Use stdlib instead of malloc.h. Andy Wingo2011-12-221-4/+1
| * fix scm_protects deprecation warning...* libguile/gc.c: Fix warning about scm_protects being deprecated. Andy Wingo2011-12-191-0/+2
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: configure.ac Andy Wingo2011-12-131-0/+4
|\|
| * fix compilation with gc 7.1...* configure.ac: Add checks for GC_gcollect_and_unmap and GC_get_unmapped_bytes. * libguile/gc-malloc.c (scm_realloc): GC_gcollect() if we don't have GC_gcollect_and_unmap. * libguile/gc.c (GC_get_heap_usage_safe): Likewise, don't GC_get_unmapped_bytes if the function doesn't exist. Chris K. Jester-Young2011-12-081-0/+4
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm Andy Wingo2011-12-011-8/+212
|\|
| * fix deadlock in before-gc-hook on certain 7.2alpha gc versions...* libguile/gc.c (scm_init_gc): Only adjust gc frequency in the gc start hook if we know that it won't take a lock. Andy Wingo2011-12-011-1/+10
| * attempt to handle steady-state mallocations better...* libguile/gc-malloc.c (scm_realloc): Call the new scm_gc_register_allocation() here. If we have to collect, do a GC_gcollect_and_unmap. * libguile/gc.c (scm_gc_register_allocation): Add a routine to track steady-state mallocation, and cause gc to run if there is a high mallocation rate. (adjust_gc_frequency): Reset the bytes-until-GC countdown timer. Andy Wingo2011-11-291-0/+35
| * adjust_gc_frequency before gc, for more precision...* libguile/gc.c (scm_init_gc): Run the adjust_gc_frequency from the before-gc-hook, not the after-gc-hook. More precise, this way. Andy Wingo2011-11-291-1/+1
| * fix uninitialized variable in gc.c...* libguile/gc.c (get_image_size): Fix use of uninitialized variable. Andy Wingo2011-11-291-1/+1
| * switch off debugging flag that was mistakenly left on...* libguile/gc.c (HEURISTICS_DEBUG): Whoops, switch this off. Andy Wingo2011-11-291-1/+1
| * increase garbage collection rate if the process is growing...* configure.ac: Check for GC_get_free_space_divisor. * libguile/gc.c (GC_get_free_space_divisor): Define an implementation, if needed. (accumulate_gc_timer): Fix indentation. (get_image_size): New terrible hack. Needs implementations on other platforms. (adjust_gc_frequency): Attempt to adjust the GC frequency based on process image growth. Needs more comments. (scm_init_gc): Add the adjust_gc_frequency to the after_gc_c_hook. Andy Wingo2011-11-291-2/+148
| * get heap stats with GC_get_heap_usage_safe, if available....* configure.ac: Check for GC_get_heap_usage_safe. * libguile/gc.c (SCM_DEFINE): Use GC_get_heap_usage_safe. Andy Wingo2011-11-281-6/+20
| * deprecate direct scm_protects access...* libguile/gc.h: * libguile/gc.c: Deprecate direct access to scm_protects. Andy Wingo2011-11-211-1/+4