* module/ice-9/boot-9.scm (else, =>, ..., _): New definitions. These
are specified by the r6rs and the r7rs.
* module/ice-9/sandbox.scm (core-bindings): Include the aux syntax
definitions.
* module/rnrs/base.scm:
* module/rnrs.scm: Re-export aux syntax.
Since the change in 2.2 noted in the NEWS as "Fix literal matching for
module-bound literals", defining `_' makes `syntax-rules' and `match'
fail to recognize `_' as the catch-all literal. This change adapts the
recommendations to current practice in 2.2, as users have had to adapt
to this change.
* doc/ref/api-i18n.texi (Gettext Support): Update documentation.
* module/language/tree-il/analyze.scm (proc-ref?, gettext?): G_ is the
conventional abbreviation, not _.
* test-suite/tests/tree-il.test: Adapt.
* module/ice-9/command-line.scm: Use G_ instead of _.
* module/language/tree-il/letrectify.scm (compute-private-toplevels):
New function; computes the subset of declarative bindings that are
private to a module. If the module exports a macro, all bindings are
public, as we have no way to know what binding might be exported.
(letrectify): Add #:seal-private-bindings? keyword arg. If true, avoid
making boxes for private definitions.
* module/language/tree-il/optimize.scm (optimize): Add
-Oseal-private-bindings, enabled at -O3.
* module/language/cps/cse.scm (compute-equivalent-subexpressions): When
CSE sees a definition like `(cons a b)', it will also record an
"auxiliary definition" for `(car x)', where x is the variable defined
by the cons, whereby calling `(car x)' can reduce to `a' if there is
no intervening effect that clobbers the definitions. However, when
the successor of the cons is a control-flow join, then any variables
defined there have multiple definitions. It's incorrect to add the
aux definition in that case.
* test-suite/tests/compiler.test ("cse auxiliary definitions"): New
test.
This fixes a bug whereby the compiler would sometimes allocate floats in
marked space.
* libguile/gc-inline.h (scm_inline_gc_malloc_pointerless_words): New
internal helper.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* libguile/intrinsics.c (allocate_pointerless_words):
(allocate_pointerless_words_with_freelist): New intrinsics.
* libguile/jit.c (compile_allocate_pointerless_words):
(compile_allocate_pointerless_words_immediate): New compilers.
* libguile/vm-engine.c (allocate_pointerless_words)
(allocate_pointerless_words_immediate): New opcodes.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (param):
* module/language/cps/reify-primitives.scm (reify-primitives):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
* module/language/cps/types.scm (allocate-words):
(allocate-words/immediate):
* module/system/vm/assembler.scm (system): Add support for the new
opcodes.
* test-suite/standalone/test-out-of-memory: Prevent the test harness
from being inlined. If the test harness is inlined, it might cause
the optimizer to omit the allocations being tested!
* NEWS: Update.
* doc/ref/api-binding.texi (Internal Definitions): Update to mention
that mixed definitions and expressions are allowed.
* doc/ref/scheme-ideas.texi (Creating a Procedure):
(Lambda Alternatives): Update documentation to avoid implying that
bodies are only expressions.
This change to the expander allows mixed local definitions and
expressions. The expansion turns:
(let () (a) (define (b) 42) (b) (b))
into:
(let ()
(letrec* ((t0 (begin (a) (if #f #f)))
(b (lambda () 42)))
(b)))
Which is to say, expressions that precede definitions are expanded as
definitions of a temporary via (begin EXP (if #f #f)).
* module/ice-9/psyntax.scm (expand-body): Allow mixed definitions and
expressions.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add a couple tests and update for new
error messages.
* doc/ref/api-evaluation.texi (Compilation): Document the -O options.
* doc/ref/api-modules.texi (Using Guile Modules): @@ docs refer to
declarative modules.
(Creating Guile Modules): Use when for 1-armed if.
(Declarative Modules): Make implications of declarative bindings more
explicit, and explicitly document ways to disable the optimization.
* module/language/tree-il/optimize.scm (tree-il-optimizations): Punt
letrectification to -O2.
* libguile/intrinsics.c (scm_atan1): New intrinsic, wrapping scm_atan.
(scm_bootstrap_intrinsics): Add new intrinsics.
* libguile/intrinsics.h (scm_t_f64_from_f64_f64_intrinsic): New
intrinsic type.
(SCM_FOR_ALL_VM_INTRINSICS): Add intrinsics for floor, ceiling, sin,
cos, tan, asin, acos, atan, and their unboxed counterparts.
* libguile/jit.c (sp_f64_operand): New helper.
(compile_call_f64_from_f64, compile_call_f64_from_f64_f64): Call out
to intrinsics.
* libguile/vm-engine.c (call-f64<-f64-f64): New opcode.
* module/language/cps/effects-analysis.scm: Add new intrinsics.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
Add new intrinsics.
* module/language/cps/slot-allocation.scm (compute-var-representations):
Add 'f64 slot types for the new unboxed intrinsics.
* module/language/cps/specialize-numbers.scm (specialize-operations):
Support unboxing the new intrinsics.
* module/language/cps/types.scm: Define type inferrers for the new
intrinsics.
* module/language/tree-il/cps-primitives.scm: Define CPS translations
for the new intrinsics.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*effect-free-primitives*, atan): Define primitive resolvers.
* module/system/vm/assembler.scm: Export assemblers for the new
intrinsics.
(define-f64<-f64-f64-intrinsic): New helper.
* test-suite/tests/srfi-64-test.scm: Skip a couple of tests that have
unspecified result due to eq? being unspecified on procedures.
* module/language/tree-il/letrectify.scm (letrectify): Add a comment.
* doc/ref/api-modules.texi (Declarative Modules): New subsection.
* module/ice-9/boot-9.scm (module): Change eval-closure slot, which was
deprecated and unused, to be a "declarative?" slot, indicating that
definitions from the module are declarative.
(user-modules-declarative?): New parameter.
(make-fresh-user-module): Set declarative according to parameter.
(define-module*, define-module): Add #:declarative? keyword argument,
defaulting to the value of user-modules-declarative? parameter when
the module was expanded.
(guile-user): This module is not declarative.
* module/language/tree-il/letrectify.scm (compute-declarative-toplevels):
Use the new declarative? module flag.
* module/language/tree-il/letrectify.scm: New pass, not wired up yet.
Adds lexical definitions for declarative top-level definitions, for
better inlining and contification within a compilation unit.
* am/bootstrap.am:
* module/Makefile.am: Add to build.
* module/language/tree-il/primitives.scm (primitive-expander):
(define-primitive-expander!): New helpers.
(define-primitive-expander): Rewrite in terms of syntax-case.
(error, make-vector, eqv?, equal?, call-with-prompt)
(abort-to-prompt*, abort-to-prompt): Use new helper.
Add "mod" field to <toplevel-ref>, <toplevel-set>, and
<toplevel-define>, indicating the expander's idea of what the current
module is when a toplevel variable is accessed or created. This will
help in later optimizations.
* libguile/expand.c (TOPLEVEL_REF, TOPLEVEL_SET, TOPLEVEL_DEFINE)
(expand, expand_define, expand_set_x, convert_assignment):
* libguile/expand.h (SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_REF, SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_SET, SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE):
* module/ice-9/compile-psyntax.scm (translate-literal-syntax-objects):
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/tree-il.scm:
* module/language/tree-il.scm (parse-tree-il, make-tree-il-folder):
(pre-post-order):
* module/language/tree-il/analyze.scm (goops-toplevel-definition):
(macro-use-before-definition-analysis, proc-ref?, format-analysis):
* module/language/tree-il/compile-cps.scm (convert):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/fix-letrec.scm (free-variables):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/tree-il.test: Adapt uses.
* module/language/cps/compile-bytecode.scm (compile-function): When
shuffling return values, we need to reset the frame after any "extra"
values are read and before any "extra" values may be set.
* module/ice-9/format.scm (format): Refactor naming of some local
variables. Assigned variables get a % sigil before them. Also, avoid
the mutable-error dance.
* module/language/tree-il/fix-letrec.scm (fix-scc): Initial binding of
letrec values is unspecified, not false.
* test-suite/tests/peval.test (pass-if-peval): Fix letrec before
pevalling. Update tests. A couple got better, no regressions.
* module/language/tree-il/optimize.scm (optimize): Change to run
fix-letrec before peval. Also, run it unconditionally, so that later
passes don't have to deal with letrec.
* module/language/tree-il/peval.scm (build-var-table, peval): Remove
letrec cases.
* module/language/tree-il/fix-letrec.scm: Update algorithm to use
approach from "Fixing Letrec (reloaded)", which sorts mutually
recursive bindings by using Tarjan's algorithm to partition the
bindings into strongly-connected components. The result is that users
can use letrec* or internal definitions and get a result that is as
efficient as manual placement of let / letrec.
Some components of this have been wired up for a while; this commit
finishes the compiler, runtime, and JIT support.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* libguile/intrinsics.c (scm_bootstrap_intrinsics): Declare the new
intrinsics.
* libguile/jit.c (compile_call_f64_from_f64): Define code generators for
the new intrinsics.
* libguile/vm-engine.c (call-f64<-f64): New instruction.
* module/language/cps/effects-analysis.scm:
* module/language/cps/reify-primitives.scm (compute-known-primitives):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/specialize-numbers.scm (specialize-operations):
* module/language/tree-il/cps-primitives.scm (abs):
* module/system/vm/assembler.scm (system, define-f64<-f64-intrinsic):
(sqrt, abs, fsqrt, fabs):
* module/language/cps/types.scm (fsqrt, fabs): Add new f64<-f64
primitives.