bpt/guile.git
12 years agoCorrect typing of assertion in the `wind' instruction.
Ludovic Courtès [Fri, 4 May 2012 22:44:54 +0000 (00:44 +0200)]
Correct typing of assertion in the `wind' instruction.

* libguile/vm-i-system.c (wind): Check `scm_to_bool (scm_thunk_p (x))'
  instead of `scm_thunk_p'.

12 years agoSimplify the reader's `read_complete_token'.
Ludovic Courtès [Fri, 4 May 2012 20:36:27 +0000 (22:36 +0200)]
Simplify the reader's `read_complete_token'.

* libguile/read.c (read_token): Remove unneeded `const' before `size_t'.
  (read_complete_token): Remove `overflow_buffer' parameter; return
  `char *' instead of `int'.  Allocate the overflow buffer with
  `scm_gc_malloc_pointerless' instead of `scm_malloc'.  Return either
  the overflow buffer or BUFFER.
  (scm_read_number, scm_read_mixed_case_symbol,
  scm_read_number_and_radix): Rename `buffer' to `local_buffer', and
  `overflow_buffer' to `buffer'.  Remove `overflow'.  Adjust code to new
  `read_complete_token'.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Mon, 30 Apr 2012 19:34:58 +0000 (21:34 +0200)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/vm-engine.c
libguile/vm-i-system.c

12 years agopush error handlers out of line in the vm
Andy Wingo [Mon, 30 Apr 2012 18:25:53 +0000 (20:25 +0200)]
push error handlers out of line in the vm

* libguile/vm.c:
  (vm_error):
  (vm_error_bad_instruction):
  (vm_error_unbound):
  (vm_error_unbound_fluid):
  (vm_error_not_a_variable):
  (vm_error_not_a_thunk):
  (vm_error_apply_to_non_list):
  (vm_error_kwargs_length_not_even):
  (vm_error_kwargs_invalid_keyword):
  (vm_error_kwargs_unrecognized_keyword):
  (vm_error_too_many_args):
  (vm_error_wrong_num_args):
  (vm_error_wrong_type_apply):
  (vm_error_stack_overflow):
  (vm_error_stack_underflow):
  (vm_error_improper_list):
  (vm_error_not_a_pair):
  (vm_error_not_a_bytevector):
  (vm_error_not_a_struct):
  (vm_error_no_values):
  (vm_error_not_enough_values):
  (vm_error_continuation_not_rewindable):
  (vm_error_bad_wide_string_length):
  (vm_error_invalid_address):
  (vm_error_object):
  (vm_error_free_variable): New internal helpers, implementing VM error
  handling.

* libguile/vm-engine.h (VM_ASSERT): New helper macro.
  (ASSERT, CHECK_OBJECT, CHECK_FREE_VARIABLE):
  (PRE_CHECK_UNDERFLOW, PUSH_LIST): Use the new helper.

* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: Use VM_ASSERT and the out-of-line error
  handlers.

* libguile/vm-engine.c (vm_engine): Remove inline error handlers, and
  remove a couple of local vars.  Use VM_ASSERT.  Have halt handle the
  return itself.

12 years agoadd internal SCM_NOINLINE definition
Andy Wingo [Mon, 30 Apr 2012 17:51:06 +0000 (19:51 +0200)]
add internal SCM_NOINLINE definition

* libguile/_scm.h (SCM_NOINLINE): New internal define, for things that
  we definitely don't want the compiler to inline.

12 years agoadd scm_c_values helper
Andy Wingo [Mon, 30 Apr 2012 17:40:52 +0000 (19:40 +0200)]
add scm_c_values helper

* libguile/values.h:
* libguile/values.c (scm_c_values): New public helper.

12 years agofix peval test for recent merge
Andy Wingo [Mon, 30 Apr 2012 18:26:09 +0000 (20:26 +0200)]
fix peval test for recent merge

* test-suite/tests/peval.test: Fix test for master.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Thu, 26 Apr 2012 21:40:57 +0000 (23:40 +0200)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
test-suite/tests/cse.test

12 years agoMerge commit 'f66cbb99ee096186837536885d3436bb334df34d'
Andy Wingo [Thu, 26 Apr 2012 21:09:21 +0000 (23:09 +0200)]
Merge commit 'f66cbb99ee096186837536885d3436bb334df34d'

12 years agoMerge commit '1cd63115be7a25d0ea18aaa0e1eff5658d8db77a'
Andy Wingo [Thu, 26 Apr 2012 21:08:14 +0000 (23:08 +0200)]
Merge commit '1cd63115be7a25d0ea18aaa0e1eff5658d8db77a'

Conflicts:
module/language/tree-il/peval.scm
test-suite/tests/peval.test

12 years agoMerge commit 'de1eb420a5a95b17e85b19c4d98c869036e9ecb0'
Andy Wingo [Thu, 26 Apr 2012 20:56:45 +0000 (22:56 +0200)]
Merge commit 'de1eb420a5a95b17e85b19c4d98c869036e9ecb0'

Conflicts:
module/language/tree-il/primitives.scm
test-suite/tests/tree-il.test

12 years agoMerge commit 'd10f7b572c0ca1ccef87f9c46069daa30946e0cf'
Andy Wingo [Thu, 26 Apr 2012 20:17:47 +0000 (22:17 +0200)]
Merge commit 'd10f7b572c0ca1ccef87f9c46069daa30946e0cf'

Conflicts:
libguile/smob.c
libguile/smob.h
test-suite/tests/tree-il.test

12 years agoClean up stack tests
Noah Lavine [Tue, 24 Apr 2012 01:35:08 +0000 (21:35 -0400)]
Clean up stack tests

* test-suite/tests/eval.test: remove duplicate code.

12 years agomake-stack handles prompt tags better
Noah Lavine [Thu, 19 Apr 2012 02:10:21 +0000 (22:10 -0400)]
make-stack handles prompt tags better

* libguile/stacks.c: update make-stack and narrow_stack to handle
  prompt tags that are not symbols.
* test-suite/tests/eval.test: add tests for trimming a stack with
  a prompt tag.

12 years agovlist performance improvements; allocate vhash data inline
Andy Wingo [Mon, 23 Apr 2012 19:42:40 +0000 (21:42 +0200)]
vlist performance improvements; allocate vhash data inline

* module/ice-9/vlist.scm (make-block): If we are making a hash table,
  allocate it inline with the contents.  Otherwise don't even add a
  pointer to the block.
  (block-hash-table?): New internal accessor.
  (block-ref*): Remove.  Vhash entries are no longer wrapped.
  (block-ref):
  (block-hash-table-next-offset):
  (block-hash-table-set-next-offset!):
  (block-hash-table-ref):
  (block-hash-table-set!):
  (block-hash-table-add!): Adapt to take content vector explicitly, and
  to expect the hash table inline with the contents.  Some of these
  accessors are new.  Adapt callers.
  (assert-vlist): New helper.
  (vlist-cons): Update comment.
  (vhash?): Update scheme to allocate the hash table and chain links
  inline with the contents.
  (%vhash-fold*, %vhash-assoc): Rewrite to be more performant.

12 years agoavoid emitting degenerate aliases in peval
Andy Wingo [Mon, 23 Apr 2012 15:56:28 +0000 (17:56 +0200)]
avoid emitting degenerate aliases in peval

* module/language/tree-il/peval.scm (<operand>, make-operand)
  (make-bound-operands, peval): Avoid emitting needless aliases in
  degenerate cases of let.
  (visit-operand): If we visit an operand with a fresh counter and have
  to abort, record that fact.

* test-suite/tests/peval.test ("partial evaluation"): Add a test.

12 years agovlist-cons micro-optimizations
Andy Wingo [Mon, 23 Apr 2012 11:07:34 +0000 (13:07 +0200)]
vlist-cons micro-optimizations

* module/ice-9/vlist.scm (set-block-next-free!): Define this instead of
  increment-block-next-free!.
  (block-append!): Refactor to take an offset, and only append if the
  offset is the next free value, and there is space in the block.
  (block-cons): Refactor to not be a loop.  The partial evaluator would
  have to understand effects analysis in order to be able to unroll it,
  and there's at most one recursion.

  Recovers the performance loss resulting from the previous commit.

12 years agoslight vlist refactor
Andy Wingo [Mon, 23 Apr 2012 09:43:01 +0000 (11:43 +0200)]
slight vlist refactor

* module/ice-9/vlist.scm: Use define-inlinable instead of define-inline,
  to ensure strict argument evaluation.  There is a slight performance
  penalty, but I hope subsequent hacks make it up.

12 years agonew pass: cse
Andy Wingo [Fri, 13 Apr 2012 22:23:15 +0000 (15:23 -0700)]
new pass: cse

* module/language/tree-il/cse.scm: New pass, some simple common
  subexpression elimination with effects analysis.

* test-suite/tests/cse.test: New test.

* test-suite/Makefile.am:
* module/Makefile.am: Adapt.

12 years agominor tweaks to a peval test
Andy Wingo [Fri, 13 Apr 2012 22:13:19 +0000 (15:13 -0700)]
minor tweaks to a peval test

* test-suite/tests/peval.test: Update mutable var test to really ensure
  that the function can't inline.

12 years agofix replacement of CSE with lexical-ref
Andy Wingo [Mon, 16 Apr 2012 23:25:19 +0000 (16:25 -0700)]
fix replacement of CSE with lexical-ref

* module/language/tree-il/cse.scm (cse): Fix dominator unrolling for
  lexical propagation.

* test-suite/tests/cse.test ("cse"): Add test.

12 years agopeval uses effects analysis
Andy Wingo [Thu, 12 Apr 2012 23:46:18 +0000 (16:46 -0700)]
peval uses effects analysis

* module/language/tree-il/peval.scm: Use effects analysis from (language
  tree-il effects) instead of our own constant-expression?.  Eagerly
  mark assigned lexicals as non-copyable.

12 years agocse hashing tweak
Andy Wingo [Mon, 16 Apr 2012 19:42:31 +0000 (12:42 -0700)]
cse hashing tweak

* module/language/tree-il/cse.scm (cse): Minor tweak to hash depth based
  on time profile of compiling peval.scm.

12 years agomore inlining in effects.scm
Andy Wingo [Sun, 15 Apr 2012 20:41:05 +0000 (13:41 -0700)]
more inlining in effects.scm

* module/language/tree-il/effects.scm (define-effects)
  (&no-effects, &all-effects-but-bailout):
  (cause, &depends-on, &causes, depends-on-effects?)
  (causes-effects?, effects-commute?): Add ham-fisted inlining.

12 years agobetter primitives support for bit operations
Andy Wingo [Sun, 15 Apr 2012 20:39:56 +0000 (13:39 -0700)]
better primitives support for bit operations

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add lognot.
  (*effect-free-primitives*): Add ash, logand, logior, logxor, and
  lognot.
  (logior, logand): Define associative expanders.

12 years agodisable optimizations in goops dispatch procedures
Andy Wingo [Sun, 15 Apr 2012 20:00:30 +0000 (13:00 -0700)]
disable optimizations in goops dispatch procedures

* module/oop/goops/dispatch.scm: Disable peval and cse.

12 years agoenable cse
Andy Wingo [Fri, 13 Apr 2012 22:23:20 +0000 (15:23 -0700)]
enable cse

* module/language/tree-il/optimize.scm: Enable CSE unless #:cse? #f is
  passed.

* test-suite/tests/tree-il.test: Disable CSE for one test.

12 years agoadd effects
Andy Wingo [Thu, 12 Apr 2012 23:25:45 +0000 (16:25 -0700)]
add effects

* module/language/tree-il/effects.scm: New module, for effects
  analysis.
* module/Makefile.am: Adapt.

12 years agopeval tests into separate file
Andy Wingo [Wed, 11 Apr 2012 18:43:00 +0000 (11:43 -0700)]
peval tests into separate file

* test-suite/tests/tree-il.test ("partial evaluation"):
* test-suite/tests/peval.test ("partial evaluation"): Separate peval
* tests.

* test-suite/Makefile.am: Adapt.

12 years agoadd more primitives and predicates to (language tree-il primitives)
Andy Wingo [Tue, 10 Apr 2012 22:47:21 +0000 (15:47 -0700)]
add more primitives and predicates to (language tree-il primitives)

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add number? and char?.  Add more
  numeric predicates.  Add character comparators.  Add throw, error, and
  scm-error.
  (*primitive-accessors*): Remove struct-vtable.  Though the vtable's
  contents may change (through redefinition), its identity does not
  change.
  (*effect-free-primitives*): Put struct-vtable, number?, and char?
  here.
  (*multiply-valued-primitives*): Instead of listing singly-valued
  primitives, list multiply-valued primitives.
  (*bailout-primitives*): New list.
  (*negatable-primitives*): New alist.
  (*bailout-primitive-table*, *multiply-valued-primitive-table*)
  (*negatable-primitive-table*): New tables.
  (singly-valued-primitive?): Adapt to
  use *multiply-valued-primitive-table*.
  (bailout-primitive?, negate-primitive): New exported procedures.

12 years agomove (test-suite lib) to lower dir; cleans up uninstalled paths.
Andy Wingo [Sat, 21 Apr 2012 21:06:48 +0000 (17:06 -0400)]
move (test-suite lib) to lower dir; cleans up uninstalled paths.

* check-guile.in:
* test-suite/Makefile.am:
* test-suite/test-suite/lib.scm:

* benchmark-guile.in:
* benchmark-suite/Makefile.am:
* benchmark-suite/benchmark-suite/lib.scm: Lower the lib modules in the
  source tree.  This lets us remove top_srcdir and top_builddir from the
  uninstalled paths.

* test-suite/tests/asm-to-bytecode.test:
* test-suite/tests/brainfuck.test:
* test-suite/tests/compiler.test:
* test-suite/tests/ftw.test:
* test-suite/tests/gc.test:
* test-suite/tests/match.test:
* test-suite/tests/rnrs-libraries.test:
* test-suite/tests/rnrs-test-a.scm:
* test-suite/tests/sxml.match.test: Adapt to not expect that module
  names be prefixed with "test-suite".

12 years agomodernize (benchmark-suite lib)
Andy Wingo [Mon, 23 Apr 2012 08:42:09 +0000 (04:42 -0400)]
modernize (benchmark-suite lib)

* benchmark-suite/benchmark-suite/lib.scm: Rewrite to be more modern,
  using parameters, records, and higher precision timers.  Since this
  file was never installed, this is an acceptable interface change.
  (run-benchmark): Run the thunk once before going into the benchmark.
  Adapt to new `report' interface.
  (report): Change to expect only one argument, a <benchmark-result>
  object.
  (print-result): Adapt.  The result is in the same format as before.
  (print-user-result): Adapt.  The result is different from before, but
  as this is just printed on stdout and not logged, there should be no
  problem.
  (calibrate-benchmark-framework): Pull initialization into a function.

