1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

20536 commits

Author SHA1 Message Date
Andy Wingo
4da276de16 Implement cross-module inlining
* 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-04-26 17:56:56 +02:00
Andy Wingo
c4a4c330f3 Add support for recording inlinable module exports
* 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-04-26 17:56:56 +02:00
Andy Wingo
b1c3d14679 Add pass to resolve free toplevel references in declarative modules
* 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-04-26 17:56:56 +02:00
Andy Wingo
532c241e38 Letrectify links module defs with uses
* 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-04-26 17:56:56 +02:00
Andy Wingo
04e9245918 Bump minor objcode version for new intrinsics
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2021-04-26 17:05:34 +02:00
Andy Wingo
b7822d9e4a Allow contification for $callk
* 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-26 16:05:21 +02:00
Andy Wingo
c52dc02bbe CPS conversion calls module variables through trampolines
* 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-26 16:05:21 +02:00
Andy Wingo
2b58c49e59 Fix CPS optimizations to allow callk in front half
* 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.
2021-04-26 16:05:13 +02:00
Andy Wingo
e0d022c347 Fix error when argument to < not a real
* libguile/intrinsics.c (less_p): scm_nan_p raises an error if arg is
not a real; guard.
2021-04-26 12:26:33 +02:00
Andy Wingo
83023160b1 Simplify module variable lookup slow-path
* libguile/intrinsics.h:
* libguile/intrinsics.c (lookup_bound_public, lookup_bound_private): Two
new intrinsics.
(scm_bootstrap_intrinsics): Wire them up.
* libguile/jit.c (compile_call_scm_from_scmn_scmn):
(compile_call_scm_from_scmn_scmn_slow):
(COMPILE_X8_S24__N32__N32__C32): Add JIT support for new instruction
kind.
* libguile/vm-engine.c (call-scm<-scmn-scmn): New instruction, takes
arguments as non-immediate offsets, to avoid needless loads and register
pressure.
* module/language/cps/effects-analysis.scm: Add cases for new
primcalls.
* module/language/cps/compile-bytecode.scm (compile-function): Add new
primcalls.
* module/language/cps/reify-primitives.scm (cached-module-box): If the
variable is bound, call lookup-bound-public / lookup-bound-private as
appropriate instead of separately resolving the module, name, and doing
the bound check.
* module/language/tree-il/compile-bytecode.scm (emit-cached-module-box):
Use new instructions.
* module/system/vm/assembler.scm (define-scm<-scmn-scmn-intrinsic):
(lookup-bound-public, lookup-bound-private): Add assembler support.
2021-04-26 09:48:52 +02:00
Andy Wingo
976433d667 Fix cached-module-box cache keys
* module/language/cps/reify-primitives.scm (cached-module-box): Include
public? in cache key, so we don't accidentally alias private and
exported names.  Also include bound?, to avoid a window in which thread
A resolves and caches var V in preparation for setting it, but thread B
sees V for ref before it was initialized.
2021-04-25 20:27:34 +02:00
Andy Wingo
5809279b99 Fix bugs introduced when allowing $kfun -> $kargs
* module/language/cps/dce.scm (compute-known-allocations):
* module/language/cps/simplify.scm (eta-reduce): Allow the case-lambda
without clauses.
2021-04-25 13:33:06 +02:00
Andy Wingo
39619988e4 Fix comments in cps/compile-bytecode
* module/language/cps/compile-bytecode.scm (compile-function): Fix
unfinished comments.
2021-04-23 21:42:44 +02:00
Andy Wingo
86e86ec1c7 New pass: elide-arity-checks
* module/language/cps/elide-arity-checks.scm: New file.  Elides argument
count checks for known callers.
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES): Add new file.
* module/language/cps/optimize.scm (optimize-first-order-cps):
* module/system/base/optimize.scm (available-optimizations): Add new
pass.
2021-04-21 22:41:12 +02:00
Andy Wingo
8aacaad96a Allow $kargs as entry of $kfun
* module/language/cps.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/types.scm: Allow $kargs to follow $kfun.  In that
case, the function must be well-known and callers are responsible for
calling with the appropriate arity.
* module/language/cps/compile-bytecode.scm: Emit "unchecked-arity" for
$kargs following $kfun.
* module/system/vm/assembler.scm: Adapt.
2021-04-21 22:41:12 +02:00
Andy Wingo
58ce5fac7d Mark some elisp runtime modules as non-declarative
* module/language/elisp/runtime/function-slot.scm (language):
* module/language/elisp/runtime/value-slot.scm (language):
Non-declarative.
2021-04-21 22:41:12 +02:00
Andy Wingo
fafe845c11 Optimize letrec* binding order in fix-letrec
* module/language/tree-il/fix-letrec.scm (reorder-bindings):
(fix-letrec): Reorder definitions so that lambdas tend to stick
together, to avoid "complex" expressions interposing in lambda SCCs.
2021-04-21 22:41:12 +02:00
Jan (janneke) Nieuwenhuizen
6069fa5ce2
Compile fix for x86_64-MinGW.
* libguile/posix-w32.h (start_child): Return pid_t.
2021-04-12 12:18:53 +02:00
Jan (janneke) Nieuwenhuizen
855f3948ec
ice-9 ftw: Use 'absolute-file-name?' in 'nftw'.
* module/ice-9/ftw.scm (abs?): Remove.
(nftw): Use 'absolute-file-name?' instead.
2020-08-13 18:54:22 +02:00
Jan (janneke) Nieuwenhuizen
3db293a71d
Document write-line.
* libguile/rdelim.c (SCM_DEFINE): Use "procedure" rather than
"function".
* doc/ref/api-io.texi (Line/Delimited): Use it to document 'write-line'.
2020-10-05 15:25:52 +02:00
Daniel Llorens
bdb07f8fc7 Update gnulib to a3a946f670718d0dee5a7425ad5ac0a29fb46ea1
This fixes https://lists.gnu.org/archive/html/guile-devel/2021-04/msg00009.html
2021-04-08 21:00:42 +02:00
Mikael Djurfeldt
88e7030845 Fix typos in examples.
Thanks to Eugene Klimov.
2021-04-04 20:16:58 +02:00
Mikael Djurfeldt
01bfd18f3d Fix handling of parameter lists to elisp defun to allow nil.
Thanks to Vasilij Schneidermann.
2021-04-01 20:56:22 +02:00
David Thompson
498564e3e3 goops: Preserve all slot options in redefinable classes.
* module/goops.scm (compute-slots): Fix <redefinable-class> slot
transformation.
* test-suite/tests/goops.test ("slot options on redefinable classes"):
Add a test.
2021-03-19 21:45:53 +01:00
Ludovic Courtès
c92f2c7df0 web: 'tls-wrap' returns an unbuffered custom port.
This mirrors Guix commit b168acae2a01fd84075cc134a6140594a978fde5.

