| Commit message (Expand) | Author | Age | Files | Lines |
* | 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 | -1/+2 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -1/+1 |
* | 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.
| Andy Wingo | 2013-11-21 | 1 | -1/+3 |
* | abort-to-prompt* instead of @abort...* libguile/control.h:
* libguile/control.c (scm_abort_to_prompt_star): Rename from
scm_at_abort.
* module/ice-9/boot-9.scm (abort-to-prompt): Use abort-to-prompt*.
* module/language/tree-il/primitives.scm: Handle abort-to-prompt*
instead of @abort.
| Andy Wingo | 2013-06-25 | 1 | -2/+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 | -16/+1 |
* | 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 | -20/+8 |
* | 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 | -1/+1 |
* | fix prompt and abort with the boot evaluator...* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Take a VM instead
of a prompt, given that it's the VM's registers that record the abort
arguments, not the prompt registers (which actually point right below
the abort values).
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Pass the vm instead of a prompt.
| Andy Wingo | 2011-03-29 | 1 | -2/+2 |
* | remove internal treatment of default prompt tag, it seems there was no need...* libguile/control.h (scm_sys_default_prompt_tag):
* libguile/control.c (scm_init_control): Remove the logic that defined
%default-prompt-tag.
(scm_c_abort): Remove check for default prompt tag, it wasn't useful.
* libguile/throw.c (sym_pre_init_catch_tag): Define as the pre-init
prompt tag.
(pre_init_catch, pre_init_throw): Use sym_pre_init_catch_tag.
* module/ice-9/boot-9.scm (default-prompt-tag): Define as a simple
value, not a fluid. Perhaps we can expose it as a fluid later.
| Andy Wingo | 2010-03-11 | 1 | -3/+0 |
* | add printers for prompts and with-fluids objects...* libguile/control.c:
* libguile/control.h (scm_i_prompt_print):
* libguile/fluids.c:
* libguile/fluids.h (scm_i_with_fluids_print):
* libguile/print.c (iprin1): Add printers for prompts and with-fluids
objects.
| Andy Wingo | 2010-03-04 | 1 | -0/+1 |
* | rewinding prompts works...* libguile/control.h (SCM_PROMPT_HANDLER): Remove, it was unused.
(SCM_PROMPT_DYNWINDS): Rename from SCM_PROMPT_DYNENV.
* libguile/control.c: (scm_c_make_prompt): Take another arg, the winds
that are to be in place for the prompt. Fix allocation to be 4 words
instead of 5 (the handler was never used).
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt to scm_c_make_prompt change.
* libguile/vm-i-system.c (partial-cont-call): Grovel the new elements of
the wind list in order to call setjmp() on the new prompts. Pass
cookie to vm_reinstate_partial_continuation.
(prompt): Adapt to scm_c_make_prompt change.
* libguile/vm.c (vm_reinstate_partial_continuation): Take a cookie arg,
used when winding captured prompts onto the stack. Winding a prompt
implies making a new prompt, actually -- with new registers, a new
jump buffer, new winds, etc.
* test-suite/tests/control.test ("rewinding prompts"): Add a test for
rewinding prompts.
| Andy Wingo | 2010-02-26 | 1 | -3/+3 |
* | fix a prompt bug...* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Instead of taking a VM arg,
take the registers directly.
(scm_c_abort): Declare as returning void. In fact it will never
return.
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt to prompt API change.
* libguile/vm-i-system.c (prompt): Pass the abort ip as the ip to
scm_c_make_prompt. This fixes a bug in which we used the "offset"
local var, but it wasn't guaranteed to be around after a longjmp.
| Andy Wingo | 2010-02-26 | 1 | -4/+6 |
* | simplify handling of nonlocal prompt returns from c...* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): New helper.
* libguile/eval.c (eval): Use the new helper.
| Andy Wingo | 2010-02-25 | 1 | -0/+2 |
* | add %default-prompt-tag, and error (not abort()) on an abort to bad tag...* libguile/init.c (scm_i_init_guile): Call scm_init_control after
initing fluids.
* libguile/control.h (scm_sys_default_prompt_tag): New internal var.
* libguile/control.c (scm_c_abort): If abort is called for an unknown
tag, raise an exception, except if the tag was the default prompt tag,
in which case really abort -- to prevent recursion when some other
patches land.
(scm_init_control): Define %default-prompt-tag in the default
environment.
| Andy Wingo | 2010-02-24 | 1 | -0/+3 |
* | 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 | -1/+2 |
* | 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 | -1/+4 |
* | prompt as part of guile's primitive language...* libguile/control.h:
* libguile/control.c: Remove scm_atcontrol and scm_atprompt.
(scm_c_make_prompt): Remove handler arg, as the handler is inline.
(scm_abort): New primitive, exported to Scheme as `abort'. The
compiler will also recognize calls to `abort', but this is the base
case.
(scm_init_control): Remove scm_register_control, just have this
function, which adds `abort' to the `(guile)' module.
* libguile/eval.c (eval): Add SCM_M_PROMPT case.
* libguile/init.c (scm_i_init_guile): Change scm_register_control call
into a nice orderly scm_init_control call.
* libguile/memoize.h: (scm_sym_at_prompt, SCM_M_PROMPT):
* libguile/memoize.c (MAKMEMO_PROMPT, scm_m_at_prompt, unmemoize): Add
prompt support to the memoizer.
* libguile/vm-i-system.c (prompt): Fix to not expect a handler on the
stack.
* module/ice-9/boot-9.scm (prompt): Add definition in terms of @prompt.
* module/ice-9/control.scm: Simplify, and don't play with the compiler
here, now that prompt and abort are primitive.
* module/ice-9/eval.scm (primitive-eval): Add a prompt case.
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Add @prompt and prompt.
| Andy Wingo | 2010-02-19 | 1 | -3/+2 |
* | add scm_c_abort, wire it up to the abort opcode...* libguile/control.h:
* libguile/control.c (scm_c_abort): Add an implementation of `abort',
but it doesn't reify the continuation yet.
* libguile/vm-i-system.c (abort):
* libguile/vm.c (vm_abort): Wire up the call to `abort', avoiding
consing the args into a list.
* module/language/tree-il/compile-glil.scm (flatten): Add some compily
bits that can allow the abort to be resumed.
| Andy Wingo | 2010-02-19 | 1 | -0/+1 |
* | prompt handlers are always inline...* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_PROMPT_INLINE_P): Remove;
prompts always have "inline" handlers now.
* libguile/control.c (scm_c_make_prompt): Remove inline_handler_p arg.
* libguile/vm-i-system.c (prompt):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
Adapt to prompt changes.
* module/language/glil.scm (make-glil-prompt, glil-prompt-inline?):
Remove inline? flag.
(parse-glil, unparse-glil):
* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
<glil-prompt> change.
* module/language/tree-il/compile-glil.scm (flatten): Require the
handler of a <prompt> to be a lambda-case.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Ensure that the handler of a <prompt> is a lambda-case.
* module/language/tree-il/inline.scm (inline!): Simplify a degenerate
case: (lambda args (apply (lambda ...) args)) => (lambda ...).
| Andy Wingo | 2010-02-19 | 1 | -5/+2 |
* | <prompt> has no pre-unwind-handler, it's unnecessary...* libguile/control.h:
* libguile/control.c (scm_c_make_prompt, SCM_PROMPT_PRE_UNWIND_HANDLER):
* libguile/vm-i-system.c (prompt)
* module/language/tree-il.scm (<prompt> prompt-pre-unwind-handler):
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm: Remove the "pre-unwind"
handler from prompt; it turns out not to be necessary. Adapt all
references.
| Andy Wingo | 2010-02-19 | 1 | -3/+3 |
* | connect a few more wires to promptenstein...* libguile/tags.h (scm_tc7_prompt): Allocate a tc7 for prompt objects.
* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_F_PROMPT_ESCAPE)
(SCM_PROMPT_P, SCM_PROMPT_FLAGS, SCM_PROMPT_INLINE_P)
(SCM_PROMPT_ESCAPE_P, SCM_PROMPT_TAG, SCM_PROMPT_REGISTERS)
(SCM_PROMPT_DYNENV, SCM_PROMPT_HANDLER)
(SCM_PROMPT_PRE_UNWIND_HANDLER, SCM_PROMPT_SETJMP)
(struct scm_prompt_registers):
* libguile/control.c (scm_c_make_prompt): Flesh out a simple prompts
implementation.
* libguile/vm-i-system.c (prompt): Wire up the implementation.
* libguile/vm.c: Add a needed #include.
| Andy Wingo | 2010-02-08 | 1 | -0/+28 |
* | add @control and @prompt stub primitives...* libguile/Makefile.am:
* libguile/control.c:
* libguile/control.h:
* libguile/init.c: Add stub @control and @prompt primitives, for use
when bootstrapping (ice-9 control).
| Andy Wingo | 2010-01-31 | 1 | -0/+26 |