summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-06-22New CPS pass: lower-primcallsAndy Wingo2-0/+593
This pass will implement the specialized lowering of object accessors to Guile's VM primitives. * am/bootstrap.am (SOURCES): Add new file. * module/language/cps/lower-primcalls.scm: New file.
2023-06-22Fix target-max-size-t/scm to not be a fraction (oops)Andy Wingo1-4/+2
* module/system/base/target.scm (target-max-size-t/scm): Use floor/ instead of /.
2023-06-19Consider $code to make 'ptr representationAndy Wingo1-1/+1
* module/language/cps/utils.scm (compute-var-representations): For the wasm target, these values are (ref $kvarargs), not i64. Will need to distinguish from bytevector pointers at some point, though.
2023-06-19Fix bug in compilation of rsh/lshAndy Wingo1-2/+2
* module/language/cps/compile-bytecode.scm (compile-function): The rsh/lsh patterns would never match. I think these would end up dispatching through emit-text though.
2023-06-19Use tree-il-srcv instead of tree-il-srcAndy Wingo8-29/+32
This prevents eager conversion to alists.
2023-06-19Excise use of `record-case`Andy Wingo3-113/+106
This macro expands to field accessors, which in the case of tree-il-src will force an eager conversion of the source info to alists.
2023-06-09maint: Add to 'EXTRA_DIST' instead of overwriting it.Ludovic Courtès1-1/+1
Reported by Mike Gran. * gc-benchmarks/local.mk (EXTRA_DIST): Change = to +=.
2023-06-08Fix exn dispatch for exns within pre-unwind handlersAndy Wingo3-46/+81
* libguile/exceptions.c (exception_epoch_fluid): Rename from active_exception_handlers_fluid. (scm_dynwind_throw_handler): Increment exception epoch instead of resetting active exception handlers. (scm_init_exceptions): Update. * module/ice-9/boot-9.scm (with-exception-handler): Rework to associate an "epoch" fluid with each exception handler. (with-throw-handler): Establish a new epoch, during the execution of a throw handler. (raise-exception): Rework to avoid capturing a list of exception handlers, and to use epochs as a way to know which handlers have already been examined and which are on the dispatch stack. * test-suite/tests/exceptions.test ("throwing within exception handlers"): New test.
2023-06-08Deprecate (ice-9 lineio)Andy Wingo1-1/+5
* module/ice-9/lineio.scm: Deprecate.
2023-06-08Load (ice-9 binary-ports) from C in thread-safe wayAndy Wingo1-6/+31
* libguile/r6rs-ports.c: Do the usual dance to load make-custom-binary-input-port et al just once.
2023-06-08Fix allow-newline? in call-with-truncating-output-stringAndy Wingo1-1/+3
* module/ice-9/pretty-print.scm (call-with-truncating-output-string): Actually detect newlines.
2023-06-08truncated-print: use call-with-truncating-output-stringAndy Wingo1-32/+31
* module/ice-9/pretty-print.scm (truncated-print): Use new call-with-truncating-output-string, to allow for early bailout when printing large records.
2023-06-08Inline generic-write into pretty-printAndy Wingo1-230/+219
* module/ice-9/pretty-print.scm (pretty-print): Inline generic-write into its only caller.
2023-06-08pretty-print: width arg is never falseAndy Wingo1-5/+2
* module/ice-9/pretty-print.scm (generic-write): width is never false.
2023-06-08Rewrite pretty-print to rely on port-column, abort earlyAndy Wingo1-185/+246
* module/ice-9/pretty-print.scm (call-with-truncating-output-string): New function. * module/ice-9/pretty-print.scm (generic-write): Rewrite so that instead of keeping track of the column, we just use port-column on the port. Also, when checking if a possibly-improper list can print on one line, use new call-with-truncating-output-string so as to always abort early, even for long bytevectors.
2023-06-08Modernize soft portsAndy Wingo3-34/+178
* doc/ref/api-io.texi (Soft Ports): Update docs. * module/ice-9/boot-9.scm (make-soft-port): Don't eagerly load soft ports. * module/ice-9/soft-ports.scm (deprecated-make-soft-port): Rename from make-soft-port. (make-soft-port): New interface.
2023-06-08Implement R6RS custom textual portsAndy Wingo5-32/+346
* module/ice-9/textual-ports.scm (custom-textual-port-read+flush-input): (custom-textual-port-write): (custom-textual-port-seek): (custom-textual-port-close): (custom-textual-port-random-access?): (make-custom-textual-input-port): (make-custom-textual-output-port): (make-custom-textual-input/output-port): New procedures. * doc/ref/api-io.texi (Ports): Update docs. * doc/ref/r6rs.texi (rnrs io ports): Mention custom textual port interfaces. * module/rnrs/io/ports.scm: Re-export custom textual port interfaces from (ice-9 textual-ports). * test-suite/tests/r6rs-ports.test: Add minimal tests for textual ports.
2023-06-08Rewrite soft ports in SchemeAndy Wingo7-216/+224
This also makes soft ports suspendable. * am/bootstrap.am (SOURCES): Add (ice-9 soft-ports). * libguile/init.c (scm_i_init_guile): No need to init vports. * libguile/vports.c: Call out to (ice-9 soft-ports). * libguile/vports.h: Remove internal scm_init_vports. * module/ice-9/boot-9.scm (the-scm-module): Import (ice-9 soft-ports). Really this enlarges the boot closure a bit, so we should probably refactor. * module/ice-9/soft-ports.scm: New file.
2023-06-08Use custom binary output ports for make-chunked-output-portAndy Wingo1-25/+13
* module/web/http.scm (make-chunked-output-port): Use custom binary output ports.
2023-06-08Rewrite custom binary ports in Scheme, in terms of custom portsAndy Wingo3-340/+142
* libguile/r6rs-ports.c: Call out to Scheme instead of defining here. * libguile/r6rs-ports.h: Put custom binary port decls together, to deprecate later. * module/ice-9/binary-ports.scm: Re-implement custom binary ports in terms of custom ports.
2023-06-08Add "custom ports"Andy Wingo7-180/+664
Custom ports are a kind of port that exposes the C port type interface directly to Scheme. In this way the full capability of C is available to Scheme, and also the read and write functions can be tail-called from Scheme (via port-read / port-write). * libguile/custom-ports.c: * libguile/custom-ports.h: * module/ice-9/custom-ports.scm: New files. * libguile/init.c: * libguile/Makefile.am: * am/bootstrap.am: Add to the build. * doc/ref/api-io.texi: Update the manual.
2023-06-08bytevector-slice: optimize trivial caseAndy Wingo1-0/+3
* libguile/bytevectors.c (scm_bytevector_slice): Return the bytevector directly if start==0 and count==len.
2023-06-08pretty-print: inline some handling of read macrosAndy Wingo1-35/+21
* module/ice-9/pretty-print.scm (generic-write): Not really sure why read macros are duplicated, but this is a refactor to use more match and less cadr.
2023-06-08pretty-print: inline genwrite:newline-strAndy Wingo1-4/+2
* module/ice-9/pretty-print.scm (genwrite:newline-str): Remove. (generic-write): Just use "\n".
2023-06-08pretty-print: Use string-concatenate-reverseAndy Wingo1-21/+2
* module/ice-9/pretty-print.scm (generic-write): Use string-concatenate-reverse instead of locally-defined reverse-string-append. (reverse-string-append): Remove.
2023-06-05guix: Add missing module import.Ludovic Courtès1-0/+1
* .guix/modules/guile-package.scm: Add missing module import.
2023-06-05Remove recursive Makefile for 'am'.Ludovic Courtès3-30/+3
* Makefile.am (SUBDIRS): Remove 'am'. (EXTRA_DIST): Add files from am/. * am/Makefile.am: Remove. * configure.ac: Don't emit 'am/Makefile'.
2023-06-05Remove recursive Makefile for 'gc-benchmarks'.Ludovic Courtès3-33/+33
* gc-benchmarks/Makefile.am: Rename to... * gc-benchmarks/local.mk: ... this. Prefix file names with %D%. (benchmarks): Rename to... (gc_benchmarks): ... this. * Makefile.am: Include it. * configure.ac: Don't output 'gc-benchmarks/Makefile'.
2023-06-05Remove 'emacs/Makefile.am'.Ludovic Courtès3-26/+0
This is a followup to 178e9d237b6522ba8f72162949d9b925f6750266. * emacs/Makefile.am: Delete. * configure.ac: Don't output 'emacs/Makefile'. * Makefile.am (SUBDIRS): Remove 'emacs'.
2023-06-05maint: Move Guix files to '.guix'.Ludovic Courtès5-4/+4
* build-aux/guix: Rename to... * .guix/modules: ... this. * .guix-channel: Adjust accordingly. * guix.scm: Likewise. * build-aux/manifest.scm: Rename to... * .guix/manifest.scm: ... this. * Makefile.am (EXTRA_DIST): Adjust accordingly.
2023-06-05maint: Avoid 'specification->package' when referring to packages.Ludovic Courtès1-25/+38
This avoids ambiguity when using channels in addition to 'guix'. * build-aux/guix/guile-package.scm (guile): Refer to packages by their bindings rather than using 'specification->package'.
2023-05-08Use /dev/null in 'piped-process' if port is not backed by a fdes.Josselin Poiret3-5/+29
In Guile 3.0.9, 'system*' would no longer open /dev/null for file descriptors 0, 1, and 2 when its 'current-input-port', 'current-output-port', or 'current-output-port' is not bound to a file port. This patch reinstates that behavior. Fixes <https://bugs.gnu.org/63024>. * libguile/posix.c (piped_process): Open /dev/null to use as in/out/err if the corresponding port is not backed by a file descriptor. * test-suite/tests/posix.test ("system*")["https://bugs.gnu.org/63024"]: New test. * NEWS: Update. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2023-05-08Add error handling for spawn's posix_spawn_file_actions_adddup2.Josselin Poiret1-6/+13
* libguile/posix.c (do_spawn): Add error handling if posix_spawn_file_actions_adddup2 fails. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-05-07call-with-values builtin doesn't leave garbage on the stackAndy Wingo3-11/+50
Fixes https://debbugs.gnu.org/63279. The issue was that if the producer thunk caused a backtrace, pretty-printing the call-with-values frame would segfault because there was an unininitialized slot on the stack. For functions produced by the compiler this wouldn't be a problem because there are stack maps, but primitives require that all slots on a pending stack frame be packed (no uninitialized values) and tagged (all SCM values, no unboxed values). * test-suite/tests/error-handling.test: New test. * test-suite/Makefile.am: Add new file. * libguile/vm.c (define_vm_builtins): Fix call-with-values to have a more compact stack.
2023-04-27Use SCM_GSUBR_MAX in place of the hardcoded numberDaniel Llorens2-4/+4
* libguile/gsubr.c (scm_apply_subr): Reference the limit. (get_subr_stub_code): As stated. * libguile/jit.c (compile_subr_call): As stated.
2023-04-05Fix typo in append procedure documentationJorge Gomez1-1/+1
Fixes <https://bugs.gnu.org/62456>. Signed-off-by: Mikael Djurfeldt <mikael@djurfeldt.com>
2023-04-04Add missing backslash.Mikael Djurfeldt1-1/+1
2023-04-02Adjust 'spawn' tests to accept 'LD_ORIGIN_PATH' on GNU/Hurd.Ludovic Courtès2-1/+9
Fixes <https://bugs.gnu.org/62501>. * test-suite/tests/posix.test ("spawn")["env with #:environment and #:output"]: Add workaround for GNU/Hurd. * NEWS: Update.
2023-04-02Use 'posix_spawn_file_actions_addclosefrom_np' where available.Ludovic Courtès2-1/+17
* configure.ac: Check for 'posix_spawn_file_actions_addclosefrom_np'. * libguile/posix.c (HAVE_ADDCLOSEFROM): New macro. (close_inherited_fds): Wrap in #ifdef HAVE_ADDCLOSEFROM. (do_spawn) [HAVE_ADDCLOSEFROM]: Use 'posix_spawn_file_actions_addclosefrom_np'.
2023-04-02Remove racy optimized file descriptor closing loop in 'spawn'.Ludovic Courtès1-29/+1
This reverts 9332b632407894c2e1951cce1bc678f19e1fa8e4, thereby reinstating the performance issue in <https://bugs.gnu.org/59321>. This optimization was subject to race conditions in multi-threaded code: new file descriptors could pop up at any time and thus leak in the child. * libguile/posix.c (close_inherited_fds): Remove. (close_inherited_fds_slow): Rename to... (close_inherited_fds): ... this.
2023-04-02'spawn' closes only open file descriptors on non-GNU/Linux systems.Ludovic Courtès2-2/+21
Fixes <https://bugs.gnu.org/61095>. Reported by Omar Polo <op@omarpolo.com>. * libguile/posix.c (close_inherited_fds_slow): On systems other than GNU/Linux, call 'addclose' only when 'fcntl' succeeds on MAX_FD. * NEWS: Update.
2023-03-20Update NEWS.Ludovic Courtès1-3/+3
2023-03-20Fix some invalid unicode handling issues with suspendable ports.Christopher Baines3-4/+14
Fixes <https://bugs.gnu.org/62290>. Based on the implementation in ports.c. I don't understand what this code is really doing, but the suspendable ports implementation differs from the similar C code for a couple of inequalities. * module/ice-9/suspendable-ports.scm (decode-utf8, bad-utf8-len): Flip a couple of inequalities. * test-suite/tests/ports.test ("string ports"): Add additional invalid UTF-8 test case. * NEWS: Update. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-03-18scm_i_utf8_string_hash: compute u8 chars not bytesRob Browning6-3/+86
Noticed while investigating a migration to utf-8 strings. After making changes that routed non-ascii symbol hashing through this function, encoding-iso88597.test began intermittently failing because it would traverse trailing garbage when u8_strnlen reported 8 chars instead of 4. Change the scm_i_str2symbol and scm_i_str2uninterned_symbol internal hash type to unsigned long to explicitly match the scm_i_string_hash result type. * libguile/hash.c (scm_i_utf8_string_hash): Call u8_mbsnlen not u8_strnlen. * libguile/symbols.c (scm_i_str2symbol, scm_i_str2uninterned_symbol): Use unsigned long for scm_i_string_hash result. * test-suite/standalone/.gitignore: Add test-hashing. * test-suite/standalone/Makefile.am: Add test-hashing. * test-suite/standalone/test-hashing.c: Add.
2023-03-17Fix no-clause case-lambda in pevalDaniel Llorens2-1/+2
This is checked by optargs.test, which 3b47f87618047ebb8812788c64a44877a4f2e0dd broke. * module/language/tree-il/peval.scm (peval): Account for no clause (= no body) case-lambda.
2023-02-27peval reduces some inlined case-lambda callsDaniel Llorens2-0/+95
* module/language/tree-il/peval.scm (peval): Reduce multiple case lambda in <call> trees according to the number of arguments. Do not try to reduce case-lambda using keyword arguments. * test-suite/tests/peval.test: Tests.
2023-02-24Remove unnecessary module imports.Ludovic Courtès37-70/+0
These were found with: make GUILE_WARNINGS='-W1 -Wunused-module' * module/ice-9/copy-tree.scm: * module/ice-9/eval-string.scm: * module/ice-9/getopt-long.scm: * module/ice-9/poll.scm: * module/ice-9/popen.scm: * module/ice-9/sandbox.scm: * module/ice-9/threads.scm: * module/sxml/apply-templates.scm: * module/sxml/simple.scm: * module/system/base/types.scm: * module/system/repl/command.scm: * module/system/repl/common.scm: * module/system/repl/coop-server.scm: * module/system/repl/debug.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/repl/server.scm: * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm: * module/system/vm/dwarf.scm: * module/system/vm/elf.scm: * module/system/vm/frame.scm: * module/system/vm/inspect.scm: * module/system/vm/linker.scm: * module/system/vm/program.scm: * module/system/vm/trace.scm: * module/system/vm/trap-state.scm: * module/system/vm/traps.scm: * module/system/xref.scm: * module/texinfo/indexing.scm: * module/texinfo/plain-text.scm: * module/texinfo/reflection.scm: * module/texinfo/string-utils.scm: * module/web/client.scm: * module/web/http.scm: * module/web/request.scm: * module/web/response.scm: Remove imports of unused modules.
2023-02-24Add -Wunused-module.Ludovic Courtès4-3/+336
* module/language/tree-il/analyze.scm (<module-info>): New record type. (unused-module-analysis): New variable. (make-unused-module-analysis): New analysis. (make-analyzer): Add it. * module/system/base/message.scm (%warning-types): Add 'unused-module'. * test-suite/tests/tree-il.test (%opts-w-unused-module): New variable. ("warnings")["unused-module"]: New test prefix. * NEWS: Update.
2023-02-24Add 'record-case' to '.dir-locals.el'.Ludovic Courtès2-4/+1
* module/language/tree-il/fix-letrec.scm (fix-letrec): Remove "Local Variables" bit. * .dir-locals.el (scheme-mode): Add 'record-case'.
2023-02-24Fix typo in raise-exception documentationDaniel Llorens1-1/+1
* doc/ref/api-control.texi (Raising and Handling Exceptions): Fix typo, h/t gtz on #guile.