Andy Wingo
bd63e5b2c3
scm_call_n sets up boot continuation frame for VM
...
* libguile/vm-engine.c:
* libguile/vm.c (scm_call_n): Move boot continuation setup to
scm_call_n, so that vm-engine takes all of its state from the vp.
2013-11-21 19:05:43 +01:00
Andy Wingo
b85cd20f80
scm_call_n avoids double TLS lookup
...
* libguile/vm-engine.c (VM_NAME): Take the current thread as an
argument.
* libguile/vm.c (scm_i_capture_current_stack): Call thread_vm.
(thread_vm): New helper.
(scm_the_vm): Call thread_vm.
(scm_call_n): Call thread_vm. Avoids a double TLS lookup.
2013-11-21 18:50:12 +01:00
Andy Wingo
350930756c
Remove scm_tc7_vm
...
* libguile/tags.h (scm_tc7_vm): Return to pool.
* libguile/goops.c:
* libguile/gc.c (scm_i_tag_name):
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/print.c (iprin1): Remove tc7_vm things.
* libguile/vm.h (scm_the_vm_fluid): Remove stray declaration. Remove
SCM_VM_P. Remove SCM_VM_DATA. Remove SCM_VALIDATE_VM.
* libguile/vm.c (scm_i_vm_print): Remove.
2013-11-21 18:39:21 +01:00
Andy Wingo
3506b1521e
Remove last use of SCM vm
...
* libguile/threads.h (scm_i_thread): Hold a struct scm_vm*, not a SCM
vm.
* libguile/threads.c (guilify_self_2):
* libguile/vm.c (make_vm): Adapt.
2013-11-21 18:33:06 +01:00
Andy Wingo
e7f9ababe0
scm_the_vm now returns raw struct scm_vm pointer
...
* libguile/vm.h (scm_the_vm): Return struct scm_vm*.
(scm_c_vm_run): Remove.
* libguile/control.c:
* libguile/eval.c:
* libguile/throw.c:
* libguile/vm.c: Adapt.
2013-11-21 18:28:06 +01:00
Andy Wingo
55ee360700
Prefer scm_call_n to scm_c_vm_run (scm_the_vm())
...
* libguile/vm.c (scm_i_capture_current_stack): Cosmetic tweak.
(scm_call_n): Define here instead of in eval.c. All callers of
scm_c_vm_run were passing scm_the_vm() as the VM. Eventually
scm_call_n will replace scm_c_vm_run.
* libguile/eval.c: Adapt all callers.
2013-11-21 18:23:08 +01:00
Andy Wingo
4fcbc1b0d8
scm_i_prompt_pop_abort_args_x takes struct scm_vm* as arg
...
* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Change to take VP
as an arg, not VM.
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt.
2013-11-21 18:09:29 +01:00
Andy Wingo
9b4c3ab5fa
Engine takes struct scm_vm* as argument
...
* libguile/vm-engine.c:
* libguile/vm.c (scm_c_vm_run): VM engine now takes struct scm_vm* as
argument, not SCM vm.
2013-11-21 17:52:00 +01:00
Andy Wingo
796e54a74c
One more SCM vm user: continuations.
...
* libguile/continuations.c:
* libguile/continuations.h (struct scm_t_contregs): Rename SCM vm member
to struct scm_vm *vp.
(scm_i_make_continuation): Take vp instead of vm.
(scm_i_contregs_vp): Rename from scm_i_contregs_vm, return vp.
* libguile/vm-engine.c (continuation-call, call/cc): Fix remaining SCM
vm user.
* libguile/vm.c (vm_return_to_continuation): Adapt prototype.
2013-11-21 17:50:33 +01:00
Andy Wingo
b44f5451f8
Remove last use of SCM vm in VM
...
* libguile/control.h:
* libguile/control.c (reify_partial_continuation, scm_c_abort): Take
struct scm_vm *vp as an arg.
* libguile/dynstack.h: Remove control.h include.
* libguile/vm.c (vm_abort): Take struct scm_vm *vp as an arg.
* libguile/vm-engine.c (abort): Adapt to vm_abort change.
2013-11-21 17:36:22 +01:00
Andy Wingo
44ece39907
Remove use of SCM vm in compose-continuation
...
* libguile/vm.c (vm_reinstate_partial_continuation): Take struct scm_vm
argument instead of SCM.
* libguile/vm-engine.c (compose-continuation): Adapt.
2013-11-21 17:28:34 +01:00
Andy Wingo
59f85eedc2
Dispatch hooks use "vp" rather than "vm"
...
* libguile/vm.c (vm_dispatch_hook):
(vm_dispatch_apply_hook):
(vm_dispatch_push_continuation_hook):
(vm_dispatch_pop_continuation_hook):
(vm_dispatch_next_hook):
(vm_dispatch_abort_hook):
(vm_dispatch_restore_continuation_hook): Use scm_vm pointer instead of
Scheme vm object.
2013-11-21 17:24:48 +01:00
Andy Wingo
5515edc5f2
Heap frame "stack holders" are raw scm_vm / scm_vm_cont pointers
...
* libguile/frames.h (struct scm_frame): stack_holder is a void*.
* libguile/frames.c (scm_i_frame_stack_base, scm_i_frame_offset): Expect
stack_holder to be the raw struct scm_vm or scm_vm_cont.
* libguile/continuations.c (scm_i_continuation_to_frame):
* libguile/stacks.c (scm_make_stack)
* libguile/vm.c (vm_dispatch_hook): Adapt creators.
2013-11-21 17:21:37 +01:00
Andy Wingo
050a40db5b
Heap frames have a "frame kind" bit
...
* libguile/frames.h (enum scm_vm_frame_kind, SCM_VM_FRAME_KIND)
(scm_c_make_frame): Add a "frame kind" bit to the first word. This
will allow the "stack holder" to be a non-SCM object.
* libguile/continuations.c (scm_i_continuation_to_frame):
* libguile/frames.c (scm_c_make_frame, scm_frame_previous)
* libguile/stacks.c (scm_make_stack):
* libguile/vm.c (vm_dispatch_hook): Adapt frame creators to set the
frame kind bit.
2013-11-21 17:13:18 +01:00
Andy Wingo
0bca90aac9
The dynamic stack records SP and FP values as offsets
...
* libguile/dynstack.h:
* libguile/dynstack.c (PROMPT_FP, PROMPT_SP):
(scm_dynstack_push_prompt, scm_dynstack_find_prompt): Prompts on the
dynstack are recorded as offsets from the base stack address in this
thread.
* libguile/control.c (scm_c_abort):
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt, narrow_stack):
* libguile/throw.c (pre_init_catch):
* libguile/vm-engine.c (prompt): Adapt.
2013-11-21 16:51:15 +01:00
Andy Wingo
a3da449801
Reorder struct scm_vm fields.
...
* libguile/vm.h (struct scm_vm): Reorder fields, perhaps for better
locality.
2013-11-21 16:51:15 +01:00
Andy Wingo
a222cbc9d1
No more VM objects visible to Scheme
...
* libguile/vm.h:
* libguile/vm.c (scm_the_vm): Don't expose to Scheme.
(scm_vm_p): Remove, as it is not needed.
* module/system/vm/vm.scm: Remove the-vm and vm? exports.
* doc/ref/api-coverage.texi (Code Coverage):
* test-suite/tests/coverage.test:
* module/system/vm/coverage.scm (with-code-coverage): Don't take a VM
argument. Adapt documentation and tests.
* module/ice-9/command-line.scm: Remove the-vm autoload.
* module/system/vm/trace.scm (trace-calls-to-procedure):
(trace-calls-in-procedure):
(trace-instructions-in-procedure):
(call-with-trace): Remove #:vm kwarg, and adapt to trap changes.
* module/system/vm/trap-state.scm (the-trap-state): Rework to use a
parameter underneath instead of a weak key on (the-vm).
* module/system/vm/traps.scm (new-disabled-trap):
(new-enabled-trap): Remove vm argument.
(trap-at-procedure-call):
(trap-in-procedure):
(trap-instructions-in-procedure):
(trap-at-procedure-ip-in-range):
(trap-at-source-location):
(trap-frame-finish):
(trap-in-dynamic-extent):
(trap-calls-in-dynamic-extent):
(trap-instructions-in-dynamic-extent):
(trap-calls-to-procedure):
(trap-matching-instructions): Remove vm keyword arguments.
* test-suite/tests/control.test ("unwind"): Adapt test.
* test-suite/tests/eval.test (test-suite): Remove the-vm import.
2013-11-21 16:45:03 +01:00
Andy Wingo
972275eee5
VM accessors take VM as implicit argument, not explicit argument
...
* 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.
2013-11-21 16:10:41 +01:00
Andy Wingo
6b4ba76d05
Change eval.c to use scm_c_vm_run instead of scm_call_with_vm.
...
* libguile/eval.c (scm_apply_0, scm_apply_1, scm_apply_2, scm_apply_3)
(scm_map, scm_for_each, scm_apply): Change to prefer scm_apply_0, and
to have it call vm_run instead of call_with_vm.
(eval): Use scm_apply_0 and scm_call_0.
* libguile/srfi-1.c (scm_srfi1_count): Use scm_apply_0.
2013-11-21 15:43:21 +01:00
Andy Wingo
3583665aa0
Remove unused vm:ip, vm:sp, vm:fp
...
* libguile/vm.h:
* libguile/vm.c (scm_vm_ip, scm_vm_fp, scm_vm_sp): Remove unused
functions.
* module/system/vm/vm.scm: Remove exports.
2013-11-21 15:02:36 +01:00
Andy Wingo
e08caa5620
Remove make-vm; there will be one vm per thread now.
...
* libguile/vm.h:
* libguile/vm.c (scm_make_vm): Remove.
* module/system/vm/vm.scm: Remove make-vm export.
* test-suite/tests/control.test ("the-vm"):
* test-suite/tests/coverage.test (%test-vm):
* test-suite/tests/eval.test ("stack overflow"): Adapt tests.
2013-11-21 15:00:03 +01:00
Andy Wingo
89b235afd3
Scheme frame objects hold relative stack offsets
...
* libguile/frames.h: Wrap the C interface to VM frames in
BUILDING_LIBGUILE. Change VM frames to record relative offsets into a
stack held by some other object, so that if the stack moves they will
remain valid.
* libguile/frames.c (scm_c_make_frame): Remove offset argument.
(scm_i_frame_offset): Instead, compute the offset from the stack
holder.
(scm_i_frame_stack_base): New helper.
(scm_frame_previous): Adapt.
* libguile/stacks.c (scm_make_stack)
* libguile/vm.c (vm_dispatch_hook):
* libguile/continuations.c (scm_i_continuation_to_frame): Adapt.
2013-11-21 11:20:19 +01:00
Andy Wingo
eadd9eb4c9
Prepare for moveable stacks in the VM.
...
* libguile/vm-engine.c (CHECK_OVERFLOW, ALLOC_FRAME, vm_engine): Prepare
for moveable stacks.
2013-11-21 10:23:35 +01:00
Andy Wingo
f593117165
CHECK_OVERFLOW tweak
...
* libguile/vm-engine.c (CHECK_OVERFLOW): Now that we aren't checking for
overflow on every push, fetch the stack limit from the vm instead of a
local.
2013-11-21 10:07:58 +01:00
Andy Wingo
6ed55e9143
vm-engine cosmetic cleanup
...
* libguile/vm-engine.c: Reindent UNPACK macros.
2013-11-20 19:39:40 +01:00
Andy Wingo
62e1660695
Remove unused resolve_variable helper
...
* libguile/vm.c (resolve_variable): Remove unused helper.
2013-11-20 19:38:06 +01:00
Andy Wingo
ea0cd17d11
Rework hook dispatch mechanism
...
* libguile/vm-engine.c (RUN_HOOK, RUN_HOOK0, RUN_HOOK1): Rework to
dispatch through specific per-hook procedures. Might reduce register
pressure in the VM.
* libguile/vm.c (vm_dispatch_apply_hook):
(vm_dispatch_push_continuation_hook):
(vm_dispatch_pop_continuation_hook):
(vm_dispatch_next_hook):
(vm_dispatch_abort_hook):
(vm_dispatch_restore_continuation_hook): New internal helpers.
2013-11-19 22:14:20 +01:00
Andy Wingo
c4f7923fa9
Remove VM_ENABLE_STACK_NULLING
...
* libguile/vm.c: Remove code dependent on VM_ENABLE_STACK_NULLING. This
defined didn't work and doesn't apply to the RTL model.
2013-11-19 21:47:55 +01:00
Andy Wingo
4cbc95f150
Rename objcodes?.{scm,c,h} to loader.{scm,c,h}
...
* libguile/loader.c:
* libguile/loader.h: Rename from objcodes.[ch].
* module/system/vm/loader.scm: Rename from objcode.scm.
* libguile/Makefile.am:
* libguile/gsubr.c:
* libguile/init.c:
* libguile/procs.c:
* libguile/vm.c:
* module/Makefile.am:
* module/ice-9/eval-string.scm:
* module/language/rtl/spec.scm:
* module/system/base/target.scm:
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/vm/debug.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/objcode.scm:
* test-suite/tests/compiler.test:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl-compilation.test:
* test-suite/tests/rtl.test: Adapt.
2013-11-19 21:45:07 +01:00
Andy Wingo
74870c0d2f
Fix gsubr comment
...
* libguile/gsubr.c: Update comment to excise RTL.
2013-11-19 21:27:38 +01:00
Andy Wingo
f42cfbf0b7
Lingering RTL excision in vm.c
...
* libguile/vm-engine.c:
* libguile/vm.c: Rework VM inclusion so that we don't define VM_ENGINE
and expect vm-engine.c to understand that -- since there is only
VM_USE_HOOKS, define that in vm.c directly. Rename rtl_vm_foo to
vm_foo.
* libguile/vm.h: Remove scm_t_vm_engine typedef.
2013-11-19 21:26:26 +01:00
Andy Wingo
20b1b91394
Move RTL unpack macros to vm-engine.c
...
* libguile/instructions.h: Remove SCM_UNPACK macros from here.
* libguile/vm-engine.c: Add them here, without the RTL_, and without the
SCM_ prefix.
2013-11-19 21:12:21 +01:00
Andy Wingo
095100bbdb
Change SCM_PACK_RTL macros to SCM_PACK_OP / SCM_PACK_OP_ARG
...
* libguile/instructions.h: Guard in BUILDING_LIBGUILE.
(SCM_PACK_OP_24):
(SCM_PACK_OP_8_8_8):
(SCM_PACK_OP_8_16):
(SCM_PACK_OP_16_8):
(SCM_PACK_OP_12_12): Rename from SCM_PACK_RTL_*, and splice in the
opcode.
(SCM_PACK_OP_ARG_8_24): New helper.
* libguile/vm.c:
* libguile/gsubr.c:
* libguile/foreign.c:
* libguile/control.c:
* libguile/continuations.c: Adapt.
2013-11-19 21:04:24 +01:00
Andy Wingo
3fe96dd808
scm_rtl_op_* -> scm_op_*
...
* libguile/instructions.h (scm_opcode): Rename from scm_rtl_opcode.
Rename opcodes from scm_rtl_op_* to scm_op_*.
* libguile/continuations.c:
* libguile/control.c:
* libguile/foreign.c:
* libguile/gsubr.c:
* libguile/instructions.c:
* libguile/vm.c: Adapt.
2013-11-19 20:46:10 +01:00
Andy Wingo
1b780c134b
(system vm instruction) rtl-instruction-list -> (language rtl) instruction-list
...
* libguile/instructions.c (struct scm_instruction, fetch_instruction_table)
(scm_instruction_list): Remove rtl_ infix.
* libguile/instructions.h: Adapt.
* module/system/vm/instruction.scm: Remove.
* module/language/rtl.scm: Export instruction-list from here.
* module/Makefile.am:
* module/language/cps/primitives.scm:
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/frame.scm:
* module/system/vm/program.scm:
* module/system/vm/trace.scm:
* module/system/vm/traps.scm: Adapt.
2013-11-19 20:45:57 +01:00
Andy Wingo
ef6b7f718a
Internal RTL excision in vm.c
...
* libguile/vm.c (vm_boot_continuation, vm_boot_continuation_code):
Rename from rtl_boot_continuation[_code].
(scm_bootstrap_vm):
* libguile/vm-engine.c (rtl_vm_engine): Adapt.
2013-11-19 20:05:45 +01:00
Andy Wingo
827c2c26fc
Small comment fix.
...
* libguile/vm-builtins.h: Rename RTL to VM in a comment.
2013-11-19 20:02:49 +01:00
Andy Wingo
8bf83893c7
Rename DT_GUILE_VM_VERSION.
...
* libguile/objcodes.c (DT_GUILE_VM_VERSION, process_dynamic_segment):
* module/system/vm/elf.scm (DT_GUILE_VM_VERSION): Rename from
DT_GUILE_RTL_VERSION.
* module/system/vm/assembler.scm (link-dynamic-section): Adapt.
2013-11-19 20:02:15 +01:00
Andy Wingo
6b9470bf48
Rename internal rtl-program-properties -> program-properties
...
* module/system/vm/program.scm (program-properties): Rename from
rtl-program-properties.
* libguile/programs.c (scm_i_program_properties): Adapt.
2013-11-19 19:50:15 +01:00
Andy Wingo
2b4d21d53e
Excise "rtl-" from fallback program printer
...
* libguile/programs.c (scm_i_program_print): Fallback printer uses
"program", not "rtl-program".
2013-11-19 19:47:33 +01:00
Andy Wingo
34cf09ccdf
Rename internals of (system vm program) program-minimum-arity
...
* module/system/vm/debug.scm (find-program-minimum-arity): Rename from
program-minimum-arity.
* module/system/vm/program.scm (program-minimum-arity): Rename from
rtl-program-minimum-arity.
* libguile/programs.c (scm_i_program_arity): Adapt.
2013-11-19 19:45:56 +01:00
Andy Wingo
2e12c1a2b7
Rename (system vm program) internal functions to remove rtl-
...
* module/system/vm/program.scm (program-name)
(program-documentation): Rename (removing rtl-).
* libguile/programs.c (scm_i_program_name):
(scm_i_program_documentation): Adapt callers.
2013-11-19 19:38:48 +01:00
Andy Wingo
fd5621f868
Remove unused C scm_program_source.
...
* libguile/programs.c (scm_program_source): Remove; not called. (The
definition is in Scheme.)
2013-11-19 19:36:38 +01:00
Andy Wingo
a1eb8d1168
Reorganize programs.h.
...
* libguile/programs.h: Reorganize.
2013-11-19 19:36:38 +01:00
Andy Wingo
d1100525ff
rtl-program-code -> program-code
...
* libguile/programs.h:
* libguile/programs.c (scm_program_code): Rename from
scm_rtl_program_code. Also renames rtl-program-code to program-code.
* module/statprof.scm:
* module/system/repl/command.scm:
* module/system/repl/debug.scm:
* module/system/vm/coverage.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/program.scm:
* module/system/vm/traps.scm:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl.test: Adapt callers.
2013-11-19 19:36:27 +01:00
Andy Wingo
0bd1e9c6a0
rtl-program? -> program?
...
* libguile/programs.c (scm_program_p): Rename from scm_rtl_program_p.
Changes name also from rtl-program? to program?.
* libguile/programs.h:
* module/ice-9/session.scm:
* module/language/tree-il/analyze.scm:
* module/statprof.scm:
* module/system/repl/command.scm:
* module/system/repl/debug.scm:
* module/system/vm/coverage.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/frame.scm:
* module/system/vm/program.scm:
* module/system/vm/traps.scm:
* module/system/xref.scm: Adapt.
2013-11-19 19:11:40 +01:00
Andy Wingo
edba822553
Remove make-rtl-program.
...
* libguile/programs.h:
* libguile/programs.c (scm_make_rtl_program): Remove. Unused.
* module/system/vm/program.scm (system): Remove make-rtl-program
export. Unused.
2013-11-19 19:03:09 +01:00
Andy Wingo
8079714576
scm_i_rtl_program_* -> scm_i_program_*
...
* libguile/programs.h (scm_i_make_program):
* libguile/programs.c (scm_i_program_name):
(scm_i_program_documentation):
(scm_i_program_properties): Remove "rtl_" infix.
* libguile/objcodes.c:
* libguile/procprop.c:
* libguile/vm.c: Adapt callers.
2013-11-19 18:57:31 +01:00
Andy Wingo
e326baac0b
scm_i_make_rtl_program in BUILDING_LIBGUILE
...
* libguile/programs.h (scm_i_make_rtl_program): Enclose in a
BUILDING_LIBGUILE guard.
2013-11-19 18:55:03 +01:00
Andy Wingo
d798a895cc
Remove RTL_ infix from macros
...
* libguile/programs.h (SCM_PROGRAM_P):
(SCM_PROGRAM_CODE):
(SCM_PROGRAM_FREE_VARIABLES):
(SCM_PROGRAM_FREE_VARIABLE_REF):
(SCM_PROGRAM_FREE_VARIABLE_SET):
(SCM_PROGRAM_NUM_FREE_VARIABLES):
(SCM_VALIDATE_PROGRAM): Remove RTL_ infix.
* libguile/continuations.c:
* libguile/continuations.h:
* libguile/control.c:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/stacks.c:
* libguile/vm-engine.c: Adapt.
2013-11-19 18:28:19 +01:00