* module/web/client.scm (tls-wrap)[unbuffered]: New procedure.
Pass the result of 'make-custom-binary-input/output-port' to
'unbuffered'.
2021-03-19 14:13:31 +01:00
Ludovic Courtès
e4f54d4b32 web: 'tls-wrap' avoids intermediate buffer.
This mirrors Guix commit 279d932b1ca7bfbb8657c41a84616dd0dfc6e0a8.

* module/web/client.scm (tls-wrap)[read!]:  Read straight into BV
instead of calling 'get-bytevector-some' and 'unget-bytevector'.
2021-03-19 14:08:58 +01:00
Andy Wingo
ef7952984c Update NEWS
* NEWS: Updates.
2021-03-18 22:05:58 +01:00
Andy Wingo
9e32c5729e Fix recent i18n tests
* test-suite/tests/i18n.test ("text collation (French)"): Fix to
actually pass locale arg.
2021-03-16 21:55:22 +01:00
Andy Wingo
72bf9d93ca Fix buffer overread in string-locale<?
* libguile/i18n.c (compare_strings): In all cases, convert to a
null-terminated string.  While we're doing that, might as well use
utf-8.
* test-suite/tests/i18n.test ("text collation (French)"): Add test.

Thanks again to Rob Browning for the report.
2021-03-15 22:02:12 +01:00
Andy Wingo
8a8727db5c Adapt test for string-locale-ci=?
* test-suite/tests/i18n.test ("text collation (French)"): Punt on
collating if utf8 locale unavailable.
2021-03-15 21:59:15 +01:00
Andy Wingo
d87b57a00b Fix buffer overread in string-locale-ci=? and related functions
* libguile/i18n.c (u32_locale_casecoll): Take lengths of incoming
strings as parameters rather than assuming "nul" termination.
(compare_u32_strings_ci): Pass string lengths as computed from the
Scheme strings.
* test-suite/tests/i18n.test ("text collation (English)"): Add a test
case.

