summaryrefslogtreecommitdiff
path: root/test-suite/tests
AgeCommit message (Collapse)AuthorFilesLines
2011-11-15set names of functions defined at the toplevel from `eval'Andy Wingo1-1/+6
* module/ice-9/eval.scm (primitive-eval): Set the name of toplevel-defined functions.
2011-11-15better debuggability for interpreted proceduresAndy Wingo1-2/+17
* 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.
2011-11-11Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-1/+3
2011-11-11update letrec compilation testAndy Wingo1-1/+3
* test-suite/tests/tree-il.test ("letrec"): Update to clear the temporary `let' bindings.
2011-11-11Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo2-12/+37
2011-11-10fix bit-set*! bug (!)Andy Wingo1-3/+18
* 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.
2011-11-09when leaving a non-tail let, allow bound vals to be collectedAndy Wingo1-9/+19
* 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.
2011-11-09inline dynwind guards for normal control flowAndy Wingo1-2/+8
* module/language/tree-il.scm (<tree-il>): Add `pre' and `post' fields to <dynwind>, so that we can inline the guard bodies in the normal control-flow case. It also avoids duplicating code in compile-glil, which probably hides more bugs in 2.0. (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold) (make-tree-il-folder, post-order!, pre-order!): Update. * module/language/tree-il/analyze.scm (analyze-lexicals): Update. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update to use `pre' and `post' instead of compiling code twice. * module/language/tree-il/debug.scm (verify-tree-il): Update. * module/language/tree-il/peval.scm (peval): Update. Instead of doing complicated things in <dynwind>, handle 'dynamic-wind primcalls. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Remove 'dynamic-wind mess. Adapt '@dynamic-wind. * test-suite/tests/tree-il.test ("partial evaluation"): Update tests.
2011-11-09Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo2-0/+44
Conflicts: module/language/tree-il/peval.scm module/language/tree-il/primitives.scm test-suite/tests/tree-il.test
2011-11-09peval: fix dynwind bug.Andy Wingo1-0/+20
* 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.
2011-11-07add tests for hygienic name introductionAndy Wingo1-1/+37
* test-suite/tests/syntax.test ("top-level define"): Add tests for hygienic introduction of names.
2011-11-07another scoping testAndy Wingo1-0/+13
* test-suite/tests/syntax.test ("top-level define"): Add another test for scoping.
2011-11-07add scoping testAndy Wingo1-1/+18
* test-suite/tests/syntax.test ("top-level define"): Add a test for module scoping of introduced identifiers.
2011-11-04peval doesn't resolve primitivesAndy Wingo1-35/+40
* module/language/tree-il/peval.scm (peval): Don't resolve primitives, as resolve-primitives! handles that already. * test-suite/tests/tree-il.test (pass-if-peval): Always resolve and expand primitives. ("partial evaluation"): Update tests to assume expanded primitives.
2011-11-01Fix R6RS `fold-left' so the accumulator is the first argument.Ian Price1-0/+26
* 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>
2011-10-27fix the peval merge and a testAndy Wingo1-1/+1
* module/language/tree-il/peval.scm (peval): Accessor primitives applied to constants are pure if the call type-checks. Also, fold constants in accessor primcalls. * test-suite/tests/tree-il.test ("partial evaluation"): Fix the "yo" test.
2011-10-27Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo4-4/+77
Conflicts: GUILE-VERSION libguile/deprecated.c libguile/gc-malloc.c module/language/tree-il/peval.scm
2011-10-26fix a vhash testAndy Wingo1-2/+2
* test-suite/tests/vlist.test ("vhash"): As far as I can tell this test was not testing the right thing.
2011-10-24remove weak pairs, rewrite weak vectorsAndy Wingo1-12/+12
* libguile/weak-vector.c: * libguile/weak-vector.h: Renamed from weaks.[ch]. Remove weak pairs. They were not safe to access with `car' and `cdr'. Remove weak alist vectors, as we have weak tables and sets. Reimplement weak vectors, moving the implementation here. * libguile/vectors.c: * libguile/vectors.h: Remove the extra header word. Use scm_c_weak_vector_ref / scm_c_weak_vector_set_x to access weak vectors. * libguile/snarf.h: Remove the extra header word in vectors. * libguile/threads.c (do_thread_exit, fat_mutex_lock, fat_mutex_unlock): Instead of weak pairs, store thread-owned mutexes in a list of one-element weak vectors. * libguile/guardians.c (finalize_guarded): Similarly, store object guardians in a list of one-element weak vectors. * libguile/modules.c (scm_module_reverse_lookup): We no longer need to handle the case of weak references. * libguile/print.c (iprin1): Use the standard vector accessor to print vectors. * libguile.h: * libguile/Makefile.am: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/goops.c: * libguile/init.c: * libguile/objprop.c: * libguile/struct.c: Update includes. * module/ice-9/weak-vector.scm: Load weak vector definitions using an extension instead of %init-weaks-builtins. * test-suite/tests/weaks.test: Use the make-...-hash-table names instead of the old alist vector names.
2011-10-21fix segfault in goops if class fields are redefinedAndy Wingo1-2/+9
* 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.
2011-10-20fix misallocation of some <fix> proceduresAndy Wingo1-0/+13
* 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.
2011-10-16Update (ice-9 match) from Chibi-Scheme.Ludovic Courtès1-0/+1
* 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.
2011-10-15coverage: Add tests for `case-lambda'.Ludovic Courtès1-0/+22
* test-suite/tests/coverage.test ("line-execution-counts")["case-lambda"]: New test. ("procedure-execution-count")["case-lambda"]: New test.
2011-10-15coverage: Add test with `eval'.Ludovic Courtès1-2/+17
* test-suite/tests/coverage.test (test-procedure): New procedure. ("procedure-execution-count")["called from eval"]: New test.
2011-10-10fold constants with accessorsAndy Wingo1-0/+15
* 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.
2011-10-10Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo2-31/+190
Does not include psyntax regeneration. Conflicts: module/ice-9/psyntax-pp.scm module/language/tree-il/peval.scm test-suite/tests/tree-il.test
2011-10-10peval support for memq and memvAndy Wingo1-0/+37
* 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.
2011-10-10peval: visit operands on-demand, to inline mutually recursive bindingsAndy Wingo1-31/+125
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.
2011-10-05fix reading of #||||#Andy Wingo1-0/+8
* 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!
2011-09-30peval: Add test for possible infinite recursion.Ludovic Courtès1-0/+9
* test-suite/tests/tree-il.test ("partial evaluation"): Add test.
2011-09-30peval: Recognize module-refs to primitives.Ludovic Courtès1-0/+13
* module/language/tree-il/optimize.scm (peval): Handle module-refs to primitives. * test-suite/tests/tree-il.test ("partial evaluation"): Add test, using `pmatch'.
2011-09-29Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo7-41/+1051
This was a pretty big merge involving a fair amount of porting, especially to peval and its tests. I did not update psyntax-pp.scm, that comes in the next commit. Conflicts: module/ice-9/boot-9.scm module/ice-9/psyntax-pp.scm module/language/ecmascript/compile-tree-il.scm module/language/tree-il.scm module/language/tree-il/analyze.scm module/language/tree-il/inline.scm test-suite/tests/tree-il.test
2011-09-28((lambda ...) ...) fixAndy Wingo1-6/+4
* 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.
2011-09-28peval: more effective binding pruningAndy Wingo1-1/+19
* 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.
2011-09-28don't propagate pure primcalls that might not type-checkAndy Wingo1-2/+3
* 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.
2011-09-28peval: elide make-prompt-tag in effect contextAndy Wingo1-4/+10
* 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.
2011-09-28peval: add support for <prompt> and <abort>Andy Wingo1-0/+11
* 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.
2011-09-27peval: more strict accountingAndy Wingo1-4/+6
* 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.
2011-09-26peval: fix inlining of lambda* with #:optionalAndy Wingo1-0/+21
* 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.
2011-09-25peval: simpler and more precise treatment of mutabilityAndy Wingo1-20/+91
* 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.
2011-09-25peval uses effort counters, propagates lambdas more effectivelyAndy Wingo1-132/+164
* 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.
2011-09-24attempt to prune unreferenced bindingsAndy Wingo1-4/+13
* module/language/tree-il/optimize.scm (peval): Rename `record-lexicals' to `record-lexical-bindings'. Record residualized lexical references. Record lexical references in maybe-unlambda. Unfortunately this has the disadvantage that the speculative mapping of lambda expressions to lexical references records that reference, even if we are not going to residualize it. After processing a `let', prune pure unreferenced bindings. (We can do better than this in the future: we can simply process them for effect.) * test-suite/tests/tree-il.test (pass-if-peval): More debugging. ("partial evaluation"): Update to reflect the fact that the `y' binding won't be emitted.
2011-09-24peval: don't propagate expressions that access memoryAndy Wingo1-65/+77
* module/language/tree-il/optimize.scm (peval): Rename `pure-expression?' to `constant-expression?', in the sense of GCC's `pure' and `const'. A <toplevel-ref> is not constant, because it can be mutated. A <dynref> isn't constant either, for the same reason. * test-suite/tests/tree-il.test ("partial evaluation"): Add a test, and update existing tests that assumed that toplevel-ref would propagate.
2011-09-24paper around `match' bugAndy Wingo1-0/+12
* module/ice-9/match.scm (match): Always introduce a lexical binding, to avoid http://debbugs.gnu.org/9567. Real fix ongoing. Patch and original report by Stefan Israelsson Tampe. * test-suite/tests/match.test: Add test.
2011-09-23peval: Add test for multiple-value returns.Ludovic Courtès1-3/+22
* test-suite/tests/tree-il.test (pass-if-peval): Support the `resolve-primitives' keyword. ("partial evaluation"): Add test for `call-with-values'.
2011-09-23prevent propagation for memory-dependent operations like `car'Andy Wingo1-0/+24
* module/language/tree-il/primitives.scm (*primitive-constructors*): Record car, cdr, vector-ref, and struct-ref as "constructors". Comment to come later. (*effect-free-primitives*): Update. * test-suite/tests/tree-il.test ("partial evaluation"): Add tests.
2011-09-18peval: Abort inlining when the residual code contains recursive calls.Ludovic Courtès1-42/+27
* module/language/tree-il/optimize.scm (code-contains-calls?): New procedure. (peval): Use it and abort inlining if the residual code of a procedure application contains recursive calls. Suggested by Wingo, Waddell, and Dybvig. Fixes <http://debbugs.gnu.org/9542>. * test-suite/tests/tree-il.test ("partial evaluation"): Update 2 tests that relied on the previous behavior. Add 1 another test.
2011-09-18peval: Improve alpha-renaming test.Ludovic Courtès1-12/+45
* test-suite/tests/tree-il.test ("partial evaluation")["inlined lambdas are alpha-renamed"]: Rewrite.
2011-09-18Arrange so that stack-cleaning loops in GC tests are not optimized out.Ludovic Courtès2-7/+18
* test-suite/tests/gc.test (stack-cleanup): New procedure. ("Unused modules are removed"): Use it. * test-suite/tests/threads.test (stack-cleanup): Likewise. ("mutex with owner not retained (bug #27450)"): Use it.
2011-09-17peval: Alpha-rename anonymous lambdas that are duplicated.Ludovic Courtès1-0/+58
* module/language/tree-il/optimize.scm (alpha-rename): New procedure. (peval)[maybe-unlambda]: Use it. * test-suite/tests/tree-il.test ("partial evaluation"): Add two test cases for <https://lists.gnu.org/archive/html/bug-guile/2011-09/msg00019.html>.