* 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/system/vm/trace.scm (print-return): Remove frame argument.
(trace-calls-to-procedure, trace-calls-in-procedure): Adapt callers.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
(trap-calls-to-procedure): Since the pop continuation hook is now
called after the continuation is popped, we need to check the right
frame. Fixes tail-calls in the trace root, and probably other things.
* libguile/vm.h:
* libguile/vm.c:
(scm_vm_apply_hook, scm_vm_push_continuation_hook,
scm_vm_pop_continuation_hook, scm_vm_abort_continuation_hook,
scm_vm_restore_continuation_hook, scm_vm_next_hook,
scm_vm_trace_level, scm_set_vm_trace_level_x, scm_vm_engine,
scm_set_vm_engine_x, scm_c_set_vm_engine_x): The VM argument is now
implicit: the VM for the current thread.
* doc/ref/api-debug.texi (VM Hooks): Try to adapt.
* module/ice-9/command-line.scm:
* module/statprof.scm:
* module/system/vm/coverage.scm:
* module/system/vm/trace.scm:
* module/system/vm/trap-state.scm:
* module/system/vm/traps.scm:
* test-suite/tests/control.test:
* test-suite/tests/eval.test: Adapt users that set hooks or ensure that
we have a debug engine.
* libguile/frames.h: Change so that fp points at local 0 instead of
local 1, and clean up a bit.
(struct scm_vm_frame): Remove program, and rename stack to locals.
(SCM_FRAME_DATA_ADDRESS): Remove; it was redundant with
SCM_FRAME_LOWER_ADDRESS.
(SCM_FRAME_STACK_ADDRESS): Remove; replace with the new
SCM_FRAME_LOCALS_ADDRESS.
(SCM_FRAME_UPPER_ADDRESS): Remove; unused.
(SCM_FRAME_NUM_LOCALS, SCM_FRAME_PREVIOUS_SP): New defines.
(SCM_FRAME_BYTE_CAST, SCM_FRAME_STACK_CAST): Remove; unused;
(SCM_FRAME_LOCAL): New define, replaces SCM_FRAME_VARIABLE.
(SCM_FRAME_PROGRAM): Add cautionary commentary.
* libguile/frames.c: Adapt static asserts.
(scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x):
Adapt. This means that frame-local-ref 0 now returns the procedure.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME)
(FRAME_LOCALS_COUNT, LOCAL_REF, LOCAL_SET, RETURN_VALUE_LIST): Adapt
to change in fp.
(LOCAL_ADDRESS): New helper.
(POP_CONTINUATION_HOOK): Reimplement, taking the previous FP as an
argument.
(ABORT_CONTINUATION_HOOK): Reimplement, taking no arguments.
(RETURN_ONE_VALUE): Reimplement.
(RETURN_VALUE_LIST): Adapt to FP change.
(halt, return-values, subr-call, foreign-call, prompt)
(continuation-call, compose-continuation, call/cc, abort): Adapt to FP
change, mostly via using LOCAL_ADDRESS, etc abstractions instead of
using the raw frame pointer.
* libguile/control.c (reify_partial_continuation): Update for fp
change.
* libguile/vm.c (vm_reinstate_partial_continuation): Adapt to removal of
SCM_FRAME_UPPER_ADDRESS.
* module/system/vm/frame.scm (frame-call-representation): Adapt to
frame-local-ref change.
* module/system/vm/trace.scm (print-return): Remove unused
frame-num-locals call.
* doc/ref/api-debug.texi (VM Hooks): Update documentation.
* libguile/vm.c (vm_dispatch_hook):
* libguile/vm-engine.c: Rework the hook machinery so that they can
receive an arbitrary number of arguments. The return and abort
hooks will pass the values that they return to their continuations.
(vm_engine): Adapt to ABORT_CONTINUATION_HOOK change.
* libguile/vm-i-system.c (return, return/values): Adapt to
POP_CONTINUATION_HOOK change.
* module/system/vm/frame.scm (frame-return-values): Remove. The
pop-continuation-hook will pass the values directly.
* module/system/vm/trace.scm (print-return):
(trace-calls-to-procedure):
(trace-calls-in-procedure): Update to receive return values
directly.
* module/system/vm/traps.scm (trap-in-procedure)
(trap-in-dynamic-extent): Ignore return values.
(trap-frame-finish, trap-calls-in-dynamic-extent)
(trap-calls-to-procedure): Pass return values to the handlers.
* module/system/vm/trace.scm (build-prefix): New helper.
(print-application, print-return): Use the helper.
(trace-calls-to-procedure, trace-calls-in-procedure):
(trace-instructions-in-procedure, call-with-trace): Add #:max-indent
argument, defaulting to the terminal width less 40 characters.
* doc/ref/scheme-using.texi: Update `trace' docs.
Based on a patch by Nala Ginrut.
* module/system/vm/trace.scm (print-application, print-return): Change
to add more whitespace, as (ice-9 debug) did.
(call-with-trace): Rename from vm-trace, and make the vm a keyword
argument.
* module/system/repl/command.scm: Don't autoload (system vm profile).
(trace): Update for call-with-trace name change.
* module/system/vm/frame.scm (frame-return-values): New exported
function, gives the return values for a frame.
* module/system/vm/trace.scm: Remove frame-return-values from here.
* module/system/vm/trace.scm (print-application, print-return): Add a
prefix before the printout.
(trace-calls-to-procedure, trace-calls-in-procedure): Add prefix
keyword args.
* module/system/vm/trap-state.scm (add-trace-at-procedure-call!): Give a
useful prefix for tracepoint printouts.
* module/system/vm/trace.scm (print-return, print-application)
(frame-return-values): Factored out of other things.
(trace-calls-to-procedure): New proc, installs a trap tracing only
calls to the given proc.
(trace-calls-in-procedure): Refactor a bit.
* module/system/vm/trap-state.scm (add-trace-at-procedure-call!): New
proc.
* module/system/repl/command.scm (tracepoint): New command, installs a
tracepoint on a procedure.
* module/system/vm/traps.scm (trap-frame-finish)
(trap-in-dynamic-extent, trap-calls-in-dynamic-extent)
(trap-instructions-in-dynamic-extent): New traps, for implementing
tracing, and the `finish' command.
* module/system/vm/trace.scm (trace-calls-in-procedure)
(trace-instructions-in-procedure): New tracing traps.
(vm-trace): Reimplement in terms of the new traps.
* module/system/vm/trap-state.scm (add-trap!): New helper; not used in
this commit, though.
* libguile/vm.h (SCM_VM_PUSH_CONTINUATION_HOOK)
(SCM_VM_POP_CONTINUATION_HOOK): New hooks, to replace
enter/exit/return.
(SCM_VM_BOOT_HOOK, SCM_VM_HALT_HOOK, SCM_VM_BREAK_HOOK): Remove these
useless hooks.
* libguile/vm.c (scm_vm_push_continuation_hook)
(scm_vm_pop_continuation_hook): New accessors.
* libguile/vm-i-system.c: Remove boot, halt, break, enter, exit, and
return hooks. Also remove the break instruction. Instead now when we
push a new continuation onto the stack we call PUSH_CONTINUATION_HOOK,
and when we pop via a return we call POP_CONTINUATION_HOOK. APPLY_HOOK
is now decoupled from continuation pushes and pops.
* libguile/vm-engine.h:
* libguile/vm-engine.c: Adapt for hooks.
* module/system/vm/trace.scm (vm-trace): Adapt for hooks. Also revive
the #:instructions? #t mode.
* module/system/vm/vm.scm: Adapt exports for new set of hooks.
* module/system/vm/trace.scm (vm-trace): Change to just export the one
procedure, vm-trace. This way it's threadsafe and more robust. Also
refactor to not print any of Guile's internal bits. Hopefully Neil
will be happier :)
* module/system/repl/command.scm (option): Adapt to removal of
vm-trace-on! and vm-trace-off!, as those are unlikely to DTRT.
* libguile/tags.h (scm_tc7_frame, scm_tc7_objcode, scm_tc7_vm)
(scm_tc7_vm_cont): Take more tc7s for VM-related data structures.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/gc.c (scm_i_tag_name):
* libguile/goops.c (scm_class_of, create_standard_classes):
* libguile/print.c (iprin1): Add cases for the new tc7s.
* libguile/frames.c:
* libguile/frames.h:
* libguile/objcodes.c:
* libguile/objcodes.h:
* libguile/vm.c:
* libguile/vm.h: Desmobify.
* libguile/vm.c (scm_vm_apply): Export to Scheme, because VM objects are
no longer applicable.
* module/system/repl/command.scm (profile):
* module/system/vm/trace.scm (vm-trace):
* module/system/vm/vm.scm (vm-load): Call vm-apply to run a program in a
VM instead of treating the VM as applicable.
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/repl/repl.scm:
* module/system/vm/debug.scm:
* module/system/vm/trace.scm: Change #:use-syntax to #:use-module, as
that's really what we want to do.
* module/system/base/syntax.scm (keywords): Don't enable :keywords, it
breaks code that may assume that ':foo is a symbol, like boot-9.
* module/*.scm: Don't use :keywords, use #:keywords. The user can decide
if she wants #:keywords in their .guile, and :keywords might make us
compile modules differently.
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.
* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
procedure-documentation.
* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
handles setting load-compiled for us.
* module/system/vm/core.scm: Removed, functionality folded into other
modules.
* module/system/vm/frame.scm: Export the C frame procedures here; also
move scheme functions from core.scm here.
* module/system/vm/instruction.scm: New file, exports procedures from
instructions.c.
* module/system/vm/objcode.scm: New file, exports procedures from
objcodes.c.
* module/system/vm/program.scm: New file, exports procedures from
programs.c, and some scheme functions originally from core.scm.
* module/system/vm/vm.scm: New file, from vm.c and core.scm.
* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.
* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
scm_init_* functions call.
* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):
* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
in an init function. Bootstrap_vm will call bootstrap_instructions(),
etc to initialize types, then set load-compiled to point to
load-compiled/vm.
* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
they're present.
* module/system/base/compile.scm:
* module/system/il/ghil.scm:
* module/system/repl/describe.scm:
* module/system/vm/core.scm:
* module/system/vm/frame.scm:
* module/system/vm/trace.scm: Explicitly list exports in the module
declaration instead of using define-public.