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

4323 commits

Author SHA1 Message Date
Leo Prikler
5c6a944173 bug#45131: [PATCH] Compile directly to target language if no joint is found.
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-10 10:16:10 +02:00
Andy Wingo
1432088f27 Minor tweak to truncate-bits
* module/system/base/types/internal.scm (truncate-bits): Use bits-case
in all cases.
2021-05-10 10:07:12 +02:00
Andy Wingo
05614f792b Optimize truncate-bits
* 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-06 21:51:37 +02:00
jakub-w
f10bc1a864 [srfi-64] Fix a bug with test-end removing globally installed test-runner
* 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-05 12:29:47 +02:00
Ludovic Courtès
5969490f55 analyze: 'unbound-variable' warning handles re-exported bindings.
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-02 01:20:19 +02:00
Andy Wingo
d4b7cbc68c Fix R7RS include-library-declarations and cond-expand in define-library
* 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-01 22:23:06 +02:00
Andy Wingo
d643913ac2 Fix bug if call-with-prompt tag not a lexical
* module/language/tree-il/peval.scm (peval): peval could throw if the
call-with-prompt operand wasn't a lexical.  Terrible!
2021-05-01 22:16:40 +02:00
Andy Wingo
44a6a21dcc Fix tree-il effects analysis for prompts
* 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-01 22:16:20 +02:00
Andy Wingo
3383a2cb10 Fix bug for read-syntax on ( . args)
* 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-05-01 20:43:07 +02:00
Andy Wingo
ee7d18ec41 Fix syntax-violation, which was passing vectors instead of alists
* 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-29 22:00:18 +02:00
Andy Wingo
c72a0237e3 Fix compile-psyntax.scm -- canonicalize pass not needed
* module/ice-9/compile-psyntax.scm: Remove use of canonicalization pass,
as it's not needed.  Whoopdy!
2021-04-29 21:52:27 +02:00
Andy Wingo
7da831af18 Fix line and column for read errors
* 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-29 21:46:31 +02:00
Andy Wingo
19f38a38fd Fix duplicates handlers for interfaces that use interfaces
* 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-28 22:04:37 +02:00
Andy Wingo
e49794a3bb Add ice-9/read.scm to extra_dist
* module/Makefile.am (NOCOMP_SOURCES): Add ice-9/read.scm.
2021-04-27 22:16:48 +02:00
Andy Wingo
12fa7d115d Fix closure-conversion bug for SCC with all free vars pruned
* 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-27 14:51:38 +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
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
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
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
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
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
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
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
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
Linus
0bd7497b61 Write a proper vector-map and vector-for-each for (rnrs base)
* module/rnrs/base.scm (vector-map vector-for-each): Rewrite to not be
slow.
* NEWS: Update.
2021-03-09 21:10:04 +01:00
Andy Wingo
5046385df8 Document syntax-sourcev
* NEWS: Add doc link.
* doc/ref/api-macros.texi (Syntax Transformer Helpers): Document
syntax-sourcev.
* module/system/syntax.scm: Re-export syntax-sourcev.
2021-03-09 20:50:08 +01:00
Andy Wingo
cad6094cbc Fix reading #!!#
* module/ice-9/read.scm (%read): Fix reading #!!#.
* test-suite/tests/reader.test ("reading"): Add some test cases.
2021-03-07 20:17:58 +01:00
Michael Gran
1114122fbb tweak unknown hash object error in reader
This makes it match the other species of unknown hash object error
when reading number with radix.

* module/ice-9/read.scm (read-sharp): modified
2021-03-05 22:33:20 -08:00
Michael Gran
d6753e5af5 print token in error msg for unknown hash object
* module/ice-9/read.scm (read-number-and-radix): modified
2021-03-05 22:26:00 -08:00
Michael Gran
1ae9a8df3a Handle <eof> in reader's character escape sequences
* module/ice-9/read.scm (read-r6rs-hex-escape, read-fixed-hex-escape):
    modified
2021-03-05 22:24:40 -08:00
Andy Wingo
9fb550b945 Fix reading "#;", "'", and similar premature-EOF situations
* module/ice-9/read.scm (%read): Adjust how subexpressions are read to
error on EOF.  Improve the error message.
* test-suite/tests/reader.test ("#;"): Adapt expectation.
2021-03-05 21:06:04 +01:00
Andy Wingo
9897650f7a Fix reading of #true / #false
* module/ice-9/read.scm (%read): Fix bad argument order to unread-char.
2021-03-05 20:44:58 +01:00
Andy Wingo
2c3029e660 Syntax objects print with source locations
* module/system/syntax.scm (print-syntax): Print source locations.
2021-03-04 21:42:22 +01:00
Daniel Llorens
bd93eaf7cc Add docstring for array-shape 2021-03-04 14:35:50 +01:00