Thanks a million to Rob Browning for the report.
2021-03-15 21:23:43 +01:00
Mike Gran
5a1a1eee50 Add JIT capability for MinGW
* libguile/jit.c [__MING32__]: add windows.h on Win32
  (struct code_arena) [__MINGW32__]: a HANDLE for Win32 mmap
  (BIGENDIAN): rename to JIT_BIGENDIAN, to avoid collision with
    Win32 BIGENDIAN constant. All users changed
  (allocate_code_arena) [__MINGW32__]: add Win32 mmap allocator
  (emit_code) [__MINGW32__]: add Win32 munmap
* libguile/lightening/lightening/lightening.c: remove unnecessary mman.h
2021-03-13 15:43:57 -08:00
Mike Gran
5a1e78a278 On Cygwin, 'lib' DLLs use 'cyg' prefix
When using automake and libtool to build DLLs on Cygwin, libtool
will rename libXXX to cygXXX. 'load-foreign-library' should
emulate libltdl behavior and search for DLLs using that convention.

* module/system/foreign-library.scm (lib->cyg): new helper function
  (load-foreign-library): add rename-on-cygwin? option to rename
    libraries using Cygwin semantics
* test-suite/tests/foreign.test: new test section 'lib->cyg'
* doc/ref/api-foreign.text: document new rename-on-cygwin? option
    for load-foreign-library
2021-03-13 09:09:30 -08:00
Andy Wingo
db9725fd02 Don't force installation of GMP allocators in guile shell
* libguile/guile.c (main): Don't override initial setting of
scm_install_gmp_memory_functions.  Thanks to Andrew Whatson for the
fix.
2021-03-12 22:38:21 +01:00
Ricardo G. Herdt
23042a1ef9 Fix hash-table-merge! bug.
* module/srfi/srfi-69.scm : fold over second hash table.
2021-03-12 22:31:00 +01:00
Andrew Whatson
f591ad28f1 Fix suspendable implementation of 'get-bytevector-some!'
* module/ice-9/suspendable-ports.scm (get-bytevector-some!): Fix
  incorrect arguments to bytevector-copy!
2021-03-12 22:11:58 +01:00
Andrew Whatson
bc50aff6f8 Add tests for get-bytevector-some!
* test-suite/tests/r6rs-ports.test (get-bytevector-n! [short]): add
  (get-bytevector-n! [long]): add
2021-03-12 22:11:51 +01:00
Andy Wingo
e30ee90478 Revert "Handle CRLF and Unicode line endings in read-line"
This reverts commit 0f983e3db0.

After discussing with Mike we are going to punt the read-line changes
for now.  Open the port in O_TEXT mode if you want to chomp the CR in
CFLF sequences.
2021-03-12 22:08:16 +01:00
Michael Gran
1c472fef54 Add read-line and ftw changes to NEWS
* NEWS: updated
2021-03-11 20:03:10 -08:00
Mike Gran
0f983e3db0 Handle CRLF and Unicode line endings in read-line
* libguile/rdelim.c (scm_read_line): handle CRLF, LS and PS
* module/ice-9/suspendable-ports.scm (read-line): handle CRLF, LS, and PS
* module/web/http.scm (read-header-line): take advantage of CRLF in read-line
   (read-header): don't need to test for \return
* test-suite/tests/rdelim.test: new tests for read-line CRLF, LS and PS
* doc/ref/api-io.texi: update doc for read-line
2021-03-11 19:42:33 -08:00
Michael Gran
a744f98dcc ice-9 ftw: handle non-working inodes
* module/ice-9/ftw.scm (visited?-proc): accept filename for string hash
  (file-system-fold): use string hash if ino = 0
  (ftw): use new visited?-proc