12 years agoavoid inexact iteration count in benchmarks
Andy Wingo [Mon, 23 Apr 2012 08:27:34 +0000 (04:27 -0400)]
avoid inexact iteration count in benchmarks

* benchmark-suite/benchmarks/arithmetic.bm:
* benchmark-suite/benchmarks/r6rs-arithmetic.bm: Use #e1e7 for the
  iteration count, instead of the flonum 1e7.

12 years agoThank Klaus.
Ludovic Courtès [Sat, 21 Apr 2012 21:08:49 +0000 (23:08 +0200)]
Thank Klaus.

12 years agobytevectors: Fix IEEE-754 endianness conversion.
Ludovic Courtès [Sat, 21 Apr 2012 21:08:49 +0000 (23:08 +0200)]
bytevectors: Fix IEEE-754 endianness conversion.

Fixes <http://bugs.gnu.org/11310>.
Reported by Klaus Stehle <klaus.stehle@uni-tuebingen.de>.

* libguile/ieee-754.h: Remove.
* libguile/Makefile.am (noinst_HEADERS): Remove `ieee-754.h'.

* libguile/bytevectors.c (scm_ieee754_float, scm_ieee754_double): New
  unions.
  (float_to_foreign_endianness, float_from_foreign_endianness,
  double_to_foreign_endianness, double_from_foreign_endianness): Rewrite
  in terms of the new unions.

* test-suite/tests/bytevectors.test ("2.8 Operations on IEEE-754
  Representations")["single, little endian", "single, big endian",
  "double, little endian", "double, big endian"]: New tests.

12 years agoFix and clarify documentation of `sorted?'.
Ludovic Courtès [Sat, 21 Apr 2012 21:08:49 +0000 (23:08 +0200)]
Fix and clarify documentation of `sorted?'.

Fixed <http://bugs.gnu.org/11262>.
Reported by Alexei Matveev <alexei.matveev@gmail.com>.

* libguile/sort.c (scm_sorted_p): Fix and clarify docstring.
* doc/ref/api-utility.texi (Sorting): Update accordingly.

12 years agoRemove duplicate test in `tree-il.test'.
Ludovic Courtès [Sat, 21 Apr 2012 21:08:49 +0000 (23:08 +0200)]
Remove duplicate test in `tree-il.test'.

* test-suite/tests/tree-il.test ("partial evaluation"): Remove duplicate
  test for `(cons 0 (cons 1 (cons 2 (list 3 4 5))))'.

