* module/system/vm/debug.scm: Export program-debug-info-size.
* module/system/vm/traps.scm (frame-matcher): Remove stack program
case. Use absolute frame-instruction-procedure to match if
match-code?.
(program-last-ip): Use (system vm debug) interfaces.
(program-sources-by-line): Use program-sources, as
program-sources-pre-retire will go away soon. Return absolute
addresses.
* module/system/xref.scm (nested-procedures): New helper.
(program-callee-rev-vars): Rewrite using fold-program-code and
nested-procedures.
(add-sources, forget-sources): Use match instead of pmatch. Use
nested-procedures.
* module/ice-9/session.scm (procedure-arguments): Add an rtl-program?
case.
* module/system/vm/debug.scm (arity-arguments-alist): Use the order that
session.test expects.
* test-suite/tests/session.test ("procedure-arguments"): Adapt tests
with keywords for the new starting-with-the-procedure numbering of
locals.
* module/language/cps/contification.scm (compute-contification): Fail as
soon as we see an arity with rest, optional, or keyword arguments.
Fixes ((case-lambda ((a . b) #t) ((a b) #f)) 1 2).
* module/ice-9/eval.scm (primitive-eval): For ((lambda* (#:key foo) foo) 'bar),
give an "invalid keyword" error instead of a "wrong number of
arguments" error.
* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_primitive_call_ip):
* libguile/programs.c (scm_primitive_call_ip): Adapt to return an
absolute address.
* module/system/vm/assembler.scm (write-arity-headers): Adapt to write
byte addresses (relative to the text base).
* module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Return
absolute addresses, instead of word offsets relative to the text
base.
(find-first-arity): Adapt for absolute addresses.
* module/system/vm/program.scm (program-arguments-alist): Adapt for
arity-low-pc / arity-high-pc absolute addresses.
* libguile/frames.c (scm_frame_source): Instead of assuming that
scm_frame_procedure is correct, use the IP to get the source.
(scm_frame_instruction_pointer): Return an absolute value instead of
assuming that slot 0 is correct. (It isn't, when preparing for a tail
call.)
* libguile/programs.h:
* libguile/programs.c (scm_find_source_for_addr): New internal helper.
* module/system/repl/debug.scm (print-registers): Readably print
absolute instruction pointers.
* module/system/vm/coverage.scm: Complete rewrite to use absolute IP's.
We can't assume that frame-procedure is cheap if it is correct, or
correct if it is cheap. Anyway using the address is better anyway.
(coverage-data->lcov): Disable per-function info temporarily.
(loaded-modules, module-procedures, closest-source-line)
(closed-over-procedures): Remove these. Instead of going from
procedures to source info, now we go from ELF image to source info.
* module/system/vm/debug.scm (debug-context-length): New interface.
* module/system/vm/program.scm (source-for-addr): New internal helper.
* module/system/repl/debug.scm (<debug>): Remove for-trap?. Backtraces
with RTL will always happen pre-retire on the top frame, source info
is pre-retire, and continuations will always have a source-marked
receive or receive-values or whatever with the right source marking,
so we can remove this complication.
(print-frame): Use frame-source.
(print-frames): Remove for-trap? kw.
* module/system/repl/command.scm (define-stack-command, backtrace)
(up, down, frame): Remove for-trap? introduced local, and its uses.
(repl-pop-continuation-resumer): Adapt to make-debug change.
* module/system/repl/error-handling.scm (call-with-error-handling):
Adapt to make-debug change.
* module/system/vm/frame.scm (frame-next-source): Remove. RTL sources
are pre-retire.
* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): Adapt
to use frame-source. Still some work to do here.
* module/system/vm/objcode.scm:
* libguile/objcodes.c (scm_all_mapped_elf_images): New proc.
* module/system/vm/debug.scm (fold-all-debug-contexts):
(fold-source-locations): New public interfaces.
* module/language/cps.scm ($continue, $cont): Put source information on
the $continue, not on the $cont. Otherwise it is difficult for CPS
conversion to preserve source information.
($fun): Add a src member to $fun. Otherwise we might miss the source
info for the start of the function.
* .dir-locals.el:
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update the whole CPS world
for this change.
* module/system/vm/assembler.scm (link-docstrs): Write pc offsets as
byte addresses. Works better with native code.
* module/system/vm/debug.scm (find-program-docstring): Fix the linear
search. How embarassing!
* libguile/arrays.c (scm_from_contiguous_typed_array):
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): For
bitvectors, round up the length to 32-bit units, as they are stored
internally. Otherwise I think this probably does the wrong thing for
the last word on big-endian systems.
* libguile/bitvectors.c (BITVECTOR_LENGTH, BITVECTOR_BITS):
(scm_c_make_bitvector): Reorder the length and pointer words to match
the layout of bytevectors.
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/system/vm/assembler.scm (br-if-bitvector):
* module/system/vm/disassembler.scm (code-annotation): Add bitvector
test support.
* module/system/vm/assembler.scm (<uniform-vector-backing-store>): Add
an element-size field.
(intern-constant): Adapt make-uniform-vector-backing-store call. Use
uniform-array->bytevector, as the old compiler did.
(link-data): Add bitvector cases.
* module/ice-9/eval.scm (let-env-evaluator, primitive-eval): Evaluate
initializers of let expressions before creating the environment rib.
This prevents call/cc-related shenanigans.
* module/language/cps/contification.scm (compute-contification): When
eliding let-bound functions, also record the cont that declares the
function.
(apply-contification): Instead of reifying ($values ()) gotos instead
of the elided function, inline the body that binds the function
directly. This ensures that the function gets contified in its own
scope.
* module/language/cps/compile-rtl.scm (compile-fun): Rewrite to visit
conts in reverse-post-order, which is a topological sort on the basic
blocks.
* module/language/cps/slot-allocation.scm (allocate-slots): Expect a DFG
as an argument.
* module/ice-9/match.upstream.scm (match-next): Call out to an external
procedure on error, and use a begin instead of double-parens. This
results in less generated code.
* libguile/memoize.h (SCM_M_CAPTURE_MODULE)
* libguile/memoize.c (MAKMEMO_CAPTURE_MODULE, capture_env):
(maybe_makmemo_capture_module, memoize): Determine when to capture the
module on the environment chain at compile-time, instead of at
runtime. Introduces a new memoized expression type, capture-module.
(scm_memoized_expression): Start memoizing with #f as the
environment.
(unmemoize): Add unmemoizer.
(scm_memoize_variable_access_x): Cope with #f as module, and treat as
the root module (captured before modules were booted).
* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Adapt.
* module/language/cps/dfg.scm (reverse-post-order): Add an optional
"fold-all-conts" argument.
(compute-live-variables): Take the function as an arg instead of the
start continuation, and implement fold-all-conts so that nodes that
never reach the tail also get liveness information.
* module/language/cps/dfg.scm ($cfa, $dominator-analysis): Remove
dominator things from $cfa, to break out to separate structure.
(cfa-k-idx, cfa-k-count, cfa-k-sym, cfa-predecessors): New public
accessors.
(analyze-control-flow): New public function.
(analyze-dominators): Adapt.
* libguile/vm-engine.c (define!): Rename from define.
* module/language/cps/arities.scm (fix-clause-arities): If a prim
aliases an RTL instruction with a different name and we reify a
primcall, reify the instruction name.
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Update
emit-define! for new name.
* module/language/cps/primitives.scm (*rtl-instruction-aliases*): Add
bytevector native accessors.
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add emitters
for bytevector ops. Add br-if-bytevector emitter.
* module/language/cps/primitives.scm (*branching-primcall-arities*):
Mark bytevector? as a branching primitive.
* module/system/vm/assembler.scm (br-if-bytevector): New instruction
* module/system/vm/disassembler.scm (code-annotation): Add support for
bytevector?.
* libguile/uniform.h:
* libguile/uniform.c (scm_uniform_vector_element_type_code): New
interface, returns a type code as an integer.
* module/system/vm/assembler.scm (<uniform-vector-backing-store>)
(simple-vector?, uniform-array?, statically-allocatable?)
(intern-constant, link-data, link-constants): Support uniform arrays,
and punt on vectors aren't contiguous from 0. Support for general
arrays will come later.
* test-suite/tests/rtl.test ("load-constant"): Add tests.