summaryrefslogtreecommitdiff
path: root/module
AgeCommit message (Collapse)AuthorFilesLines
2021-10-21Provide xxvector-copy and xxvector-copy! for srfi-4 vectorsDaniel Llorens1-22/+98
These use the argument conventions of vector-copy!, string-copy!, etc. and not that of bytevector-copy! (which is from r6rs). * module/srfi/srfi-4/gnu.scm: As stated. * test-suite/tests/srfi-4.test: Tests. * doc/ref/srfi-modules.texi: Documentation. * libguile/bytevectors.c (bytevector-copy!): Add overlap note to docstring. * libguile/vectors.c (vector-copy!): Reuse text for the overlap note.
2021-10-19(ice-9 format): Fix scaling floats with leading zerosTimothy Sample1-2/+2
2021-10-03Add primitive alias analysis to CSEAndy Wingo2-5/+72
* module/language/cps/effects-analysis.scm (compute-known-allocations): (compute-clobber-map): Add "conts" parameter, and use it to compute primcalls that access known allocations. A write to a known allocation only clobbers a read to a known allocation if they are the same. * module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun): Pass conts also to compute-clobber-map.
2021-10-03Use more logtest in cse.scmAndy Wingo1-3/+3
* module/language/cps/effects-analysis.scm (causes-effect?): (effect-clobbers?): Use logtest.
2021-10-01Allow primcalls with multiple defsAndy Wingo1-1/+1
* module/language/cps/types.scm (infer-types): Allow multiple defs.
2021-10-01Add ,optimize-cps REPL meta-commandAndy Wingo2-10/+23
* module/system/repl/command.scm (*command-table*): Add optimize-cps / optx. (optimize-cps): Define meta-command. * module/system/repl/common.scm (optimize*): New helper. (repl-optimize): Use helper. (repl-optimize-cps): New public function.
2021-10-01Add CPS pretty-printerAndy Wingo2-0/+318
* module/language/cps/dump.scm: New file. * module/Makefile.am (SOURCES): Add to build.
2021-10-01Allow unchecked functions to have unboxed argumentsAndy Wingo2-6/+18
* module/language/cps/utils.scm (compute-var-representations): Use 'arg-representations from metadata for arg representations. * module/language/tree-il/compile-cps.scm (sanitize-meta): (convert): Make sure incoming terms have no arg representations.
2021-10-01Move live variable computation routines to utils and graphs.Andy Wingo3-248/+225
* module/language/cps/graphs.scm (rename-keys, rename-intset) (rename-graph, compute-reverse-control-flow-order) (compute-live-variables): Move here from slot-allocation. * module/language/cps/utils.scm: Remove duplicate compute-idoms definition. (compute-defs-and-uses, compute-var-representations): Move here from slot-allocation. * module/language/cps/slot-allocation.scm: Move routines out to utils and graphs.
2021-09-30Hotfix to unify (x ...) patterns in matchAndy Wingo1-16/+53
* module/ice-9/match.upstream.scm (match-gen-ellipsis): Instead of just binding the identifier when matching (x ...), go through match-one so that if the id is already bound, we unify instead. * test-suite/tests/match.test ("unify in list patterns"): Add test. * test-suite/tests/match.test.upstream: Add additional tests from upstream. See commit 05c546e38 in Chibi Scheme. Thanks to Alex Shinn for help here!
2021-09-20Baseline compiler no longer swaps rsh/lsh when transforming ash calls.Ludovic Courtès1-2/+2
Reported by Marius Bakke <marius@gnu.org> at <https://issues.guix.gnu.org/50696>. Previously, the baseline compiler would incorrectly emit a right shift when for, say, (ash x 2), and a left shift for (ash x -2). * module/language/tree-il/compile-bytecode.scm (canonicalize): When Y is negative, emit 'rsh', not 'lsh'. * test-suite/tests/numbers.test ("ash at -O1"): New test.
2021-09-20Fix 'ash' primcall match clause in baseline compiler.Ludovic Courtès1-3/+3
Previously the pattern would only match when the two 'src' values were the same, which is not the case for example when running on the interpreter. * module/language/tree-il/compile-bytecode.scm (canonicalize): In 'ash primcall pattern, rename second 'src' to 'src*'.
2021-09-20srfi-1: 'find-tail' passes 'check-arg' the right procedure name.Ludovic Courtès1-2/+2
* module/srfi/srfi-1.scm (find-tail): Pass 'find-tail' as the 3rd argument to 'check-arg'.
2021-09-20(system repl command) autoloads the compiler, disassembler, and profiler.Ludovic Courtès1-4/+6
* module/system/repl/command.scm: Autoload (system base compile), (system vm disassembler), and (statprof).
2021-09-17Revert shift of ndim in array tag from 3df3ba1a2c956bba122328e1fc4be614171a4f42Daniel Llorens1-1/+1
To avoid breaking ABI. * libguile/arrays.h (SCM_I_ARRAY_DIM, scm_i_raw_array): As stated. * module/system/vm/assembler.scm: As stated.
2021-09-02foreign-library: fix darwin detectionAleix Conchillo Flaqué1-1/+1
* module/system/foreign-library.scm (system-library-extensions): fix darwin host detection. darwin host types have "-darwin" but not "-darwin-".
2021-08-16Remove array contp flagDaniel Llorens1-2/+3
This flag was set, but never used in Guile, and there was no documented API to access it. To check if an array is contiguous, use (array-contents <> #t). * libguile/arrays.h (scm_i_raw_array): New function. SCM_I_ARRAY_CONTIGUOUS, SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG, SCM_I_ARRAY_CONTP: Remove. scm_t_array_dim: Declare here, not in array-handle.h. SCM_I_ARRAY_NDIM: Shift by one bit since the contp flag isn't there anymore. * module/syste/vm/assembler.scm: Match removal of contp flag. * libguile/arrays.c (scm_i_make_array): Reuse scm_i_raw_array. (scm_i_ra_set_contp): Remove. (scm_transpose_array): Don't set or clear the contp flag. (scm_make_shared_array): Don't set or clear the contp flag. (scm_make_typed_array): Don't set the contp flag. * libguile/array-map.c (scm_i_array_rebase): Reuse scm_i_raw_array.
2021-08-06Add function vector-copy! to coreDaniel Llorens2-30/+4
This is up to 20%-30% faster than the previous versions in (scheme base) or (srfi srfi-43) that used vector-move-left!/vector-move-right!. * libguile/vectors.h: * libguile/vectors.c: As stated. * doc/ref/api-data.texi (vector-copy!): Document the new function. (vector-fill!): Document optional arguments. (vector-copy): Document optional arguments. * module/scheme/base.scm: Reuse core vector-copy!. * module/srfi/srfi-43.scm: Reuse core vector-copy!.
2021-08-06Reuse core vector-fill! in (scheme base)Daniel Llorens1-11/+1
module/scheme/base.scm: As stated.
2021-08-06Extend core vector-copy to r7rs vector-copyDaniel Llorens2-36/+14
* libguile/vectors.h: Declare scm_vector_copy_partial. * libguile/vectors.c (scm_vector_copy_partial): As stated. (scm_vector_copy): Reuse scm_vector_copy_partial. * module/scheme/base.scm: Reuse core vector-copy. * module/srfi/srfi-43: Reuse core vector-copy. * test-suite/tests/vectors.test: Test vector-copy.
2021-08-02ice-9/read: Parse #{}}# properly.Maxime Devos1-2/+5
This is a regression since Guile 3.0.2 and breaks compilation of a Guile library. * module/ice-9/read.scm (%read)[read-parenthesized]: When SAW-BRACE? is #t but CH isn't #\#, don't eat CH. * test-suite/tests/reader.test ("#{}#): Add four test cases.
2021-07-11Fix crash on #nil in syntaxesRob Browning1-0/+1
In 3.0.7 (after 0cc799185576712d69f11fc794454f2f5447bef7 "Ensure that (syntax ()) results in ("), the use of #nil in syntax-rules expansions like this: (define-syntax foo (syntax-rules () ((_ x) (eq? #nil x)))) (foo #t) could cause a crash that looks like this: ice-9/psyntax.scm:2795:12: In procedure syntax-violation: Syntax error: unknown location: unexpected syntax in form () To fix it, add another special case (the commit mentioned above special-cased the empty list) to preserve #nil * module/ice-9/psyntax.scm (gen-syntax): Preserve #nil. * test-suite/tests/syntax.test: Test #nil in syntax expansions. Closes: 49305
2021-05-24Fix bug in eq-constant? propagation in CSE if kf == ktAndy Wingo1-3/+3
* module/language/cps/cse.scm (compute-out-edges): Only propagate constant to successor if successor not kf. * test-suite/tests/compiler.test ("cse auxiliary definitions"): ("closure conversion"): Refactor. ("constant propagation"): New test. Fixes #48368.
2021-05-21Fix bug in nftw functionDaniel Llorens1-4/+4
Fixes bug #44182. Thanks to Matija Obid for the report and RhodiumToad in
2021-05-19Fix trace-calls-to-procedureRobin Green1-1/+1
Fixes #43102 and duplicate #48412.
2021-05-18Add ‘expt’ to the list of effect-free primitives.Maxime Devos1-1/+2
I find myself writing code like (- (expt 2 32) 1) lately. Let's allow constant-folding that. * module/language/tree-il/primitives.scm (*interesting-primitive-names*, *effect-free-primitives*): Add 'expt'.
2021-05-11Implement cross-module inliningAndy Wingo2-58/+137
* module/language/tree-il/optimize.scm (make-optimizer): Pass cross-module-inlining? to peval. * module/language/tree-il/peval.scm (peval): Add cross-module-inlining? kwarg. Try to inline public module-ref.
2021-05-11Add support for recording inlinable module exportsAndy Wingo5-8/+890
* module/language/tree-il/inlinable-exports.scm: New module. * am/bootstrap.am: * module/Makefile.am: * module/language/tree-il/optimize.scm (make-optimizer): * module/system/base/optimize.scm (available-optimizations): Wire up new module. * module/ice-9/boot-9.scm (module): Add inlinable-exports field. (define-module*): Add #:inlinable-exports kwarg.
2021-05-11Add pass to resolve free toplevel references in declarative modulesAndy Wingo4-0/+286
* am/bootstrap.am (SOURCES): * module/Makefile.am (SOURCES): * module/language/tree-il/optimize.scm (make-optimizer): Wire up the new pass. * module/language/tree-il/resolve-free-vars.scm: New pass. * module/system/base/optimize.scm (available-optimizations): Enable new pass at -O1.
2021-05-11Letrectify links module defs with usesAndy Wingo1-1/+19
* module/language/tree-il/letrectify.scm (letrectify): Inline "let" bindings inside residualized "letrec*" forms, to allow the dominator relationship to be reflected in the scope tree. Also, detect "define-module*" invocations, and add these to the mod-vars set, so that residualized "module-ensure-local-variable!" primcalls can clearly denote their module without having to use "current-module".
2021-05-11Bump objcode versionAndy Wingo1-1/+1
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump, as we're going to start adding inlinable exports.
2021-05-10bug#45131: [PATCH] Compile directly to target language if no joint is found.Leo Prikler1-11/+15
This enables the compilation from "manually" written Tree-IL to bytecode. See also <https://bugs.gnu.org/45131>. * system/base/compile.scm (read-and-compile)[(joint #f)]<? eof-object?>: Join exps using the default joiner for to. <exp>: Compute compiler for to. * test-suite/test/compiler.test ("read-and-compile tree-il"): New test.
2021-05-10Minor tweak to truncate-bitsAndy Wingo1-8/+5
* module/system/base/types/internal.scm (truncate-bits): Use bits-case in all cases.
2021-05-06Optimize truncate-bitsAndy Wingo1-4/+17
* module/system/base/types/internal.scm (truncate-bits): Inline cases for 16, 32, and 64, to avoid allocating bignums for the boundary conditions.
2021-05-05[srfi-64] Fix a bug with test-end removing globally installed test-runnerjakub-w1-4/+7
* testing.scm (%test-begin, %test-end): When (test-runner-current) is not set, create a new one like before but also add a finalizer that will remove it after the test is finished. Previously the test runner was getting unset unconditionally. See https://srfi-email.schemers.org/srfi-64/msg/16468240/
2021-05-02analyze: 'unbound-variable' warning handles re-exported bindings.Ludovic Courtès1-0/+5
Fixes <https://bugs.gnu.org/47031>. * module/language/tree-il/analyze.scm (make-use-before-definition-analysis) [resolve]: Add case for when NAME is re-exported by MOD. * test-suite/tests/tree-il.test ("warnings")["re-exported binding"]: New test.
2021-05-01Fix R7RS include-library-declarations and cond-expand in define-libraryAndy Wingo1-3/+3
* module/ice-9/r7rs-libraries.scm (define-library): Fix bug handling include-library-declarations and cond-expand subforms. Thanks to Adam Nelson for the fix! Fixes #40252.
2021-05-01Fix bug if call-with-prompt tag not a lexicalAndy Wingo1-2/+2
* module/language/tree-il/peval.scm (peval): peval could throw if the call-with-prompt operand wasn't a lexical. Terrible!
2021-05-01Fix tree-il effects analysis for promptsAndy Wingo1-3/+7
* module/language/tree-il/effects.scm (make-effects-analyzer): The body of a prompt is an expression only for escape-only prompts, and the handler is always a lambda. Fix bug where a prompt could be incorrectly marked effect-free. * test-suite/tests/tree-il.test ("optimize"): Add test for bug 48098. Fixes bug 48098.
2021-05-01Fix bug for read-syntax on ( . args)Andy Wingo2-5/+18
* module/ice-9/boot-9.scm: Capture syntax?. * module/ice-9/read.scm (read-syntax): Avoid re-annotating objects. * test-suite/tests/reader.test ("read-syntax"): Add test.
2021-04-29Fix syntax-violation, which was passing vectors instead of alistsAndy Wingo2-3/+5
* module/ice-9/psyntax.scm (syntax-violation): Pass source as an alist. A sourcev would be better but it's incompatible. * module/ice-9/psyntax-pp.scm: Regenerate.
2021-04-29Fix compile-psyntax.scm -- canonicalize pass not neededAndy Wingo1-6/+4
* module/ice-9/compile-psyntax.scm: Remove use of canonicalization pass, as it's not needed. Whoopdy!
2021-04-29Fix line and column for read errorsAndy Wingo1-1/+2
* module/ice-9/read.scm (%read): Add 1 to both line and column: the former to make 1-based user lines instead of 0-based Guile lines, and the latter because apparently that's how we always did it :) Fixes
2021-04-28Fix duplicates handlers for interfaces that use interfacesAndy Wingo1-3/+3
* module/ice-9/boot-9.scm (duplicate-handlers): Use module-variable instead of module-local-variable in the warn-override-core, first, and last handlers. Fixes #47084 mostly, though relative to pre-3.0 there is still a difference in that a module needs to explicitly declare which bindings are intended as replacements -- a binding being a replacement is a property of the module in 3.0, rather than the variable as was the case before 3.0.
2021-04-27Add ice-9/read.scm to extra_distAndy Wingo1-0/+1
* module/Makefile.am (NOCOMP_SOURCES): Add ice-9/read.scm.
2021-04-27Fix closure-conversion bug for SCC with all free vars prunedAndy Wingo1-5/+11
* module/language/cps/closure-conversion.scm (convert-one): Fix bug when getting value of SCC whose free variables have been elided. Thanks to abcdw for the report! * test-suite/tests/compiler.test ("cse auxiliary definitions"): Remove spurious newline. ("closure conversion"): New test.
2021-04-26Bump minor objcode version for new intrinsicsAndy Wingo1-1/+1
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Bump. * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2021-04-26Allow contification for $callkAndy Wingo1-36/+132
* module/language/cps/contification.scm (compute-first-class-functions): (compute-functions-called-by-label): (compute-functions): (compute-arities): (compute-contification-candidates): (compute-call-graph): (compute-contification): (apply-contification): (contify): Given that the frontend will produce $callk now, allow it to be contified if such callees are all called with the same continuation.
2021-04-26CPS conversion calls module variables through trampolinesAndy Wingo1-2/+86
* module/language/tree-il/compile-cps.scm (module-call-stubs): (module-call-label, convert, cps-convert/thunk): Arrange to call module variables through out-of-line trampolines with unchecked arity. This should speed up compile time in large files and reduce code size on hot paths.
2021-04-26Fix CPS optimizations to allow callk in front halfAndy Wingo4-34/+45
* module/language/cps/closure-conversion.scm: Use standard compute-reachable-functions and intmap-select from utils to filter reachable functions, allowing us to pick up callk. Adapt some uses to expect callk for calls. * module/language/cps/self-references.scm (resolve-self-references): Subst the proc, if it's there. * module/language/cps/split-rec.scm (compute-free-vars): Add a case for callk.