12 years agoAvoid use of `GC_PTR' in "smob.h".
Ludovic Courtès [Thu, 12 Apr 2012 21:16:48 +0000 (23:16 +0200)]
Avoid use of `GC_PTR' in "smob.h".

Commit c46fee438cf9f4a3449e8d04e7a54805517fd092 removed the "bdw-gc.h"
include from "smob.h", so better avoid `GC_PTR'.

* libguile/smob.c (scm_i_finalize_smob): Use `void *' instead of `GC_PTR'.
* libguile/smob.h (scm_i_finalize_smob): Update declaration accordingly.

12 years agoSRFI-9: Set the `record-constructor' slot of the RTD.
Ludovic Courtès [Mon, 9 Apr 2012 22:17:39 +0000 (00:17 +0200)]
SRFI-9: Set the `record-constructor' slot of the RTD.

Fixed <http://bugs.gnu.org/11196>.
Reported by Klaus Stehle <klaus.stehle@uni-tuebingen.de>.

* module/srfi/srfi-9.scm (define-record-type): Define the contructor
  before TYPE-NAME.  Set RTD's constructor field.

* test-suite/tests/srfi-9.test ("record compatibility"): New test
  prefix.

12 years agoFix scm_to_utf8_stringn once and for all; optimize; add tests
Mark H Weaver [Wed, 4 Apr 2012 22:58:44 +0000 (18:58 -0400)]
Fix scm_to_utf8_stringn once and for all; optimize; add tests

