* libguile/vm.c (scm_call_n): Only call hooks if the engine supports
it.
(vm_dispatch_abort_hook, vm_dispatch_next_hook)
(vm_dispatch_pop_continuation_hook, vm_dispatch_push_continuation_hook)
(vm_dispatch_apply_hook, vm_dispatch_hook): Take a thread as arg
instead of VM, because that will probably already be in a register in
the VM. Given that all values are taken relative to the SP, no
need to pass that either.
* libguile/vm-engine.c (RUN_HOOK0, RUN_HOOK1): Update appropriately.
* libguile/vm-engine.c (vm_engine): Remove "resume" argument; scm_call_n
will handle the differences.
* libguile/vm.c (scm_call_n): Inline handling of what to do in normal
and resume cases. Remove resume argument to vm_engine.
* libguile/continuations.c (scm_i_make_continuation): Remove registers
argument; instead get from thread.
* libguile/vm-engine.c (vm_engine): Adapt VM engine to not receive a
registers argument, and thus to not pass it to intrinsics either.
* libguile/intrinsics.h:
* libguile/intrinsics.c (push_prompt):
* libguile/vm.c (capture_continuation, compose_continuation)
(abort_to_prompt): Refactor these intrinsics to not take a registers
argument; it's not necessary.
(scm_call_n): Don't pass registers argument.
* libguile/vm-engine.c (CALL_INTRINSIC): New helper macro.
(ALLOC_FRAME, vm_engine): Use CALL_INTRINSIC when we need to call
intrinsics. GCC still doesn't allocate intrinsics to a register
though!
* libguile/vm.c (vm_apply_non_program_code): Remove, now unneeded.
* libguile/vm-engine.c (vm_engine, call, tail-call, tail-call/shuffle)
(tail-apply, call/cc): Inline handling of non-programs, as will be the
case with JIT code.
* libguile/intrinsics.c (error_wrong_num_args, error_no_values)
(error_not_enough_values, error_wrong_number_of_values): New
intrinsics.
* libguile/intrinsics.h: Add new intrinsics.
* libguile/vm-engine.c: Signal errors using the new intrinsics.
* libguile/vm.c (vm_error): Remove, now that it's unused.
(vm_error_bad_instruction): Abort instead of throwing an exception.
If we get a bad instruction, nothing good will ever happen!
(compose_continuation): Use wrong-type-arg for unrewindable
continuations.
(scm_bootstrap_vm): No need to make "vm-run" or "vm-error" symbols.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add intrinsics for
throw, throw/value, and throw/value+data.
* libguile/intrinsics.c (throw_, throw_with_value):
(throw_with_value_and_data): And here they are.
* libguile/vm-engine.c (throw, throw/value, throw/value+data): Use
intrinsics.
* libguile/vm.c: Remove vm_throw et al.
* libguile/control.h:
* libguile/control.c (scm_i_make_composable_continuation): Rename from
make_partial_continuation and expose internally.
(scm_abort_to_prompt_star): Adapt to scm_i_vm_abort name change.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Define
abort_to_prompt intrinsic.
* libguile/throw.c (abort_to_prompt): Adapt to scm_i_vm_abort name
change.
* libguile/vm-engine.c (abort): Use abort_to_prompt intrinsic.
* libguile/vm.c (capture_delimited_continuation): Move here from
control.c where it was named reify_partial_continuation.
(scm_i_vm_abort): Move from control.c where it was named
scm_c_abort (and only exposed internally).
(abort_to_prompt): New intrinsic, replacing vm_abort.
* libguile/vm.h: Add setjmp include and scm_i_vm_abort decl.
* libguile/intrinsics.h:
* libguile/vm.c (rest_arg_length): New intrinsic.
(vm_error_apply_to_non_list): Remove now-unused error proc.
* libguile/vm-engine.c (tail-apply): Use new intrinsic.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add
compose-continuation intrinsic.
* libguile/vm-engine.c (compose-continuation): Call compose-continuation
intrinsic.
* libguile/vm.c (compose_continuation_inner, compose_continuation): Move
down and rename from vm_reinstate_partial_continuation, and make into
a form that works as an intrinsic.
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Refactor to expect
registers to already be captured.
* libguile/scm.h (scm_i_thread): Add forward decl.
* libguile/threads.h (struct scm_i_thread): Just fill in the struct
type.
* libguile/vm-engine.c (call/cc); Use the registers already captured
before entering the VM.
* libguile/continuations.h (scm_t_contregs): Remove "struct vm*" member;
unneeded.
* libguile/continuations.c (scm_i_make_continuation): No need to store
continuation->vp.
(scm_i_contregs): New internal function, replaces scm_i_contregs_vp
and scm_i_contregs_vm_cont.
(scm_i_check_continuation): Remove; moved to vm.c.
(scm_i_reinstate_continuation): Add an abort(), to satisfy
SCM_NORETURN.
* libguile/intrinsics.h: Add new "reinstate-continuation!" intrinsic.
* libguile/vm-engine.c (continuation-call): Use new
reinstate-continuation! intrinsic.
* libguile/vm.c (vm_return_to_continuation_inner): Move later in the
file.
(reinstate_continuation_x): New intrinsic.
(scm_bootstrap_vm): Init new intrinsic.
* libguile/Makefile.am (noinst_HEADERS, modinclude_HEADERS): Change to
not install intrinsics.h.
* libguile/intrinsics.h: Add an error if BUILDING_LIBGUILE isn't set, to
catch any stray bad inclusions. Add intrinsic for foreign-call.
* libguile/foreign.c (foreign_call): Rename from scm_i_foreign_call, and
set as the foreign-call intrinsic.
* libguile/vm-engine.c (foreign-call): Use the intrinsic. In the future
we'll want to totally revamp the FFI, if we know that a JIT is
available!
* libguile/scm.h (scm_tc7_values): New tc7. Never seen by Scheme, so we
don't need to update it anywhere else.
* libguile/values.h (scm_is_values): New public static inline function.
(scm_i_nvalues, scm_i_value_ref): New private static inline
functions.
(SCM_VALUESP): Use scm_is_value.
(scm_values_2, scm_values_3): New functions.
(scm_values_vtable): Remove; values objects are not structs any more.
* libguile/values.c (scm_i_extract_values_2): Adapt to new values
representation.
(print_values): Remove now-unused function.
(scm_c_nvalues): Use scm_i_nvalues.
(scm_c_value_ref): Use scm_i_value_ref.
(scm_values, scm_c_values): Make the new-style objects, which store
their values inline.
(scm_values_2, scm_values_3): New helpers, to avoid consing little
useless lists.
* libguile/vm-engine.c (halt, subr-call)
* libguile/eval.c (eval): Adapt to new values representation.
* libguile/i18n.c (scm_locale_string_to_integer)
(scm_locale_string_to_integer)
* libguile/numbers.c (scm_i_floor_divide, scm_i_ceiling_divide)
(scm_i_truncate_divide, scm_i_centered_divide, scm_i_round_divide)
(scm_i_exact_integer_sqrt)
* libguile/r6rs-ports.c (make_bytevector_output_port)
* libguile/srfi-1.c (scm_srfi1_partition, scm_srfi1_partition_x)
* libguile/srfi-14.c (scm_char_set_diff_plus_intersection)
(scm_char_set_diff_plus_intersection_x)
* libguile/posix.c (scm_getrlimit, scm_open_process): Adapt to use
scm_values_2 or scm_values_3.
* libguile/print.c (iprin1): Add printer for values objects.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add
push-interrupt-frame.
* libguile/vm.c (push_interrupt_frame): New intrinsic. Goal is to
reduce the amount of inline code the JIT will generate for handling
interrupts.
* libguile/vm-engine.c (handle-interrupts): Call out to the
push_interrupt_frame intrinsic in the slow case.
* libguile/intrinsics.h (scm_t_thread_sp_intrinsic): Change to take
thread instead of vp.
(SCM_FOR_ALL_VM_INTRINSICS): Change expand_stack to expect thread, not
vp.
* libguile/vm-engine.c (ALLOC_FRAME): Call expand_stack with thread.
* libguile/vm.c (thread_expand_stack, scm_bootstrap_vm): Adapt.
* libguile/vm.c (scm_t_vm_engine, scm_call_n): Remove "vp" argument.
* libguile/vm-engine.c (VP): New macro, to get VP from thread. Replace
all uses of vp with this.
As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.' It does take up
space though! For that reason, we remove it here from our C files.
* libguile/__scm.h (scm_i_jmp_buf): Remove definition, which was a shim
for ia64. Instead, always use setjmp/longjmp and jmp_buf.
* libguile/_scm.h (SCM_I_SETJMP, SCM_I_LONGJMP): Remove; instead use
setjmp and longjmp.
* libguile/continuations.c (capture_auxiliary_stack):
(restore_auxiliary_stack): New helpers.
(scm_i_make_continuation): Use capture_auxiliary_stack.
(copy_stack_and_call): Use restore_auxiliary_stack. No need to stash
the aux stack on the thread, either.
* libguile/continuations.h (scm_t_contregs): Use
SCM_HAVE_AUXILIARY_STACK to flag when to have an auxiliary_stack
member.
* libguile/control.h:
* libguile/control.c (reify_partial_continuation, scm_c_abort):
(scm_suspendable_continuation_p): Adapt to use setjmp/longjmp
directly.
* libguile/deprecated.h: Add deprecated scm_i_jmp_buf define.
* libguile/dynstack.h:
* libguile/dynstack.c (PROMPT_JMPBUF):
(scm_dynstack_push_prompt, scm_dynstack_find_prompt):
(scm_dynstack_wind_prompt): Adapt to jmp_buf type.
* libguile/eval.c (eval): Use jmp_buf and setjmp directly.
* libguile/gc-malloc.c: No need for ia64-specific things.
* libguile/gc.c: No need for ia64-specific things.
* libguile/gc.h: No need to declare scm_ia64_ar_bsp.
* libguile/init.c: Remove typedef of setjmp_type for Cray, unused.
* libguile/threads.c (guilify_self_1): No more pending_rbs_continuation
in scm_i_thread, and register_backing_store_base is handled by libgc.
(scm_ia64_ar_bsp): Remove definitions; inlined into continuations.c's
capture_auxiliary_stack.
* libguile/threads.h (scm_i_thread): jmpbuf member is plain jmp_buf.
* libguile/throw.c (catch): Just use jmp_buf and setjmp.
* libguile/vm-engine.c (VM_NAME): Adapt prototype to take jmp_buf
pointer.
* libguile/vm.c (vm_abort): Adapt jmp_buf types.
(scm_call_n): Use setjmp.
* libguile/intrinsics.c (less_p): New intrinsic.
(scm_bootstrap_intrinsics): Wire up intrinsic.
* libguile/intrinsics.h: Declare new intrinsic.
* libguile/vm-engine.c (less_p): Call through intrinsic.