summaryrefslogtreecommitdiff
path: root/module/language
Commit message (Expand)AuthorAgeFilesLines
* Add disjoint syntax object type...* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and syntax.h. * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init): * libguile/init.c (scm_init_guile): * libguile/print.c (iprin1): * libguile/tags.h (scm_tc7_syntax): * module/oop/goops.scm (<syntax>): * module/system/base/types.scm (%tc7-syntax, cell->object): * module/system/vm/disassembler.scm (code-annotation): Wire up the new data type. * libguile/syntax.c: * libguile/syntax.h: New files. * module/ice-9/boot-9.scm: Move new definitions to (system syntax internal). * module/system/syntax.scm (print-syntax): New helper. * module/system/vm/assembler.scm (statically-allocatable?) (intern-constant, link-data): Arrange to be able to write syntax objects into images. * module/language/cps/types.scm (&syntax): New type. Remove &hash-table; it was never detected, an internal binding, and we need the bit to avoid going into bignum territory. Andy Wingo2017-03-281-2/+4
* Nonlocal prompt returns cause all effects...* module/language/cps/effects-analysis.scm (expression-effects): Prompts cause &all-effects. I tried to limit this change to CSE but it was actually LICM that was borked, so better to be conservative * test-suite/tests/control.test ("escape-only continuations"): Add test. Andy Wingo2017-03-131-1/+4
* VM support for string-set!; slimmer read-string...* doc/ref/vm.texi (Inlined Scheme Instructions): Add string-set!. * libguile/vm-engine.c (string-set!): New opcode. * module/ice-9/rdelim.scm (read-string): Reimplement in terms of a geometrically growing list of strings, to reduce total heap usage when reading big files. * module/language/cps/compile-bytecode.scm (compile-function): Add string-set! support. * module/language/cps/types.scm (string-set!): Update for &u64 index. * module/language/tree-il/compile-cps.scm (convert): Unbox index to string-set!. * module/system/vm/assembler.scm (system): Export string-set!. Andy Wingo2017-03-093-3/+6
* Fix bug in comparison between real and complex...This bug was introduced by 35a90592501ebde7e7ddbf2486ca9d315e317d09. * module/language/cps/specialize-numbers.scm (specialize-operations): Check that both operands are real as a condition for specialize-f64-comparison. * test-suite/tests/numbers.test: Add test. Daniel Llorens2017-03-091-6/+8
* Remove contification restriction in case-lambda...* module/language/cps/compile-bytecode.scm (compile-function): Check for fallthrough after $kclause too; possible to need to jump if clause tails are contified. * module/language/cps/contification.scm (compute-contification-candidates): Enable inter-clause contification. Andy Wingo2017-03-092-31/+12
* All clauses of function have same nlocals...* module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/slot-allocation.scm ($allocation) (lookup-nlocals, compute-frame-size, allocate-slots): Adapt to have one frame size per function, for all clauses. Andy Wingo2017-03-092-33/+25
* psyntax: Generate identifiers in a deterministic fashion....Fixes <http://bugs.gnu.org/20272>. * module/ice-9/boot-9.scm (module-generate-unique-id!) (module-gensym): New procedures. (module): Add 'next-unique-id' field. (the-root-module): Inherit 'next-unique-id' value from early stub. (make-module, make-autoload-interface): Adjust calls to module-constructor. * module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique identifiers from the module name and the per-module unique-id. (build-lexical-var, generate-temporaries): Use 'module-gensym' instead of 'gensym'. * module/ice-9/psyntax-pp.scm: Regenerate. * module/language/tree-il/fix-letrec.scm (fix-letrec!): Use 'module-gensym' instead of 'gensym'. * module/system/base/syntax.scm (define-record): Likewise. (transform-record): Likewise. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Mark H Weaver2017-03-071-2/+4
* Fix guild compile --to=cps / --from=cps...* module/language/cps/spec.scm (read-cps, write-cps): Fix CPS serialization and parsing, so that "guild compile" works with --to=cps and --from=cps. Andy Wingo2017-02-231-3/+17
* Fix kfun parse-cps bug...* module/language/cps.scm (parse-cps): Fix bug parsing kfun. Andy Wingo2017-02-231-1/+1
* Fix flonum/complex type inference....* module/language/cps/types.scm (define-binary-result!): Arithmetic where one argument is a flonum may produce a complex. * test-suite/tests/compiler.test: Add test. Andy Wingo2017-02-191-2/+6
* Add unboxed floating point comparison instructions....* libguile/vm-engine.c (BR_F64_ARITHMETIC): New preprocessor macro. (br_if_f64_ee, br_if_f64_lt, br_if_f64_le, br_if_f64_gt, br_if_f64_ge): New VM instructions. * doc/ref/vm.texi ("Unboxed Floating-Point Arithmetic"): Document them. * module/language/cps/compile-bytecode.scm (compile-function): Emit f64 comparison instructions. * module/language/cps/effects-analysis.scm: Define effects for f64 primcalls. * module/language/cps/primitives.scm (*branching-primcall-arities*): Add arities for f64 primcalls. * module/language/cps/specialize-numbers.scm (specialize-f64-comparison): New procedure. (specialize-operations): Specialize f64 comparisons. * module/system/vm/assembler.scm (emit-br-if-f64-=, emit-br-if-f64-<) (emit-br-if-f64-<=, emit-br-if-f64->, emit-br-if-f64->=): Export. * module/system/vm/disassembler.scm (code-annotation): Add annotations for f64 comparison instructions. David Thompson2017-01-125-16/+60
* Improve handle-interrupts placement...* module/language/cps/handle-interrupts.scm (compute-safepoints): New function. (add-handle-interrupts): Add safepoints at backedge targets, not backedges. Gives better register allocation, loop rotation, and code size. Andy Wingo2016-12-181-21/+32
* Fix bug in compute-significant-bits for phi predecessors...* module/language/cps/specialize-numbers.scm (compute-significant-bits): Always revisit predecessors after first visit. Avoids situation where predecessor of an unvisited phi var could default to 0 significant bits and never be revisited. Fixes (format #f "~2f" 9.9). Andy Wingo2016-12-141-11/+15
* with-dynamic-state compiler and VM support...* libguile/dynstack.h (SCM_DYNSTACK_TYPE_DYNAMIC_STATE): * libguile/dynstack.c (DYNAMIC_STATE_WORDS, DYNAMIC_STATE_STATE_BOX): (scm_dynstack_push_dynamic_state): (scm_dynstack_unwind_dynamic_state): New definitions. (scm_dynstack_unwind_1, scm_dynstack_wind_1): Add with-dynamic-state cases. * libguile/memoize.c (push_dynamic_state, pop_dynamic_state) (do_push_dynamic_state, do_pop_dynamic_state): New definitions. (memoize, scm_init_memoize): Handle push-dynamic-state and pop-dynamic-state. * libguile/vm-engine.c (push-dynamic-state, pop-dynamic-state): New opcodes. * module/ice-9/boot-9.scm (with-dynamic-state): New definition in Scheme so that the push-dynamic-state and pop-dynamic-state always run in the VM. * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/effects-analysis.scm: * module/language/cps/types.scm: * module/language/tree-il/effects.scm (make-effects-analyzer): * module/language/tree-il/peval.scm (peval): * module/language/tree-il/primitives.scm (*interesting-primitive-names*): * module/system/vm/assembler.scm: Add support for with-dynamic-state to the compiler. * test-suite/tests/fluids.test ("dynamic states"): Add basic tests. * doc/ref/vm.texi (Dynamic Environment Instructions): Update. Andy Wingo2016-12-056-3/+32
* Compile fluid-set! to VM opcode...* libguile/vm-engine.c (fluid-set!): Fix name of opcode to correspond with name of Tree-IL primitive. Fixes compilation of fluid-set! to actually use the fluid-set! opcode. * doc/ref/vm.texi (Dynamic Environment Instructions): Update. * module/language/cps/compile-bytecode.scm (compile-function): Add fluid-set! case. * module/system/vm/assembler.scm: Update export name for emit-fluid-set!. Andy Wingo2016-11-271-0/+2
* Add handle-interrupts inst and compiler pass...* libguile/vm-engine.c (vm_engine): Remove initial VM_HANDLE_INTERRUPTS call; surely our caller already handled interrupts. Add handle-interrupts opcode. * am/bootstrap.am (SOURCES): * module/Makefile.am (SOURCES): Add handle-interrupts.scm. * module/system/vm/assembler.scm (system): * module/language/cps/compile-bytecode.scm (compile-function): (lower-cps): Add handle-interrupts support. * module/language/cps/handle-interrupts.scm: New file. Andy Wingo2016-11-162-1/+63
* Fix tree-il code generation for ECMAscript `new' expression....The compiler was producing `((toplevel foo))' instead of `(toplevel foo)'. Changed to use `call' form with target type and spliced constructor arguments. * module/language/ecmascript/compile-tree-il.scm (comp): Replace `@impl' shorthand with `call' + `@implv' for better control over resulting tree-il. * test-suite/tests/ecmascript.test (compiler): Add test for "new Object();" Signed-off-by: Ludovic Courtès <ludo@gnu.org> Julian Graham2016-10-251-4/+4
* Move thread bindings to (ice-9 threads)...* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs. * libguile/threads.c (scm_init_ice_9_threads): Rename from scm_init_thread_procs, make static. (scm_init_threads): Register scm_init_thread_procs extension. * libguile/threads.h (scm_init_thread_procs): Remove decl. * module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side effects occur early. * module/ice-9/deprecated.scm (define-deprecated): Fix to allow deprecated bindings to appear in operator position. Export deprecated bindings. (define-deprecated/threads, define-deprecated/threads*): Trampoline thread bindings to (ice-9 threads). * module/ice-9/futures.scm: Use ice-9 threads. * module/ice-9/threads.scm: Load scm_init_ice_9_threads extension. Reorder definitions and imports so that the module circularity with (ice-9 futures) continues to work. * module/language/cps/intmap.scm: * module/language/cps/intset.scm: * module/language/tree-il/primitives.scm: Use (ice-9 threads). * module/language/cps/reify-primitives.scm: Reify current-thread in (ice-9 threads) module. * module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and adapt all users. Use proper keywords in module definition form. * test-suite/tests/filesys.test (test-suite): * test-suite/tests/fluids.test (test-suite): * test-suite/tests/srfi-18.test: Use ice-9 threads. * NEWS: Add entry. * doc/ref/api-scheduling.texi (Threads): Update. * doc/ref/posix.texi (Processes): Move current-processor-count and total-processor-count docs to Threads. Andy Wingo2016-10-234-0/+4
* Fix slot allocation for prompts...* module/language/cps/slot-allocation.scm (add-prompt-control-flow-edges): Fix to add links from prompt bodies to handlers, even in cases where the handler can reach the body but the body can't reach the handler. * test-suite/tests/compiler.test ("prompt body slot allocation"): Add test case. Andy Wingo2016-10-111-21/+30
* Compiler support for atomics...* doc/ref/vm.texi (Inlined Atomic Instructions): New section. * libguile/vm-engine.c (VM_VALIDATE_ATOMIC_BOX, make-atomic-box) (atomic-box-ref, atomic-box-set!, atomic-box-swap!) (atomic-box-compare-and-swap!): New instructions. * libguile/vm.c: Include atomic and atomics-internal.h. (vm_error_not_a_atomic_box): New function. * module/ice-9/atomic.scm: Register primitives with the compiler. * module/language/cps/compile-bytecode.scm (compile-function): Add support for atomic ops. * module/language/cps/effects-analysis.scm: Add comment about why no effects analysis needed. * module/language/cps/reify-primitives.scm (primitive-module): Add case for (ice-9 atomic). * module/language/tree-il/primitives.scm (*effect-free-primitives*): (*effect+exception-free-primitives*): Add atomic-box?. * module/system/vm/assembler.scm: Add new instructions. * test-suite/tests/atomic.test: Test with compilation and interpretation. Andy Wingo2016-09-064-3/+24
* Better char<? compilation...* module/language/tree-il/primitives.scm (character-comparison-expander): Expand out char<? and friends to <, unboxing the char arguments. * module/language/cps/types.scm: * module/language/cps/effects-analysis.scm: Remove mention of char<? and friends as we won't see them any more. Also fixes #24318. Andy Wingo2016-09-023-8/+18
* Better unboxing...* module/language/cps/specialize-numbers.scm (truncate-u64): New helper, truncates a SCM value. (specialize-u64-binop): Add ulogxor case. (sigbits-union, sigbits-intersect, sigbits-intersect3) (next-power-of-two, range->sigbits, inferred-sigbits) (significant-bits-handlers, define-significant-bits-handler): (significant-bits-handler, compute-significant-bits): Add facility to compute the bits in a value that are significant. (specialize-operations): Unbox in more cases, when only u64 bits are significant. Unbox logxor. Elide logand where it has no effect. Andy Wingo2016-09-011-69/+211
* Fabricated expression tweak in CSE...* module/language/cps/cse.scm (compute-equivalent-subexpressions): u64->scm fabricates equivalence for scm->u64/truncate too. Andy Wingo2016-09-011-1/+2
* Add unboxed logxor on u64 values...* libguile/vm-engine.c (ulogxor): New instruction. * module/language/cps/effects-analysis.scm (ulogxor): * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/types.scm (ulogxor): * module/system/vm/assembler.scm (emit-ulogxor): Add support for new instruction. * doc/ref/vm.texi (Unboxed Integer Arithmetic): Document ulogxor. Andy Wingo2016-09-013-1/+8
* Fix compilation of `continue' in `while'....* module/language/cps/rotate-loops.scm (rotate-loops-in-function): Don't attempt to rotate a loop whose header is a $prompt. Fixes use of `continue' in `while'. Thanks to Nala Ginrut for the report :) Andy Wingo2016-08-041-5/+9
* Add -Wmacro-use-before-definition...* module/ice-9/boot-9.scm (%auto-compilation-options): * am/guilec (GUILE_WARNINGS): Add -Wmacro-use-before-definition. * module/language/tree-il/analyze.scm (unbound-variable-analysis): Use match-lambda. (<macro-use-info>, macro-use-before-definition-analysis): New analysis. * module/system/base/message.scm (%warning-types): Add macro-use-before-definition warning type. * module/language/tree-il/compile-cps.scm (%warning-passes): Add support for macro-use-before-definition. Andy Wingo2016-06-252-9/+72
* Fix duplicate case in peval...* module/language/tree-il/peval.scm (singly-valued-expression?): Fix duplicate case. Spotted by "mejja" on IRC. Andy Wingo2016-06-251-1/+0
* Constant-folding eq? and eqv? uses deduplication...* test-suite/tests/peval.test ("partial evaluation"): Add tests. * module/language/tree-il/peval.scm (peval): Constant-fold eq? and eqv? using equal?, anticipating deduplication. Andy Wingo2016-06-241-1/+9
* Fix (< 'foo) compilation...* module/language/tree-il/primitives.scm (expand-chained-comparisons): Fix (< 'foo) compilation. * test-suite/tests/compiler.test ("regression tests"): Add test case. Andy Wingo2016-06-211-1/+6
* `define!' instruction returns the variable...* doc/ref/vm.texi (Top-Level Environment Instructions): Update documentation. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly. * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump. * libguile/vm-engine.c (define!): Change to store variable in dst slot. * module/language/tree-il/compile-cps.scm (convert): * module/language/cps/compile-bytecode.scm (compile-function): Adapt to define! change. * module/language/cps/effects-analysis.scm (current-module): Fix define! effects. Incidentally here was the bug: in Guile 2.2 you can't have effects on different object kinds in one instruction, without reverting to &unknown-memory-kinds. * test-suite/tests/compiler.test ("regression tests"): Add a test. Andy Wingo2016-06-213-4/+7
* Fix peval on (call-with-values foo (lambda (x) x))...* module/language/tree-il/peval.scm (peval): Don't inline (call-with-values foo (lambda (x) exp)) to (let ((x (foo))) exp). The idea is that call-with-values sets up an explicit context in which we are requesting an explicit return arity, and that dropping extra values when there's not a rest argument is the wrong thing. Fixes #13966. * test-suite/tests/peval.test ("partial evaluation"): Update test. Andy Wingo2016-06-201-4/+0
* Type inference: Use &u64-max instead of #xffff......* module/language/cps/types.scm: Use &u64-max where possible. Andy Wingo2016-06-101-7/+7
* Types refactor for unboxed char ranges...* module/language/cps/types.scm (*max-codepoint*): Factor codepoint range restrictions to use this value. Andy Wingo2016-06-101-10/+9
* Add integer->char and char->integer opcodes...* libguile/vm-engine.c (integer_to_char, char_to_integer): New opcodes. * libguile/vm.c (vm_error_not_a_char): New error case. * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/types.scm: * module/language/tree-il/compile-cps.scm (convert): * doc/ref/vm.texi (Inlined Scheme Instructions): * module/system/vm/assembler.scm: Add support for new opcodes. Andy Wingo2016-05-044-5/+17
* Fix lower-bound saturation in type inference...* module/language/cps/types.scm (type-entry-saturating-union): Fix range saturation in the negative direction. Previously we were artificially truncating negative range ends to zero. Andy Wingo2016-03-141-2/+2
* Fix type inference of integer division...* module/language/cps/types.scm (define-binary-result!): Fix inference of integer division. Andy Wingo2016-01-171-7/+11
* Remove unused function in simplify.scm...* module/language/cps/simplify.scm (intset-add*): Remove unused function. Andy Wingo2016-01-041-6/+0
* Inline some helpers in intset.scm....* module/language/cps/intset.scm (round-down): Inline. (clone-branch-and-set): Inline, and inline the vector-move-left!. Andy Wingo2016-01-041-3/+7
* Include missing #:simplify? option in (language cps optimize)....* module/language/cps/optimize.scm (cps-default-optimization-options): Add missing #:simplify? option. Otherwise the simplification pass was running even at -O0. Andy Wingo2016-01-041-0/+1
* Better CPS conversion for tests in tests...* module/language/tree-il/compile-cps.scm (convert): Tests in tests have their consequents and alternates also converted in test context. Andy Wingo2016-01-031-2/+9
* Better partial evaluation of tests in tests...* module/language/tree-il/peval.scm (peval): In test context, fold (let ((x EXP)) (if x x ALT)) to (if EXP #t ALT). This reduces the number of boolean literals that the compiler has to reify, by causing EXP to evaluate in test context instead of value context. Also, rotate `let' out of the test part of conditionals, for the same reason. Andy Wingo2016-01-031-20/+53
* Better folding of branches on $values...* module/language/cps/type-fold.scm (local-type-fold): Fold branches on $values, if we can. Andy Wingo2016-01-031-0/+14
* Eta-reduce branches...* module/language/cps/simplify.scm (compute-eta-reductions): Eta-reduce branches as well, so that passing a constant to a branch will fold to the true or false branch, provided that the test variable was just used in the branch. Andy Wingo2016-01-031-26/+39
* Fix module for reification of srfi-4 primitives...* module/language/cps/reify-primitives.scm (primitive-module): Add cases for SRFI-4 primitives. These primitives are only treated as such for the purposes of Tree-IL primitive expansion; perhaps the right fix is elsewhere, but it's here for now. Andy Wingo2015-12-301-0/+7
* Type inference copes better with unsorted graphs...* module/language/cps/types.scm (&min/0, &min/s64, &max/s64, &max/size) (&max/u64, &max/vector): New clamped variable range accessors. Use them in type inferrers. Andy Wingo2015-12-261-51/+65
* Fix bug in intmap-map...* module/language/cps/utils.scm (intmap-map): Use transient intmap-add! on an empty intmap to build the result instead of intmap-replace! on the argument. Avoids spooky action-at-a-distance mutation of the argument if it happens to be a transient -- although the intmap-fold will correctly traverse a snapshot of the argument and the result will be correct, the argument value would be modified in place, causing strange results to calling code that passes in a transient. Andy Wingo2015-12-261-2/+2
* Fix build when threads are disabled...* module/language/cps/intmap.scm: Remove srfi-18 import. We just need current-thread which is actually defined in (guile), and importing (srfi srfi-18) raises an error if Guile is compiled without threads support. Andy Wingo2015-12-161-1/+0
* Add another simplification pass to make rotate-loops work better...* module/language/cps/optimize.scm (optimize-first-order-cps): Toss in another simplification pass. Andy Wingo2015-12-031-0/+2
* Add support for comparing u64 values with SCM values...* libguile/vm-engine.c (BR_U64_SCM_COMPARISON): New helper. (br-if-u64-<=-scm, br-if-u64-<-scm, br-if-u64-=-scm) (br-if-u64->-scm, br-if-u64->=-scm): New instructions, to compare an untagged u64 with a tagged SCM. Avoids many u64->scm operations. * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/effects-analysis.scm: * module/language/cps/type-fold.scm: * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm (code-annotation, compute-labels): * module/language/cps/primitives.scm (*branching-primcall-arities*): Add support for new opcodes. * module/language/cps/specialize-numbers.scm (specialize-u64-scm-comparison): New helper. * module/language/cps/specialize-numbers.scm (specialize-operations): Specialize u64 comparisons. * module/language/cps/types.scm (true-comparison-restrictions): New helper. (define-comparison-inferrer): Use the new helper. Add support for u64-<-scm et al. Andy Wingo2015-12-036-13/+84
* Add ursh/immediate and ulsh/immediate ops...* libguile/vm-engine.c (ursh/immediate, ulsh/immediate): New ops. * module/language/cps/effects-analysis.scm: * module/language/cps/slot-allocation.scm (compute-var-representations) (compute-needs-slot): * module/language/cps/specialize-primcalls.scm (specialize-primcalls): * module/language/cps/compile-bytecode.scm (compile-function): * module/system/vm/assembler.scm: * module/language/cps/types.scm: Add support for new ops, and specialize ursh and ulsh. Andy Wingo2015-12-025-1/+18