* libguile/strings.c (scm_to_utf8_stringn): Fix another new bug in this
  recent comedy of errors: pass the size of the preallocated buffer to
  u32_to_u8.  Arrange to call 'scm_i_string_wide_chars' and
  'scm_i_string_length' only once each.  Rename local variables for
  improved code clarity.

* test-suite/standalone/test-conversion.c (test_to_utf8_stringn): New
  function to test scm_to_utf8_stringn.

12 years agoFix scm_to_utf8_stringn to NUL-terminate properly
Mark H Weaver [Tue, 3 Apr 2012 13:50:20 +0000 (09:50 -0400)]
Fix scm_to_utf8_stringn to NUL-terminate properly

* libguile/strings.c (scm_to_utf8_stringn): NUL-terminate using the
  correct pointer.

12 years agoFix scm_to_utf8_stringn to return the length in bytes, et al
Mark H Weaver [Mon, 2 Apr 2012 22:55:45 +0000 (18:55 -0400)]
Fix scm_to_utf8_stringn to return the length in bytes, et al

* libguile/strings.c (u32_u8_length_in_bytes): Internal static function
  renamed from u32_u8_strlen, whose name was potentially confusing.  For
  added safety, handle everything that can be encoded in the more
  general UTF-8 encoding: up to six bytes for each code point, with code
  points up to 2^31-1.

  (scm_to_utf8_stringn): NUL-terminate only if (lenp == NULL).
  If (lenp != NULL) return the length in bytes in *lenp.

