summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-09-06Fix missing port in `pretty-print'Andy Wingo1-1/+1
* module/ice-9/pretty-print.scm (pretty-print): We were defaulting to the current output port.
2023-09-05Add reprs for more s64 macro-instructionsAndy Wingo1-0/+3
* module/language/cps/utils.scm (primcall-raw-representations): Add sadd, ssub, etc; these are lowered to uadd, usub, etc later for the guile-vm target, but it is still useful to record their reprs for pre-lowering analysis.
2023-09-04Recognize `make-variable' as primitiveAndy Wingo2-5/+6
* module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*primitive-constructors*): (*effect+exception-free-primitives*): Add make-variable. * module/language/tree-il/cps-primitives.scm (make-variable): Lower as `box' primitive.
2023-08-28Better compilation of calls to `raise-exception`Andy Wingo8-8/+67
Recognize `raise-exception` in the same way we recognize `throw`, though it is a bit less optimized and the boot story is not as complicated. * doc/ref/vm.texi (Non-Local Control Flow Instructions): * libguile/jit.c (compile_unreachable): (compile_unreachable_slow): * libguile/vm-engine.c (VM_NAME): * module/language/cps/compile-bytecode.scm (compile-function): * module/system/vm/assembler.scm (emit-unreachable): Add new "unreachable" instruction, inserted after a call to non-continuable `raise-exception`. * module/language/tree-il/compile-cps.scm (raise-exception): * module/language/tree-il/primitives.scm (*interesting-primitive-names*): Recognize raise-exception, and if it is called with just one argument, prune that branch of the control-flow graph.
2023-08-28Fix typo in documentation for (socket)Daniel Llorens1-1/+1
H/t cow_2001 on #guile. * libguile/socket.c: As stated.
2023-08-24Fix embarrassing pretty-print bugAndy Wingo2-5/+21
* module/ice-9/pretty-print.scm (pretty-print): We were never indenting more than 8 spaces. Doh! * test-suite/tests/print.test (prints?, "pretty-print"): Add test.
2023-08-24define-inlinable marks residualized procedure as maybe-unusedAndy Wingo2-7/+9
* module/ice-9/boot-9.scm (define-inlinable): * module/srfi/srfi-9.scm (define-tagged-inlinable): Add maybe-unused declaration. Also require at least one body expr, otherwise the metadata declaration could escape as the proc body.
2023-08-24Allow functions to mark themselves as maybe-unusedAndy Wingo3-31/+66
* module/language/tree-il/analyze.scm (<reference-graph>): Oh my goodness, constructor args were reversed relative to field order. Constructor use was consistent but it was terribly confusing; fixed and updated uses. (unused-toplevel-analysis): Add ability for functions to mark themselves as "maybe-unused"; such functions won't cause unused toplevel warnings. * module/language/tree-il/compile-bytecode.scm (sanitize-meta): (compile-closure): * module/language/tree-il/compile-cps.scm (sanitize-meta): Prevent maybe-unused from being needlessly written out to the binary.
2023-08-24Add "custom primcall converter" facility to tree-il->cps loweringAndy Wingo1-67/+80
* module/language/tree-il/compile-cps.scm (define-custom-primcall-converter): New exported macro, handling primcalls that need special logic. Fold "throw" and "values" into this macro. The goal is to allow the Hoot compiler to specially convert an "inline assembly" primcall.
2023-08-17Revert recent change to r5rs.texiAndy Wingo1-5/+5
* doc/r5rs/r5rs.texi: Revert c7d170c5d1e90de64962d4cf3cb257364f77b08f, as R5RS is a historical document, and our packaging of it is something that other people rely on. See also 7fb9c4aff29daab35d0726bac58f8fbd6bd2e26c when I was also bitten by this error!
2023-08-17Add unboxed representations for fadd/immediate, fmul/immediateAndy Wingo1-0/+1
* module/language/cps/utils.scm (primcall-raw-representations): Add fadd/immediate, fmul/immediate as f64.
2023-08-17Allow compute-var-representations extensibilityAndy Wingo1-33/+55
* module/language/cps/utils.scm (primcall-raw-representations): New function. (compute-var-representations): Use #:primcall-raw-representations keyword arg, which defaults to primcall-raw-representations.
2023-08-17More precise value representations for bv-contents, $codeAndy Wingo3-7/+11
* module/language/cps/utils.scm (compute-var-representations): $code makes a 'code. bv-contents makes a 'bv-contents. * module/language/cps/slot-allocation.scm: * module/language/cps/hoot/tailify.scm: * module/system/vm/assembler.scm: Adapt.
2023-08-17Add new $calli expression type.Andy Wingo22-20/+102
* module/language/cps.scm ($calli): New expression type which calls a function entry as originally captured via $code. Adapt all callers.
2023-08-17Fix compute-defs-and-uses for $primAndy Wingo1-1/+1
* module/language/cps/utils.scm (compute-defs-and-uses): Add $prim. Wasn't needed before because this function was only ever called after reify-primitives.
2023-08-17Include nfree in closure-ref, closure-set primcall paramsAndy Wingo3-6/+10
* module/language/cps/closure-conversion.scm (convert-one): Add nfree to the param. This will help the wasm target. * module/language/cps/effects-analysis.scm (closure-ref, closure-set!): * module/language/cps/lower-primcalls.scm (closure-ref,closure-set!): Adapt.
2023-08-17Add wasm32 and wasm64 CPU typesAndy Wingo1-1/+3
* module/system/base/target.scm (cpu-endianness): wasm targets are little-endian.
2023-08-17Introduce target-runtime parameter for backend-specific CPS loweringAndy Wingo7-19/+67
* module/system/base/target.scm (target-runtime): New export. * module/language/cps/optimize.scm (make-cps-lowerer): Load a backend-specific lowering module dynamically. * module/language/cps/guile-vm.scm: New module for lowering to Guile's VM. * module/language/cps/guile-vm/loop-instrumentation.scm: * module/language/cps/guile-vm/lower-primcalls.scm: * module/language/cps/guile-vm/reify-primitives.scm: Move here, from parent dir. * am/bootstrap.am: Update for new file list.
2023-07-17In test-extensions test, must export library fuctions when built as DLLMichael Gran1-2/+8
The test-extensions standalone test creates a library to be loaded with load-extension. When such libraries are DLLs, the public functions must be marked with the dllexport function attribute. * test-suite/standalone/test-extensions-lib.c (API): new define Mark public functions with define.
2023-07-17Modify SCM_API for DLLsMichael Gran1-4/+4
In https://gcc.gnu.org/wiki/Visibility, they recommend _WIN32 and __CYGWIN__ as the test defines for dllexport. Also, logic is incorrect since HAVE_VISIBILITY can be defined but zero. * libguile/scm.h (SCM_API): modify #ifdef logic
2023-07-17Test for clearenv functionMichael Gran2-1/+7
clearenv() may not be provided by non-glibc systems. As a fallback, just set environ to NULL. * libguile/posix.c (scm_environ)[!HAVE_CLEARENV]: add fallback logic for clearenv()
2023-07-17Avoid inline assembly in VM when using ClangMichael Gran1-1/+1
Clang uses a different format for inline assembly. Also, as noted in the comment, this register usage is likely moot. * libguile/vm-engine.c (JT_REG)[__GNUC__ && !__clang __]: define to empty
2023-07-17Check return value of niceMichael Gran1-2/+2
'nice' is marked as 'warn_unused_result' on some versions of Ubuntu which causes make distcheck to fail. This implements the error checking logic exactly as POSIX suggests to silence the warning. * libguile/posix.c (scm_nice): new error checking logic.
2023-07-16Revert "Mention package GNU Autopoint in README."Bruno Victal1-1/+0
GNU Autopoint is a part of GNU gettext. This reverts commit 3badbb71c6d29ea94e500309b8d6b80e61d0c460. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-07-16doc: Use archived URL from Internet Archive for syntax-rules primer.Bruno Victal1-2/+9
* doc/ref/api-macros.texi (Syntax Rules): Use archived URL from Internet Archive for syntax-rules primer. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-07-16r7rs: 'read-u8' now defaults to 'current-input-port'.Ludovic Courtès2-2/+4
Fixes <https://bugs.gnu.org/62690>. Reported by Rui Zhang <zrui16@hotmail.com>. * module/scheme/base.scm (read-u8): Change default value of 'port'.
2023-07-16Avoid module resolution in 'call-with-new-thread'.Timothy Sample2-1/+11
Fixes <https://bugs.gnu.org/62691>. Reported by Михаил Бахтерев <mike.bakhterev@gmail.com>. * module/ice-9/threads.scm (call-with-new-thread): Do not use 'set!' to set object properties while the calling thread is waiting on the new thread to initialize. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-07-16Fix dangling pointers in `environ'.Olivier Dion1-1/+20
When calling `environ', Guile set the global variable `environ' to a list allocated with the GC. Strings in it are also allocated with the GC. However, if an user call the Scheme setenv() procedure, the resulting call to putenv() in libc might reallocate `environ' to a new pointer while copying sub-pointers owned by Guile in it. This results in the GC marking these strings for reclamation when they are actually still present in `environ'. Thus, the values in the environment are now undefined. To fix this, Guile should only manipulate the `environ' using the standard libc functions. This ensures that concurrent modification of it is safe in multi-threaded program. Therefore, the procedure `environ' now call the libc clearenv() procedure to purge the environment. Then, the desired values are put in `environ' using scm_putenv(). At the end, no GC allocated memory is put in `environ'. Also, since `environ' can be changed at anytime in a multi-thread program, emit a warning stipulating that the result is undefined behavior if multiple threads are created in the program. Consider for example a thread iterating over `environ' while another one do a call to putenv(). The latter would do a realloc() on `environ' and thus the old array read by the former now contains garbage. On system where clearenv() is not present, an atomic store of NULL with sequential consistency to `environ' should be sufficient but see the NOTES of clearenv(3). * libguile/posix.c (scm_environ): Do not store GC allocated memory in environ. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-07-16Fix typos throughout codebase.Morgan Smith40-360/+360
* NEWS: * README: * doc/r5rs/r5rs.texi: * doc/ref/api-data.texi: * doc/ref/api-debug.texi: * doc/ref/api-evaluation.texi: * doc/ref/api-io.texi: * doc/ref/api-macros.texi: * doc/ref/api-procedures.texi: * doc/ref/api-scheduling.texi: * doc/ref/api-undocumented.texi: * doc/ref/libguile-concepts.texi: * doc/ref/posix.texi: * doc/ref/srfi-modules.texi: * doc/ref/vm.texi: * doc/ref/web.texi: * examples/box-dynamic-module/box.c: * examples/box-dynamic/box.c: * examples/box-module/box.c: * examples/box/box.c: * examples/safe/safe: * examples/scripts/README: * examples/scripts/hello: * gc-benchmarks/larceny/twobit-input-long.sch: * gc-benchmarks/larceny/twobit-smaller.sch: * gc-benchmarks/larceny/twobit.sch: * libguile/expand.c: * libguile/load.c: * libguile/net_db.c: * libguile/scmsigs.c: * libguile/srfi-14.c: * libguile/threads.c: * meta/guile.m4: * module/ice-9/match.upstream.scm: * module/ice-9/ports.scm: * module/language/cps/graphs.scm: * module/scripts/doc-snarf.scm: * module/srfi/srfi-19.scm: * module/system/repl/command.scm: * test-suite/tests/srfi-18.test: Fix typos. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-07-16Remove recursive Makefile for 'benchmark-suite'.Ludovic Courtès4-26/+29
* benchmark-suite/Makefile.am: Rename to... * benchmark-suite/local.mk: ... this. Prefix file names with %D%. (EXTRA_DIST): Use '+=' and add 'README'. * Makefile.am: Include it. * configure.ac: Don't output 'benchmark-suite/Makefile'.
2023-07-16tests: Skip web server tests when thread support is missing.Ludovic Courtès1-20/+22
* test-suite/tests/web-server.test ("server is listening"): Throw to 'unresolved when not (provided? 'threads).
2023-07-16Fix possible deadlock in 'scm_sigaction_for_thread'.Ludovic Courtès2-2/+8
Fixes <https://bugs.gnu.org/64666>. * libguile/scmsigs.c (scm_sigaction_for_thread): Swap the 'scm_dynwind_block_asyncs' and 'scm_i_dynwind_pthread_mutex_lock' calls. * NEWS: Update.
2023-06-22Add representations for new primcallsAndy Wingo1-3/+6
* module/language/cps/utils.scm (compute-var-representations): Add representations for vector-length and so on.
2023-06-22Tree-IL-to-CPS lowers to high-level object reprs: vectorsAndy Wingo1-162/+104
* module/language/tree-il/compile-cps.scm: Lower to allocate-vector, vector-ref/immediate, and so on.
2023-06-22Tree-IL-to-CPS lowers to high-level object reprs: stringsAndy Wingo1-54/+6
* module/language/tree-il/compile-cps.scm: Lower to string-length, string-ref, et al.
2023-06-22Tree-IL-to-CPS lowers to high-level object reprs: bytevectorsAndy Wingo1-17/+8
* module/language/tree-il/compile-cps.scm: Lower to bv-length, bv-contents.
2023-06-22Tree-IL-to-CPS lowers to high-level object reprs: structsAndy Wingo1-124/+33
* module/language/tree-il/compile-cps.scm: Lower to allocate-struct, struct-ref, and so on.
2023-06-22Tree-IL-to-CPS lowers to high-level object reprs: pairsAndy Wingo1-23/+4
* module/language/tree-il/compile-cps.scm: Lower to cons, car, set-car!, etc.
2023-06-22Tree-IL-to-CPS lowers to high-level object reprs: atomic boxesAndy Wingo1-30/+4
* module/language/tree-il/compile-cps.scm: Lower to make-atomic-box, atomic-box-ref, and so on.
2023-06-22Tree-IL-to-CPS lowers to high-level object representations: boxesAndy Wingo1-34/+11
* module/language/tree-il/compile-cps.scm: Lower to box, box-ref, and box-set!.
2023-06-22Closure conversion produces high-level object representationsAndy Wingo1-63/+52
* module/language/cps/closure-conversion.scm (convert-one): Build closures with make-closure, cons, and so on; leave lowering to scm-ref to the backend.
2023-06-22Contification uses 'cons primcallAndy Wingo1-13/+4
* module/language/cps/contification.scm (apply-contification): Reify 'cons instead of using the lower-level scm-set! etc.
2023-06-22DCE ignores setters to dead objectsAndy Wingo1-3/+8
* module/language/cps/dce.scm (compute-live-code): Add the new higher-level object mutators.
2023-06-22Remove useless code in CSEAndy Wingo1-4/+0
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun): Defs must be a list.
2023-06-22Add CSE auxiliary definitions for cons, set-car! etcAndy Wingo1-1/+16
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun): Add cons, set-car!, etc.
2023-06-22Fix effects analysis bug for synthesized definitions at allocationsAndy Wingo1-0/+1
* module/language/cps/effects-analysis.scm (compute-known-allocations): For a primcall that allocates, sometimes we will synthesize auxiliary definitions as part of CSE, for example to indicate that if (cons x y) is bound to z, that a later call to (car z) should give x unless there might be an intervening set-car!. We had a bug in which aux definitions attached to allocations were being incorrectly associated with the first operand. Probably this is a bug in other contexts but it really starts to hit with the high-level constructors, e.g. `box`.
2023-06-22Add effects analysis for new high-level object accessorsAndy Wingo1-1/+47
* module/language/cps/effects-analysis.scm: Add car, box-ref, etc to effects analysis.
2023-06-22Add support for higher-level object representations in type analysisAndy Wingo1-3/+72
* module/language/cps/types.scm: Add inferrers for vector-ref, car, etc.
2023-06-22Move f64->scm lowering to lower-primcallsAndy Wingo2-32/+32
* module/language/cps/lower-primcalls.scm (f64->scm): Move here... * module/language/cps/reify-primitives.scm (reify-primitives): from here. Seems a more fitting place.
2023-06-22Wire in lower-primitives passAndy Wingo1-15/+29
* module/language/cps/optimize.scm (lower-cps/generic): Rename from lower-cps; these are the lowerings that apply to everyone. (select-opts-for-optimization-level): Factor out of make-cps-lowerer. (make-backend-cps-lowerer): New procedure. For the Guile VM backend, we have a few mandatory passes, including the new lower-primitives. (make-cps-lowerer): Apply backend-specific lowering pass.