Andy Wingo [Tue, 6 Dec 2011 12:50:05 +0000 (13:50 +0100)]
port locking refactor
* libguile/ports.h (struct scm_t_port): Make the lock into a pointer
field instead of an inline field. It should be possible to make
unlocked ports by having a NULL lock field.
(scm_c_lock_port, scm_c_try_lock_port): Return the mutex if the port
was actually locked.
(scm_c_unlock_port): Remove.
* libguile/ports.c (scm_c_make_port_with_encoding): For now, leave
`lock' set to 0.
Change scm_c_lock_port callers to pay attention to the new API.
* libguile/print.c (scm_write, scm_display): Fix call to
dynwind-lock-port for ports-with-print-states.
Andy Wingo [Fri, 2 Dec 2011 11:00:33 +0000 (12:00 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
libguile/guile.c
libguile/numbers.c
Andy Wingo [Fri, 2 Dec 2011 10:22:46 +0000 (11:22 +0100)]
install gmp memory functions that let libgc know about allocations
* libguile/numbers.c (custom_gmp_malloc, custom_gmp_realloc,
custom_gmp_free): New static functions used by GMP for allocation.
These are just wrappers for scm_malloc, scm_realloc, and free.
(scm_init_numbers): If scm_install_gmp_memory_functions is nonzero,
use mp_set_memory_functions to configure GMP to use
custom_gmp_{malloc,realloc,free} for memory allocation.
(scm_bigprint): Ask gmp for the function used to deallocate the string
returned by mpz_get_str.
* libguile/numbers.h: Declare scm_install_gmp_memory_functions.
* libguile/guile.c: When running the Guile binary, install the
gmp_memory_functions.
Based on a patch by Mark H Weaver <mhw@netris.org>.
Andy Wingo [Thu, 1 Dec 2011 22:31:50 +0000 (23:31 +0100)]
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 Wingo [Thu, 1 Dec 2011 11:57:49 +0000 (12:57 +0100)]
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 Wingo [Tue, 29 Nov 2011 20:36:31 +0000 (21:36 +0100)]
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 Wingo [Tue, 29 Nov 2011 19:26:40 +0000 (20:26 +0100)]
collect a little in call-with-new-thread
* libguile/threads.c (scm_call_with_new_thread): Collect a little before
making a new thread. Our adjust_gc_frequency hack doesn't work well
if the main allocation load is thread creation, as in
https://savannah.gnu.org/bugs/?34140. This does not appreciably
affect the speed of the test in that bug, but does effectively limit
the image size.
Andy Wingo [Tue, 29 Nov 2011 19:24:23 +0000 (20:24 +0100)]
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 Wingo [Tue, 29 Nov 2011 12:43:52 +0000 (13:43 +0100)]
fix uninitialized variable in gc.c
* libguile/gc.c (get_image_size): Fix use of uninitialized variable.
Andy Wingo [Tue, 29 Nov 2011 09:17:07 +0000 (10:17 +0100)]
switch off debugging flag that was mistakenly left on
* libguile/gc.c (HEURISTICS_DEBUG): Whoops, switch this off.
Andy Wingo [Mon, 28 Nov 2011 23:48:56 +0000 (00:48 +0100)]
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 Wingo [Mon, 28 Nov 2011 18:58:53 +0000 (19:58 +0100)]
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.
Ludovic Courtès [Sat, 26 Nov 2011 21:27:32 +0000 (22:27 +0100)]
FFI: Hold a weak reference to the procedure passed to `procedure->pointer'.
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference
to PROC.
* test-suite/tests/foreign.test ("procedure->pointer")["procedure is
retained"]: New test.
Andy Wingo [Wed, 23 Nov 2011 23:33:49 +0000 (00:33 +0100)]
support for new GC_move_disappearing_link
* configure.ac: Check for GC_move_disappearing_link.
* libguile/weak-set.c (move_weak_entry):
* libguile/weak-table.c (move_disappearing_links):
(move_weak_entry): Use GC_move_disappearing_link if available.
Andy Wingo [Fri, 18 Nov 2011 11:25:30 +0000 (12:25 +0100)]
remove scm_si_name_access
* libguile/goops.h (scm_si_name_access): Remove alias for
scm_si_getters_n_setters.
Andy Wingo [Fri, 18 Nov 2011 11:23:52 +0000 (12:23 +0100)]
remove unused <class> slot: keyword-access
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, scm_si_keyword_access):
* libguile/goops.c (build_class_class_slots): Remove unused
keyword-access slot from classes.
Andy Wingo [Fri, 18 Nov 2011 10:50:50 +0000 (11:50 +0100)]
deprecate make-vtable-vtable
* libguile/struct.h:
* libguile/struct.c (scm_make_vtable_vtable): Deprecate, as you can
handle most of the use cases with make-vtable, and we don't want to
promote the creation of new roots to the type hierarchy.
(scm_i_make_vtable_vtable): The internal replacement.
Andy Wingo [Fri, 18 Nov 2011 10:35:07 +0000 (11:35 +0100)]
simplify %condition-type-vtable
* module/srfi/srfi-35.scm (%condition-type-vtable): Use make-vtable
instead of make-vtable-vtable.
Andy Wingo [Fri, 18 Nov 2011 10:32:24 +0000 (11:32 +0100)]
record-type-vtable is not a new root of the vtable hierarchy
* module/ice-9/boot-9.scm (record-type-vtable): Simplify to use
make-vtable instead of make-vtable-vtable.
Andy Wingo [Fri, 18 Nov 2011 10:31:52 +0000 (11:31 +0100)]
Scheme standard-vtable-fields binding
* libguile/struct.c (scm_init_struct): Export standard-vtable-fields to
Scheme.
Andy Wingo [Fri, 18 Nov 2011 10:15:43 +0000 (11:15 +0100)]
add Scheme binding for scm_standard_vtable_vtable
* libguile/struct.c (scm_init_struct): Export <standard-vtable> to
Scheme.
Andy Wingo [Fri, 18 Nov 2011 10:10:54 +0000 (11:10 +0100)]
remove public scm_protects export
* libguile/gc.h:
* libguile/gc.c: Remove scm_protects from the API. It is deprecated on
stable-2.0.
Andy Wingo [Fri, 18 Nov 2011 10:01:13 +0000 (11:01 +0100)]
no gc_register_root in scm_init_print
* libguile/print.c (scm_init_print): No need to gc_register_root here.
Andy Wingo [Fri, 18 Nov 2011 09:59:13 +0000 (10:59 +0100)]
remove object protection from options.c
* libguile/options.c (change_option_setting, scm_init_options): Rely on
the options being allocated in GC-able memory, as in static memory.
Therefore there is no need for the gc-protect dance.
Andy Wingo [Fri, 18 Nov 2011 09:50:35 +0000 (10:50 +0100)]
simplify scm_init_print
* libguile/print.c (scm_init_print): Simplify creation of print-state
vtable.
Daniel Hartwig [Wed, 23 Nov 2011 19:56:30 +0000 (20:56 +0100)]
web-http.test validates headers
* test-suite/tests/web-http.test (pass-if-parse): Validate header values
as well.
Daniel Hartwig [Wed, 23 Nov 2011 19:56:10 +0000 (20:56 +0100)]
fix validators for various list-style headers
* module/web/http.scm (default-val-validator): Valid with no value.
(key-value-list?): Keys are always symbols, do not accept strings.
(validate-param-list): Apply `valid?' to list elements.
(validate-credentials): Validate param for Basic scheme, which
is parsed as a string.
(declare-symbol-list-header!): `list-of?' args were in wrong order.
("Cache-Control"): Replace `default-val-validator' with more
specific procedure.
("Accept"): Validate on first param which has no value.
Ludovic Courtès [Wed, 23 Nov 2011 21:19:40 +0000 (22:19 +0100)]
Update cross-compilation instructions.
* README (Cross building Guile): Update.
Ludovic Courtès [Wed, 23 Nov 2011 21:05:53 +0000 (22:05 +0100)]
configure: Make sure $GUILE_FOR_BUILD is suitable.
* acinclude.m4 (GUILE_CHECK_VERSION, GUILE_CHECK_GUILE_FOR_BUILD): New
macros.
* configure.ac: Remove $GUILE_FOR_BUILD tests. Use
`GUILE_CHECK_GUILE_FOR_BUILD'.
Ludovic Courtès [Wed, 23 Nov 2011 14:29:18 +0000 (15:29 +0100)]
Allow $GUILE_FOR_BUILD to use its own environment when cross-compiling.
* am/guilec (.scm.go): Use `-L' to specify the search path.
* module/Makefile.am (ice-9/psyntax-pp.go): Likewise.
* meta/uninstalled-env.in (top_builddir): Leave $GUILE_LOAD_PATH,
$GUILE_SYSTEM_PATH, and $GUILE_SYSTEM_EXTENSIONS_PATH unchanged when
cross-compiling.
Andy Wingo [Wed, 23 Nov 2011 11:40:33 +0000 (12:40 +0100)]
Use default value for make-fluid in Scheme files
* module/ice-9/boot-9.scm (%exception-handler)
(%running-exception-handlers, read-eval?, *repl-stack*)
(make-mutable-parameter):
* module/ice-9/getopt-long.scm (%program-name):
* module/language/elisp/runtime.scm (built-in-macro, defspecial):
* module/srfi/srfi-39.scm (make-parameter/helper):
* module/system/base/language.scm (*current-language*):
* module/system/base/message.scm (*current-warning-port*):
(*current-warning-prefix*):
* module/system/base/target.scm (%target-type, %target-endianness)
(%target-word-size):
* module/texinfo/plain-text.scm (*indent*, *itemizer*):
* benchmark-suite/lib.scm (prefix-fluid):
* test-suite/lib.scm (prefix-fluid): Give fluids a useful default
value.
Andy Wingo [Wed, 23 Nov 2011 11:21:22 +0000 (12:21 +0100)]
use new scm_make_fluid_with_default
* libguile/load.c (scm_init_load):
* libguile/ports.c (scm_init_ports):
* libguile/read.c (scm_init_read): Use scm_make_fluid_with_default.
Andy Wingo [Wed, 23 Nov 2011 11:13:12 +0000 (12:13 +0100)]
optional default-value arg to make-fluid
* libguile/fluids.c (grow_dynamic_state, new_fluid): Arrange for the
default value in the dynamic-state vector to be SCM_UNDEFINED instead
of SCM_BOOL_F. If the value in the dynamic-state is #f, default to a
value attached to the fluid instead. This allows useful default
values.
(scm_make_fluid_with_default): New function, allows the user to
specify a default value for the fluid. Defaults to #f. Bound to
`make-fluid' on the Scheme side.
(scm_make_unbound_fluid): Use SCM_UNDEFINED as the default in all
threads.
(scm_fluid_unset_x): Also unset the default value. Not sure if this
is the right thing.
(fluid_ref): Update to the new default-value strategy.
* libguile/threads.c (scm_i_reset_fluid): Reset to SCM_UNDEFINED.
* libguile/threads.h: Remove extra arg to scm_i_reset_fluid.
* libguile/vm-i-system.c (fluid-ref): Update to new default-value
strategy.
* module/ice-9/vlist.scm (block-growth-factor): Default to 2 in all
threads. Fixes http://debbugs.gnu.org/10093.
Ludovic Courtès [Tue, 22 Nov 2011 11:11:48 +0000 (12:11 +0100)]
Install the current locale when Guile is invoked directly.
* libguile/guile.c (main): Add `setlocale' call.
Ludovic Courtès [Tue, 22 Nov 2011 11:03:32 +0000 (12:03 +0100)]
Add Gnulib `largefile' module.
It will really be added next time we run "gnulib-tool --update".
Ludovic Courtès [Tue, 22 Nov 2011 09:09:27 +0000 (10:09 +0100)]
Leave $GUILE_LOAD_COMPILED_PATH unchanged when cross-compiling.
* meta/uninstalled-env.in: Don't define $GUILE_LOAD_COMPILED_PATH when
cross-compiling.
Ludovic Courtès [Tue, 22 Nov 2011 08:07:25 +0000 (09:07 +0100)]
Build `psyntax-pp.go' with `--target=$(host)'.
* module/Makefile.am (ice-9/psyntax-pp.go): Pass `--target=$(host)'.
Ludovic Courtès [Mon, 21 Nov 2011 23:21:39 +0000 (00:21 +0100)]
Run `guild compile' with `--target=$(host)'.
* am/guilec (.scm.go): Run `guild compile' with `--target=$(host)'.
Ludovic Courtès [Mon, 21 Nov 2011 23:19:03 +0000 (00:19 +0100)]
Add a `--target' option to `guild compile'.
* module/scripts/compile.scm (%options)["--target"]: New option.
(show-version): Update copyright year.
(compile): Use `with-target' to install the target.
* doc/ref/api-evaluation.texi (Compilation): Mention `--target' option.
Ludovic Courtès [Mon, 21 Nov 2011 23:09:22 +0000 (00:09 +0100)]
Add missing implicit `SCM_API' for `scm_c_make_objcode_slice'.
* libguile/objcodes.h (scm_c_make_objcode_slice): Add implicit `SCM_API'.
Ludovic Courtès [Mon, 21 Nov 2011 21:08:22 +0000 (22:08 +0100)]
Complete cross-compilation support.
* module/system/base/target.scm (%target-endianness, %target-word-size):
New fluids.
(%native-word-size): New variable.
(with-target): Set these fluids.
(cpu-endianness, cpu-word-size, triplet-cpu, triplet-vendor,
triplet-os): New procedures.
(target-cpu, target-vendor, target-os): Use them.
(target-endianness, target-word-size): Refer to the corresponding
fluid.
* libguile/objcodes.c (target_endianness_var, target_word_size_var): New
global variables.
(NATIVE_ENDIANNESS): New macro.
(target_endianness, target_word_size, to_native_order): New functions.
(make_objcode_from_file): Use `scm_bytecode_to_native_objcode' instead
of `scm_bytecode_to_objcode'.
(bytecode_to_objcode): New function, based on `scm_bytecode_to_objcode',
with the addition of an `endianness' and `word_size' parameters.
(scm_bytecode_to_objcode): Use it.
(scm_bytecode_to_native_objcode): New function.
(scm_write_objcode): Use `target_word_size' and `target_endianness'.
Convert OBJCODE's len and meta-len to native byte order.
(scm_init_objcodes): Initialize `target_endianness_var' and
`target_word_size_var'.
* libguile/objcodes.h (scm_bytecode_to_native_objcode): New declaration.
* libguile/vm.c (really_make_boot_program): Use
`scm_bytecode_to_native_objcode' instead of `scm_bytecode_to_objcode'.
* test-suite/tests/asm-to-bytecode.test (%objcode-cookie-size): New
variable.
(test-target): New procedure.
("cross-compilation"): Add `test-target' calls and the "unknown
target" test.
Ludovic Courtès [Mon, 21 Nov 2011 20:55:13 +0000 (21:55 +0100)]
Fix `validate-target' in (system base target).
* module/system/base/target.scm (validate-target): Accept any tuple with
at least 3 parts.
* test-suite/tests/asm-to-bytecode.test (test-triplet): New procedure.
("cross-compilation"): New test prefix.
Andy Wingo [Fri, 18 Nov 2011 10:09:48 +0000 (11:09 +0100)]
deprecate direct scm_protects access
* libguile/gc.h:
* libguile/gc.c: Deprecate direct access to scm_protects.
Ludovic Courtès [Sun, 20 Nov 2011 00:10:58 +0000 (01:10 +0100)]
Allow overlapping regions to be passed to `bytevector-copy!'.
Reported by Dmitry Chestnykh <dmitry@codingrobots.com>.
Fixes <http://debbugs.gnu.org/10070>.
* libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not
`memcpy'.
* test-suite/tests/bytevectors.test ("2.2 General
Operations")["bytevector-copy! overlapping"]: New test.
* doc/ref/api-data.texi (Bytevector Manipulation): Mention possible
overlapping.
Andy Wingo [Thu, 17 Nov 2011 09:52:06 +0000 (10:52 +0100)]
eval.test work
* test-suite/tests/eval.test ("stacks"): Enable another test, fix to use
with-throw-handler, and remove a duplicate test, now that there is no
difference between subrs and gsubrs.
Ludovic Courtès [Wed, 16 Nov 2011 22:53:58 +0000 (23:53 +0100)]
FFI: Hold a weak reference to the CIF made by `procedure->pointer'.
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference
to CIF so that it is not reclaimed before POINTER. Before that it
could be reclaimed and typically reused to store the CIF of another
procedure with the same arity, leading to obscure wrong-type-arg
errors.
Ludovic Courtès [Wed, 16 Nov 2011 22:51:34 +0000 (23:51 +0100)]
FFI: Add a `procedure->pointer' test.
* test-suite/tests/foreign.test ("procedure->pointer")["procedures
returning a pointer"]: New test.
Andy Wingo [Wed, 16 Nov 2011 22:21:59 +0000 (23:21 +0100)]
fix urls in docs
* doc/ref/intro.texi (Introduction):
* doc/ref/scheme-reading.texi (Further Reading):
* doc/ref/srfi-modules.texi (SRFI Support): Fix some urls. Thanks to
Henrik Sandklef for the report.
Andy Wingo [Wed, 16 Nov 2011 22:17:51 +0000 (23:17 +0100)]
fix web.texi typo
* doc/ref/web.texi (HTTP Headers): Fix a typo. Thanks to Brian Gough
for the report.
Andy Wingo [Wed, 16 Nov 2011 22:13:55 +0000 (23:13 +0100)]
hack the port-column of current-output-port after printing a prompt
* module/ice-9/boot-9.scm (repl-reader): Reset the output-column to 0
after printing the prompt. Fixes bug 9664.
Andy Wingo [Wed, 16 Nov 2011 19:15:26 +0000 (20:15 +0100)]
eval-when tidying up
* module/ice-9/psyntax.scm: Rename expand-when-list to parse-when-list,
and simplify to compare literal values.
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Wed, 16 Nov 2011 19:08:40 +0000 (20:08 +0100)]
psyntax: s/chi/expand/g
* module/ice-9/psyntax.scm: Rename all instances of "chi" to "expand".
Addded a hack to expand-eval-when that will be fixed later.
* module/ice-9/psyntax-pp.scm: Regenerated.
Andy Wingo [Wed, 16 Nov 2011 18:44:04 +0000 (19:44 +0100)]
fix bug in make-repl when lang is actually a language
* module/system/repl/common.scm (make-repl): Fix to accept language
objects in addition to symbols. Fixes http://debbugs.gnu.org/9857.
Thanks to Tristan Colgate for the report.
Ludovic Courtès [Wed, 16 Nov 2011 14:11:55 +0000 (15:11 +0100)]
Re-enable a couple of evaluator tests.
These tests had been disabled as part of
b7742c6b7132544b9d6cd9cb32c09e2084ad9e52 ("new evaluator, y'all").
* test-suite/tests/eval.test ("define set procedure-name")["closure"]:
Change to `pass-if' since it now works, as a result of
ee15aa46e3fb29e609bd7c431e8f2676f6573d57 ("set names of functions
defined at the toplevel from `eval'").
("stacks")["arguments of a gsubr stack frame"]: Remove (throw
'unresolved).
Andy Wingo [Wed, 16 Nov 2011 12:33:52 +0000 (13:33 +0100)]
memoize: booleanify the rest arg
* libguile/memoize.c (memoize): Turn the rest arg into a boolean. Fixes
an error when rest gets passed to set-procedure-minimum-arity!.
Andy Wingo [Tue, 15 Nov 2011 22:38:40 +0000 (23:38 +0100)]
set names of functions defined at the toplevel from `eval'
* module/ice-9/eval.scm (primitive-eval): Set the name of
toplevel-defined functions.
Andy Wingo [Tue, 15 Nov 2011 22:36:07 +0000 (23:36 +0100)]
better debuggability for interpreted procedures
* libguile/procprop.c (scm_set_procedure_minimum_arity_x): New
function, allows a user to override a function's arity.
(scm_i_procedure_arity): Look up in the overrides table first.
* libguile/procprop.h: Add scm_set_procedure_minimum_arity_x.
* module/ice-9/eval.scm (primitive-eval): Override arity of "general
closures".
* test-suite/tests/procprop.test ("procedure-arity"): Add tests.
Based on a patch from Stefan Israelsson Tampe. Test based on work by
Patrick Bernaud.
Andy Wingo [Fri, 11 Nov 2011 15:40:49 +0000 (16:40 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Fri, 11 Nov 2011 15:39:28 +0000 (16:39 +0100)]
update letrec compilation test
* test-suite/tests/tree-il.test ("letrec"): Update to clear the
temporary `let' bindings.
Andy Wingo [Fri, 11 Nov 2011 15:27:30 +0000 (16:27 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Thu, 10 Nov 2011 21:30:02 +0000 (22:30 +0100)]
fix bit-set*! bug (!)
* libguile/bitvectors.c (scm_bit_set_star_x): Fix a long-standing (since
2005) bug in which instead of using the kv bitvector, we actually use
the `v' bitvector. Also, change to allow `kv' being shorter than
`v'.
* test-suite/tests/bitvectors.test ("bit-set*!"): Add tests.
Andy Wingo [Wed, 9 Nov 2011 22:45:53 +0000 (23:45 +0100)]
when leaving a non-tail let, allow bound vals to be collected
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Clear
lexical stack slots at the end of a non-tail let, letrec, or fix.
Fixes http://debbugs.gnu.org/9900.
* test-suite/tests/gc.test ("gc"): Add test.
Andy Wingo [Wed, 9 Nov 2011 22:02:02 +0000 (23:02 +0100)]
disable port locking
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port)
(scm_c_unlock_port): Disable port locking until I have time to sort
out the bugs that are coming up.
Andy Wingo [Wed, 9 Nov 2011 18:36:10 +0000 (19:36 +0100)]
inline dynwind guards for normal control flow
* module/language/tree-il.scm (<tree-il>): Add `pre' and `post' fields
to <dynwind>, so that we can inline the guard bodies in the normal
control-flow case. It also avoids duplicating code in compile-glil,
which probably hides more bugs in 2.0.
(parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold)
(make-tree-il-folder, post-order!, pre-order!): Update.
* module/language/tree-il/analyze.scm (analyze-lexicals): Update.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update
to use `pre' and `post' instead of compiling code twice.
* module/language/tree-il/debug.scm (verify-tree-il): Update.
* module/language/tree-il/peval.scm (peval): Update. Instead of doing
complicated things in <dynwind>, handle 'dynamic-wind primcalls.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove 'dynamic-wind mess. Adapt '@dynamic-wind.
* test-suite/tests/tree-il.test ("partial evaluation"): Update tests.
Andy Wingo [Wed, 9 Nov 2011 16:04:44 +0000 (17:04 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
module/language/tree-il/peval.scm
module/language/tree-il/primitives.scm
test-suite/tests/tree-il.test
Andy Wingo [Wed, 9 Nov 2011 15:44:59 +0000 (16:44 +0100)]
simplify primitives.scm for dynwind
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove a dynwind hack, as we have a good inliner now.
Andy Wingo [Wed, 9 Nov 2011 14:23:58 +0000 (15:23 +0100)]
peval: fix dynwind bug.
* module/language/tree-il/peval.scm (peval): The <dynwind> compiler will
copy the winder and unwinder values, so make sure that they are
constant, and if not, create lexical bindings. Fixes
http://debbugs.gnu.org/9844.
* test-suite/tests/tree-il.test ("partial evaluation"): Add a couple
<dynwind> tests.
Andy Wingo [Wed, 9 Nov 2011 15:41:56 +0000 (16:41 +0100)]
fix <dynwind> serialization.
* module/language/tree-il.scm (unparse-tree-il): Fix <dynwind>
serialization.
Andy Wingo [Wed, 9 Nov 2011 14:22:01 +0000 (15:22 +0100)]
peval: don't copy assigned lexical bindings
* module/language/tree-il/peval.scm (peval): Since constant-expression?
is used to determine whether to copy values, return #f if any lexical
is assigned.
Andy Wingo [Tue, 8 Nov 2011 18:17:23 +0000 (19:17 +0100)]
lock ports in `write' and `display'
* libguile/print.c (scm_write, scm_display): Lock the port during
`display' and `write' calls. Fixes
https://savannah.gnu.org/bugs/?33996.
Andy Wingo [Tue, 8 Nov 2011 18:16:33 +0000 (19:16 +0100)]
add scm_dynwind_lock_port
* libguile/ports.h:
* libguile/ports.c (scm_dynwind_lock_port): New function.
Andy Wingo [Mon, 7 Nov 2011 23:46:41 +0000 (00:46 +0100)]
locking for write, lfwrite
* libguile/ports.c (scm_c_write_unlocked, scm_c_write)
(scm_lfwrite_unlocked, scm_lfwrite): Add locking and _unlocked
variants. Change uses to _unlocked.
Andy Wingo [Mon, 7 Nov 2011 23:36:48 +0000 (00:36 +0100)]
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.
Andy Wingo [Mon, 7 Nov 2011 23:29:46 +0000 (00:29 +0100)]
locking on port buffering operations
* libguile/ports.c (scm_fill_input_unlocked, scm_fill_input)
(scm_end_input, scm_end_input_unlocked, scm_flush)
(scm_flush_unlocked): Add locking and _unlocked variants.
* libguile/filesys.c:
* libguile/fports.c:
* libguile/gdbint.c:
* libguile/r6rs-ports.c:
* libguile/read.c:
* libguile/rw.c: Adapt callers to use _unlocked variants.
Andy Wingo [Mon, 7 Nov 2011 23:14:16 +0000 (00:14 +0100)]
locking on unget_byte, ungetc, ungets
* libguile/ports.h:
* libguile/ports.c (scm_unget_byte_unlocked, scm_unget_byte)
(scm_ungetc_unlocked, scm_ungetc, scm_ungets_unlocked, scm_ungets):
Add locking and _unlocked variants.
* libguile/arrays.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/vports.c: Adapt callers to use the _unlocked variants.
Andy Wingo [Mon, 7 Nov 2011 22:53:06 +0000 (23:53 +0100)]
locking on scm_c_read, scm_getc
* libguile/ports.c (scm_c_read_unlocked, scm_c_read, scm_getc_unlocked)
(scm_getc): Split getc and read operations into locked and unlocked
variants. Change most uses to use the _unlocked version.
Andy Wingo [Mon, 7 Nov 2011 19:17:22 +0000 (20:17 +0100)]
threadsafe get-byte-or-eof, peek-byte-or-eof
* libguile/ports.h (scm_get_byte_or_eof_unlocked):
(scm_peek_byte_or_eof_unlocked): Rename, adding _unlocked.
* libguile/ports.c (scm_get_byte_or_eof, scm_peek_byte_or_eof): Add
locking implementations. Adapt callers to use _unlocked variants;
they will do locking.
* libguile/read.c (read_token, scm_read_semicolon_comment)
(scm_read_shebang): Use unlocked variants. We will add locking
later.
Andy Wingo [Mon, 7 Nov 2011 19:00:39 +0000 (20:00 +0100)]
threadsafe port revealed counts
* libguile/ports.h:
* libguile/ports.c (scm_revealed_count, scm_set_port_revealed_x): Make
threadsafe.
(scm_adjust_port_revealed_x): New function, to adjust a port's
revealed count in a threadsafe way.
Andy Wingo [Mon, 7 Nov 2011 23:50:47 +0000 (00:50 +0100)]
scm_c_lock_port takes a port
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port)
(scm_c_unlock_port): Take a port instead of an entry.
Andy Wingo [Mon, 7 Nov 2011 18:48:50 +0000 (19:48 +0100)]
ports implementation reordering
* libguile/ports.h: Slight reorder.
* libguile/ports.c: Reorder ports implementation to match the header
file. This will make it easier to add locking and _unlocked
variants.
Andy Wingo [Mon, 7 Nov 2011 17:58:01 +0000 (18:58 +0100)]
threadsafe access to scm_ptobs
* libguile/ports.h (SCM_PORT_DESCRIPTOR): New macro, to get at a port
descriptor in the third word of a port instead of looking it up in a
table.
(scm_c_port_type_ref, scm_c_port_type_add_x): New API for working with
numbered ptob descriptors.
(SCM_PTOBNAME): Implement in terms of scm_c_port_type_ref.
(scm_get_byte_or_eof, scm_peek_byte_or_eof): Use SCM_PORT_DESCRIPTOR.
* libguile/ports.c (scm_c_num_port_types, scm_c_port_type_ref)
(scm_c_port_type_add_x, scm_make_port_type): Protect scm_ptobs access
with a mutex. Have it be an array of pointers instead of an array of
structures. Adapt users to the new APIs.
(scm_c_make_port_with_encoding): Allocate ports with three words. The
third word is the ptob descriptor.
* libguile/backtrace.c:
* libguile/goops.c:
* libguile/ioext.c:
* libguile/print.c: Adapt to use scm_c_port_type_ref and
SCM_PORT_DESCRIPTOR.
Andy Wingo [Mon, 7 Nov 2011 16:08:31 +0000 (17:08 +0100)]
reorder ports.h declarations
* libguile/ports.h: Reorder declarations.
Andy Wingo [Mon, 7 Nov 2011 15:25:37 +0000 (16:25 +0100)]
remove scm_markstream
* libguile/ports.h:
* libguile/ports.c (scm_markstream): Remove obsolete definition. Moved
around a couple of other declarations.
Andy Wingo [Mon, 7 Nov 2011 15:22:55 +0000 (16:22 +0100)]
ports.h: remove unimplemented declarations
* libguile/ports.h (scm_grow_port_cbuf, scm_pt_size, scm_pt_member):
Remove declarations of unimplemented functions. Move a couple of
other definitions around.
Andy Wingo [Mon, 7 Nov 2011 15:14:15 +0000 (16:14 +0100)]
inlined port functions to ports.h
* libguile/inline.h:
* libguile/ports.h (scm_get_byte_or_eof, scm_peek_byte_or_eof)
(scm_putc, scm_puts): Move definitions here, from inline.h.
Andy Wingo [Mon, 7 Nov 2011 15:01:01 +0000 (16:01 +0100)]
add lock to scm_t_port
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port)
(scm_c_unlock_port): New inline functions.
(scm_t_port): Add a lock field, if threads are enabled. This is a
first step towards threadsafe ports.
* libguile/ports.c (scm_c_make_port_with_encoding): Init the port's
lock.
* libguile/inline.c: Residualize the inline functions from ports.h.
Andy Wingo [Mon, 7 Nov 2011 10:48:30 +0000 (11:48 +0100)]
regenerate psyntax-pp
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Mon, 7 Nov 2011 10:47:26 +0000 (11:47 +0100)]
add tests for hygienic name introduction
* test-suite/tests/syntax.test ("top-level define"): Add tests for
hygienic introduction of names.
Andy Wingo [Fri, 4 Nov 2011 18:34:22 +0000 (19:34 +0100)]
hygienically rename macro-introduced bindings, reproducibly
* module/ice-9/psyntax.scm (chi-top-sequence): Detect bindings to
identifiers introduced by macros. In that case, in order to preserve
hygiene, uniquify the variable's name, but in a way that is
reproduceable (i.e., yields the same uniquified name after a
recompile).
Andy Wingo [Mon, 7 Nov 2011 09:22:26 +0000 (10:22 +0100)]
fix scope bug in <module> definition in boot-9
* module/ice-9/boot-9.scm (define-record-type): Fix scope bug when
generating identifiers.
Andy Wingo [Mon, 7 Nov 2011 10:44:54 +0000 (11:44 +0100)]
another scoping test
* test-suite/tests/syntax.test ("top-level define"): Add another test
for scoping.
Andy Wingo [Mon, 7 Nov 2011 08:55:57 +0000 (09:55 +0100)]
resolve-identifier for toplevel definitions resolves by module
* module/ice-9/psyntax.scm (id-var-name): For mapping identifiers to
toplevel definitions, also compare against the module.
(resolve-identifier): Pass the module to id-var-name when looking up
identifiers.
(free-id=?): Adapt to id-var-name change.
(chi-top-sequence): When adding a mapping from the given identifier
to a toplevel definition, make the name be a pair.
Andy Wingo [Mon, 7 Nov 2011 10:41:00 +0000 (11:41 +0100)]
add scoping test
* test-suite/tests/syntax.test ("top-level define"): Add a test for
module scoping of introduced identifiers.
Andy Wingo [Fri, 4 Nov 2011 18:37:04 +0000 (19:37 +0100)]
defined identifiers scoped in the current module
* ice-9/psyntax.scm (chi-top-sequence): Wrap defined identifiers with
the current module. Fixes http://savannah.gnu.org/bugs/?31472.
Andy Wingo [Sat, 5 Nov 2011 14:36:02 +0000 (15:36 +0100)]
syntax parameters implemented properly
* module/ice-9/psyntax.scm (resolve-identifier): Take an additional
argument, indicating whether syntax parameters should be resolved or
not. Just return three values: the binding type and value, and the
module for resolving toplevels.
(chi-install-global): Take an extra arg, the type. If we are defining
a syntax parameter, construct a pair for the binding.
(chi-body): Syntax parameters now use a per-parameter unique value (a
pair) as a key in the expansion-time environment `r'.
(syntax-parameterize): Don't allow parameterization of
non-parameters. This is an incompatible change, but it is for the
better; you don't want to allow users to parameterize `lambda', after
all.
Andy Wingo [Sat, 5 Nov 2011 12:53:33 +0000 (13:53 +0100)]
syntax-parameterize, not fluid-let-syntax
* module/ice-9/psyntax.scm (syntax-parameterize): Rename from
fluid-let-syntax.
* module/ice-9/boot-9.scm (define-inlinable): Use syntax-parameterize
(and define-syntax-parameter).
Andy Wingo [Sat, 5 Nov 2011 11:40:58 +0000 (12:40 +0100)]
add define-syntax-parameter, same as define-syntax
* module/ice-9/psyntax.scm (define-syntax-parameter): New toplevel form.
Will be used to implement syntax parameters, following Barzilay,
Culpepper, and Flatt's 2011 SFP workshop paper, "Keeping it Clean with
syntax-parameterize". Adds a new binding type and definition form.
Andy Wingo [Fri, 4 Nov 2011 17:50:38 +0000 (18:50 +0100)]
psyntax: resolve-identifier refactor
* module/ice-9/psyntax.scm (id-var-name): Add a nice long comment.
(lookup): Remove, as it is no longer used.
(resolve-identifier): New helper, replaces most uses of id-var-name
then `lookup'.
(syntax-type, syntax, set!, fluid-let-syntax): Adapt to use
resolve-identifier.
(free-id=?): Adapt to id-var-name returning syntax objects.
Andy Wingo [Fri, 4 Nov 2011 12:47:24 +0000 (13:47 +0100)]
chi-top-sequence refactor
* module/ice-9/psyntax.scm (chi-top-sequence): Reimplement, more like
chi-body. Instead of adding empty definitions to the toplevel, add
toplevel definitions to the wrap shared by all forms in the sequence.
Andy Wingo [Fri, 4 Nov 2011 12:44:41 +0000 (13:44 +0100)]
minor psyntax refactors
* module/ice-9/psyntax.scm (syntax-type): Remove redundant lexical
case.
(syntax-rules, define-syntax-rule): Use `_' instead of `dummy' for the
keyword.
* module/ice-9/boot-9.scm (define-syntax-rule): Remove redundant
definition.