12 years agofix scm_to_utf8_stringn for wide strings to NUL-append the strings
Andy Wingo [Sun, 1 Apr 2012 18:29:41 +0000 (11:29 -0700)]
fix scm_to_utf8_stringn for wide strings to NUL-append the strings

* libguile/strings.c (u32_u8_strlen, scm_to_utf8_stringn): Sigh, fix the
  u32-to-u8 optimization to ensure that the utf8 string is
  NUL-terminated.

12 years agolength's argument is a sequence
BT Templeton [Sun, 1 Apr 2012 19:59:42 +0000 (15:59 -0400)]
length's argument is a sequence

* module/language/elisp/boot.el (length): Use `length' if the argument
  is a list or `generalized-vector-length' otherwise.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Sun, 25 Mar 2012 22:56:29 +0000 (00:56 +0200)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/procprop.c
libguile/smob.c
libguile/smob.h
libguile/vm.c
module/language/tree-il/primitives.scm

12 years agoprimitive resolution for public refs
BT Templeton [Sat, 10 Mar 2012 08:31:58 +0000 (03:31 -0500)]
primitive resolution for public refs

* module/language/tree-il/primitives.scm (resolve-primitives!): Resolve
  public module-refs to primitives.

* test-suite/tests/tree-il.test: New tests for primitive resolution.

