This was a failed experiment. It had good space complexity but terrible
time complexity.
* module/Makefile.am: Update.
* module/language/cps/nameset.scm: Remove.
* module/Makefile.am: Build types.scm early, but don't block the rest of
the build on it.
* module/language/cps/types.scm: Rewrite to use namesets.
* module/language/cps/dce.scm:
* module/language/cps/type-fold.scm: Adapt to interface changes.
* module/language/cps/cse.scm:
* module/language/cps/dfg.scm (compute-idoms, compute-dom-edges): Move
these procedures from cse.scm to dfg.scm.
Remove loop-detection code; that can come back later but it is
bitrotten for now.
* module/language/cps/effects-analysis.scm (define-enumeration): New
helper.
(&memory-kind-mask): Define as an enumeration, not a bitfield. Add
&unknown-memory-kinds.
(&all-effects, effect-clobbers?, make-prompt-tag, expression-effects):
Adapt.
Note that this change requires dce.go and cse.go to be recompiled.
* module/language/cps/dce.scm (elide-type-checks!, compute-live-code):
Replace old ad-hoc type check elision with one driven from type
analysis. Type check elision only operates on smallish functions, to
avoid n**2 explosion in type inference.
* module/language/cps/types.scm (infer-types): Add #:max-label-count
argument.
* module/language/cps/type-fold.scm (compute-folded, fold-constants*):
Disable for big functions. Perhaps we can relax this if we find an
O(n log n) way to represent types.
* module/Makefile.am (BOOT_SOURCES, BOOT_GOBJECTS): New variables.
(CLEANFILES, nobase_mod_DATA, nobase_ccache_DATA, EXTRA_DIST)
(ETAGS_ARGS): Use the new variables.
(CPS_LANG_SOURCES): Remove language/cps/types.scm, as it is a boot
file.
* module/language/cps/types.scm: New file, implementing type and range
inference over CPS.
* module/language/cps/type-fold.scm: New file, implementing abstract
constant folding for CPS.
* module/Makefile.am: Add the new files.
* module/language/cps/compile-bytecode.scm: Wire up type-fold, but
currently disabled.
* module/language/cps/effects-analysis.scm: Rewrite so that instead of
the depends/causes effects, there is just &type-check, &allocation,
&read, and &write. The object kind is a separate part of the
bitfield, and the field in the object (if appropriate) is another
field. Effects are still a fixnum. This enables precise effects for
vectors and structs on all architectures.
This kind of effects analysis was not possible in Tree-IL because
Tree-IL relied on logior-ing effects of subexpressions, whereas with
CPS we have no sub-expressions and we do flow analysis instead.
(effect-clobbers?): Replace effects-commute? with this inherently
directional and precise predicate.
* module/language/cps/cse.scm (compute-always-available-expressions):
(compute-equivalent-subexpressions): Adapt to effects analysis
change.
* module/language/cps/dce.scm (compute-live-code): Likewise.
* module/language/cps/cse.scm (compute-always-available-expressions):
Use constant? instead of zero?, to avoid punching through the effects
abstraction.
* module/language/cps/cse.scm (compute-available-expressions):
Simplify initialization.
(compute-equivalent-subexpressions): When synthesizing definitions,
use substed vars. Add synthetic definitions after processing an
expression, to take advantage of the substed vars.
* module/language/cps/effects-analysis.scm (synthesize-definition-effects!):
Fix a boneheaded thinko that caused all primcalls to be marked as
causing car, cdr, vector, struct, and box effects.
* module/system/vm/program.scm (print-program): New public interface --
the guts of write-program, but refactored to be able to work when only
given an addr.
(write-program): Use print-program.
* module/system/vm/frame.scm (frame-call-representation): Remove attempt
to abbreviate procedure representations; was confusing because the
result would write as a string, quotes and all.
* libguile/vm-engine.c (vm_engine): Always invoke the apply hook after
the ip has been reset. Avoids problems in frame-bindings, which
builds its bindings map based on the IP. Invoke push-continuation
before linking the new frame, so that more locals are available to the
frame inspector.
* module/system/vm/traps.scm (trap-in-procedure): No need for a
push-cont handler, as the apply handler will exit the frame.
* libguile/frames.c (scm_frame_address, scm_frame_stack_pointer): Return
offsets instead of absolute pointers. This is robust in the presence
of stack relocation.
* module/system/repl/debug.scm (print-registers): Adapt to print sp and
fp as integers.
* module/system/vm/frame.scm (frame-call-representation): Change
top-frame? argument to be a keyword instead of an optional argument.
* module/system/vm/trace.scm (print-application): Adapt caller.
* module/language/cps/dce.scm (constant-type, lookup-type)
(default-type-checker, *primcall-type-checkers*)
(define-primcall-type-checker, define-simple-primcall-types)
(check-primcall-arg-types): Define a really lame type analysis that
can elide some expressions causing &type-check.
(compute-live-code): Wire up the type checker.
* module/language/cps/effects-analysis.scm (effects-clobber): New
helper.
(length): Only depend on &cdr.
(synthesize-definition-effects!): New interface.
* module/language/cps/cse.scm (compute-available-expressions): Don't
count out constructors here -- we'll do that below.
(compute-defs): Add a comment.
(compute-equivalent-subexpressions): Synthesize getter calls at
constructor/setter sites, so that (set-car! x y) can cause a
future (car x) to just reference y. The equiv-labels set now stores
the defined vars, so there is no need for the defs vector.
(cse, apply-cse): Adapt to compute-equivalent-subexpressions change.
* module/ice-9/boot-9.scm (map): Rewrite to be recursive and pure
instead of iterative and effectful. At best this is faster; at worst
it is slower. In any case it resolves continuation-related issues.
* module/srfi/srfi-1.scm (fold): Specialize the two-arg case.
(map): Rewrite to be recursive.
* test-suite/tests/r5rs_pitfall.test (8.3): Update for new expected map
behavior.
* doc/ref/api-debug.texi (Stack Capture): Update make-stack docs.
* libguile/programs.h:
* libguile/programs.c (scm_program_address_range): New internal
procedure.
* libguile/stacks.c (narrow_stack): Interpret a pair of integers as an
address range. If a cut is a procedure, attempt to resolve it to an
address range.
(scm_make_stack): Update docstring.
* module/system/vm/program.scm (program-address-range): New exported
procedure.
* module/statprof.scm (statprof, gcprof): Use program-address-range to
get the outer-cut, for efficiency.
* libguile/goops.c (scm_sys_initialize_object): Refactor initialization
so that we don't ref uninitialized slots before initializing them.
This allows foreign slots, whose initial value is 0, to be initialized
via #:init-form.
* module/oop/goops.scm (@slot-ref, @slot-set!): Remove definitions.
Change callers to use struct-ref and struct-set!. slot-ref and
slot-set! were only marginally more efficient and were much more
dangerous. This change allows the standard accessors to work on
foreign slots; that was not the case before, as the 'u' fields of the
struct were read as if they were 'p' slots.
* module/language/tree-il/compile-glil.scm (lambda): Remove support for
compiling @slot-ref/@slot-set!. These were private to GOOPS.
* test-suite/tests/goops.test ("active-slot"): Update to not expect a
ref before initialization.
("foreign slots"): Add tests.
* module/language/cps/slot-allocation.scm (allocate-slots): Avoid
allocating locals in the range [253,255].
* module/system/vm/assembler.scm: List exports explicitly. For
operations with limited-range operands, export wrapper assemblers that
handle shuffling their operands into and out of their range.
(define-assembler): Get rid of enclosing begin.
(shuffling-assembler, define-shuffling-assembler): New helpers to
define shuffling wrapper assemblers.
(emit-mov*, emit-receive*): New functions.
(shuffle-up-args): New helper.
(standard-prelude, opt-prelude, kw-prelude): Call shuffle-up-args
after finishing.
* test-suite/tests/compiler.test ("limits"): Add test cases.