Andy Wingo [Sun, 11 Mar 2012 09:57:05 +0000 (10:57 +0100)]
add bad-request printer
* module/web/request.scm (bad-request-printer): Add printer for these
exceptions.
Andy Wingo [Sun, 11 Mar 2012 09:29:06 +0000 (10:29 +0100)]
web server http: 400 Bad Request on bad requests
* module/web/server/http.scm (bad-request, http-read): If an exception
is raised while reading a response, write out a 400 Bad Request
response before closing the port.
Andy Wingo [Sun, 11 Mar 2012 09:24:08 +0000 (10:24 +0100)]
add exception printers for bad-header, bad-header-component
* module/web/http.scm (bad-header-component): Throw
'bad-header-component instead of 'bad-header.
(bad-header-printer, bad-header-component-printer): Add exception
printers.
Andy Wingo [Thu, 8 Mar 2012 22:50:41 +0000 (23:50 +0100)]
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.
BT Templeton [Thu, 8 Mar 2012 01:09:21 +0000 (20:09 -0500)]
elisp rng
* module/language/elisp/boot.el (random): New function.
BT Templeton [Thu, 8 Mar 2012 01:08:46 +0000 (20:08 -0500)]
elisp i/o
* module/language/elisp/boot.el (send-string-to-terminal)
(read-from-minibuffer, prin1-to-string): New functions.
BT Templeton [Thu, 8 Mar 2012 01:06:54 +0000 (20:06 -0500)]
elisp: symbol-name, intern
* module/language/elisp/boot.el (symbol-name, intern): New functions.
BT Templeton [Thu, 8 Mar 2012 01:05:16 +0000 (20:05 -0500)]
elisp: when, unless
* module/language/elisp/boot.el (when, unless): New macros.
BT Templeton [Thu, 8 Mar 2012 01:04:46 +0000 (20:04 -0500)]
elisp sequence functions
* module/language/elisp/boot.el (nreverse, assoc, assq, rplaca, rplacd)
(caar, cadr, cdar, cddr, dolist, stringp, string-equal, string=)
(substring, upcase, downcase, string-match, make-vector, mapc, aref)
(aset, concat): New functions.
BT Templeton [Wed, 7 Mar 2012 19:34:13 +0000 (14:34 -0500)]
integerp, wholenump return nil for non-numbers
* module/language/elisp/boot.el (integerp, wholenump): Call `integer?'
before `exact?' so that these predicates return nil for non-numbers
instead of signalling an error.
Andy Wingo [Thu, 8 Mar 2012 12:22:09 +0000 (13:22 +0100)]
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 Wingo [Fri, 24 Feb 2012 12:18:48 +0000 (13:18 +0100)]
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 Wingo [Sun, 19 Feb 2012 11:23:29 +0000 (12:23 +0100)]
use the new finalizer helpers
* libguile/foreign.c (scm_set_pointer_finalizer_x)
* libguile/ports.c (finalize_port)
* libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob)
* libguile/struct.c (scm_i_alloc_struct)
* libguile/numbers.c (make_bignum): Use the new API.
Andy Wingo [Sun, 19 Feb 2012 11:22:12 +0000 (12:22 +0100)]
add scm_i_set_finalizer, scm_i_add_finalizer, scm_i_add_resuscitator
* libguile/finalizers.h:
* libguile/finalizers.c: New files.
* libguile.h:
* libguile/Makefile.am: Add to build.
Andy Wingo [Thu, 26 May 2011 14:49:47 +0000 (16:49 +0200)]
scm_new_smob, scm_new_double_smob inline functions
* libguile/smob.h (scm_new_smob, scm_new_double_smob): New constructors,
which do what SCM_NEWSMOB / SCM_NEWSMOB3 had done, but with inline
functions instead of macros. They also bail to scm_i_new_smob /
scm_i_new_double_smob in either the mark or the free case, so that the
inline definition doesn't reference other internal details like libgc
stuff.
(SCM_SMOB_TYPE_MASK et al): Move definitions up so the new_smob see
them as already being declared.
(SCM_NEWSMOB, SCM_RETURN_NEWSMOB, SCM_NEWSMOB2, SCM_RETURN_NEWSMOB2):
(SCM_NEWSMOB3, SCM_RETURN_NEWSMOB3): Reimplement in terms of the new
inline functions.
Remove now-unneeded bdw-gc include.
* libguile/smob.c (finalize_smob): Rename from scm_i_finalize_smob, and
make static.
(scm_i_new_smob, scm_i_new_double_smob): Slow-path allocators.
(scm_i_finalize_smob, scm_i_new_smob_with_mark_proc): Add
back-compatibility shims to preserve ABI.
* libguile/inline.c: Include smob.h, so as to reify scm_new_smob and
scm_new_double_smob.
Andy Wingo [Thu, 26 May 2011 14:08:02 +0000 (16:08 +0200)]
scm_cell, scm_double_cell, scm_words back to gc.h
* libguile/inline.h:
* libguile/gc.h (scm_cell, scm_double_cell, scm_words): Move
declarations and definitions back here, from inline.h. It's more
natural.
* libguile/inline.c: Include gc.h as well.
Andy Wingo [Thu, 26 May 2011 13:53:02 +0000 (15:53 +0200)]
simplify inline function infrastructure
* libguile/__scm.h (SCM_C_EXTERN_INLINE): Move this definition here,
from inline.h. We'd like to support inline function definitions in
more header files: not just inline.h.
(SCM_CAN_INLINE, SCM_INLINE, SCM_INLINE_IMPLEMENTATION): New
definitions.
* libguile/gc.h (SCM_GC_MALLOC, SCM_GC_MALLOC_POINTERLESS): Define these
wrappers, which redirect to the GC_MALLOC macros when building Guile,
and the scm_gc_malloc functions otherwise. A step towards getting
BDW-GC out of Guile's API.
* libguile/inline.h: Simplify, using SCM_INLINE,
SCM_INLINE_IMPLEMENTATION, and SCM_IMPLEMENT_INLINES. Also use the
new SCM_GC_MALLOC macros.
Ian Price [Fri, 27 Jan 2012 06:38:09 +0000 (06:38 +0000)]
Fix flush on soft ports, so that it actually runs.
* libguile/vports.c (sf_flush): Remove conditional testing the
position in the port's write_buf, as it is no longer used.
Ludovic Courtès [Wed, 7 Mar 2012 21:50:44 +0000 (22:50 +0100)]
Change `scm_words' to accept a 32-bit word number.
Fixes <http://bugs.gnu.org/10914>.
Reported by Tobias Brandt <tob.brandt@googlemail.com>.
* libguile/gc.h (scm_words): Change `n_words' to be `scm_t_uint32'.
* libguile/inline.h: Update extraneous declaration.
Ludovic Courtès [Wed, 7 Mar 2012 20:57:58 +0000 (21:57 +0100)]
Improve port benchmark.
* benchmark-suite/benchmarks/ports.bm (sequence): New macro, formerly
local to the "rdelim" benchmark prefix.
(large-string): New procedure.
(%latin1-port, %utf8/ascii-port, %utf8/wide-port): Use it.
("peek-char", "char-ready?", "read-char"): Use `sequence'.
Giuseppe Scrivano [Tue, 21 Feb 2012 14:55:44 +0000 (15:55 +0100)]
Fix a segfault when /dev/urandom is not accessible
* libguile/init.c (scm_i_init_guile): Call `scm_init_random' before
`scm_init_macros'.
Andy Wingo [Wed, 7 Mar 2012 18:01:56 +0000 (19:01 +0100)]
faster (make-prompt-tag); default-prompt-tag is a parameter
* module/ice-9/boot-9.scm (default-prompt-tag): Once parameters have
booted, redefine as a parameter.
(make-prompt-tag): Change from a gensym to a list. Thanks to Mark
Weaver for the suggestion.
* doc/ref/api-control.texi (Prompt Primitives): Update docs.
Andy Wingo [Wed, 7 Mar 2012 12:34:06 +0000 (13:34 +0100)]
call-with-{input,output}-string implemented in scheme
* module/ice-9/boot-9.scm (call-with-input-string)
(call-with-output-string): Implement in Scheme.
* libguile/strports.c (scm_call_with_output_string):
(scm_call_with_input_string): Dispatch to Scheme.
Andy Wingo [Wed, 7 Mar 2012 11:39:30 +0000 (12:39 +0100)]
micro-optimizations to string-trim-both, and to (web http)
* libguile/srfi-13.c (scm_string_trim, scm_string_trim_right)
(scm_string_trim_both): Take the whitespace fast-path if the char_pred
is scm_char_set_whitespace.
* module/web/http.scm (read-header, split-and-trim, parse-quality-list):
(parse-param-component, parse-credentials, "Content-Type"):
(read-request-line, read-response-line): Use char-set:whitespace
instead of char-whitespace?. It avoids recursing into the VM.
Andy Wingo [Wed, 7 Mar 2012 11:10:28 +0000 (12:10 +0100)]
names of encodings are ascii
* libguile/ports.c (scm_mode_bits): Parse the mode bits as latin1.
(scm_i_set_default_port_encoding, open_iconv_descriptors)
(scm_port_encoding, scm_set_port_encoding_x): Restrict the names of
encodings to ASCII.
Andy Wingo [Wed, 7 Mar 2012 09:27:16 +0000 (10:27 +0100)]
dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
Andy Wingo [Tue, 6 Mar 2012 21:22:31 +0000 (22:22 +0100)]
micro-optimization in (web server)
* module/web/server.scm (extend-response): Micro-optimize to not mutate
data, and to copy as little as possible.
Andy Wingo [Tue, 6 Mar 2012 21:21:39 +0000 (22:21 +0100)]
ports.c: inline get_codepoint
* libguile/ports.c (get_codepoint): Add inline keyword. It showed up
high in benchmarks, and it's static, so it's probably important to
inline.
Andy Wingo [Tue, 6 Mar 2012 10:19:06 +0000 (11:19 +0100)]
optimize symbol printing
* libguile/print.h: Remove internal declaration of
scm_i_print_symbol_name.
* libguile/print.c (symbol_has_extended_read_syntax): Optimize to avoid
calling symbol_to_string if we know the symbol cannot be mistaken for
a number.
(print_normal_symbol): Optimize to call display_string directly,
instead of jumping through scm_display.
(print_symbol): Rename from scm_i_print_symbol_name.
(scm_print_symbol_name, iprin1): Adapt to print_symbol name change.
Andy Wingo [Mon, 5 Mar 2012 23:51:31 +0000 (00:51 +0100)]
shuffle r4rs procedures into boot-9
* module/ice-9/boot-9.scm: Refine a comment about low-level port
functions. Move call-with-foo-port, with-input-from-foo, etc later in
the file, and define using `parameterize' instead of `dynamic-wind'.
Somewhat cleaner, and avoids thunk? checks for "swaports" in the old
implementation.
Andy Wingo [Mon, 5 Mar 2012 23:44:01 +0000 (00:44 +0100)]
load parameters earlier in boot-9
* module/ice-9/boot-9.scm: Move parameters earlier in the boot process.
The new with-output-to-port code will use it.
Andy Wingo [Mon, 5 Mar 2012 23:36:25 +0000 (00:36 +0100)]
slight tweak to file-exists?, file-is-directory?
* module/ice-9/boot-9.scm (file-exists?, file-is-directory?): For the
fallback cases, use open-input-file instead of open-file with
OPEN_READ.
Andy Wingo [Mon, 5 Mar 2012 23:34:59 +0000 (00:34 +0100)]
bootstrapping shenanigans in `warn'
* module/ice-9/boot-9.scm (warn): Don't use with-output-to-port, as
we'll move that definition after the psyntax boot.
Andy Wingo [Mon, 5 Mar 2012 23:33:14 +0000 (00:33 +0100)]
more clear comments in boot-9.scm
* module/ice-9/boot-9.scm: Update comment header for language
primitives.
Andy Wingo [Mon, 5 Mar 2012 23:31:13 +0000 (00:31 +0100)]
remove deprecated close-io-port
* module/ice-9/boot-9.scm (close-io-port): Remove proc that was
deprecated in 2.0.
Andy Wingo [Mon, 5 Mar 2012 22:33:50 +0000 (23:33 +0100)]
inline ice-9/r4rs.scm into ice-9/boot-9.scm
* module/ice-9/boot-9.scm: Inline r4rs.scm, in anticipation of more
refactorings.
* module/ice-9/r4rs.scm: Remove.
* module/Makefile.am: Update.
BT Templeton [Mon, 5 Mar 2012 23:10:29 +0000 (18:10 -0500)]
use #nil as default for elisp rest parameters
* module/langauge/elisp/compile-tree-il.scm (compile-lambda): Bind the
rest parameter to `#nil' instead of `()' by default.
Andy Wingo [Mon, 5 Mar 2012 22:52:00 +0000 (23:52 +0100)]
deprecate close-io-port
* module/ice-9/r4rs.scm:
* module/ice-9/deprecated.scm (close-io-port): Deprecate.
BT Templeton [Mon, 5 Mar 2012 21:52:05 +0000 (16:52 -0500)]
Merge branch 'bt/elisp'
Conflicts:
am/guilec
libguile/_scm.h
libguile/vm-i-scheme.c
module/language/elisp/compile-tree-il.scm
module/language/elisp/runtime.scm
module/language/elisp/runtime/macros.scm
module/language/tree-il/compile-glil.scm
module/language/tree-il/primitives.scm
Mark H Weaver [Mon, 5 Mar 2012 03:47:04 +0000 (22:47 -0500)]
Don't call SYMBOL_STRINGBUF on a string
* libguile/strings.c (scm_i_make_symbol): Use STRING_STRINGBUF
instead of SYMBOL_STRINGBUF to get the stringbuf of a string.
Mark H Weaver [Mon, 5 Mar 2012 03:12:48 +0000 (22:12 -0500)]
Remove documentation of internal static string comparison functions
* doc/ref/api-data.texi (String Comparison): Remove documentation for
scm_i_string{,_ci}_{equal,less,leq,gr,geq}_p, which are not only
internal functions but static, and thus unusable by external code.
Mark H Weaver [Sun, 4 Mar 2012 17:01:10 +0000 (12:01 -0500)]
Comment out unused definitions of 'do' and 'case' in psyntax.scm
* module/ice-9/psyntax.scm (do, case): Comment out these definitions,
which are never used and immediately replaced by definitions in
boot-9.scm.
* module/ice-9/psyntax-pp.scm: Regenerate.
Mark H Weaver [Sun, 4 Mar 2012 16:53:23 +0000 (11:53 -0500)]
Fix syntax wrap comments; remove old unused cruft
* module/ice-9/psyntax.scm (subst-rename?, rename-old, rename-new,
rename-marks, make-rename): Remove these unused syntax rules.
Fix description of syntax wraps to match current reality.
Mark H Weaver [Sun, 4 Mar 2012 01:20:16 +0000 (20:20 -0500)]
Merge branch 'stable-2.0'
Conflicts:
module/ice-9/psyntax-pp.scm
module/language/tree-il.scm
Mark H Weaver [Fri, 2 Mar 2012 23:40:43 +0000 (18:40 -0500)]
Minimize size of embedded syntax objects in psyntax-pp.scm
* module/ice-9/compile-psyntax.scm: Minimize syntax object literals
embedded in psyntax-pp.scm.
* module/ice-9/psyntax.scm: Rename a few variables so that syntax
objects embedded in macros have no lexical bindings, so that their
minimized syntax objects will have no embedded labels. These labels
were the last remaining gensym counters in psyntax-pp.scm.
* module/ice-9/psyntax-pp.scm: Regenerate. It is now less than one
quarter of its previous size! More importantly, this file no longer
contains any gensym counters, which means that in the future, local
changes to psyntax.scm will usually result in only local changes to
psyntax-pp.scm.
Mark H Weaver [Thu, 1 Mar 2012 22:56:14 +0000 (17:56 -0500)]
tree-il->scheme improvements
* module/language/tree-il.scm (tree-il->scheme): New implementation that
simply calls 'decompile-tree-il'.
* module/language/scheme/decompile-tree-il.scm (choose-output-names,
do-decompile): New internal procedures.
(decompile-tree-il): New and improved implementation. Print source
identifiers where possible, otherwise add minimal numeric suffixes.
Previously we printed the gensyms. Avoid 'begin' in contexts that
provide an implicit 'begin'. Produce 'cond', 'case', 'and', 'or',
'let*', named let, and internal defines where appropriate. Recognize
keyword arguments in 'opts' to disable the production of these derived
syntactic forms, and to optionally strip numeric suffixes from
variable names.
* module/ice-9/compile-psyntax.scm: Disable partial evaluation, letrec
fixing, and primitive expansion when producing psyntax-pp.scm, in
order to produce output as close to the original source as practical.
Disable production of derived syntactic forms as needed during
bootstrap. Strip numeric suffixes from variable names. Adjust
pretty-printing parameters.
* module/ice-9/psyntax-pp.scm: Regenerate. It is now less than half
of the original size.
Andy Wingo [Sat, 3 Mar 2012 20:46:38 +0000 (21:46 +0100)]
optimize dynamic-wind when we know winders are thunks
* libguile/vm-i-system.c (wind):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
Instead of making `wind' call `scm_thunk_p' on the winder and unwinder
at runtime, make it the responsibility of the compiler to emit code to
call thunk? and error, but only if the compiler cannot prove them to
be thunks.
* libguile/vm-engine.c (vm_engine): Remove a now-unused error block.
Andy Wingo [Sat, 3 Mar 2012 20:06:49 +0000 (21:06 +0100)]
remove out-of-date comment
* libguile/dynwind.c (scm_dynwind_end): Remove out-of-date comment.
Andy Wingo [Sat, 3 Mar 2012 16:01:16 +0000 (17:01 +0100)]
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
Mark H Weaver [Sun, 26 Feb 2012 20:58:30 +0000 (15:58 -0500)]
pretty-print: allow max-expr-width to be set; recognize more keywords
* module/ice-9/pretty-print.scm (pretty-print): Add new keyword argument
'#:max-expr-width'.
(generic-write): Add new argument 'max-expr-width'. Previously this
was internally defined to the constant value 50.
Mark H Weaver [Fri, 2 Mar 2012 22:54:23 +0000 (17:54 -0500)]
Fix typos in psyntax.scm
* module/ice-9/psyntax.scm (gen-syntax-case): #'pad --> #'pat
(define*): #'x --> #'id
* module/ice-9/psyntax-pp.scm: Regenerate
Andy Wingo [Sun, 26 Feb 2012 22:02:16 +0000 (23:02 +0100)]
comment formatting in ports.c
* libguile/ports.c: Fix comment.
Andy Wingo [Fri, 2 Mar 2012 17:26:56 +0000 (18:26 +0100)]
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.
Andy Wingo [Fri, 2 Mar 2012 16:46:52 +0000 (17:46 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Fri, 2 Mar 2012 16:46:28 +0000 (17:46 +0100)]
tweaks to -Wformat's gettext detection
* module/language/tree-il/analyze.scm (proc-ref?): Change to use less
false-if-exception and more variable-bound?. If a variable is present
in the local module but not bound, assume that it is gettext if it has
the right name. This is to allow for (define _ gettext).
* test-suite/tests/tree-il.test ("warnings"): Update (_ "foo") example.
Andy Wingo [Fri, 2 Mar 2012 16:20:47 +0000 (17:20 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
There are a some failures currently:
FAIL: tree-il.test: warnings: format: non-literal format string with forward declaration
ERROR: srfi-18.test: current-exception-handler: current handler returned at top level - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
ERROR: srfi-18.test: current-exception-handler: multiple levels of handler nesting - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
ERROR: srfi-18.test: current-exception-handler: exception handler installation is thread-safe - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
Conflicts:
module/language/tree-il/peval.scm
module/language/tree-il/primitives.scm
test-suite/tests/tree-il.test
Andy Wingo [Fri, 2 Mar 2012 14:51:05 +0000 (15:51 +0100)]
peval: inline applications of lambda to rest args
* module/language/tree-il/peval.scm (peval): Add optimization to
hoist the inner procedure out of e.g.
(lambda args (apply (lambda ...) args))
This commit restores the ability to detect escape-only prompts at
compile-time.
* test-suite/tests/tree-il.test: Update test for prompt with a lambda,
and add a specific test for lambda application.
Andy Wingo [Fri, 2 Mar 2012 15:39:56 +0000 (16:39 +0100)]
tree-il: fix `canonicalize!' for prompts
* module/language/tree-il/canonicalize.scm (canonicalize!): Fix a bug in
which the sense of `escape-only?' was reversed. We never saw this
though, because for other reasons, no prompts were being identified as
escape-only.
Andy Wingo [Fri, 2 Mar 2012 12:02:19 +0000 (13:02 +0100)]
more general treatment of call-with-prompt
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Don't limit the call-with-prompt to <prompt> transition to lambda
expressions. Instead we can lexically bind the handler, and rely on
peval to propagate a lambda expression.
Mark H Weaver [Sun, 26 Feb 2012 20:53:11 +0000 (15:53 -0500)]
pmatch: always wrap with let, even if the expression appears atomic
* module/system/base/pmatch.scm (pmatch): Always wrap with 'let', even
if the expression appears atomic, because in the presence of
'identifier-syntax', we cannot know what an atomic expression will
later expand to. Also use '#:export-syntax' instead of '#:export'
to export 'pmatch'.
Mark H Weaver [Thu, 1 Mar 2012 21:07:28 +0000 (16:07 -0500)]
Fix <TAG>vector-length when applied to other uniform vector types
* module/srfi/srfi-4.scm, module/srfi/srfi-4/gnu.scm
(define-bytevector-type): Fix definition of <TAG>vector-length when
applied to uniform vectors of different element sizes. Thanks to
Tobias Brandt <tob.brandt@googlemail.com> for reporting this bug.
* test-suite/tests/srfi-4.test: Add tests.
Ludovic Courtès [Sun, 26 Feb 2012 23:51:09 +0000 (00:51 +0100)]
Avoid failure when `format-analysis' stumbles upon unbound variables.
* module/language/tree-il/analyze.scm (proc-ref?): Wrap `variable-ref'
in `false-if-exception'.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string with forward declaration"): New test.
Andy Wingo [Fri, 24 Feb 2012 22:05:02 +0000 (23:05 +0100)]
port i/o optimizations for iso-8859-1
* libguile/ports.h (scm_t_port_encoding_mode):
* libguile/ports.c (scm_c_make_port_with_encoding):
(scm_i_set_port_encoding_x): Add special treatment for latin1
encoding.
(get_latin1_codepoint, get_codepoint): Add latin1 fast-path.
* libguile/print.c (display_string_as_latin1): Add latin1 fastpath.
Andy Wingo [Fri, 24 Feb 2012 22:03:31 +0000 (23:03 +0100)]
fixes to threaded finalizers
* libguile/finalizers.c (finalization_thread_proc):
(run_finalization_thread):
(start_finalization_thread):
(stop_finalization_thread): Use pthreads + scm_with_guile instead of
scm_spawn_thread, to avoid deadlocks.
Andy Wingo [Fri, 24 Feb 2012 19:01:47 +0000 (20:01 +0100)]
srfi-18 test fix
* test-suite/tests/srfi-18.test: Enclose the tests in a begin instead of
an and. Before, they were not being run, for some reason I don't
fully understand.
Andy Wingo [Fri, 24 Feb 2012 18:58:45 +0000 (19:58 +0100)]
slight cleanup to run-test
* test-suite/lib.scm (run-test): Slight cleanup.
Andy Wingo [Fri, 24 Feb 2012 18:42:00 +0000 (19:42 +0100)]
srfi-18 cleanup
* module/srfi/srfi-18.scm (with-exception-handler):
(thread-join!, mutex-lock!, mutex-unlock!): Avoid useless invocations
of `apply'.
Andy Wingo [Fri, 24 Feb 2012 17:57:37 +0000 (18:57 +0100)]
statically initialize the pthread mutex in fat mutexen
* libguile/threads.c (make_fat_mutex): Remove smob free function.
Because we use normal mutexen, we can just blit the mutex to
initialize it.
Andy Wingo [Fri, 24 Feb 2012 12:18:48 +0000 (13:18 +0100)]
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 Wingo [Fri, 24 Feb 2012 10:20:21 +0000 (11:20 +0100)]
signal an error on multithreaded fork
* libguile/posix.c (scm_fork): Signal an error if a `fork' is attempted
after threads have been spawned.
* test-suite/tests/00-socket.test: Moved here, from socket.test, so as
to run before any threads are created.
* test-suite/Makefile.am: Adapt.
Andy Wingo [Thu, 23 Feb 2012 13:20:48 +0000 (14:20 +0100)]
remove atfork on revealed mutex in fports.c
* libguile/fports.c: Remove atfork call.
Andy Wingo [Thu, 23 Feb 2012 13:18:57 +0000 (14:18 +0100)]
Revert "add pthread_atfork helpers to our threading shims"
This reverts commit
2f745b64a1eb06e9e175a1b497d5270bebff9097.
Andy Wingo [Thu, 23 Feb 2012 13:18:56 +0000 (14:18 +0100)]
Revert "with a threaded guile, lock weak sets and tables during a fork"
This reverts commit
f609480611cfd1585409fd6b1b90beb730b026cf.
Andy Wingo [Thu, 23 Feb 2012 13:18:56 +0000 (14:18 +0100)]
Revert "install pthread_atfork handlers for guile's static mutexen"
This reverts commit
6a97b1f93aace5c7c976aef51d36b3ae9cfd5630.
Andy Wingo [Thu, 23 Feb 2012 13:18:52 +0000 (14:18 +0100)]
Revert "wrap iconv_open / iconv_close with a lock to help in thread/fork issues"
This reverts commit
8dfb7bbfd908ca883d0fdd0d868e13e6b20803ae.
Andy Wingo [Thu, 23 Feb 2012 13:10:22 +0000 (14:10 +0100)]
Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
module/language/tree-il/analyze.scm
Andy Wingo [Thu, 23 Feb 2012 12:56:06 +0000 (13:56 +0100)]
rewrite open-process in C, for robustness
* libguile/posix.c (scm_open_process): Rewrite in C, so as to avoid
allocations and other calls that are not async-signal-safe.
(scm_init_popen, scm_init_posix): Register popen extension.
* module/ice-9/popen.scm: Load the popen extension, to get open-process.
Andy Wingo [Wed, 22 Feb 2012 19:40:55 +0000 (20:40 +0100)]
microoptimizations in (web uri)
* module/web/uri.scm (valid-host?): Micro-optimizations.
Andy Wingo [Wed, 22 Feb 2012 19:08:44 +0000 (20:08 +0100)]
add test for recent quick fix
* test-suite/tests/web-uri.test ("string->uri"): Add test for
string->uri with hosts beginning in digits.
Andy Wingo [Tue, 21 Feb 2012 16:50:55 +0000 (16:50 +0000)]
quick fix the quick fix
Andy Wingo [Tue, 21 Feb 2012 16:42:53 +0000 (16:42 +0000)]
quick fix to uri parser
* module/web/uri.scm: Quick fix to not throw an error on e.g.
http://2012.jsconf.us.
Noah Lavine [Sat, 18 Feb 2012 15:55:49 +0000 (10:55 -0500)]
Optimize Equality Primitives
* module/language/tree-il/primitives.scm: add equality-primitive?,
which is true for eq?, eqv?, and equal?
* module/language/tree-il/peval.scm: if an equality primitive is
applied to the same variable twice, fold it to #t
* test-suite/tests/tree-il.test: add tests for pevaling equality
primitives
Ludovic Courtès [Sun, 19 Feb 2012 22:54:18 +0000 (23:54 +0100)]
Have `-Wformat' recognize `ngettext' calls.
* module/language/tree-il/analyze.scm (gettext?): Rename to...
(proc-ref?): ... this. Add `proc' and `special-name' parameters.
(gettext?): Define in terms of `proc-ref?'.
(ngettext?): New procedure.
(const-fmt): Recognize `ngettext' calls.
(format-analysis)[<down>](check-format-args]: Check
constant-but-non-string 2nd argument in the (not (const-fmt ...))
case.
[check-simple-format-args]: Use `const-fmt'.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string using ngettext", "non-literal format string using
ngettext as N_"): New tests.
("simple-format")["unsupported, ngettext"]: New test.
Ludovic Courtès [Sun, 19 Feb 2012 22:08:49 +0000 (23:08 +0100)]
Have `-Wformat' better recognize the `gettext' procedure.
Fixes <http://bugs.gnu.org/10846>.
Reported by Bruno Haible <bruno@clisp.org>.
* module/language/tree-il/analyze.scm (gettext?): New procedure.
(const-fmt): Add `env' parameter; update callers. Use `gettext?'.
(format-analysis)[check-simple-format-args]: Actually support
gettextized format strings.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string using gettext"): Use `gettext' as the procedure name.
("non-literal format string using gettext as _"): New test.
["simple-format"]("unsupported, gettext"): New test.
Andy Wingo [Sun, 19 Feb 2012 11:23:29 +0000 (12:23 +0100)]
use the new finalizer helpers
* libguile/foreign.c (scm_set_pointer_finalizer_x)
* libguile/ports.c (finalize_port, scm_c_make_port_with_encoding)
(open_iconv_descriptors)
* libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob)
* libguile/struct.c (scm_i_alloc_struct)
* libguile/weak-set.c (weak_gc_finalizer)
(scm_c_register_weak_gc_callback)
* libguile/weak-table.c (scm_c_register_weak_gc_callback)
(weak_gc_finalizer)
* libguile/numbers.c (make_bignum): Use the new API.
Andy Wingo [Sun, 19 Feb 2012 11:22:12 +0000 (12:22 +0100)]
add scm_i_set_finalizer, scm_i_add_finalizer, scm_i_add_resuscitator
* libguile/finalizers.h:
* libguile/finalizers.c: New files.
* libguile.h:
* libguile/Makefile.am: Add to build.
Andy Wingo [Sun, 19 Feb 2012 19:34:26 +0000 (20:34 +0100)]
better hysteresis in weak-set, weak-table
* libguile/weak-set.c:
* libguile/weak-table.c: Attempt to avoid bouncing between sizes when
growing the vector causes elements to be removed from the set/table.
Andy Wingo [Sun, 19 Feb 2012 14:19:14 +0000 (15:19 +0100)]
tune default hash table sizes
* libguile/modules.c: In my current image, there are 1790 bindings in
the root module, which tips over to the next hash vector size, so
declare that to prevent rehashing.
* libguile/srcprop.c (scm_init_srcprop): Don't preallocate a big
source_whash table, as we might not need it (if everything is
compiled, for example).
* module/ice-9/boot-9.scm (make-module): Don't preall-cate big hash
tables for imported bindings. Instead trust that resizing works
correctly.
Andy Wingo [Sun, 19 Feb 2012 11:34:20 +0000 (12:34 +0100)]
move revealed-count mechanism to fports.c
* libguile/fports.c (scm_revealed_count, scm_port_revealed)
(scm_set_port_revealed_x, scm_adjust_port_revealed_x): Move these APIs
here, and only operate on fports. To keep revealed ports alive, now
we will just keep them in a data structure that the GC knows about --
a static list.
* libguile/fports.h: Add revealed count to scm_t_fport, and move decls
of revealed-count functions here.
* libguile/ports.h:
* libguile/ports.c: Adapt to change. Remove SCM_REVEALED and
SCM_SETREVEALED; since they only apply to fports now, keeping them
around would be inviting type errors.
(finalize_port): We don't need to worry about resuscitating ports
here.
* libguile/init.c: Use the scm_set_port_revealed_x function to set the
revealed counts on stream ports.
Andy Wingo [Sun, 19 Feb 2012 12:29:59 +0000 (13:29 +0100)]
ice-9/poll optimization
* module/ice-9/poll.scm (poll-set-add!): Use fileno instead of
port->fdes, to avoid manipulating revealed counts.
Ludovic Courtès [Fri, 17 Feb 2012 23:04:17 +0000 (00:04 +0100)]
Don't fail when locale env. vars specify a dot-less locale name.
Fixes <http://bugs.gnu.org/10742>.
Reported by Alírio Eyng <alirioeyng@ig.com.br>.
* gnulib-local/lib/localcharset.c.diff (environ_locale_charset): Change
to set CODESET to "" when LOCALE lacks a dot. Return "ISO-8859-1"
when CODESET is the empty string.
* lib/localcharset.c: Update.
* test-suite/standalone/Makefile.am (check_SCRIPTS): Add
`test-command-line-encoding2'.
(TESTS): Likewise.
* test-suite/standalone/test-command-line-encoding2: New file.
Andy Wingo [Tue, 14 Feb 2012 13:30:48 +0000 (14:30 +0100)]
wrap iconv_open / iconv_close with a lock to help in thread/fork issues
* libguile/bytevectors.c (STRING_TO_UTF, scm_string_to_utf8)
(UTF_TO_STRING):
* libguile/ports.c (open_iconv_descriptors, close_iconv_descriptors):
* libguile/strings.c (scm_from_stringn, scm_to_stringn): Wrap operations
that acquire and destroy iconv contexts with a mutex. While iconv is
threadsafe, internally it uses a lock, and we need to make sure when
we fork() that no one has that lock -- so we surround it with another
one. Gross.
Andy Wingo [Wed, 8 Feb 2012 18:57:41 +0000 (19:57 +0100)]
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 Wingo [Fri, 17 Feb 2012 10:35:02 +0000 (11:35 +0100)]
add pthread_atfork helpers to our threading shims
* libguile/null-threads.h:
* libguile/pthread-threads.h (SCM_DEFINE_ATFORK_HANDLERS_FOR_MUTEX)
(scm_i_pthread_atfork): Define a pthread_atfork shim, and a helper to
declare procedures to lock and unlock a mutex.
* libguile/threads.h (SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX): New macro,
causes the snarfer to emit a pthread_atfork call to lock a mutex, if
threads are enabled.
Andy Wingo [Fri, 17 Feb 2012 10:47:52 +0000 (11:47 +0100)]
with a threaded guile, lock weak sets and tables during a fork
* libguile/weak-set.c (make_weak_set):
* libguile/weak-table.c (make_weak_table): If we have a threaded Guile,
* keep a weak set (table) of weak sets (tables). Use this and the
pthread_atfork mechanism to lock and unlock weak sets and weak tables
during a fork().
* libguile/weak-set.h (scm_weak_set_prehistory): New internal API.
* libguile/init.c: Add call to scm_weak_set_prehistory().
Andy Wingo [Fri, 17 Feb 2012 09:21:50 +0000 (10:21 +0100)]
Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
libguile/read.c
libguile/srcprop.c
module/ice-9/psyntax-pp.scm
Andy Wingo [Wed, 15 Feb 2012 22:40:42 +0000 (23:40 +0100)]
remove deprecated features test
* test-suite/tests/procprop.test ("procedure-arity"): Remove a test of
deprecated features.
Andy Wingo [Wed, 15 Feb 2012 22:04:53 +0000 (23:04 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
module/ice-9/psyntax-pp.scm
Mark H Weaver [Wed, 15 Feb 2012 17:23:12 +0000 (12:23 -0500)]
Add tests to verify that 'read' sets source properties when appropriate
* test-suite/tests/srcprop.test (source properties): Add tests.
Mark H Weaver [Wed, 15 Feb 2012 16:47:31 +0000 (11:47 -0500)]
Add support for source properties on non-immediate numbers
* libguile/read.c (scm_read_number): Set source properties on
non-immediate numbers if the 'positions' reader option is set.
* doc/ref/api-debug.texi (Source Properties): Update manual.