12 years agoadd bad-request printer
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.

12 years agoadd exception printers for bad-header, bad-header-component
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.

12 years agomicro-optimizations to string-trim-both, and to (web http)
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.

12 years agomake applicable smob calls cheaper, and fix a memory leak
Andy Wingo [Sun, 18 Mar 2012 19:04:28 +0000 (20:04 +0100)]
make applicable smob calls cheaper, and fix a memory leak

* libguile/vm.c (prepare_smob_call): New helper.  Now, instead of making
  a per-smob trampoline, we will shuffle the smob into the args and use
  a gsubr.  This prevents a memory leak in which the trampolines, which
  were values in a weak-key table, were preventing the smobs from being
  collected.

* libguile/vm-i-system.c (call, tail-call, mv-call): Adapt to new smob
  application mechanism.
  (smob-call): Remove this instruction.

* libguile/smob.h (scm_smob_descriptor): Rename apply_trampoline_objcode
  to apply_trampoline.

* libguile/smob.c: Remove our own objcode trampolines in favor of using
  scm_c_make_gsubr.
  (scm_smob_prehistory): No more trampoline weak map.

* libguile/procprop.c (scm_i_procedure_arity): Adapt to applicable smob
  representation change.

12 years agofix to procedure-arity in previous patch
Andy Wingo [Sun, 18 Mar 2012 19:14:27 +0000 (20:14 +0100)]
fix to procedure-arity in previous patch

* libguile/procprop.c (scm_i_procedure_arity): Fix infinite loop.

12 years agomake applicable smob calls cheaper, and fix a memory leak
Andy Wingo [Sun, 18 Mar 2012 19:04:28 +0000 (20:04 +0100)]
make applicable smob calls cheaper, and fix a memory leak

* libguile/vm.c (prepare_smob_call): New helper.  Now, instead of making
  a per-smob trampoline, we will shuffle the smob into the args and use
  a gsubr.  This prevents a memory leak in which the trampolines, which
  were values in a weak-key table, were preventing the smobs from being
  collected.

* libguile/vm-i-system.c (call, tail-call, mv-call): Adapt to new smob
  application mechanism.
  (smob-call): Remove this instruction.

* libguile/smob.h (scm_smob_descriptor): Rename apply_trampoline_objcode
  to apply_trampoline.

* libguile/smob.c: Remove our own objcode trampolines in favor of using
  scm_c_make_gsubr.
  (scm_smob_prehistory): No more trampoline weak map.