* test-suite/tests/ftw.test (visited?-proc valid inodes): add filenames to visited?-proc calls
  (visited?-proc broken inodes): new tests
  (%top-srcdir): canonicalize-path
2021-03-11 10:46:35 -08:00
Michael Gran
c150044640 ice-9 ftw: handle missing getuid and getgid
* module/ice-9/ftw.scm (getuid-or-false, getgid-or-false): new macros
  (stat-dir-readable?-proc): don't overwrite arguments
  (ftw, nftw): use new macros
* test-suite/tests/ftw.test (test-EACCES): don't presume getuid exists
2021-03-11 10:46:24 -08:00
Michael Gran
3f4d5d128c For MinGW use Windows filepaths in libpath.h
* configure.ac (MINGW_LIBPATH): new automake conditional and test
* libguile/Makefile.am (libpath.h) [MINGW_LIBPATH]: use Windows-style
    paths
2021-03-11 10:46:06 -08:00
Mike Gran
1b0da42672 on MinGW, prefer winsock2.h over sys/select in iselect
* libguile/iselect.h [__MINGW32__]: add winsock2 include
2021-03-11 09:37:12 -08:00
Mike Gran
db13f6e282 Build standalone test libraries as unversioned
* test-suite/standalone/Makefile.am (libtest_asmobs_la_LDFLAGS): avoid version
    (libtest_ffi_la_LDFLAGS, libtest_extensions_la_LDFLAGS): avoid version
2021-03-11 08:31:07 -08:00
Mike Gran
7d08c72cf9 Add windows stubs for dlopen, dlclose, dlsym, dlerror
* libguile/dynl.c [__MING32__] (dlopen, dlsym, dlclose, dlerror): use windows stubs
* libguile/posix-w32.c (dlopen_w32, dlsym_w32, dlclose_w32, dlerror_w32):
    new procedures
    (dlerror_str): new module-level variable
    (DLERROR_LEN): new define
* libguile/posix-w32.h: declare dlopen_w32, dlsym_w32, dlclose_w32, dlerror_w32.
    Declare RTLD_NOW, RTLD_LAZY, RTLD_GLOBAL, RTLD_LOCAL
2021-03-11 08:30:57 -08:00
Andy Wingo
85433fc2b1 Add mkstemp; undocument mkstemp!
* doc/ref/posix.texi (File System): Update to document mkstemp only.
* libguile/filesys.c: Make a mkstemp that doesn't modify the input
template.  Instead the caller has to get the file name from
port-filename.
(scm_mkstemp): Use the new mkstemp to implement mkstemp!.  Can't
deprecate yet though as the replacement hasn't been there for long
enough.
* libguile/posix.c (scm_tempnam): Update to mention mkstemp instead.
* module/system/base/compile.scm (call-with-output-file/atomic): Use
mkstemp.
* test-suite/tests/posix.test:
* test-suite/tests/r6rs-files.test: Use mkstemp.
* NEWS: Update.
2021-03-10 20:40:10 +01:00
Mike Gran
89a299102f On Win32, prefer winsock2 header for socket declarations
* libguile/posix-w32.h: prefer lowercase windows.h for MinGW cross-builds
* libguile/socket.c [HAVE_WINSOCK2_H]: use only winsock2.h for socket
    declarations
2021-03-10 02:01:03 -08:00
Michael Gran
1b697d339b remove 2nd attempt at invoking ComSpec when spawning child
The start_child procedure is used to spawn a child process. If it fails
to launch the given argv[0] as if it were a command, it has logic to
retry using the ComSpec as a command interpreter, treating argv[0] as
a batch file name. Usually, this fails because batch files would have
been handled in the first pass if they were valid.  Also, this has
the unfortunate side effect of spawning a shell awaiting user input.

It is safer to remove this attempt.

* libguile/posix-w32.c (start_child): remove fallback processing
2021-03-10 02:00:15 -08:00
Michael Gran
653cc0bf95 disable popen 'no duplicates' test for MinGW
This test, which seems quite complicated to fix, causes the MinGW build
to hang. Disable it for now, but, come back to it later.

* test-suite/tests/popen.test (mingw?): new constant
  (no duplicate): disable for mingw, for now
2021-03-10 01:59:59 -08:00