* module/language/cps/types.scm (constant-type): Add case for EOF.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*effect+exception-free-primitives*): Add case for eof-object?.
(eof-object?): Expand to eq? on the-eof-object.
* NEWS: Update.
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES): Add system/foreign-library.scm.
* configure.ac: Replace ltdl check with -ldl check.
* libguile/dynl.c: Rewrite to just expose core dlopen / dlsym / etc to a
helper Scheme module.
(scm_dynamic_link, scm_dynamic_pointer, scm_dynamic_function)
(scm_dynamic_object_p, scm_dynamic_call): Rewrite in terms of (system
foreign-library).
* libguile/extensions.c (load_extension): Avoid scm_dynamic_call.
* module/system/foreign-library.scm: New file.
* module/oop/goops.scm (<dynamic-object>): Hackily export
<foreign-library> instead of a class here.
* doc/ref/api-foreign.texi (Foreign Function Interface): Rewrite to only
document the new interfaces. Eventually we will deprecate
dynamic-link and friends.
* doc/ref/guile.texi (API Reference): Move Foreign Objects after Foreign
Function Interface. Seems there should be some closer relationship
but this will do for now.
* doc/ref/tour.texi (Putting Extensions into Modules):
* doc/ref/libguile-parallel.texi (Parallel Installations): Update for
rename of Modules and Extensions to Foreign Extensions.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_dynamic_unlink): Deprecate.
* libguile/guile.c: Remove ltdl include.
* test-suite/tests/foreign.test: Update tests to use new API, and update
error expectations.
* module/scheme/base.scm (member): Match the r7rs requirement, as assoc
already does.
Thanks to Erik Dominikus for reporting the problem.
Closes: 43304
* module/rnrs/io/ports.scm (call-with-port): Remove local definition.
* module/system/repl/server.scm (system): Call-with-port is imported
via (ice-9 ports).
* module/ice-9/binary-ports.scm (call-with-input-bytevector):
(call-with-output-bytevector): New functions.
* module/ice-9/iconv.scm: Remove superfluous copies of
call-with-output-string* and call-with-output-bytevector*, now that
the former closes the port and the latter exists.
(call-with-encoded-output-string): Adapt.
* module/web/uri.scm: Use (ice-9 iconv) instead of local
bytevector/string conversion procedures.
* module/ice-9/ports.scm (call-with-port): New procedure, from r7rs.
(call-with-input-file, call-with-output-file): Refactor to use
call-with-port.
(call-with-output-string): Close the string after normal exit.
* module/scheme/base.scm (scheme): Re-export call-with-port from base.
* module/ice-9/boot-9.scm (%auto-compilation-options): Add
use-before-definition and non-idempotent-definition.
* module/language/tree-il/analyze.scm (<use-before-def-info>): New
analysis info.
(make-use-before-definition-analysis): New function.
(goops-toplevel-definition): Move down.
(unbound-variable-analysis, macro-use-before-definition): Remove, as
they are subsumed by use-before-def. There are some deprecated
bindings though.
(make-analyzer): Rework to allow for use-before-def analysis to handle
multiple
* module/system/base/message.scm (%warning-types): Add handlers for the
new warning types.
* test-suite/tests/tree-il.test: Add tests.
* doc/ref/api-evaluation.texi (Compilation): Update.
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Accept up to version 4.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Produce
version 4.
* module/language/cps/cse.scm (intset-intersect*): New helper. Use it
to replace manual uses.
(lset-unionq, meet-constants, adjoin-constant, set-constants): New
helpers.
(compute-consts): New function, to compute constants at each label,
using not only definitions but flow.
(<analysis>): Add consts to analysis.
(elide-predecessor, prune-branch, forward-branch, compute-out-edges)
(propagate-analysis, eliminate-common-subexpressions-in-fun): Plumb
consts through the algorithm.
(fold-branch): Fold an eq-constant? using the flow-determined constant
info. Finally allows compile-bytecode to fold to switch statements!
* module/language/cps/optimize.scm (optimize-first-order-cps): Move
branch chain optimization before the final CSE/DCE pass.
Reported by Jérémy Korwin-Zmijowski
(https://lists.gnu.org/archive/html/bug-guile/2020-08/msg00010.html).
Fix from
7cf4c01039:
Apply fix from Per Bothner.
In Per's words:
* testing.scm (%test-end): Reset test-runner-current if done.
This fixes bug "Loading test source file multiple time without having
report incrementing" reported to srfi-64 mailing list.
* srfi-64-test.scm: Update due to recent srfi-64 implementation change.
* module/language/cps/compile-bytecode.scm (compile-function): Expect
eq-constant? instead of eq-null?, etc.
* module/language/cps/effects-analysis.scm: Likewise.
* module/language/cps/reify-primitives.scm (reify-primitives): For
eq-constant?, reify a $const unless the constant is an immediate whose
encoding fits in 16 bits.
* module/language/cps/type-fold.scm (materialize-constant): Helper to
make a constant from a type, min, and max.
(fold-eq-constant?): New helper.
(eq-constant?): New folder.
(undefined?): Define specifically.
(define-nullish-predicate-folder): Renamd from
define-special-immediate-predicate-folder. Use only for null?, false,
and nil?.
(*branch-reducers*): New mechanism. Reduce eq? to eq-constant? if
possible.
(local-type-fold): Refactor to use materialize-constant, and to allow
reducing branches.
* module/language/cps/types.scm (constant-type): Return three values
instead of a type entry.
(constant-type-entry): New function that returns a type entry. Adapt
callers.
(infer-constant-comparison): New helper.
(eq-constant?): New inferrer.
(undefined?): New inferrer.
* module/language/tree-il/compile-bytecode.scm (eq-constant?): Fix
truncate-bits signed arg.
(define-immediate-type-predicate): Adapt to visit-immediate-tags
change.
* module/language/tree-il/compile-cps.scm (convert): Convert eq? to
constant to eq-constant?. Advantaged is that it gets fixnums and
chars in addition to special immediates.
* module/language/tree-il/cps-primitives.scm (define-immediate-type-predicate):
Adapt to allow #f as pred.
* module/system/base/types/internal.scm (immediate-tags): Use #f as pred
for false, nil, etc.
(immediate-bits->scm): Adapt.
* module/system/vm/assembler.scm (emit-eq-null?, emit-eq-nil?)
(emit-eq-false?, emit-eq-true?, emit-unspecified?, emit-eof-object?):
Remove specialized emitters.
* module/system/vm/assembler.scm (define-immediate-tag=?-macro-assembler):
Allow for pred to be #f.
* module/system/vm/disassembler.scm (define-immediate-tag-annotation):
Adapt to pred being #f.
* module/language/tree-il/compile-bytecode.scm (eq?): Define
eq-immediate? as immediate emitter.
(canonicalize): Don't fuss so much about eq?; only if commutation is
needed. (Perhaps a more generic commutation pass is needed.)
(compile-closure): Add support for emit/immediate for branches.
* module/system/base/types/internal.scm (scm->immediate-bits):
(immediate-bits->scm, sign-extend, truncate-bits): New public
routines.
* module/system/vm/assembler.scm (immediate-bits): Reimplement in terms
of scm->immediate-bits and similar.
(X8_S8_I16, X8_S8_ZI16): Rework operand encodings.
(load-constant): Use truncate-bits to determine which cases apply.
* doc/ref/vm.texi (Instruction Set, Constant Instructions): Document new
instruction.
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): New first
word kind with zi16 operand.
* libguile/jit.c (compile_make_immediate, compile_make_immediate_slow):
New compilers.
(COMPILE_X8_S8_ZI16): New operand kind.
* libguile/vm-engine.c (make-immediate): New instruction.
* module/language/bytecode.scm:
* module/system/vm/assembler.scm (encode-X8_S8_ZI16<-/shuffle):
(signed-bits, load-constant): Support the new instruction kind.
* module/system/vm/disassembler.scm (disassemblers)
(sign-extended-immediate, code-annotation): Support for zi16
operands.
* module/ice-9/popen.scm (open-process)[unbuffered, fdes-pair]: New
procedures.
Use them. Return unbuffered ports.
* test-suite/tests/popen.test ("open-pipe*"): New test prefix.
Fixes a bug whereby, for example, "guild compile --target=i686-linux-gnu"
running on x86_64 would generate invalid code for 'bytevector-u32-native-set!'
because 'target-most-positive-fixnum' was called from the top-level
when (language tree-il compile-cps) was loaded.
Consequently, the .go files under prebuilt/ would be invalid, leading to
build failures on 32-bit platforms.
This issue became apparent with cb8cabe85f.
* module/language/tree-il/compile-cps.scm (bytevector-ref-converter)[tag]:
Turn into a lambda so that 'target-most-positive-fixnum' is called in
the right context.
(bytevector-set-converter)[integer-unboxer]: Likewise.
Fixes <https://bugs.gnu.org/40582>.
Reported by Julien Lepiller <julien@lepiller.eu>.
Previously, a host part consisting of hex digits would be mistaken as an
IPv6 address and rejected by 'valid-host?'.
* module/web/uri.scm (ipv6-regexp): Add colon.
* test-suite/tests/web-uri.test ("string->uri")["xyz://abc/x/y/z"]: New
test.
* NEWS: Update.
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
I think it's possible to get an orphan loop, with predecessors
after successors in the original RPO. Handle that here.
* bootstrap/Makefile.am (GUILE_OPTIMIZATIONS): Change to just -O1.
* module/language/tree-il/spec.scm (choose-compiler): Use CPS for -O2
and higher.
* module/system/base/optimize.scm (available-optimizations): CPS for -O2
and higher, but -Oresolve-primitives now at -O1 also.
* module/language/cps/cse.scm (propagate-analysis): New helper.
(eliminate-common-subexpressions-in-fun): Recompute avail and bool set
in response to simplifications in predecessor CFG. Allows much better
compilation of pattern-matching idioms!
* module/language/cps/cse.scm (forward-cont, forward-branch)
(compute-avail-and-bool-edge): New helpers.
(add-equivalent-expression!): Allow idempotent adds; can happen now
when revisiting a cont after changes to its predecessors.
(fold-branch): New helper.
(eliminate-common-subexpressions-in-fun): Allow for reductions to
branch predecessors. In that case, revisit the branch, as the CFG
will have changed.
* module/language/cps/cse.scm (elide-predecessor, prune-branch)
(prune-successors, term-successors): New helpers.
(eliminate-common-subexpressions-in-fun): When we modify the CFG,
update the analysis. Also, thread the substs map through CSE so that
closures in high-level CPS can take advantage of eliminated variables.
(fold-renumbered-functions): Take multiple seeds.
(eliminate-common-subexpressions): Thread var substs map through CSE.
* module/language/cps/cse.scm (<analysis>): New data type, grouping
available expression analysis, predecessor map, etc.
(eliminate-common-subexpressions-in-fun): Instead of having a static
analysis, thread it through the CSE pass so that we can update the CFG
as we go.
* module/language/cps/cse.scm (compute-available-expressions): Take a
clobber map instead of an effects map.
(compute-singly-referenced): Remove unused function.
(eliminate-common-subexpressions-in-fun): Keep a preds map. Use it
add entries to the equiv-set and var-substs at expression
continuations instead of at the expression terms themselves.
* module/language/cps/cse.scm (compute-truthy-expressions): Operate on a
single function.
(eliminate-common-subexpressions-in-fun): Instead of computing a set
of labels to eliminate, go ahead and do the elimination as we go.
(fold-renumbered-functions): Can just use a single seed now.
(eliminate-common-subexpressions): Simplify to just fold over
functions, building up renamed output as we go.
* module/language/cps/cse.scm (fold-renumbered-functions): New helper.
(compute-equivalent-expressions): Use new helper.
(compute-equivalent-expressions-in-fun): Lift to top-level.
(eliminate-common-subexpressions): Adapt.
Previously they would always assume #:verify-certificate? #t,
unless #:port was given.
Fixes <https://bugs.gnu.org/40486>.
Reported by Jan Synacek <jsynacek@redhat.com>.
* module/web/client.scm (define-http-verb): Pass #:verify-certificate?
to 'open-socket-for-uri'.
PATCH is described by RFC 5789 and CONNECT is described by RFC 7231.
* module/web/http.scm (parse-http-method): Support CONNECT and PATCH.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>