| Commit message (Expand) | Author | Age | Files | Lines |
* | VM continuations store FP/SP by offset...* libguile/continuations.c (scm_i_continuation_to_frame):
* libguile/stacks.c (scm_make_stack):
* libguile/vm.c (scm_i_vm_cont_to_frame, scm_i_vm_capture_stack):
(vm_return_to_continuation_inner)
(struct vm_reinstate_partial_continuation_data):
(vm_reinstate_partial_continuation_inner):
(vm_reinstate_partial_continuation):
* libguile/vm.h (sstruct scm_vm_cont): Simplify VM continuations by
recording the top FP by offset, not value + reloc.
* libguile/frames.c (frame_offset, scm_i_vm_frame_offset): Remove unused
functions.
* libguile/frames.h (SCM_VALIDATE_VM_FRAME, scm_i_vm_frame_offset):
Remove.
* libguile/control.c (reify_partial_continuation): Once we know the
base_fp, relocate the dynamic stack.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_relocate_prompts): New function.
(scm_dynstack_wind_prompt): Adapt to add new fp offset.
| Andy Wingo | 2017-02-12 | 1 | -2/+9 |
* | Add suspendable-continuation?...* doc/ref/api-control.texi (Prompt Primitives): Document
suspendable-continuation?.
* libguile/control.c (scm_suspendable_continuation_p): New procedure.
(scm_init_ice_9_control): New extension procedure, defines
suspendable-continuation?.
(scm_init_control): Register scm_init_ice_9_control.
* libguile/eval.c (eval):
* libguile/throw.c (catch):
* libguile/continuations.c (scm_i_make_continuation): Restore resumable
prompt cookie after continuation invocation.
* libguile/vm.c (scm_call_n): Arrange to set resumable_prompt_cookie
during invocation of VM.
* libguile/vm.h (struct scm_vm): Add resumable_prompt_cookie member.
* module/ice-9/control.scm: Export suspendable-continuation?.
* test-suite/tests/control.test ("suspendable-continuation?"): New
test.
| Andy Wingo | 2016-12-12 | 1 | -0/+1 |
* | Identify boot continuations by code, not closure...* libguile/vm.h:
* libguile/vm.c (scm_i_vm_is_boot_continuation_code): New internal
procedure.
* libguile/stacks.c (scm_make_stack):
* libguile/frames.c (scm_c_frame_previous): Use new helper to identify
boot frames.
| Andy Wingo | 2015-12-01 | 1 | -0/+1 |
* | Remove sp from scm_vm_cont...* libguile/vm.h (struct scm_vm_cont): Remove "sp" member; it's always
the same as stack_bottom.
* libguile/vm.c (scm_i_vm_cont_to_frame, scm_i_vm_capture_stack):
(vm_return_to_continuation_inner):
* libguile/stacks.c (scm_make_stack):
* libguile/continuations.c (scm_i_continuation_to_frame): Adapt.
| Andy Wingo | 2015-10-21 | 1 | -3/+0 |
* | VM stack grows downward...Adapt VM stack to grow downward. This will make native compilation look
more like the VM code, as we will be able to use native CALL
instructions, taking proper advantage of the return address buffer.
* libguile/continuations.c (scm_i_continuation_to_frame): Record offsets
from stack top.
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Adapt for reversed
order of arguments, and instead of relying on the abort to push on the
number of arguments, make the caller save the stack depth, which
allows us to compute the number of arguments ourselves.
(reify_partial_continuation, scm_c_abort): Adapt to reversed stack
order.
* libguile/dynstack.c (scm_dynstack_wind_prompt): Since we wind the
stack in a downward direction, subtract the reloc instead of adding
it.
* libguile/dynstack.h (SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY): Remove flag;
instead rely on prompt-establishing code to save the stack depth.
* libguile/eval.c (eval): Remove extraneous "volatile" declarations for
variables that are not re-set between the setjmp and any longjmp.
Adapt to save stack depth before instating the prompt.
* libguile/foreign.c (scm_i_foreign_call): Adapt to receive arguments in
reverse order.
* libguile/frames.c (frame_stack_top, scm_i_frame_stack_top): Adapt to
compute stack top instead of stack bottom.
(scm_c_frame_closure): Adapt to stack growth change.
(scm_frame_num_locals, scm_frame_local_ref, scm_frame_set_x): Use
union data type to access stack.
(RELOC): Reformat.
(scm_c_frame_previous): Adapt to stack growth change.
* libguile/frames.h: Adapt stack diagram to indicate that the stack
grows up.
(union scm_vm_stack_element): New data type used to access items on
the stack.
(SCM_FRAME_PREVIOUS_SP)
(SCM_FRAME_RETURN_ADDRESS, SCM_FRAME_SET_RETURN_ADDRESS)
(SCM_FRAME_DYNAMIC_LINK, SCM_FRAME_SET_DYNAMIC_LINK)
(SCM_FRAME_LOCAL, SCM_FRAME_NUM_LOCALS): Adapt to stack representation
change.
(SCM_FRAME_SLOT): New helper.
(SCM_VM_FRAME_FP, SCM_VM_FRAME_SP): Adapt to stack growth change.
* libguile/stacks.c (scm_make_stack): Record offsets from top of stack.
* libguile/throw.c (catch): Adapt to scm_i_prompt_pop_abort_args_x
change.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
(FRAME_LOCALS_COUNT_FROM): Adapt to stack growth change.
(LOCAL_ADDRESS): Use SCM_FRAME_SLOT to get the address as the proper
data type.
(RETURN_ONE_VALUE, RETURN_VALUE_LIST): Adapt to stack growth change.
(apply): Shuffling up the SMOB apply args can cause the stack to
expand, so use ALLOC_FRAME instead of RESET_FRAME.
(vm_engine): Adapt for stack growth change.
* libguile/vm.c (vm_increase_sp, vm_push_sp, vm_restore_sp): Adapt to
stack representation change.
(scm_i_vm_cont_to_frame): Adapt to take offsets from the top.
(scm_i_vm_capture_stack): Adapt to capture from the top.
(vm_return_to_continuation_inner): Adapt for data type changes.
(vm_return_to_continuation): Likewise, and instead of looping, just
splat the saved arguments on with memcpy.
(vm_dispatch_hook): Adapt to receive arguments in the reverse order.
Adapt callers.
(vm_abort): There is never a tail argument. Adapt to stack
representation change.
(vm_reinstate_partial_continuation)
(vm_reinstate_partial_continuation_inner): Adapt to stack growth
change.
(allocate_stack, free_stack): Adapt to data type change.
(expand_stack): Don't try to mremap(), as you can't grow a mapping
from the bottom. Without knowing that there's a free mapping space
right below the old stack, which there usually isn't on Linux, we have
to copy. We can't use MAP_GROWSDOWN because Linux is buggy.
(make_vm): Adapt to stack representation changes.
(return_unused_stack_to_os): Round down instead of up, as the stack
grows down.
(scm_i_vm_mark_stack): Adapt to walk up the stack.
(scm_i_vm_free_stack): Adapt to scm_vm changes.
(vm_expand_stack_inner, reset_stack_limit, vm_expand_stack): Adapt to
the stack growing down.
(scm_call_n): Adapt to the stack growing down. Don't allow argv to
point into the stack.
* libguile/vm.h (struct scm_vm, struct scm_vm_cont): Adapt to hold the
stack top and bottom.
| Andy Wingo | 2015-10-21 | 1 | -10/+15 |
* | make-stack works on delimited continuations...* libguile/stacks.c (scm_make_stack, scm_stack_id):
* libguile/vm.c (scm_i_vm_cont_to_frame): Allow delimited continuations
as the argument to make-stack.
| Andy Wingo | 2014-04-16 | 1 | -0/+1 |
* | Remove default soft stack limit; add call-with-stack-overflow-handler...* libguile/vm.h:
* libguile/vm.c (default_max_stack_size, initialize_default_stack_size):
Remove the default stack limit. In this way, programs run from the
command line or outside of the REPL will have no soft stack limit.
(make_vm): Change `max_stack_size' field to be a stack of limits and
handlers.
(current_overflow_size, should_handle_stack_overflow)
(reset_stack_limit, wind_overflow_handler, unwind_overflow_handler)
(vm_expand_stack): If the stack surpasses a user-set limit, call the
user-specified handler within its outer stack limit.
(call-with-stack-overflow-handler): New interface.
* module/system/vm/vm.scm: Export call-with-stack-overflow-handler.
| Andy Wingo | 2014-03-12 | 1 | -1/+4 |
* | Return unused parts of the stack to the OS...* libguile/vm.h (struct scm_vm): Reorder fields. Add "sp_max_since_gc"
field.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
* libguile/vm.c (vm_return_to_continuation)
(vm_reinstate_partial_continuation, scm_call_n): In places where we
could increase the stack height, update sp_max_since_gc.
(vm_expand_stack): Relocate sp_max_since_gc on expansion.
(scm_bootstrap_vm): Record the page size using gnulib's getpagesize.
(return_unused_stack_to_os): New routine, run when marking stacks.
| Andy Wingo | 2014-01-31 | 1 | -3/+4 |
* | Remove the restore-continuation-hook....* libguile/vm.h:
* libguile/vm.c:
* libguile/vm-engine.c:
* module/system/vm/traps.scm:
* module/system/vm/vm.scm: Remove the unused and redundant
restore-continuation-hook.
| Andy Wingo | 2013-11-27 | 1 | -2/+0 |
* | Expandable stacks....* libguile/vm-engine.c (CHECK_OVERFLOW): Call vm_expand_stack, not
vm_error_stack_overflow.
* libguile/vm.c (hard_max_stack_size, default_max_stack_size): Recast
#defines as locals. Have both hard and soft stack limits.
(initialize_default_stack_size): Set soft stack limit from
GUILE_STACK_SIZE.
(expand_stack, vm_expand_stack): Support for expanding stacks as
needed. Whee!
(make_vm): Adapt limits.
(scm_call_n): Expand stack if needed.
* libguile/vm.h (struct scm_vm): Add max_stack_size member.
| Andy Wingo | 2013-11-22 | 1 | -0/+1 |
* | Allocate stacks using mmap, and mark them via the thread marker...* libguile/threads.c (thread_mark): Mark the VM stack, if we have one.
(on_thread_exit): Free the VM stack here.
* libguile/vm.c (make_vm): Allocate the VM stack using mmap, and arrange
for it to be marked by the thread marker.
(scm_i_vm_mark_stack, scm_i_vm_free_stack): New internal interfaces.
(allocate_stack, free_stack): New helpers.
| Andy Wingo | 2013-11-22 | 1 | -0/+6 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -10/+0 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -3/+1 |
* | Reorder struct scm_vm fields....* libguile/vm.h (struct scm_vm): Reorder fields, perhaps for better
locality.
| Andy Wingo | 2013-11-21 | 1 | -2/+2 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -1/+0 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -12/+12 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -3/+0 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -3/+0 |
* | 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.
| Andy Wingo | 2013-11-19 | 1 | -2/+0 |
* | All instruction pointers are now scm_t_uint32*...* libguile/frames.h (SCM_FRAME_RTL_RETURN_ADDRESS)
(SCM_FRAME_SET_RTL_RETURN_ADDRESS): Remove. The variants without _RTL
now work fine.
(struct scm_vm_frame): Change the return address to be a
scm_t_uint32*.
(struct scm_frame): Change IP to be scm_t_uint32*.
* libguile/frames.c (scm_c_make_frame)
* libguile/control.c (reify_partial_continuation, scm_c_abort)
* libguile/dynstack.c (PROMPT_IP)
(scm_dynstack_push_prompt, scm_dynstack_find_prompt)
* libguile/dynstack.h:
* libguile/vm-engine.c (SYNC_IP, RETURN_ONE_VALUE)
(call, return-values, prompt): Adapt.
| Andy Wingo | 2013-11-19 | 1 | -3/+3 |
* | Remove MVRA accessors in libguile...* libguile/vm.c (scm_i_vm_capture_stack): Remove MVRA argument, in
preparation for removing MVRA from frames.
(scm_i_capture_current_stack): Adapt to scm_i_vm_capture_stack
change.
(vm_reinstate_partial_continuation): Remove references to MVRA.
* libguile/vm.h (struct scm_vm_cont): Remove mvra member.
* libguile/vm-engine.c (call): Set MVRA to 0. Will remove later.
(return-values): Return to RA.
(call/cc): Remove MVRA from capture call.
* libguile/frames.c:
* libguile/frames.h (SCM_FRAME_MV_RETURN_ADDRESS)
(SCM_FRAME_RTL_MV_RETURN_ADDRESS, scm_frame_mv_return_address): Remove
accessors.
* libguile/control.c (reify_partial_continuation): Adapt to
scm_i_vm_capture_stack change.
| Andy Wingo | 2013-11-15 | 1 | -2/+2 |
* | VM has "builtins": primitives addressable by emitted RTL code...* libguile/Makefile.am:
* libguile/vm-builtins.h: New header, declaring stubs needed by the
compiler like values, apply, and abort-to-prompt.
* libguile/vm.c: Adapt the apply and values stubs to conform to a
standard interface. Add an abort-to-prompt stub. Add call/cc and
call-with-values stubs.
(scm_vm_builtin_ref): New helper, for the builtin-ref opcode.
(scm_vm_builtin_name_to_index)
(scm_vm_builtin_index_to_name): New helpers, for the compiler and
disassembler, respectively.
(scm_init_vm_builtins, scm_bootstrap_vm): Allow the compiler helpers
to be loaded later into a module.
* module/language/rtl.scm: Export builtin-index->name and
builtin-name->index.
* libguile/vm-engine.c (RETURN_VALUE_LIST): Update to use new names of
"apply" and "values".
(tail-call/shuffle): New opcode.
(abort): Update to be a tail VM op, and reorder and renumber other
ops.
(builtin-ref): New opcode.
* libguile/continuations.h:
* libguile/continuations.c (scm_i_call_with_current_continuation):
Move this to vm.[ch], implemented as a builtin.
* module/language/tree-il/compile-cps.scm (convert): Convert to
'abort-to-prompt calls, possibly with 'apply, effectively undoing the
tree-il transformation.
* module/language/cps/reify-primitives.scm (builtin-ref): New helper.
(reify-primitives): Convert builtin primitives to builtin-ref.
* module/language/cps/dfg.scm (constant-needs-allocation?):
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add support
for compiling builtin-ref.
* module/system/vm/disassembler.scm (code-annotation): Add annotation
for builtin-ref.
| Andy Wingo | 2013-10-27 | 1 | -1/+2 |
* | dynstack: pushing a prompt no longer allocates memory...* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
| Andy Wingo | 2012-03-07 | 1 | -1/+0 |
* | the dynamic stack is really a stack now, instead of a list...* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
| Andy Wingo | 2012-03-03 | 1 | -2/+4 |
* | refactor tc7 and tc16 checks...* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New
macros.
* libguile/bytevectors.h (SCM_BYTEVECTOR_P):
* libguile/control.h (SCM_PROMPT_P):
* libguile/filesys.h (SCM_DIRP):
* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P)
(SCM_I_DYNAMIC_STATE_P):
* libguile/foreign.h (SCM_POINTER_P):
* libguile/fports.h (SCM_FPORTP):
* libguile/frames.h (SCM_VM_FRAME_P):
* libguile/hashtab.h (SCM_HASHTABLE_P):
* libguile/inline.h (scm_get_byte_or_eof):
* libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP):
* libguile/objcodes.h (SCM_OBJCODE_P):
* libguile/ports.h (SCM_OUTPUT_PORT_P):
* libguile/programs.h (SCM_PROGRAM_P):
* libguile/smob.h (SCM_SMOB_PREDICATE):
* libguile/srfi-14.h (SCM_CHARSETP):
* libguile/strings.c (IS_STRING):
* libguile/strports.h (SCM_STRPORTP):
* libguile/symbols.h (scm_is_symbol):
* libguile/variable.h (SCM_VARIABLEP):
* libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR):
* libguile/vm-i-system.c (call, tail-call, mv-call)
* libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P):
* libguile/weak-set.c (SCM_WEAK_SET_P):
* libguile/weak-table.c (SCM_WEAK_TABLE_P):
* libguile/weak-vector.h (SCM_I_WVECTP): Use them.
| Andy Wingo | 2011-10-24 | 1 | -2/+2 |
* | Fix prototype of `scm_the_vm'....* libguile/vm.h (scm_the_vm): Use `(void)' instead of `()'.
| Ludovic Courtès | 2011-02-13 | 1 | -2/+2 |
* | add call-with-vm; remove thread-vm bits; remove vm-apply; engines settable....* libguile/vm.h (scm_c_vm_run): Make internal.
* libguile/vm.c (vm_default_engine): New static global variable.
(make_vm): Set vp->engine based on
(scm_vm_apply): Remove in favor of call-with-vm.
(scm_thread_vm, scm_set_thread_vm_x): Remove these, as they did not
have a well-defined meaning, and were dangerous to call on other
threads.
(scm_the_vm): Reinstate previous definition.
(symbol_to_vm_engine, vm_engine_to_symbol)
(vm_has_pending_computation): New helpers.
(scm_vm_engine, scm_set_vm_engine_x, scm_c_set_vm_engine_x): New
accessors for VM engines.
(scm_c_set_default_vm_engine_x, scm_set_default_vm_engine_x): New
setters for the default VM engine.
(scm_call_with_vm): New function, applies a procedure to arguments in
a context in which a given VM is current.
* libguile/eval.c (eval, scm_apply): VM dispatch goes through
scm_call_with_vm.
* test-suite/tests/control.test ("the-vm"):
* module/system/vm/coverage.scm (with-code-coverage): Use call-with-vm.
* module/system/vm/vm.scm: Update exports.
* test-suite/vm/run-vm-tests.scm (run-vm-program):
* test-suite/tests/compiler.test ("current-reader"): Just rely on the
result of make-program being an applicable.
* test-suite/tests/eval.test ("stack overflow"): Add a note that this
test does not test what it should.
| Andy Wingo | 2010-09-27 | 1 | -4/+9 |
* | remove vm-version, vm options...* libguile/vm.h (struct scm_vm): Remove "options" member.
* libguile/vm.c (scm_vm_version, scm_vm_option, scm_set_vm_option_x):
Remove.
* module/system/vm/vm.scm (vm-version, vm-option, set-vm-option!):
Remove.
(vms:time, vms:clock): Remove these unused definitions.
(vm-load): Remove. "Load" should be reserved for things that exist on
disk, methinks.
| Andy Wingo | 2010-09-25 | 1 | -4/+0 |
* | Remove unused declarations....* libguile/vm.h (scm_vm_option_ref, scm_vm_option_set_x): Remove.
| Ludovic Courtès | 2010-09-24 | 1 | -2/+0 |
* | Add `thread-vm' and `set-thread-vm!'....* libguile/vm.c (thread_vm, scm_thread_vm, scm_set_thread_vm_x): New
functions.
(scm_the_vm): Add docstring. Use `thread_vm'.
* libguile/vm.h (scm_thread_vm, scm_set_thread_vm_x): New declarations.
* module/system/vm/vm.scm: Export `thread-vm' and `set-thread-vm!'.
| Ludovic Courtès | 2010-09-24 | 1 | -0/+2 |
* | add vm-abort-continuation-hook, vm-restore-continuation-hook...* libguile/vm-i-system.c (call_cc, tail_call_cc): Call the new
RESTORE_CONTINUATION_HOOK when a continuation is restored.
(prompt): Call the new ABORT_CONTINUATION_HOOK when entering the abort
handler's continuation.
* libguile/vm-engine.h (ABORT_CONTINUATION_HOOK)
(RESTORE_CONTINUATION_HOOK):
* libguile/vm.h (SCM_VM_ABORT_CONTINUATION_HOOK)
(SCM_VM_RESTORE_CONTINUATION_HOOK):
* libguile/vm.c: (scm_vm_abort_continuation_hook): New hook, called when
entering an abort handler.
(scm_vm_restore_continuation_hook): New hook, called after returning
to a continuation.
* module/system/vm/vm.scm: Add hooks to export list.
| Andy Wingo | 2010-09-16 | 1 | -0/+4 |
* | trim our set of vm hooks...* 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.
| Andy Wingo | 2010-09-16 | 1 | -16/+10 |
* | %start-stack in Scheme, in terms of prompts...* libguile/debug.h:
* libguile/debug.c (scm_sys_start_stack): Removed, we implement this in
Scheme now.
* libguile/vm.h:
* libguile/vm.c (scm_vm_call_with_new_stack): Likewise removed.
* module/ice-9/boot-9.scm (%start-stack): Implement in terms of prompts.
(%stacks): New fluid, for tracking active stacks.
(start-stack): Implement using syntax-rules.
| Andy Wingo | 2010-03-09 | 1 | -1/+0 |
* | error if given an unrewindable partial continuation...* libguile/vm-engine.c (vm_error_continuation_not_rewindable):
* libguile/vm-i-system.c (partial-cont-call):
* libguile/vm.h (SCM_VM_CONT_PARTIAL_P):
(SCM_VM_CONT_REWINDABLE_P): Fix a bug in which we weren't checking if
a partial continuation was actually rewindable.
| Andy Wingo | 2010-02-25 | 1 | -2/+2 |
* | actually capture partial continuations...* libguile/control.c (cont_objcode): Along with a bunch of boilerplate
that certainly needs to go in some central place, define this
continuation-calling trampoline.
(reify_partial_continuation): New function, returns a procedure that
when called will reinstate a partial continuation.
(scm_c_abort): Take an extra arg, the cookie. Actually reify a
continuation.
(scm_at_abort): Adapt to scm_c_abort change.
* libguile/control.h: Declare scm_c_abort change.
* libguile/vm-i-system.c (partial_cont_call): New instruction.
(call/cc, tail-call/cc): Adapt to scm_i_vm_capture_stack change.
(abort): Pass vm_cookie to abort.
* libguile/vm.h (SCM_F_VM_CONT_PARTIAL, SCM_F_VM_CONT_REWINDABLE): New
flags.
(struct scm_vm_cont): Add flags field.
(SCM_VM_CONT_PARTIAL_P, SCM_VM_CONT_REWINDABLE_P): New predicates.
* libguile/vm.c (scm_i_vm_capture_stack): Rename from
vm_capture_continuation, and make internal instead of static. Take a
flags argument.
(scm_i_vm_capture_continuation): Adapt to scm_i_vm_capture_stack
change.
(vm_abort): Plumb cookie to scm_c_abort.
(vm_reinstate_partial_continuation): New stub.
| Andy Wingo | 2010-02-22 | 1 | -0/+9 |
* | abort always dispatches to VM bytecode, to detect same-invocation aborts...* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
| Andy Wingo | 2010-02-22 | 1 | -0/+1 |
* | continuations return multiple values on the stack...* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
| Andy Wingo | 2010-02-08 | 1 | -4/+2 |
* | scm_i_make_continuation takes vm and vm_cont args explicitly...* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Take VM and VM
continuation arguments as well; I'm not convinced that saving all VM
continuations was the right thing, and in any case we only ever saved
the latest. Running a new VM should create a continuation barrier.
* libguile/stacks.c (scm_make_stack):
* libguile/vm-i-system.c (call/cc, tail-call/cc): Adapt callers.
* libguile/vm.h (scm_i_vm_capture_continuation)
(scm_i_vm_reinstate_continuation): Change to be internal, and to only
capture and reinstate continuations for a particular VM.
| Andy Wingo | 2010-02-08 | 1 | -2/+2 |
* | tc7 tags for vm-related data...* 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.
| Andy Wingo | 2010-01-07 | 1 | -5/+8 |
* | properly integrate vm bootstrapping into init.c...* libguile/Makefile.am (modinclude_HEADERS):
* libguile/vm-bootstrap.h: Remove vm-bootstrap.h.
* libguile/frames.c: No more vm-bootstrap.h.
* libguile/instructions.c (scm_init_instructions):
* libguile/objcodes.c (scm_init_objcodes):
* libguile/programs.c (scm_init_programs): No need to call
scm_bootstrap_vm, init.c does that for us.
* libguile/vm.c (scm_bootstrap_vm): No need call e.g.
scm_bootstrap_frames, init.c does that. Remove a twice-calling guard,
should be unnecessary. Don't define the load-compiled subr here.
* libguile/load.c (scm_init_load): Define the load-compiled subr here.
* libguile/vm.h: Declare scm_bootstrap_vm here.
* libguile/init.c (scm_i_init_guile): Properly integrate VM
bootstrapping into this file.
| Andy Wingo | 2010-01-07 | 1 | -1/+2 |
* | rework vm tracing...* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
| Andy Wingo | 2009-12-21 | 1 | -3/+4 |
* | vm no longer measures bogoclock or times, relies on os for that...* libguile/vm.h (struct scm_vm): Remove "time" and "clock" members. The
time was bogusly measured, and the "clock" measured instructions
retired, which is not a very useful measurement, and it was causing
lots of memory accesses. Not that I have done a proper profile,
though...
(scm_vm_stats): Remove this procedure, which provided access to "time"
and "clock".
* libguile/vm.c:
* libguile/vm-engine.h:
* libguile/vm-engine.c:
* libguile/vm-i-system.c: Adapt to scm_vm changes and scm_vm_stats
removal.
* module/system/repl/command.scm:
* module/system/vm/vm.scm: Adapt to vm-stats removal by removing
vm-stats from <repl>.
| Andy Wingo | 2009-12-11 | 1 | -3/+0 |
* | fix SCM_CELL macro usage....* libguile/vm.h (SCM_VM_CONT_DATA): Fix SCM_CELL macro usage.
| Andy Wingo | 2009-12-08 | 1 | -1/+1 |
* | remove debug frames...* libguile/debug.h (scm_t_debug_frame): Remove this type, as it was
internal to the old evaluator.
(SCM_EVALFRAME, SCM_APPLYFRAME, SCM_VOIDFRAME, SCM_MACROEXPF)
(SCM_TAILREC, SCM_TRACED_FRAME, SCM_ARGS_READY, SCM_DOVERFLOW)
(SCM_MAX_FRAME_SIZE, SCM_FRAMETYPE)
(SCM_EVALFRAMEP, SCM_APPLYFRAMEP, SCM_VOIDFRAMEP, SCM_MACROEXPFP)
(SCM_TAILRECP, SCM_TRACED_FRAME_P, SCM_ARGS_READY_P, SCM_OVERFLOWP)
(SCM_SET_MACROEXP, SCM_SET_TAILREC, SCM_SET_TRACED_FRAME)
(SCM_SET_ARGSREADY, SCM_SET_OVERFLOW)
(SCM_CLEAR_MACROEXP, SCM_CLEAR_TRACED_FRAME, SCM_CLEAR_ARGSREADY):
Remove macro accessors to scm_t_debug_frame.
(SCM_DEBUGOBJP, SCM_DEBUGOBJ_FRAME, SCM_SET_DEBUGOBJ_FRAME):
(scm_debug_object_p, scm_make_debugobj): Remove debugobj accessors.
(scm_i_unmemoize_expr): Remove unused declaration.
* libguile/debug.c (scm_debug_options): No more max limit on frame
sizes.
(scm_start_stack): Just call out to scm_vm_call_with_new_stack.
(scm_debug_object_p, scm_make_debugobj, scm_init_debug): No more
debugobj smob type.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_i_deprecated_last_debug_frame)
(scm_last_debug_frame): Remove deprecated debug-frame bits.
* libguile/stacks.c (scm_make_stack): Rework this function and its
dependents to only walk VM frames.
(scm_stack_id): Call out to the holder of the VM frame in question,
which should be a VM or a VM continuation, for the stack ID. Currently
this bit is stubbed out.
(scm_last_stack_frame): Removed. It seems this is mainly useful for a
debugger, and we need to rewrite the debugger to work on the Scheme
level.
* test-suite/tests/continuations.test ("continuations"): Remove test for
last-stack-frame.
* libguile/continuations.h (struct scm_t_contregs):
* libguile/continuations.c (scm_make_continuation):
(copy_stack_and_call, scm_i_with_continuation_barrier): No need to
save and restore debug frames.
* libguile/threads.h (scm_i_thread): Don't track debug frames.
(scm_i_last_debug_frame, scm_i_set_last_debug_frame): Remove macro
accessors.
* libguile/threads.c (guilify_self_1): Don't track debug frames.
* libguile/throw.c: No need to track debug frames in a jmpbuf.
* libguile/vm-engine.c (vm_engine, VM_PUSH_DEBUG_FRAMES): Don't push
debug frames.
* libguile/vm.h:
* libguile/vm.c (scm_vm_call_with_new_stack): New function. Currently
stubbed out though.
| Andy Wingo | 2009-12-03 | 1 | -0/+1 |
* | programs have their own tc7 now...* libguile/tags.h (scm_tc7_program):
* libguile/programs.h: Programs now have their own tc7 code. Fix up the
macros appropriately.
* libguile/programs.c: Remove smobby bits, leaving marking, printing,
and application for other parts of Guile.
* libguile/debug.c (scm_procedure_source):
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
(scm_trampoline_2): Add cases for tc7_program.
* libguile/eval.i.c (CEVAL, SCM_APPLY):
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/gc-card.c (scm_i_sweep_card, scm_i_tag_name):
* libguile/gc-mark.c (1):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_thunk_p)
* libguile/vm-i-system.c (make-closure): Adapt to new procedure
representation.
* libguile/procprop.c (scm_i_procedure_arity): Do the right thing for
programs.
* test-suite/tests/procprop.test ("procedure-arity"): Arity test now
succeeds.
* libguile/goops.c (scm_class_of): Programs now belong to the class
<procedure>, not a smob class.
* libguile/vm.h (struct vm, struct vm_cont):
* libguile/vm-engine.c (vm_engine):
* libguile/frames.h (SCM_FRAME_BYTE_CAST, struct vm_frame):
* libguile/frames.c (scm_c_make_vm_frame): Fix usages of scm_byte_t,
changing them to scm_t_uint8.
| Andy Wingo | 2009-08-20 | 1 | -3/+3 |
* | Change Guile license to LGPLv3+...(Not quite finished, the following will be done tomorrow.
module/srfi/*.scm
module/rnrs/*.scm
module/scripts/*.scm
testsuite/*.scm
guile-readline/*
)
| Neil Jerram | 2009-06-17 | 1 | -6/+7 |
* | adjust VM copyright notices to LGPL, use SCM_INTERNAL/API properly...* libguile/frames.c:
* libguile/frames.h:
* libguile/instructions.c:
* libguile/instructions.h:
* libguile/objcodes.c:
* libguile/objcodes.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/vm-bootstrap.h:
* libguile/vm-engine.c:
* libguile/vm-engine.h:
* libguile/vm-expand.h:
* libguile/vm-i-scheme.c:
* libguile/vm.c:
* libguile/vm.h: Update to use SCM_API and SCM_INTERNAL correctly. Adjust
copyright to be the same as the copyright of Guile itself, which should
be fine given that the FSF holds the whole thing.
| Andy Wingo | 2009-05-26 | 1 | -67/+43 |
* | scm_call_N doesn't cons for calling programs...* libguile/eval.c (scm_call_0, scm_call_1, scm_call_2, scm_call_3)
(scm_call_4): Special-case compiled procedures here, to avoid consing.
* libguile/vm.h:
* libguile/vm.c (scm_c_vm_run): Take a SCM after all.
(scm_vm_apply, scm_load_compiled_with_vm): Adapt to vm_run change.
| Andy Wingo | 2009-02-05 | 1 | -1/+1 |
* | enable multiple vm engines (regular, debug, ...)...* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
| Andy Wingo | 2009-02-04 | 1 | -0/+10 |
* | fix marking empty VM continuations...* libguile/vm.h (struct scm_vm_cont):
* libguile/vm.c (capture_vm_cont, reinstate_vm_cont): Change so we just
store the registers as they are, with the reloc.
(vm_cont_mark): Only mark the stack if it has elements on it, otherwise
we get a bogus fp.
* libguile/stacks.c (scm_make_stack): Update for change to vm
continuations.
| Andy Wingo | 2009-01-13 | 1 | -2/+2 |