Ludovic Courtès [Tue, 22 Nov 2011 09:09:27 +0000 (10:09 +0100)]
Leave $GUILE_LOAD_COMPILED_PATH unchanged when cross-compiling.
* meta/uninstalled-env.in: Don't define $GUILE_LOAD_COMPILED_PATH when
cross-compiling.
Ludovic Courtès [Tue, 22 Nov 2011 08:07:25 +0000 (09:07 +0100)]
Build `psyntax-pp.go' with `--target=$(host)'.
* module/Makefile.am (ice-9/psyntax-pp.go): Pass `--target=$(host)'.
Ludovic Courtès [Mon, 21 Nov 2011 23:21:39 +0000 (00:21 +0100)]
Run `guild compile' with `--target=$(host)'.
* am/guilec (.scm.go): Run `guild compile' with `--target=$(host)'.
Ludovic Courtès [Mon, 21 Nov 2011 23:19:03 +0000 (00:19 +0100)]
Add a `--target' option to `guild compile'.
* module/scripts/compile.scm (%options)["--target"]: New option.
(show-version): Update copyright year.
(compile): Use `with-target' to install the target.
* doc/ref/api-evaluation.texi (Compilation): Mention `--target' option.
Ludovic Courtès [Mon, 21 Nov 2011 23:09:22 +0000 (00:09 +0100)]
Add missing implicit `SCM_API' for `scm_c_make_objcode_slice'.
* libguile/objcodes.h (scm_c_make_objcode_slice): Add implicit `SCM_API'.
Ludovic Courtès [Mon, 21 Nov 2011 21:08:22 +0000 (22:08 +0100)]
Complete cross-compilation support.
* module/system/base/target.scm (%target-endianness, %target-word-size):
New fluids.
(%native-word-size): New variable.
(with-target): Set these fluids.
(cpu-endianness, cpu-word-size, triplet-cpu, triplet-vendor,
triplet-os): New procedures.
(target-cpu, target-vendor, target-os): Use them.
(target-endianness, target-word-size): Refer to the corresponding
fluid.
* libguile/objcodes.c (target_endianness_var, target_word_size_var): New
global variables.
(NATIVE_ENDIANNESS): New macro.
(target_endianness, target_word_size, to_native_order): New functions.
(make_objcode_from_file): Use `scm_bytecode_to_native_objcode' instead
of `scm_bytecode_to_objcode'.
(bytecode_to_objcode): New function, based on `scm_bytecode_to_objcode',
with the addition of an `endianness' and `word_size' parameters.
(scm_bytecode_to_objcode): Use it.
(scm_bytecode_to_native_objcode): New function.
(scm_write_objcode): Use `target_word_size' and `target_endianness'.
Convert OBJCODE's len and meta-len to native byte order.
(scm_init_objcodes): Initialize `target_endianness_var' and
`target_word_size_var'.
* libguile/objcodes.h (scm_bytecode_to_native_objcode): New declaration.
* libguile/vm.c (really_make_boot_program): Use
`scm_bytecode_to_native_objcode' instead of `scm_bytecode_to_objcode'.
* test-suite/tests/asm-to-bytecode.test (%objcode-cookie-size): New
variable.
(test-target): New procedure.
("cross-compilation"): Add `test-target' calls and the "unknown
target" test.
Ludovic Courtès [Mon, 21 Nov 2011 20:55:13 +0000 (21:55 +0100)]
Fix `validate-target' in (system base target).
* module/system/base/target.scm (validate-target): Accept any tuple with
at least 3 parts.
* test-suite/tests/asm-to-bytecode.test (test-triplet): New procedure.
("cross-compilation"): New test prefix.
Andy Wingo [Fri, 18 Nov 2011 10:09:48 +0000 (11:09 +0100)]
deprecate direct scm_protects access
* libguile/gc.h:
* libguile/gc.c: Deprecate direct access to scm_protects.
Ludovic Courtès [Sun, 20 Nov 2011 00:10:58 +0000 (01:10 +0100)]
Allow overlapping regions to be passed to `bytevector-copy!'.
Reported by Dmitry Chestnykh <dmitry@codingrobots.com>.
Fixes <http://debbugs.gnu.org/10070>.
* libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not
`memcpy'.
* test-suite/tests/bytevectors.test ("2.2 General
Operations")["bytevector-copy! overlapping"]: New test.
* doc/ref/api-data.texi (Bytevector Manipulation): Mention possible
overlapping.
Andy Wingo [Thu, 17 Nov 2011 09:52:06 +0000 (10:52 +0100)]
eval.test work
* test-suite/tests/eval.test ("stacks"): Enable another test, fix to use
with-throw-handler, and remove a duplicate test, now that there is no
difference between subrs and gsubrs.
Ludovic Courtès [Wed, 16 Nov 2011 22:53:58 +0000 (23:53 +0100)]
FFI: Hold a weak reference to the CIF made by `procedure->pointer'.
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference
to CIF so that it is not reclaimed before POINTER. Before that it
could be reclaimed and typically reused to store the CIF of another
procedure with the same arity, leading to obscure wrong-type-arg
errors.
Ludovic Courtès [Wed, 16 Nov 2011 22:51:34 +0000 (23:51 +0100)]
FFI: Add a `procedure->pointer' test.
* test-suite/tests/foreign.test ("procedure->pointer")["procedures
returning a pointer"]: New test.
Andy Wingo [Wed, 16 Nov 2011 22:21:59 +0000 (23:21 +0100)]
fix urls in docs
* doc/ref/intro.texi (Introduction):
* doc/ref/scheme-reading.texi (Further Reading):
* doc/ref/srfi-modules.texi (SRFI Support): Fix some urls. Thanks to
Henrik Sandklef for the report.
Andy Wingo [Wed, 16 Nov 2011 22:17:51 +0000 (23:17 +0100)]
fix web.texi typo
* doc/ref/web.texi (HTTP Headers): Fix a typo. Thanks to Brian Gough
for the report.
Andy Wingo [Wed, 16 Nov 2011 22:13:55 +0000 (23:13 +0100)]
hack the port-column of current-output-port after printing a prompt
* module/ice-9/boot-9.scm (repl-reader): Reset the output-column to 0
after printing the prompt. Fixes bug 9664.
Andy Wingo [Wed, 16 Nov 2011 19:15:26 +0000 (20:15 +0100)]
eval-when tidying up
* module/ice-9/psyntax.scm: Rename expand-when-list to parse-when-list,
and simplify to compare literal values.
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Wed, 16 Nov 2011 19:08:40 +0000 (20:08 +0100)]
psyntax: s/chi/expand/g
* module/ice-9/psyntax.scm: Rename all instances of "chi" to "expand".
Addded a hack to expand-eval-when that will be fixed later.
* module/ice-9/psyntax-pp.scm: Regenerated.
Andy Wingo [Wed, 16 Nov 2011 18:44:04 +0000 (19:44 +0100)]
fix bug in make-repl when lang is actually a language
* module/system/repl/common.scm (make-repl): Fix to accept language
objects in addition to symbols. Fixes http://debbugs.gnu.org/9857.
Thanks to Tristan Colgate for the report.
Ludovic Courtès [Wed, 16 Nov 2011 14:11:55 +0000 (15:11 +0100)]
Re-enable a couple of evaluator tests.
These tests had been disabled as part of
b7742c6b7132544b9d6cd9cb32c09e2084ad9e52 ("new evaluator, y'all").
* test-suite/tests/eval.test ("define set procedure-name")["closure"]:
Change to `pass-if' since it now works, as a result of
ee15aa46e3fb29e609bd7c431e8f2676f6573d57 ("set names of functions
defined at the toplevel from `eval'").
("stacks")["arguments of a gsubr stack frame"]: Remove (throw
'unresolved).
Andy Wingo [Wed, 16 Nov 2011 12:33:52 +0000 (13:33 +0100)]
memoize: booleanify the rest arg
* libguile/memoize.c (memoize): Turn the rest arg into a boolean. Fixes
an error when rest gets passed to set-procedure-minimum-arity!.
Andy Wingo [Tue, 15 Nov 2011 22:38:40 +0000 (23:38 +0100)]
set names of functions defined at the toplevel from `eval'
* module/ice-9/eval.scm (primitive-eval): Set the name of
toplevel-defined functions.
Andy Wingo [Tue, 15 Nov 2011 22:36:07 +0000 (23:36 +0100)]
better debuggability for interpreted procedures
* libguile/procprop.c (scm_set_procedure_minimum_arity_x): New
function, allows a user to override a function's arity.
(scm_i_procedure_arity): Look up in the overrides table first.
* libguile/procprop.h: Add scm_set_procedure_minimum_arity_x.
* module/ice-9/eval.scm (primitive-eval): Override arity of "general
closures".
* test-suite/tests/procprop.test ("procedure-arity"): Add tests.
Based on a patch from Stefan Israelsson Tampe. Test based on work by
Patrick Bernaud.
Andy Wingo [Fri, 11 Nov 2011 15:39:28 +0000 (16:39 +0100)]
update letrec compilation test
* test-suite/tests/tree-il.test ("letrec"): Update to clear the
temporary `let' bindings.
Andy Wingo [Thu, 10 Nov 2011 21:30:02 +0000 (22:30 +0100)]
fix bit-set*! bug (!)
* libguile/bitvectors.c (scm_bit_set_star_x): Fix a long-standing (since
2005) bug in which instead of using the kv bitvector, we actually use
the `v' bitvector. Also, change to allow `kv' being shorter than
`v'.
* test-suite/tests/bitvectors.test ("bit-set*!"): Add tests.
Andy Wingo [Wed, 9 Nov 2011 22:45:53 +0000 (23:45 +0100)]
when leaving a non-tail let, allow bound vals to be collected
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Clear
lexical stack slots at the end of a non-tail let, letrec, or fix.
Fixes http://debbugs.gnu.org/9900.
* test-suite/tests/gc.test ("gc"): Add test.
Andy Wingo [Wed, 9 Nov 2011 15:44:59 +0000 (16:44 +0100)]
simplify primitives.scm for dynwind
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove a dynwind hack, as we have a good inliner now.
Andy Wingo [Wed, 9 Nov 2011 14:23:58 +0000 (15:23 +0100)]
peval: fix dynwind bug.
* module/language/tree-il/peval.scm (peval): The <dynwind> compiler will
copy the winder and unwinder values, so make sure that they are
constant, and if not, create lexical bindings. Fixes
http://debbugs.gnu.org/9844.
* test-suite/tests/tree-il.test ("partial evaluation"): Add a couple
<dynwind> tests.
Andy Wingo [Wed, 9 Nov 2011 15:41:56 +0000 (16:41 +0100)]
fix <dynwind> serialization.
* module/language/tree-il.scm (unparse-tree-il): Fix <dynwind>
serialization.
Andy Wingo [Wed, 9 Nov 2011 14:22:01 +0000 (15:22 +0100)]
peval: don't copy assigned lexical bindings
* module/language/tree-il/peval.scm (peval): Since constant-expression?
is used to determine whether to copy values, return #f if any lexical
is assigned.
Ian Price [Wed, 26 Oct 2011 19:24:05 +0000 (20:24 +0100)]
Fix R6RS `fold-left' so the accumulator is the first argument.
* module/rnrs/lists.scm (fold-left): New procedure.
* module/rnrs/records/syntactic.scm (define-record-type): Fix to use
corrected `fold-left'.
* test-suite/tests/r6rs-lists.test: Add tests.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Sat, 22 Oct 2011 14:53:43 +0000 (16:53 +0200)]
Update `NEWS'.
Ludovic Courtès [Sat, 22 Oct 2011 14:48:46 +0000 (16:48 +0200)]
Fix compilation of `deprecated.c' with SCM_DEBUG_TYPING_STRICTNESS=2.
* libguile/deprecated.c (init_module_stuff,
scm_primitive_make_property): Use `scm_is_false' instead of direct
comparison to SCM_BOOL_F'.
(maybe_close_port, scm_close_all_ports_except): Use `SCM2PTR' and
`PTR2SCM' instead of wild casts.
Ludovic Courtès [Sat, 22 Oct 2011 14:29:20 +0000 (16:29 +0200)]
Bump version number for 2.0.3.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_CURRENT): Increment to account for new C functions
`scm_is_exact' etc.
(LIBGUILE_INTERFACE_AGE): Increment.
Ludovic Courtès [Sat, 22 Oct 2011 14:24:32 +0000 (16:24 +0200)]
Update Gnulib to
v0.0-6523-gb3609c1.
Ludovic Courtès [Sat, 22 Oct 2011 14:11:01 +0000 (16:11 +0200)]
doc: Document the `sitedir' and `extensiondir' pkg-config variables.
* doc/ref/libguile-parallel.texi (Parallel Installations): Document the
`sitedir' and `extensiondir' pkg-config variables. This fixes
<https://savannah.gnu.org/bugs/index.php?32515>, reported by
Dale. P. Smith.
Bake Timmons [Sat, 22 Oct 2011 11:28:53 +0000 (13:28 +0200)]
Fix compilation with `--enable-debug-malloc'.
* libguile/gc-malloc.c (scm_gc_register_collectable_memory): Add the
missing second argument in the call to scm_malloc_register.
Ludovic Courtès [Sat, 22 Oct 2011 11:25:11 +0000 (13:25 +0200)]
Initialize `get_internal_run_time' before it is used.
* libguile/init.c (scm_i_init_guile): Call `scm_init_stime' before
`scm_init_gc'. Fixes <https://savannah.gnu.org/bugs/?34616> reported
by Bake Timmons.
BT Templeton [Fri, 22 Jul 2011 15:35:30 +0000 (11:35 -0400)]
set width for `,trace' command
* module/system/repl/command.scm (trace): Set trace width to terminal
width by default.
Andy Wingo [Thu, 20 Oct 2011 22:22:44 +0000 (00:22 +0200)]
fix segfault in goops if class fields are redefined
* libguile/goops.c (map, filter_cpl, remove_duplicate_slots): Use
scm_is_pair instead of !scm_is_null, given that we use accessor
macros.
(check_cpl, build_slots_list): Check that descendents of <class> can't
redefine slots of <class>.
* test-suite/tests/goops.test ("defining classes"): Add a test.
Patch originally by Stefan Israelsson Tampe.
Andy Wingo [Thu, 20 Oct 2011 21:50:05 +0000 (23:50 +0200)]
fix misallocation of some <fix> procedures
* module/language/tree-il/analyze.scm (analyze-lexicals): When stepping
into a non-tail form, we know that labels allocation will be invalid,
so use an empty labels set. Fixes http://debbugs.gnu.org/9769.
* test-suite/tests/tree-il.test ("labels allocation"): Add a test.
Andy Wingo [Wed, 19 Oct 2011 09:55:27 +0000 (11:55 +0200)]
slight frames.h refactor
* libguile/frames.h: Instead of doing a lot of nasty pointer match and
casts here, simply define a struct that aliases the contents of a
stack frame. There are some naming issues here, that the SCM_FRAME
macros access the scm_vm_frame structure, but SCM_VM_FRAME macros
access scm_frame; oh well.
Ludovic Courtès [Tue, 18 Oct 2011 16:47:09 +0000 (18:47 +0200)]
doc: Add `libguile-parallel.texi' to the distribution.
This is a followup to
d32df1325dfe5f550cf1262dc7e90ba86b526a7c ("manual:
reorganize autoconf, pkg-config info").
* doc/ref/Makefile.am (guile_TEXINFOS): Add `libguile-parallel.texi'.
Andy Wingo [Mon, 17 Oct 2011 07:48:19 +0000 (09:48 +0200)]
fix (web http) write-date for mondays
* module/web/http.scm (write-date): Fix bug on Mondays. Jeez!
Ludovic Courtès [Sun, 16 Oct 2011 19:55:29 +0000 (21:55 +0200)]
doc: Complete renaming of `autoconf.texi'.
This is a followup to
d32df1325dfe5f550cf1262dc7e90ba86b526a7c ("manual:
reorganize autoconf, pkg-config info").
* doc/ref/Makefile.am: Replace references to `autoconf.texi' by
`libguile-autoconf.texi'.
Ludovic Courtès [Sun, 16 Oct 2011 16:36:20 +0000 (18:36 +0200)]
Update (ice-9 match) from Chibi-Scheme.
* module/ice-9/match.scm (match): Remove macro.
* module/ice-9/match.upstream.scm: Update from Chibi-Scheme, which fixes
<http://debbugs.gnu.org/9567>.
* test-suite/tests/match.test.upstream: Likewise.
Ludovic Courtès [Sat, 15 Oct 2011 15:05:23 +0000 (17:05 +0200)]
coverage: Add tests for `case-lambda'.
* test-suite/tests/coverage.test
("line-execution-counts")["case-lambda"]: New test.
("procedure-execution-count")["case-lambda"]: New test.
Ludovic Courtès [Sat, 15 Oct 2011 15:34:48 +0000 (17:34 +0200)]
doc: Mention the partial evaluator next to `define-inlinable'.
* doc/ref/api-procedures.texi (Inlinable Procedures): Mention inlining
performed by the partial evaluator.
Ludovic Courtès [Sat, 15 Oct 2011 14:46:29 +0000 (16:46 +0200)]
coverage: Add test with `eval'.
* test-suite/tests/coverage.test (test-procedure): New procedure.
("procedure-execution-count")["called from eval"]: New test.
Cedric Cellier [Sat, 15 Oct 2011 14:25:21 +0000 (16:25 +0200)]
Default to using poll(2) in `fport_input_waiting'.
* libguile/fports.c (fport_input_waiting): Use poll(2) instead of
select(2) when possible. Cosmetic changes by Ludovic Courtès.
Andy Wingo [Wed, 12 Oct 2011 15:12:14 +0000 (17:12 +0200)]
update NEWS for 2.0.3
* NEWS: Update.
Andy Wingo [Wed, 12 Oct 2011 14:20:51 +0000 (16:20 +0200)]
add "Installing Site Packages"
* doc/ref/scheme-using.texi (Installing Site Packages): Add a new
section about where to install .scm, .go, and .so files.
* doc/ref/tour.texi: Reference it here.
* doc/ref/guile.texi: Add new section.
Andy Wingo [Wed, 12 Oct 2011 11:07:50 +0000 (13:07 +0200)]
update tour.texi for site modules and extensions
* doc/ref/tour.texi (Putting Extensions into Modules)
(Writing new Modules): In the examples, show the files as being in the
"site" dirs.
Andy Wingo [Wed, 12 Oct 2011 11:07:30 +0000 (13:07 +0200)]
manual: reorganize autoconf, pkg-config info
* doc/ref/libguile-parallel.texi: New file, documenting parallel
installation and the use of pkg-config.
* doc/ref/libguile-linking.texi: Adapt.
* doc/ref/libguile-autoconf.texi: Rename from autoconf.texi. Lower
sections, and integrate in the "Programming in C" chapter.
* doc/ref/guile.texi: Adapt.
Andy Wingo [Wed, 12 Oct 2011 09:51:33 +0000 (11:51 +0200)]
remove documentation on autofrisk foo
* doc/ref/autoconf.texi: Remove documentation on autofrisk facility,
given that we do not ship those macros, and to my knowledge, never
have.
Andy Wingo [Wed, 12 Oct 2011 09:24:58 +0000 (11:24 +0200)]
add (web client) docs
* doc/ref/web.texi (Web Client): New doc section.
Andy Wingo [Mon, 10 Oct 2011 18:39:22 +0000 (20:39 +0200)]
fold constants with accessors
* module/language/tree-il/peval.scm (peval): Factor constant folding out
to a helper. Use it in the accessor case in addition to the normal
effect-free-primitive case.
* test-suite/tests/tree-il.test: Add a test.
Andy Wingo [Mon, 10 Oct 2011 18:19:07 +0000 (20:19 +0200)]
recognize string primitives
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Add string?, string-length, and ref
and set.
(*primitive-accessors*): Add string-ref.
(*effect-free-primitives*): Add string-length and string?
(*effect+exception-free-primitives*): Add string?.
(*singly-valued-primitives*): Add string-length and ref and set.
Andy Wingo [Mon, 10 Oct 2011 15:01:11 +0000 (17:01 +0200)]
add ,expand and ,optimize
* module/system/repl/command.scm (*command-table*, expand, optimize):
New meta-commands.
* module/system/repl/common.scm (repl-expand, repl-optimize): New
helpers.
* doc/ref/scheme-using.texi (Compile Commands): Document.
Andy Wingo [Mon, 10 Oct 2011 11:01:54 +0000 (13:01 +0200)]
regenerate psyntax-pp.scm
* module/ice-9/psyntax-pp.scm: Regenerate, now with inlined letrec
bindings. Whee!!
Andy Wingo [Mon, 10 Oct 2011 12:42:40 +0000 (14:42 +0200)]
peval support for memq and memv
* module/language/tree-il/peval.scm (peval): Add special handlers for
memq and memv, as inline.scm used to have. This is important for
`case' clauses. It is very ugly, though.
* test-suite/tests/tree-il.test ("partial evaluation"): Add tests.
Andy Wingo [Mon, 10 Oct 2011 11:23:26 +0000 (13:23 +0200)]
add accessor-primitive?, peval uses it
* module/language/tree-il/primitives.scm (*primitive-accessors*): New
set of primitives: those that access mutable memory, but are otherwise
pure. Include bytevector references here.
(accessor-primitive?): New public predicate.
* module/language/tree-il/peval.scm (peval): Refactor to distinguish
constructor-primitive? from accessor-primitive?.
Andy Wingo [Mon, 10 Oct 2011 10:58:28 +0000 (12:58 +0200)]
peval: visit operands on-demand, to inline mutually recursive bindings
This commit changes to use <operand> structures to hold the context
needed to visit lexical bindings lazily, in context, instead of eagerly
visiting them for value. This laziness enables inlining of mutually
recursive bindings.
* module/language/tree-il/peval.scm (<var>): Remove comment about copy
propagation having to run build-var-table; things don't work like that
any more.
(build-var-table): Build <var> entries for all variables, even
unreferenced variables.
(alpha-rename): Remove. We will rename bindings on-demand now.
(peval lookup-var): New helper, to fetch the <var> of a gensym.
(peval fresh-gensyms): Fold here, under peval, and in it, handle
updating the store to record a mapping between new names and <var>
entries from the source program.
(peval record-source-expression): Don't call build-var-table on the
new expression, as alpha-renaming happens on-demand now.
(peval prune-bindings): Rewrite to work with mutually-recursive
bindings, while optionally preserving binding order.
(peval extend-env): New helper.
(peval loop): OK, here goes... Remove the `operand' context, as now we
visit operands lazily. Add a `call' context, which does not
copy-propagate lambda expressions, used to residualize a call after
aborting an inlining attempt. Change the `env' to be a mapping of
gensym to <operand>. Instead of looking up the operand's binding then
alpha-renaming it, just rely on the fact that visiting the operand
will rename it if necessary.
If we residualize a lexical, do so with the fresh name from the
environment. If we visit an operand and it doesn't turn out to be
constant, we will never be able to copy it, and so cache that fact in
the operand. If we residualize a binding and we know what the value
should be, record that binding so that prune-bindings won't have to
visit it again. If the operand folds to a constant, cache that too,
to save effort when unrolling loops.
For let, letrec, fix, and lambda-case, instead of visiting the
bindings eagerly for value, simply record the source expressions and
environments in an <operand> and rely on copy-propagation to visit
them later in the right context. In the case of letrec and fix, this
allows mutually-recursive bindings to be inlined.
Refactor folding of "constructors" (which still need renaming) to
avoid visiting operands twice in some contexts.
For applications, if we have to abort, process the procedure in call
context, which allows some folding but avoids copying lambdas. If we
find a recursive procedure, mark intervening counters as recursive
too, to allow for mutual recursion at the top level.
For lambdas, if we are processing for value, record the source
expression so we can detect recursion. This was previously done in
the lexical-ref copy propagator.
* test-suite/tests/tree-il.test ("partial evaluation"): Remove unused
recursive lexicals in a couple of cases. Add a couple test cases for
pruning. Add a few recursive binding cases.
Andy Wingo [Thu, 6 Oct 2011 08:56:12 +0000 (10:56 +0200)]
peval: add operand structure
* module/language/tree-il/peval.scm (<operand>): Add operand structure,
to be used by peval.
Andy Wingo [Mon, 10 Oct 2011 10:03:17 +0000 (12:03 +0200)]
peval: refactor logging
* module/language/tree-il/peval.scm: Make it easier to turn on logging.
Mike Gran [Mon, 10 Oct 2011 03:54:37 +0000 (20:54 -0700)]
New functions scm_is_exact and scm_is_inexact
* doc/ref/api-data.texi (Exact and Inexact Numbers): doc for scm_is_exact
and scm_is_inexact
* libguile/numbers.c (scm_is_exact, scm_is_inexact): new functions
* libguile/numbers.h: declarations for scm_is_exact and scm_is_inexact
* test/suite/standalone/test-conversion.c (test_is_exact, test_is_inexact):
new tests
Mike Gran [Sun, 9 Oct 2011 00:12:12 +0000 (17:12 -0700)]
Document SCM_ASSERT_TYPE and SCM_ASRTGO macros
* doc/ref/api-control.texi (Signalling Type Errors): document macros
Andy Wingo [Fri, 7 Oct 2011 13:49:36 +0000 (15:49 +0200)]
peval: logging
* module/language/tree-il/peval.scm: Define a quick and dirty
infrastructure for logging. Use it in peval.
Andy Wingo [Thu, 6 Oct 2011 21:28:19 +0000 (23:28 +0200)]
peval: bugfix in constant-expression?
* module/language/tree-il/peval.scm (constant-expression?): Correctly
handle lambda-case alternates.
Andy Wingo [Thu, 6 Oct 2011 21:28:06 +0000 (23:28 +0200)]
optimizer verifies its output
* module/language/tree-il/optimize.scm: Verify the result of partial
evaluation.
Andy Wingo [Thu, 6 Oct 2011 21:27:43 +0000 (23:27 +0200)]
add tree-il verifier
* module/Makefile.am: Add debug.scm.
* module/language/tree-il/debug.scm: New file, a verifier for tree-il.
Andy Wingo [Thu, 6 Oct 2011 10:14:10 +0000 (12:14 +0200)]
peval refactor
* module/language/tree-il/peval.scm (peval): Refactor the for-value, etc
helpers.
Andy Wingo [Thu, 6 Oct 2011 08:39:14 +0000 (10:39 +0200)]
comment peval.scm
* module/language/tree-il/peval.scm: Add comments. Move alpha-rename
later in the file.
Andy Wingo [Wed, 5 Oct 2011 18:41:11 +0000 (20:41 +0200)]
fix reading of #||||#
* libguile/read.c (scm_read_r6rs_block_comment):
* test-suite/tests/reader.test ("reading"): Fix reading of #||||#,
originally reported in bug debbugs.gnu.org/9672, by Bruno Haible.
Thanks, Bruno!
Ludovic Courtès [Fri, 30 Sep 2011 13:20:16 +0000 (15:20 +0200)]
peval: Add test for possible infinite recursion.
* test-suite/tests/tree-il.test ("partial evaluation"): Add test.
Ludovic Courtès [Fri, 30 Sep 2011 13:16:02 +0000 (15:16 +0200)]
Add link to the (ice-9 match) bug.
* module/ice-9/match.scm: Add comment.
Ludovic Courtès [Fri, 23 Sep 2011 15:27:28 +0000 (17:27 +0200)]
peval: Recognize module-refs to primitives.
* module/language/tree-il/optimize.scm (peval): Handle module-refs to
primitives.
* test-suite/tests/tree-il.test ("partial evaluation"): Add test, using
`pmatch'.
Andy Wingo [Wed, 28 Sep 2011 17:42:32 +0000 (19:42 +0200)]
generate psyntax-pp in canonical form
* module/ice-9/compile-psyntax.scm (source): Canonicalize after
optimizing. The optimizer should be a little more clever, but
currently fix-letrec outputs some non-canonical forms.
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Wed, 28 Sep 2011 17:39:25 +0000 (19:39 +0200)]
separate peval and a new canonicalization pass into their own modules
* module/language/tree-il/peval.scm: Move to its own file. Remove the
bits about <prompt> thunk-application bodies, as they are not
optimizations, simply expectations of the compiler. `canonicalize'
handles that now.
* module/language/tree-il/optimize.scm: Use peval from its module.
Don't call `inline!', as that's useless now.
* module/language/tree-il/canonicalize.scm: New file, implementing a
pass that `compile-tree-il' runs on the result from the optimizer.
The compiler currently expects a <let> form to have bindings, for
example, and this pass turns a <let> without bindings into its body.
* module/language/tree-il/inline.scm: Deprecate, as `peval' does
everything this function ever did.
* module/language/tree-il/compile-glil.scm: Canonicalize after
optimizing. This should allow us to skip the optimizer entirely, if
we want.
* module/Makefile.am: Update and reorder a little bit.
Andy Wingo [Tue, 27 Sep 2011 13:09:25 +0000 (15:09 +0200)]
regenerate psyntax-pp.scm, with optimizations
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Tue, 27 Sep 2011 21:29:10 +0000 (23:29 +0200)]
((lambda ...) ...) fix
* module/language/tree-il/optimize.scm (peval): If it's a lambda in the
operator position, inline without a nested counter, as it's not
possible to increase code size.
Andy Wingo [Tue, 27 Sep 2011 21:21:53 +0000 (23:21 +0200)]
peval: more effective binding pruning
* module/language/tree-il/optimize.scm (peval): Factor prune-bindings
out of `let' and company. Have it process unreferenced bindings in
effect context instead of always residualizing non-constant
expressions.
Andy Wingo [Tue, 27 Sep 2011 21:20:49 +0000 (23:20 +0200)]
don't propagate pure primcalls that might not type-check
* module/language/tree-il/optimize.scm (types-check?): New helper, to
determine if a primcall will apply without throwing an exception.
(peval): constant-expression? returns #f for expressions that don't
types-check?. Effect-free primitives that type-check are void.
Andy Wingo [Tue, 27 Sep 2011 13:08:39 +0000 (15:08 +0200)]
fix unparse-tree-il of <dynset>
* module/language/tree-il.scm (unparse-tree-il): Fix printing of
`dynset'.
Andy Wingo [Tue, 27 Sep 2011 13:08:17 +0000 (15:08 +0200)]
peval works on all expressions
* module/language/tree-il/optimize.scm (alpha-rename, peval): Add
<dynset> cases. Allow any kind of <application>. Remove the `catch'
wrapper as now peval handles all kinds of expressions.
Andy Wingo [Tue, 27 Sep 2011 11:42:43 +0000 (13:42 +0200)]
peval: elide make-prompt-tag in effect context
* module/language/tree-il/optimize.scm (peval): Fix a duplicate
traversal for constructors in effect or test context. Add support for
eliding make-prompt-tag.
* test-suite/tests/tree-il.test ("partial evaluation"): Update the test
for make-prompt-tag elision.
Andy Wingo [Tue, 27 Sep 2011 11:39:29 +0000 (13:39 +0200)]
peval: add support for <prompt> and <abort>
* module/language/tree-il/optimize.scm (alpha-rename, peval): Handle
<prompt> and <abort>. Attempt to remove the prompt if the tag is
otherwise unreferenced.
* module/language/tree-il/primitives.scm (*primitive-constructors*): Add
make-prompt-tag as a constructor.
* test-suite/tests/tree-il.test ("partial evaluation"): Add a test that
an prompt whose tag is unreferenced is removed.
Andy Wingo [Tue, 27 Sep 2011 07:48:18 +0000 (09:48 +0200)]
peval: fix algorithmic behavior of `cons'
* module/language/tree-il/optimize.scm (peval): Fix treatment of `cons'
to not process the value twice, leading to n^2 work. This prevented
primitives.scm from compiling in a reasonable amount of time, because
it contained a `(foo ... ,@bar) form that resulted in a long sequence
of nested conses, and no effort counter was in place as it was not
within an inlining attempt.
Ludovic Courtès [Tue, 27 Sep 2011 16:00:20 +0000 (18:00 +0200)]
doc: (ice-9 match) doesn't have `__1'.
* doc/ref/match.texi (Pattern Matching): Remove `__1', which doesn't
exist. Thanks to Chris K. Jester-Young.
Ludovic Courtès [Tue, 27 Sep 2011 11:46:35 +0000 (13:46 +0200)]
doc: Update (ice-9 match) reference.
* doc/ref/match.texi (Pattern Matching): Document `***', `..1', and
`__1'; remove `..k' and `__k'. Reported by Chris K. Jester-Young.
Ludovic Courtès [Tue, 27 Sep 2011 11:41:21 +0000 (13:41 +0200)]
doc: Fix typesetting of function definitions in "Accessing Modules from C".
* doc/ref/api-modules.texi (Accessing Modules from C): Use the phrase "C
Function" instead of "C Procedure". Enclose multiple-word type names
in braces. Reported by Dale P. Smith.
Andy Wingo [Mon, 26 Sep 2011 22:21:16 +0000 (00:21 +0200)]
peval: more strict accounting
* module/language/tree-il/optimize.scm (transfer!, make-nested-counter):
(make-recursive-counter, peval): Limit the algorithm's time to be
strictly O(N) by transferring effort and size counters of recursive
inlining attempts from containing counters.
* test-suite/tests/tree-il.test ("partial evaluation"): Update
expectations for the ((lambda (x) (x x)) (lambda (x) (x x))) case, as
the new accounting policy will cause the entire inlining attempt to
abort.
Andy Wingo [Mon, 26 Sep 2011 20:32:45 +0000 (22:32 +0200)]
peval: fix inlining of lambda* with #:optional
* module/language/tree-il/optimize.scm (peval): Fix calculation of how
many init expressions to drop when inlining lambdas.
* test-suite/tests/tree-il.test ("partial evaluation"): Add tests.
Andy Wingo [Mon, 26 Sep 2011 20:24:00 +0000 (22:24 +0200)]
remove unused peval helpers
* module/language/tree-il/optimize.scm (peval): Remove a couple unused
helpers.
Andy Wingo [Fri, 23 Sep 2011 10:43:04 +0000 (12:43 +0200)]
peval: simpler and more precise treatment of mutability
* module/language/tree-il/optimize.scm (peval): The old approach of
optimistically producing constants and then de-constifying them at
their uses was not only cumbersome but incorrect: it both failed to
preserve identity in some cases and failed to retain immutable
constant values. Instead, now we only produce constants if they
really are constant and immutable. The constant folder has to have a
few more algebraic cases to be as effective as it was, to destructure
(car (cons _ _)) appropriately. On the plus side, now constructors
and deconstructors can handle impure cases more generally.
* test-suite/tests/tree-il.test ("partial evaluation"): Add constructor
and destructuring tests. Adapt other tests to new expectations.
Andy Wingo [Sun, 25 Sep 2011 00:54:34 +0000 (02:54 +0200)]
peval: add a bunch of missing maybe-unconst calls
* module/language/tree-il/optimize.scm (peval): Add missing
maybe-unconst calls. Things are getting ugly. They will get better
in the next commit though.
Andy Wingo [Thu, 22 Sep 2011 22:29:14 +0000 (00:29 +0200)]
peval uses effort counters, propagates lambdas more effectively
* module/language/tree-il/optimize.scm (code-contains-calls?): Remove
this helper, we will deal with recursion when it happens, not after
the fact.
(peval): Add keyword args for various size and effort limits. Instead
of keeping a call stack, keep a chain of <counter> records, each with
an abort continuation. If ever an inlining attempt is taking too
long, measured in terms of number of trips through the main loop, the
counter will abort. Add new contexts, `operator' and `operand'. They
have different default size limits. In the future we should actually
use the size counter, instead of these heuristics.
The <lexical-ref> case is smarter now, and tries to avoid propagating
too much data. Perhaps it should be dumber though, and use a
counter. That would require changes to the environment structure.
Inline <lambda> applications to <let>, so that we allow residual
lexical references to have bindings. Add a `for-operand' helper, and
use it for the RHS of `let' expressions. A `let' is an inlined
`lambda'.
`Let' and company no longer elide bindings if the result is a
constant, as the arguments could have effects. Peval will still do as
much as it can, though.
* test-suite/tests/tree-il.test ("partial evaluation"): Update the tests
for the new expectations. They are uniformly awesomer, with the
exception of two cases in which pure but not constant data is not
propagated.
Andy Wingo [Thu, 22 Sep 2011 22:21:46 +0000 (00:21 +0200)]
prune unused letrec bindings
* module/language/tree-il/optimize.scm (peval): Prune unused `letrec'
bindings.
Andy Wingo [Thu, 22 Sep 2011 22:18:13 +0000 (00:18 +0200)]
more peval refactoring
* module/language/tree-il/optimize.scm (peval): Rename `var-table' to
`store', as we're going to put some more things in it. Rename
`record-lexical-bindings' to `record-source-expression', which also
takes the original, pre-renaming expression. Keep a mapping from new
expressions to original expressions, available using the
`source-expression' helper.
Andy Wingo [Thu, 22 Sep 2011 22:12:21 +0000 (00:12 +0200)]
add helpers for effort counters
* module/language/tree-il/optimize.scm (<counter>, abort-counter)
(record-effort!, record-size!, find-counter, make-top-counter)
(make-nested-counter, make-recursive-counter): New helpers, as yet
unused, but which will implement fixed effort bounds on the inlining
algorithm.
Andy Wingo [Thu, 22 Sep 2011 22:05:27 +0000 (00:05 +0200)]
peval refactor
* module/language/tree-il/optimize.scm (peval): Add for-value, for-test,
for-effect, and for-tail helpers. Use them.