Neil Jerram [Sun, 8 May 2011 20:36:54 +0000 (21:36 +0100)]
Fix "occurrances" typos in getopt-long code and test
* module/ice-9/getopt-long.scm (process-options, getopt-long): Change
to "occurrences".
* test-suite/tests/getopt-long.test ("multiple occurrences"): Same
again.
Andy Wingo [Thu, 26 May 2011 16:29:05 +0000 (18:29 +0200)]
leave guile when reading signal pipe
* libguile/scmsigs.c (read_signal_pipe_data, signal_delivery_thread):
Leave guile when reading from the signal pipe. Hopefully that lets GC
know not to wake up this thread.
Andy Wingo [Thu, 26 May 2011 16:14:32 +0000 (18:14 +0200)]
lazily init futures worker pool
* module/ice-9/futures.scm (%workers, %create-workers!)
(create-workers!): Define a mechanism to spawn off the future threads
only when the first future is created.
(make-future): Call create-workers! here.
Andy Wingo [Thu, 26 May 2011 13:58:42 +0000 (15:58 +0200)]
remove scm_newcell_count, scm_newcell2_count
* libguile/inline.h:
* libguile/gc.c: Remove declaration and definition of unused
"scm_newcell_count" and "scm_newcell2_count". Since SCM_INTERNAL is
"extern", these symbols were not externally visible anyway, at least
under Linux or Windows.
Andy Wingo [Thu, 26 May 2011 10:34:30 +0000 (12:34 +0200)]
deprecate scm_immutable_{double_,}cell
* libguile/inline.h:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_immutable_cell, scm_immutable_double_cell):
Deprecate these, as the GC_STUBBORN API doesn't do anything any more.
* libguile/strings.c (scm_i_c_make_symbol): Change the one use of
scm_immutable_double_cell to scm_double_cell.
Mark H Weaver [Wed, 25 May 2011 16:31:21 +0000 (12:31 -0400)]
Clarify docs for SCM_UNSPECIFIED: used sometimes but not always
* doc/ref/data-rep.texi (Immediate objects): Clarify the description
of SCM_UNSPECIFIED. It is returned by some (but not all) expressions
whose value is unspecified by the Scheme standard.
Andy Wingo [Wed, 25 May 2011 08:27:46 +0000 (10:27 +0200)]
out-of-tree build fix
* test-suite/standalone/Makefile.am (GUILE_AUTO_COMPILE): Add srcdir to
the environment.
* test-suite/standalone/test-import-order: Look for the modules in the
srcdir. Fixes out-of-tree builds.
Andy Wingo [Tue, 24 May 2011 20:52:39 +0000 (22:52 +0200)]
threadsafe addition to the goops vtable_class_map
* libguile/goops.c (scm_i_define_class_for_vtable): Lock around
additions to the vtable_class_map. Use is unlocked though; solving
GOOPS parallel-initialization would be a good thing.
Andy Wingo [Tue, 24 May 2011 20:46:09 +0000 (22:46 +0200)]
threadsafe access to source properties weak hash table
* libguile/srcprop.c: Add a lock around scm_source_whash, and use it.
Andy Wingo [Tue, 24 May 2011 19:25:11 +0000 (21:25 +0200)]
read + source properties simplification
* libguile/srcprop.h: Remove internal scm_source_whash declaration.
* libguile/srcprop.c (scm_i_set_source_properties_x)
(scm_i_has_source_properties): New helpers.
(scm_source_whash): Make static.
* libguile/read.c (scm_read_sexp): Remove register declarations here;
let's trust the compiler. Remove code to incrementally build up a
copy; instead let's let scm_i_set_source_properties_x handle copying
the expression if needed.
(scm_read_quote, scm_read_syntax): Use scm_i_set_source_properties_x.
(recsexpr): Remove this helper from 1996.
(scm_read_sharp_extension): Instead of trying to recursively label
sharp-read subforms with source properties, just label the outside
form and rely on the macro-expander to propagate it down.
Andy Wingo [Tue, 24 May 2011 19:09:24 +0000 (21:09 +0200)]
safely access the trampoline weak map
* libguile/smob.c (scm_i_smob_apply_trampoline): Protect the trampoline
weak map with a mutex.
Andy Wingo [Mon, 23 May 2011 20:38:13 +0000 (22:38 +0200)]
set-procedure-property! threadsafety issue
* libguile/procprop.c (scm_set_procedure_property_x): Fix a threadsafety
bug pointed out by Ken Raeburn.
Andy Wingo [Mon, 23 May 2011 20:24:27 +0000 (22:24 +0200)]
really threadsafe access to symbol table
* libguile/symbols.c (symbols_lock): Rename from intern_lock.
(lookup_interned_symbol, lookup_interned_latin1_symbol): Instead of
faith-based programming, just use the mutex. Though I haven't seen
this break, Ken is right!
Mark H Weaver [Sun, 22 May 2011 19:23:27 +0000 (15:23 -0400)]
Don't call scm_lock_mutex and scm_unlock_mutex via pointer of wrong type
* libguile/threads.c (lock_mutex_return_void, unlock_mutex_return_void):
New static functions that simply call scm_lock_mutex and
scm_unlock_mutex, respectively, but return void instead of SCM.
(scm_dynwind_lock_mutex): Pass unlock_mutex_return_void to
scm_dynwind_unwind_handler_with_scm, and lock_mutex_return_void to
scm_dynwind_rewind_handler_with_scm. Previously, we passed
scm_unlock_mutex and scm_lock_mutex (which return SCM), but the
scm_dynwind_* functions expect pointers to functions which return
void. When SCM is of type union, this changes the calling conventions
of the functions on some platforms (e.g. GCC 4.5.2 and 4.5.3 on x86).
Andy Wingo [Sat, 21 May 2011 16:29:03 +0000 (18:29 +0200)]
fix define-module ordering
* module/ice-9/boot-9.scm (define-module): Fix to load the #:use-module
clauses in the order in which they appear in the define-module form.
Thanks to Jan Nieuwenhuizen for the report.
* test-suite/standalone/test-import-order: Add new test that
define-module and use-modules resolve the interface in the right
order.
* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-import-order-a.scm:
* test-suite/standalone/test-import-order-b.scm:
* test-suite/standalone/test-import-order-c.scm:
* test-suite/standalone/test-import-order-d.scm: Aux files.
Andy Wingo [Sat, 21 May 2011 11:12:44 +0000 (13:12 +0200)]
(syntax foo) -> #'foo in goops
* module/oop/goops.scm: Change instances of (syntax foo) to #'foo.
Andy Wingo [Fri, 20 May 2011 15:41:06 +0000 (17:41 +0200)]
clocktime freebsd portability
* libguile/stime.c (HAVE_POSIX_CPUTIME): Hack around buggy FreeBSD
implementation of _POSIX_CPUTIME.
Andy Wingo [Fri, 20 May 2011 10:50:08 +0000 (12:50 +0200)]
fix compile error in mingw fstat socket detection
* libguile/filesys.c (fstat_Win32) [__MINGW32__]: Apparently there is no
_S_IFSOCK on mingw32. Thanks to Volker Grabsch for the report.
Andy Wingo [Fri, 20 May 2011 10:26:53 +0000 (12:26 +0200)]
gen-scmconfig cross-compilation fix
* libguile/Makefile.am (gen-scmconfig.$(OBJEXT)): Fix
cross-compilation. Thanks to Volker Grabsch for the report!
Andy Wingo [Fri, 20 May 2011 09:54:46 +0000 (11:54 +0200)]
fix documentation for option-set! syntaxen
* doc/ref/api-evaluation.texi (Scheme Read): Note that read-set! is
syntax.
(Scheme Write): Likewise for print-set!.
* doc/ref/api-io.texi (Writing): Remove reference to
print-options-interface.
* doc/ref/repl-modules.texi (Readline Options): Update, and add entries
for readline-options, readline-set! et al.
Andreas Rottmann [Sat, 14 May 2011 17:29:26 +0000 (19:29 +0200)]
Improve R6RS conformance wrt. conditions in the I/O libraries
* module/rnrs/io/ports.scm (open-file-output-port): Handle `no-fail'
file option.
(with-i/o-filename-conditions): Use `with-throw-handler' instead of `catch'.
(with-i/o-port-error,
with-textual-output-conditions. with-textual-input-conditions): New
exception-conversion helpers.
(put-char, put-datum, put-string, display): Use
`with-textual-output-conditions' instead of `with-i/o-encoding-error'
to get proper conditions in case of write errors.
(get-char, get-datum, get-line, get-string-all, lookahead-char):
Likewise, for the input case.
* test-suite/tests/r6rs-ports.test (pass-if-condition, test-file,
make-failing-port): New helpers.
("8.2.10 Output ports"): Add some tests for `open-file-output-port'.
("8.2.9 Textual Input"): Add tests read error conditions.
("8.2.12 Textual Output"): Add tests for write error conditions.
("8.3 Simple I/O"): Add tests for conditions, `call-with-input-file'
and `call-with-output-file'.
Andy Wingo [Fri, 13 May 2011 11:33:59 +0000 (13:33 +0200)]
refactor do_thread_exit cleanup handler invocation
* libguile/threads.c (do_thread_exit): Redo cleanup handler call so as
not to shove a SCM into a pointer.
Andy Wingo [Fri, 13 May 2011 11:29:48 +0000 (13:29 +0200)]
i18n error return type fix
* libguile/i18n.c (chr_to_case, str_to_case): Return #f in error case
instead of 0.
Andy Wingo [Fri, 13 May 2011 11:29:15 +0000 (13:29 +0200)]
PTR2SCM and SCM2PTR in inline.h
* libguile/inline.h (scm_cell, scm_immutable_cell):
(scm_double_cell, scm_immutable_double_cell):
(scm_words): Be more consistent in use of PTR2SCM and SCM2PTR.
Andy Wingo [Fri, 13 May 2011 11:25:14 +0000 (13:25 +0200)]
compile-time assertion in net_db uses constant expressions
* libguile/net_db.c: Use constant expressions for EAI_BADFLAGS and
AI_ALL representations.
Andy Wingo [Fri, 13 May 2011 11:24:29 +0000 (13:24 +0200)]
ports.c uninitialized static SCM values are #f, not 0
* libguile/ports.c: (scm_current_input_port, scm_current_output_port)
(scm_current_error_port): Use #f as the uninitialized value instead of
0.
Andy Wingo [Fri, 13 May 2011 11:23:12 +0000 (13:23 +0200)]
scm_port_for_each fix
* libguile/ports.c (scm_port_for_each): Inline the call to
scm_c_port_for_each, to avoid type errors.
Andy Wingo [Fri, 13 May 2011 11:21:51 +0000 (13:21 +0200)]
weak_bucket_assoc tweak
* libguile/hashtab.c (weak_bucket_assoc): Change assertion to be a check
and abort, and so that only calls GC_is_visible if the check fails.
Andy Wingo [Fri, 13 May 2011 11:20:39 +0000 (13:20 +0200)]
vm_make_boot_program initializer fix
* libguile/vm.c (vm_make_boot_program): Use #f as the "I don't have a
program" value.
Andy Wingo [Fri, 13 May 2011 11:18:11 +0000 (13:18 +0200)]
correct use of SCM2PTR in SCM_I_REGISTER_DISAPPEARING_LINK forms
* libguile/hashtab.c (set_weak_cdr):
* libguile/vectors.c (scm_c_vector_set_x):
* libguile/weaks.c (scm_weak_car_pair, scm_weak_cdr_pair):
(scm_doubly_weak_pair): Use SCM2PTR for the target of
SCM_I_REGISTER_DISAPPEARING_LINK calls.
Andy Wingo [Fri, 13 May 2011 11:04:49 +0000 (13:04 +0200)]
scm_is_false instead of == SCM_BOOL_F; also is_null, is_true, etc
* libguile/deprecation.c (scm_issue_deprecation_warning)
* libguile/eval.c (CAPTURE_ENV):
* libguile/goops.c (make_dispatch_procedure, make_class_from_symbol):
(create_smob_classes):
* libguile/guardians.c (finalize_guarded, scm_i_get_one_zombie):
* libguile/hashtab.c (scm_fixup_weak_alist, scm_internal_hash_fold):
* libguile/i18n.c (scm_nl_langinfo)
* libguile/load.c (scm_primitive_load)
* libguile/posix.c (scm_setrlimit)
* libguile/socket.c (scm_to_sockaddr):
* libguile/srcprop.c (scm_make_srcprops): Use scm_is_false / scm_is_true
/ scm_is_null instead of comparing against SCM_BOOL_F et al.
Andy Wingo [Fri, 13 May 2011 10:51:56 +0000 (12:51 +0200)]
more care regarding SCM_PACK and SCM_UNPACK
* libguile/control.c (reify_partial_continuation):
* libguile/eval.c (RETURN_BOOT_CLOSURE):
* libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref)
(scm_frame_local_set_x)
* libguile/frames.h (SCM_FRAME_SET_RETURN_ADDRESS):
(SCM_FRAME_SET_MV_RETURN_ADDRESS, SCM_FRAME_SET_DYNAMIC_LINK):
* libguile/goops.c (scm_class_of, scm_primitive_generic_generic)
(scm_c_extend_primitive_generic, compute_getters_n_setters)
(scm_sys_initialize_object):
* libguile/guardians.c (finalize_guarded):
* libguile/list.c (SCM_I_CONS):
* libguile/macros.c (scm_i_make_primitive_macro)
(scm_make_syntax_transformer):
* libguile/memoize.c (MAKMEMO, SCM_MAKE_MEMOIZER)
(SCM_MAKE_REST_MEMOIZER):
* libguile/modules.c (scm_module_reverse_lookup)
* libguile/print.c (iprin1):
* libguile/promises.c (scm_make_promise)
* libguile/srcprop.c (scm_make_srcprops):
* libguile/vectors.c (scm_c_vector_ref):
* libguile/vm-engine.c (vm_engine)
* libguile/vm-i-scheme.c (REL, add1, sub1):
* libguile/vm-i-system.c (new_frame, call_cc)
* libguile/weaks.h (SCM_WEAK_PAIR_WORD_DELETED_P): Be more careful about
SCM_PACK / SCM_UNPACK.
Andy Wingo [Fri, 13 May 2011 10:42:01 +0000 (12:42 +0200)]
scm_is_eq for SCM vals, not == or !=
* libguile/bytevectors.c (scm_make_bytevector, STRING_TO_UTF)
(UTF_TO_STRING):
* libguile/continuations.c (scm_i_check_continuation):
* libguile/expand.h (SCM_EXPANDED_P):
* libguile/fluids.c (scm_i_make_with_fluids):
* libguile/generalized-vectors.c (scm_make_generalized_vector):
* libguile/goops.c (SCM_GOOPS_UNBOUNDP, slot_definition_using_name):
(scm_c_extend_primitive_generic, more_specificp, scm_make)
* libguile/i18n.c (SCM_VALIDATE_OPTIONAL_LOCALE_COPY):
(scm_locale_string_to_integer)
* libguile/modules.c (resolve_duplicate_binding):
(scm_module_reverse_lookup)
* libguile/posix.c (scm_to_resource):
* libguile/r6rs-ports.c (scm_put_bytevector):
* libguile/socket.c (scm_connect, scm_bind, scm_sendto
* libguile/stacks.c (find_prompt):
* libguile/variable.c (scm_variable_ref, scm_variable_bound_p):
* libguile/vm-engine.h (ASSERT_BOUND_VARIABLE, ASSERT_BOUND)
* libguile/vm-i-system.c (VARIABLE_BOUNDP, local_bound)
(long_local_bound, fluid_ref): Use scm_is_eq to compare, not == / !=.
Andy Wingo [Fri, 13 May 2011 10:16:56 +0000 (12:16 +0200)]
deprecate scm_internal_dynamic_wind
* libguile/dynwind.c:
* libguile/dynwind.h:
* libguile/deprecated.h (scm_t_inner):
* libguile/deprecated.c (scm_internal_dynamic_wind): Deprecate, as the
scm_dynwind API is better, and this API encourages users to stuff SCM
values into pointers.
Andy Wingo [Fri, 13 May 2011 10:24:04 +0000 (12:24 +0200)]
excise scm_internal_dynamic_wind from goops.c
* libguile/goops.c (go_to_hell, go_to_heaven, purgatory):
(scm_change_object_class): Rewrite to use scm_dynwind_begin instead of
scm_dynamic_wind.
Andy Wingo [Fri, 13 May 2011 10:15:42 +0000 (12:15 +0200)]
async.c refactor
* libguile/async.c (increase_block, decrease_block): Write more
clearly.
(scm_dynwind_block_asyncs, scm_dynwind_unblock_asyncs): Move
definitions up.
(scm_call_with_blocked_asyncs, scm_c_call_with_blocked_asyncs)
(scm_call_with_unblocked_asyncs, scm_c_call_with_unblocked_asyncs):
Implement in terms of scm_dynwind_{un,}block_asyncs, so that we don't
stuff SCM values into pointers.
Andy Wingo [Fri, 13 May 2011 08:32:46 +0000 (10:32 +0200)]
fix type errors
* libguile/numbers.c (scm_logand): Fix a type error (comparing a SCM
against an int, when we really wanted to compare the unpacked
fixnum).
* libguile/ports.c (scm_i_set_conversion_strategy_x): Check
scm_conversion_strategy_init, not scm_conversion_strategy.
* libguile/read.c (recsexpr): Fix loops to avoid strange test of SCM
values.
Andy Wingo [Fri, 13 May 2011 08:19:48 +0000 (10:19 +0200)]
allow iflags to be constant expressions with typing-strictness==2
* libguile/tags.h (SCM_MAKE_ITAG8_BITS): New helper, produces a
scm_t_bits instead of a SCM, because SCM_UNPACK is not a constant
expression with SCM_DEBUG_TYPING_STRICTNESS==2.
(SCM_MAKIFLAG_BITS): Remove SCM_MAKIFLAG, and replace with this, which
returns bits.
(SCM_BOOL_F_BITS, SCM_ELISP_NIL_BITS, SCM_EOL_BITS, SCM_BOOL_T_BITS):
(SCM_UNSPECIFIED_BITS, SCM_UNDEFINED_BITS, SCM_EOF_VAL_BITS):
(SCM_UNBOUND_BITS): New definitions. Defined SCM_BOOL_F, etc in terms
of them.
(SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_0):
(SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_1):
(SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_2):
(SCM_XXX_ANOTHER_LISP_FALSE_DONT_USE): Be bits instead of SCM values.
(SCM_BITS_DIFFER_IN_EXACTLY_ONE_BIT_POSITION):
(SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS): Rename from
SCM_VALUES_DIFFER_..., and take unpacked bits as the args.
* libguile/boolean.c: Update verify block to use
SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS et al.
* libguile/debug.c (scm_debug_opts):
* libguile/print.c (scm_print_opts):
* libguile/read.c (scm_read_opts): Use iflags bits for initializers.
* libguile/hash.c (scm_hasher): Use _BITS for iflags as case labels.
* libguile/pairs.c: Nil/null compile-time check uses
SCM_ELISP_NIL_BITS.
Andy Wingo [Thu, 12 May 2011 21:29:16 +0000 (23:29 +0200)]
fix static allocation with debug_typing_strictness==2
* libguile/tags.h (SCM): For SCM_DEBUG_TYPING_STRICTNESS==2, give the
union a tag, and use C99 compound literals to construct the value.
This allows SCM_PACK to be a constant expression.
* libguile/snarf.h: Allow SCM_SUPPORT_STATIC_ALLOCATION for
SCM_DEBUG_TYPING_STRICTNESS==2.
(SCM_IMMUTABLE_STRING): Properly parenthesize the string length.
(SCM_STATIC_PROGRAM): Fix for SCM_DEBUG_TYPING_STRICTNESS==2.
Andy Wingo [Thu, 12 May 2011 11:37:57 +0000 (13:37 +0200)]
add missing SCM_DEPRECATED annotation
* libguile/deprecated.h: Use SCM_DEPRECATED instead of SCM_API for the
asinh, acosh, atanh, and atan2 wrappers.
Andy Wingo [Thu, 12 May 2011 11:07:19 +0000 (13:07 +0200)]
all deprecated routines emit warnings
* module/ice-9/deprecated.scm (substring-move-left!)
(substring-move-right!, dynamic-maybe-call, dynamic-maybe-link)
(try-module-linked, try-module-dynamic-link)
($asinh, $acosh, $atanh, $sqrt, $abs, $exp, $log, $sin, $cos)
($tan, $asin, $acos, $atan, $sinh, $cosh, $tanh)
(process-define-module): Add deprecation warnings.
Andy Wingo [Sun, 8 May 2011 20:55:05 +0000 (22:55 +0200)]
fix some duplication in object tables
* module/language/glil/compile-assembly.scm (build-object-table): Don't
add the same value to an object table twice.
Ludovic Courtès [Sun, 8 May 2011 16:19:52 +0000 (18:19 +0200)]
Add `vhash-fold-right'.
* module/ice-9/vlist.scm (vhash-fold-right): New procedure.
* test-suite/tests/vlist.test ("vhash")["vhash-fold-right"]: New test.
* doc/ref/api-compound.texi (VHashes): Document `vhash-fold-right'.
Ludovic Courtès [Sun, 8 May 2011 16:15:10 +0000 (18:15 +0200)]
Optimize `vlist-fold-right'.
* module/ice-9/vlist.scm (vlist-fold-right): Avoid `vlist-reverse' and
instead `vlist-ref' individual elements. The result is about twice
faster. Thanks Andy for suggesting it indirectly. :-)
Andy Wingo [Sun, 8 May 2011 15:27:41 +0000 (17:27 +0200)]
add map and for-each benchmarks
* benchmark-suite/benchmarks/srfi-1.bm ("map", "for-each"): Add
benchmarks.
Ludovic Courtès [Sun, 8 May 2011 15:21:59 +0000 (17:21 +0200)]
Fix small integer return value packing on big endian machines.
* libguile/foreign.c (pack): Add `return_value_p' parameter. Update
callers.
When RETURN_VALUE_P is true, assume LOC points to an `ffi_arg', and
cast its results to the relevant type. This fixes packing of integer
return values smaller than `int' on SPARC64 and PowerPC64. Reported
by Nelson H. F. Beebe <beebe@math.utah.edu>.
Ludovic Courtès [Sun, 8 May 2011 14:25:01 +0000 (16:25 +0200)]
Make the definition of `scm_read_shebang' match its declaration.
* libguile/read.c (scm_read_shebang): Remove the `inline' keyword.
Andy Wingo [Sun, 8 May 2011 14:38:32 +0000 (16:38 +0200)]
compile-assembly: cleanup
* module/language/glil/compile-assembly.scm: Clean up code for
subprograms (not needed, we just cache the glil) and object alists
(replaced by constants tables).
Andy Wingo [Sun, 8 May 2011 14:37:47 +0000 (16:37 +0200)]
compile-assembly: use file-level constants table
* module/language/glil/compile-assembly.scm (compile-assembly): Rework
to handle toplevel-specific code generation here, instead of in
glil->assembly. Specifically, here we build a global constant table,
and arrange for it to be the objtable of the toplevel thunk.
(compile-program): New helper, compiles a <glil-program> and returns
just the (load-program ...) form.
(compile-objtable): New helper, generates assembly to build an object
table, using some other constants table, and possibly recursing to
`compile-program' for cached GLIL programs.
(glil->assembly): Simplify, removing the toplevel? argument, and
replacing the object alist with an objtable computed in a previous
pass. Adapt to the new form of the objtable, and to use
compile-program and compile-objtable.
Andy Wingo [Sun, 8 May 2011 14:31:18 +0000 (16:31 +0200)]
compile-assembly: add dump-constants, a new helper
* module/language/glil/compile-assembly.scm (dump-constants): New
helper. Generates bytecode that will result in a vector for the
global object table being pushed on the stack. The items in the
global object table will share state as much as possible.
Andy Wingo [Sun, 8 May 2011 14:15:25 +0000 (16:15 +0200)]
compile-assembly: add build-constant-store, build-object-table
* module/language/glil/compile-assembly.scm (immediate?): New helper.
(build-constant-store): New helper. Walks the GLIL tree and builds up
a constant table, as a vhash.
(build-object-table): Another helper, builds a constant table for a
given GLIL program.
Andy Wingo [Sun, 8 May 2011 14:13:41 +0000 (16:13 +0200)]
compile-assembly: make-meta refactor
* module/language/glil/compile-assembly.scm (make-meta): Avoid going
through the compiler.
Andy Wingo [Sun, 8 May 2011 14:09:22 +0000 (16:09 +0200)]
compile-assembly: add traversal helpers
* module/language/glil/compile-assembly.scm (vhash-fold-right2):
(fold2, vector-fold2): Add some traversal helpers that we'll use in
the next commit.
Andy Wingo [Sun, 8 May 2011 14:05:27 +0000 (16:05 +0200)]
fix `hash' for inf and nan
* libguile/hash.c (scm_hasher): Fix to work on inf and nan.
* test-suite/tests/hash.test ("hash"): Add tests.
Andreas Rottmann [Sat, 7 May 2011 21:40:14 +0000 (23:40 +0200)]
Make the R6RS simple I/O library use conditions
* module/rnrs/io/ports.scm (display): Implement as an
exception-converting wrapper around Guile's core display.
* module/rnrs/io/simple.scm: Don't export Guile's corresponding core
procedures, but use `(rnrs io ports)' instead. This way, we get the
conditions required by R6RS raised.
* doc/ref/r6rs.texi (rnrs io simple): Mention that these procedures are
supposed to raise R6RS conditions.
Ludovic Courtès [Sat, 7 May 2011 20:46:38 +0000 (22:46 +0200)]
Fix `get_utf8_codepoint' to not consume valid starting bytes.
Thanks to Mark H. Weaver for pointing this out.
* libguile/ports.c (CONSUME_PEEKED_BYTE): New macro.
(get_utf8_codepoint): New variable `pt'. Use
`scm_peek_byte_or_eof'/`CONSUME_PEEKED_BYTE' pairs instead of
`scm_get_byte_or_eof'.
* test-suite/tests/ports.test ("string ports")[#xc2 #x41 #x42, #xe0 #xa0
#x41 #x42, #xf0 #x88 #x88 #x88]: Fix to conform to Unicode 6.0.0.
[#xe0 #x88 #x88]: Remove test.
[#xf0 #x80 #x80 #x41]: New test.
Ludovic Courtès [Sat, 7 May 2011 20:41:32 +0000 (22:41 +0200)]
Add `scm_peek_byte_or_eof'.
* libguile/inline.h (scm_get_byte_or_eof): Add `SCM_UNLIKELY' for EOF.
(scm_peek_byte_or_eof): New function.
* libguile/r6rs-ports.c (scm_lookahead_u8): Use `scm_peek_byte_or_eof'.
Andreas Rottmann [Sat, 7 May 2011 20:30:40 +0000 (22:30 +0200)]
More completely document the `(rnrs io ports)' library
* doc/ref/api-io.texi (R6RS I/O Ports): Transcribe missing parts from
the R6RS document.
Andy Wingo [Sat, 7 May 2011 09:31:38 +0000 (11:31 +0200)]
fix srfi-1 map-in-order definition
* module/srfi/srfi-1.scm (map-in-order): As we are not extending the
core `map' binding, actually make a new `map-in-order' alias here.
Fixes fresh builds.
Ludovic Courtès [Fri, 6 May 2011 15:54:09 +0000 (17:54 +0200)]
Special-case UTF-8 ports to bypass `iconv' entirely.
* libguile/ports.c (update_port_lf): Handle EOF.
(get_utf8_codepoint, get_iconv_codepoint): New functions.
(get_codepoint): Use them.
(scm_i_set_port_encoding_x): Don't open conversion descriptors when
ENCODING is "UTF-8".
* libguile/print.c (display_string_as_utf8, display_string_using_iconv):
New functions.
(display_string): Use them.
* test-suite/tests/ports.test ("string ports")[#xc2 #x41 #x42]: Add a
note that this is not the wrong behavior per Unicode 6.0.0.
Ludovic Courtès [Fri, 6 May 2011 15:43:37 +0000 (17:43 +0200)]
Fix `foreign.test' for big endian machines.
* test-suite/tests/foreign.test ("pointer<->bytevector")["pointer from
bits", "dereference-pointer"]: Fix iteration order for big endian
machines.
Andy Wingo [Thu, 5 May 2011 22:17:35 +0000 (00:17 +0200)]
avoid tls gets when handling interrupts in the vm
* libguile/__scm.h (SCM_ASYNC_TICK_WITH_CODE): Redefine to take a
scm_i_thread* as well. OK to do because it's within a
BUILDING_LIBGUILE block.
* libguile/vm-engine.c (vm_engine): Cache the scm_i_thread* instead of
the dynstate, so we can use the thread for ticks.
* libguile/vm-engine.h (VM_HANDLE_INTERRUPTS): Tick with the
scm_i_thread* local var, to avoid excessive tls calls.
* libguile/vm-i-system.c: Fix dynstate users to use
current_thread->dynamic_state.
Andy Wingo [Thu, 5 May 2011 21:07:23 +0000 (23:07 +0200)]
map and for-each in scheme
* module/ice-9/boot-9.scm (map, for-each): Implement in Scheme instead
of C. There are boot versions before `cond' is defined.
(map-in-order): Define this alias here instead of in evalext.h.
* libguile/eval.c: Stub out the map and for-each definitions to just
call into Scheme.
* libguile/evalext.c: Remove map-in-order definition.
* module/srfi/srfi-1.scm: Replace all calls to map1 with calls to map.
(map, for-each): Define implementations here, in Scheme, instead of in
C.
* test-suite/tests/eval.test (exception:wrong-length, "map"): Update the
expected exception for mapping over lists of different lengths.
* libguile/srfi-1.h:
* libguile/srfi-1.c: Remove map and for-each definitions. Remove the
bit that extended the core `map' primitive with another method: the
right way to do that is with modules.
Andy Wingo [Thu, 5 May 2011 14:28:28 +0000 (16:28 +0200)]
psyntax simplification
* module/ice-9/psyntax.scm (strip): Inline the and-map* definition to
its one call site.
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Thu, 5 May 2011 13:13:08 +0000 (15:13 +0200)]
scm_mem[qv] optimization
* libguile/list.c (scm_memq, scm_memv): Inline the tortoise/hare check
that scm_ilength does, via SCM_VALIDATE_LIST, into the memq/memv
bodies. Avoids traversing these lists twice.
Ludovic Courtès [Thu, 5 May 2011 15:56:47 +0000 (17:56 +0200)]
Generate `escape' and `substitute' port decoding tests.
Andy Wingo [Thu, 5 May 2011 12:04:23 +0000 (14:04 +0200)]
VM tweaks
* libguile/vm-engine.c (VM_CHECK_OBJECT, VM_CHECK_FREE_VARIABLES): Set
to 0 for both engines. These are really internal debugging variables,
which don't affect user-visible features, provided that the compiler
is correct of course.
(VM_CHECK_UNDERFLOW): New var, also off by default: whether to check
for stack underflow when popping values.
(vm_engine): Don't declare object_count if we are not checking object
table accesses.
* libguile/vm-engine.h (CACHE_PROGRAM): Don't muck with object_count
if we are not checking object table accesses.
(CHECK_UNDERFLOW, PRE_CHECK_UNDERFLOW): Nop out if we are not checking
underflow.
(POP2, POP3): New macros which check for underflow before popping more
than one value.
* libguile/vm-i-loader.c (load_array):
* libguile/vm-i-scheme.c (set_car, set_cdr, vector_set, slot_set)
(BV_SET_WITH_ENDIANNESS, BV_FIXABLE_INT_SET, BV_INT_SET)
(BV_FLOAT_SET):
* libguile/vm-i-system.c (partial_cont_call, fix_closure, prompt)
(fluid_set): Use POP2 / POP3.
(local_set, long_local_set): Pop to locals instead of using values on
the stack then dropping; allows for underflow to be checked before the
value is accessed.
(BR): Don't NULLSTACK or DROP after the operation.
(br_if, br_if_not, br_if_eq, br_if_not_eq, br_if_null)
(br_if_not_null): Pop to locals before doing the compare and jump.
Andy Wingo [Thu, 5 May 2011 10:59:07 +0000 (12:59 +0200)]
srfi-1 `member' in scheme, inlines to memq / memv in some cases
* libguile/srfi-1.c:
* libguile/srfi-1.h (scm_srfi1_member): Move implementation to Scheme.
* module/srfi/srfi-1.scm (member): Implement here, with the inlining
cases for eq? and eqv?. Speeds up a compiled bootstrap of
psyntax.scm, because lset-adjoin inlines to the memq case.
(lset<=): Reindent.
(lset-adjoin, lset-union): If the comparator is eq? or eqv?, just pass
it through to `member', so we inline to memq / memv. Use something
closer to the reference implementations.
Andy Wingo [Thu, 5 May 2011 09:22:42 +0000 (11:22 +0200)]
speed up compile-bytecode
* module/language/assembly/compile-bytecode.scm (compile-bytecode):
Rewrite to fill a bytevector directly, instead of using bytevector
ports. `write-bytecode' itself is still present and almost the same
as before; it's just that `write-byte' et al now inline the effect of
writing a byte to a binary port.
* test-suite/tests/asm-to-bytecode.test (comp-test): Refactor to use
public interfaces.
Andy Wingo [Thu, 5 May 2011 08:09:48 +0000 (10:09 +0200)]
silly "optimization" in (language assembly)
* module/language/assembly.scm (byte-length): Silly, minor tweak: put
the fixed-length instruction case first. Seems to shave some 10% off
the time compiling psyntax.scm (when the whole rest of the system is
compiled, of course).
Andy Wingo [Thu, 5 May 2011 08:08:29 +0000 (10:08 +0200)]
add gcprof
* module/statprof.scm (gcprof): New variant of statprof; instead of
being driven by setitimer, this one is driven by the after-gc-hook.
Andy Wingo [Thu, 5 May 2011 07:59:59 +0000 (09:59 +0200)]
minor statprof tweaks
* module/statprof.scm (statprof-reset): Make full-stacks? into an
optional arg instead of doing the rest arg dance.
(statprof-display): Format gc-time-taken appropriately.
Ludovic Courtès [Wed, 4 May 2011 21:52:53 +0000 (23:52 +0200)]
Automatically generate `peek-char' decoding error tests.
* test-suite/tests/ports.test ("string ports")[make-peek+read-checks]:
New macro.
[test-decoding-error]: Change to take a list of expected characters or
conditions. Use `make-peek+read-checks' to generate a `peek-char'
test.
[(#xc2 #x41 #x42), (#xe0 #xa0 #x41 #x42)]: New tests.
Andy Wingo [Wed, 4 May 2011 16:48:02 +0000 (18:48 +0200)]
measure time spent in gc
* libguile/gc.c (scm_gc_stats): Set the gc-time-taken entry to our
recorded value.
(start_gc_timer, accumulate_gc_timer, scm_init_gc): Arrange to record
a conservative estimate of time spent in GC.
Andy Wingo [Wed, 4 May 2011 18:15:23 +0000 (20:15 +0200)]
scm_c_get_internal_run_time is more precise
* libguile/stime.h (SCM_TIME_UNITS_PER_SECOND): Redefine to point to a C
variable instead of being a pure preprocessor thing. This has the
possibility to break existing compiled C extensions' interpretation of
the internal-time-units-per-second, but hopefully there's no too much
of that code out there, and in the worst case they can just
recompile. Scheme code will get it right without the need to
recompile.
* libguile/stime.c (TIME_UNITS_PER_SECOND): New local define, and
increase to nanosecond resolution if we are on a system in which this
is useful and practical.
(time_from_seconds_and_nanoseconds): New helper.
(get_internal_real_time, get_internal_run_time): New global vars:
function pointers.
(get_internal_real_time_posix_timer):
(get_internal_run_time_posix_timer):
(get_internal_real_time_gettimeofday):
(get_internal_run_time_times):
(get_internal_real_time_fallback): Various implementations.
(scm_get_internal_real_time): Return the get_internal_real_time()
result.
(scm_c_get_internal_run_time): Likewise.
(scm_gettimeofday): No need for a critical section, and remove
obsolete ftime block.
(scm_init_stime): Init all of the new time bases, and decide on
implementations of real time and run time accessors.
Andy Wingo [Wed, 4 May 2011 18:16:55 +0000 (20:16 +0200)]
build support for detecting clock_gettime, with -lrt if needed
* acinclude.m4 (gl_CLOCK_TIME):
* configure.ac: Locally include gl_CLOCK_TIME. To be fixed properly
when gnulib updates their license to reflect the actual BSD state of
things.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS):
Add -lrt for clock_gettime, if needed.
* meta/guile-2.0-uninstalled.pc.in:
* meta/guile-2.0.pc.in: Likewise, in Libs.private.
Daniel Llorens [Mon, 2 May 2011 18:36:33 +0000 (20:36 +0200)]
Fix call-with-input-file & relatives for multiple values
* module/ice-9/r4rs.scm (call-with-input-file, call-with-output-file): Rewrite
with call-with-values.
(with-input-from-file): use call-with-input-file.
(with-output-to-file, with-error-to-file): use call-with-output-file.
Update docstrings to make clear that multiple values may be yielded.
Andy Wingo [Sun, 1 May 2011 21:00:55 +0000 (23:00 +0200)]
deprecate scm_struct_table
* libguile/goops.h:
* libguile/goops.c (scm_i_define_class_for_vtable): New internal helper,
defines a class for a vtable, relying on the name slot being set
correctly.
(scm_class_of, create_struct_classes): Use the local vtable-to-class
map instead of scm_struct_table.
* libguile/struct.h (SCM_STRUCT_TABLE_NAME, SCM_SET_STRUCT_TABLE_NAME)
(SCM_STRUCT_TABLE_CLASS, SCM_SET_STRUCT_TABLE_CLASS, scm_struct_table)
(scm_struct_create_handle): Deprecate these internals of the map
between structs and classes.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_struct_create_handle): Deprecated code over
here now.
Andy Wingo [Sun, 1 May 2011 18:34:47 +0000 (20:34 +0200)]
disallow get-handle / create-handle! of weak hash tables
* libguile/hashtab.c (scm_hashq_get_handle, scm_hashq_create_handle_x)
(scm_hashv_get_handle, scm_hashv_create_handle_x)
(scm_hash_get_handle, scm_hash_create_handle_x)
(scm_hashx_get_handle, scm_hashx_create_handle_x): Don't allow these
functions to be called on weak hash tables, as we have no idea when
the GC will null out fields of the handle, and set-cdr! won't register
disappearing links, and set-car! would never work of course.
Andy Wingo [Sun, 1 May 2011 19:43:04 +0000 (21:43 +0200)]
(ice-9 poe) does not get handles from weak hash tables
* module/ice-9/poe.scm (pure-funcq, perfect-funcq): Reimplement to not
use get-handle.
Andy Wingo [Sun, 1 May 2011 19:01:29 +0000 (21:01 +0200)]
boot-9 fixme note
* module/ice-9/boot-9.scm (module-replace!): Add a fixme about using
something other than object properties here.
Andy Wingo [Sun, 1 May 2011 19:00:54 +0000 (21:00 +0200)]
fix scm_object_property_set_x for handles and weak tables
* libguile/objprop.c (scm_object_property_set_x): Use ref and set!
instead of create-handle and set-cdr!, as it is a weak hash table.
(scm_set_object_properties_x): Likewise.
Andy Wingo [Sun, 1 May 2011 18:32:28 +0000 (20:32 +0200)]
deprecated primitive-properties don't get handles from weak hash tables
* libguile/deprecated.c (scm_primitive_property_ref)
(scm_primitive_property_set_x): Avoid getting handles to elements in a
weak hash table, as that's not going to work very well.
Andy Wingo [Sun, 1 May 2011 18:30:54 +0000 (20:30 +0200)]
deprecate scm_whash API
* libguile/deprecated.h:
* libguile/deprecated.c (scm_whash_get_handle, SCM_WHASHFOUNDP)
(SCM_WHASHREF, SCM_WHASHSET, scm_whash_create_handle)
(scm_whash_lookup, scm_whash_insert): Deprecate this API.
* libguile/srcprop.c:
* libguile/srcprop.h:
* libguile/read.c (scm_read_sexp): Use the hashq API instead of the
whash API.
Andy Wingo [Sun, 1 May 2011 16:01:42 +0000 (18:01 +0200)]
fix hash-set! in weak-value table from non-immediate to immediate
* libguile/hashtab.c (set_weak_cdr, scm_hash_fn_set_x): If we have a
weak-value hash table with a previous non-immediate value for a given
key, and we are setting an immediate as the new value, we were not
unregistering the disappearing link. Fixed.
Andy Wingo [Fri, 29 Apr 2011 09:11:26 +0000 (11:11 +0200)]
psyntax simplification
* module/ice-9/psyntax.scm (id-var-name): Just rely on multiple-values
truncation.
Andy Wingo [Fri, 29 Apr 2011 09:10:38 +0000 (11:10 +0200)]
MV truncation in the boot evaluator
* libguile/eval.c (truncate_values): New helper.
(EVAL1): New macro, does an eval then truncates the values.
(eval, prepare_boot_closure_env_for_apply)
(prepare_boot_closure_env_for_eval): Use EVAL1 in appropriate places
to get multiple-values truncation even here in the boot evaluator.
eval.c fixen
Andy Wingo [Fri, 29 Apr 2011 09:07:25 +0000 (11:07 +0200)]
latin1 strings in vm error messages
* libguile/vm-engine.c: Use latin1 strings here for the string
literals.
Andy Wingo [Tue, 12 Apr 2011 11:12:56 +0000 (13:12 +0200)]
check for iconveh values at configure-time
* configure.ac: Check for the iconveh values here, instead of relying on
gen-scmconfig to know them. That doesn't work in general because
gen-scmconfig runs on the build machine, not the target machine.
* libguile/Makefile.am (gen-scmconfig.$(OBJEXT)): Revert rule to the
revision before
533d8212.
* libguile/gen-scmconfig.h.in (SCM_I_GSC_ICONVEH_ERROR):
(SCM_I_GSC_ICONVEH_QUESTION_MARK):
(SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE):
* libguile/gen-scmconfig.c: Use configure-time substitutions to set
SCM_ICONVEH_ERROR_HANDLER et al.
Andy Wingo [Thu, 28 Apr 2011 19:45:02 +0000 (21:45 +0200)]
-x error message fix
* module/ice-9/command-line.scm (compile-shell-switches): Fix error
message for -x switch.
Andy Wingo [Thu, 28 Apr 2011 19:43:01 +0000 (21:43 +0200)]
fix double-loading of script in -ds case
* module/ice-9/command-line.scm (compile-shell-switches): In the -ds
case, we were erroneously loading the script twice. Fix that.
Andy Wingo [Thu, 28 Apr 2011 19:33:12 +0000 (21:33 +0200)]
fix break example
* doc/ref/api-control.texi (while do): Fix a break example.
Andy Wingo [Thu, 28 Apr 2011 11:08:22 +0000 (13:08 +0200)]
allow while as an expression
* module/ice-9/boot-9.scm (while): Specify the return value as #f under
normal conditions, #t under (break), and arg... under (break arg...).
* test-suite/tests/syntax.test ("while"): Test.
* doc/ref/api-control.texi (while do): Document.
Andy Wingo [Thu, 28 Apr 2011 10:17:56 +0000 (12:17 +0200)]
add reset and shift
* module/ice-9/control.scm (reset, shift): Add implementations of these
operators from Wolfgang J Moeller, derived from implementations by
Oleg Kiselyov.
(reset*, shift*): Procedural variants.
* test-suite/tests/control.test ("shift and reset"): Add tests,
originally from Oleg Kiselyov.
Ludovic Courtès [Wed, 27 Apr 2011 20:48:20 +0000 (22:48 +0200)]
Fix typo in `NEWS'.
Ludovic Courtès [Wed, 27 Apr 2011 20:39:38 +0000 (22:39 +0200)]
Bump version number for 2.0.1.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_CURRENT): Increment to account for new C functions
such as `scm_c_public_ref' and `scm_from_latin1_keyword'.
(LIBGUILE_INTERFACE_AGE): Increment.
Ludovic Courtès [Wed, 27 Apr 2011 20:30:20 +0000 (22:30 +0200)]
Update `NEWS'.
Ludovic Courtès [Wed, 27 Apr 2011 20:26:05 +0000 (22:26 +0200)]
Keep a 2.0.0-compatible `define-inlinable' macro in (srfi srfi-9).
Partially reverts
165b10ddfaaa8ecc72d45a9be7d29e7537dc2379 and
531c9f1dc51c4801c4d031ee80a31f15285a6b85.
* module/srfi/srfi-9.scm (define-inlinable): New macro.
Ludovic Courtès [Wed, 27 Apr 2011 20:14:31 +0000 (22:14 +0200)]
Document `(ice-9 binary-ports)'.
* doc/ref/api-io.texi (R6RS I/O Ports): Mention `(ice-9 binary-ports)'.
* NEWS: Update.
Ludovic Courtès [Wed, 27 Apr 2011 19:55:42 +0000 (21:55 +0200)]
Add tests for UTF-8 ill-formed sequence handling.
* test-suite/tests/ports.test ("string ports"): Add for
`test-decoding-error' tests for ill-formed UTF-8 sequences. Thanks
to Mark H Weaver <mhw@netris.org> for pointing this out.