* libguile/procprop.c (scm_i_procedure_arity): Adapt to applicable smob
  representation change.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Mon, 12 Mar 2012 16:00:09 +0000 (17:00 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'

12 years agoMerge branch 'master' of git.sv.gnu.org:/srv/git/guile
Andy Wingo [Mon, 12 Mar 2012 16:00:02 +0000 (17:00 +0100)]
Merge branch 'master' of git.sv.gnu.org:/srv/git/guile

12 years agoweb http: fix Ma -> Mar
Andy Wingo [Mon, 12 Mar 2012 15:58:15 +0000 (16:58 +0100)]
web http: fix Ma -> Mar

* module/web/http.scm (write-date): Fix serialization of Mar.  Oops.

12 years agofix bad-request-printer
Andy Wingo [Sun, 11 Mar 2012 10:06:39 +0000 (11:06 +0100)]
fix bad-request-printer

* module/web/request.scm (bad-request-printer): Fix printer to expect
  args as a list.

12 years agoMerge remote-tracking branch 'local-2.0/stable-2.0'
Andy Wingo [Sun, 11 Mar 2012 10:06:14 +0000 (11:06 +0100)]
Merge remote-tracking branch 'local-2.0/stable-2.0'

Conflicts:
configure.ac

12 years agoadd bad-request printer
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.

12 years agoweb server http: 400 Bad Request on bad requests
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.

12 years agoadd exception printers for bad-header, bad-header-component
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.

12 years agomore libgc 7.1 compat
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.

12 years agoelisp rng
BT Templeton [Thu, 8 Mar 2012 01:09:21 +0000 (20:09 -0500)]
elisp rng

* module/language/elisp/boot.el (random): New function.

12 years agoelisp i/o
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.

12 years agoelisp: symbol-name, intern
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.

12 years agoelisp: when, unless
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.

12 years agoelisp sequence functions
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.

12 years agointegerp, wholenump return nil for non-numbers
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.

12 years agoMerge remote-tracking branch 'local-2.0/stable-2.0'
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

12 years agorun finalizers asynchronously in asyncs
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.

12 years agouse the new finalizer helpers
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.

12 years agoadd scm_i_set_finalizer, scm_i_add_finalizer, scm_i_add_resuscitator
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.

12 years agoscm_new_smob, scm_new_double_smob inline functions
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.

12 years agoscm_cell, scm_double_cell, scm_words back to gc.h
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.

12 years agosimplify inline function infrastructure
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.

12 years agoFix flush on soft ports, so that it actually runs.
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.

12 years agoChange `scm_words' to accept a 32-bit word number.
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.

12 years agoImprove port benchmark.
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'.

12 years agoFix a segfault when /dev/urandom is not accessible
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'.

12 years agofaster (make-prompt-tag); default-prompt-tag is a parameter
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.

12 years agocall-with-{input,output}-string implemented in scheme
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.

12 years agomicro-optimizations to string-trim-both, and to (web http)
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.

12 years agonames of encodings are ascii
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.

12 years agodynstack: pushing a prompt no longer allocates memory
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.

12 years agomicro-optimization in (web server)
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.

12 years agoports.c: inline get_codepoint
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.

12 years agooptimize symbol printing
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.

12 years agoshuffle r4rs procedures into boot-9
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.

12 years agoload parameters earlier in boot-9
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.

12 years agoslight tweak to file-exists?, file-is-directory?
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.

12 years agobootstrapping shenanigans in `warn'
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.

12 years agomore clear comments in boot-9.scm
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.

12 years agoremove deprecated close-io-port
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.

12 years agoinline ice-9/r4rs.scm into ice-9/boot-9.scm
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.

12 years agouse #nil as default for elisp rest parameters
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.

12 years agodeprecate close-io-port
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.

12 years agoMerge branch 'bt/elisp'
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

12 years agoDon't call SYMBOL_STRINGBUF on a string
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.

12 years agoRemove documentation of internal static string comparison functions
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.

12 years agoComment out unused definitions of 'do' and 'case' in psyntax.scm
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.

12 years agoFix syntax wrap comments; remove old unused cruft
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.