mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
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.
This commit is contained in:
parent
b44f5451f8
commit
796e54a74c
4 changed files with 14 additions and 14 deletions
|
@ -116,7 +116,7 @@ continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED)
|
|||
placed on the VM stack). */
|
||||
#define FUNC_NAME "scm_i_make_continuation"
|
||||
SCM
|
||||
scm_i_make_continuation (int *first, SCM vm, SCM vm_cont)
|
||||
scm_i_make_continuation (int *first, struct scm_vm *vp, SCM vm_cont)
|
||||
{
|
||||
scm_i_thread *thread = SCM_I_CURRENT_THREAD;
|
||||
SCM cont;
|
||||
|
@ -137,7 +137,7 @@ scm_i_make_continuation (int *first, SCM vm, SCM vm_cont)
|
|||
#endif
|
||||
continuation->offset = continuation->stack - src;
|
||||
memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
|
||||
continuation->vm = vm;
|
||||
continuation->vp = vp;
|
||||
continuation->vm_cont = vm_cont;
|
||||
|
||||
SCM_NEWSMOB (cont, tc16_continuation, continuation);
|
||||
|
@ -186,10 +186,10 @@ scm_i_continuation_to_frame (SCM continuation)
|
|||
return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_i_contregs_vm (SCM contregs)
|
||||
struct scm_vm *
|
||||
scm_i_contregs_vp (SCM contregs)
|
||||
{
|
||||
return SCM_CONTREGS (contregs)->vm;
|
||||
return SCM_CONTREGS (contregs)->vp;
|
||||
}
|
||||
|
||||
SCM
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef struct
|
|||
#endif /* __ia64__ */
|
||||
size_t num_stack_items; /* size of the saved stack. */
|
||||
SCM root; /* continuation root identifier. */
|
||||
SCM vm; /* vm */
|
||||
struct scm_vm *vp; /* vm */
|
||||
SCM vm_cont; /* vm's stack and regs */
|
||||
|
||||
/* The offset from the live stack location to this copy. This is
|
||||
|
@ -70,12 +70,14 @@ typedef struct
|
|||
|
||||
|
||||
|
||||
SCM_INTERNAL SCM scm_i_make_continuation (int *first, SCM vm, SCM vm_cont);
|
||||
SCM_INTERNAL SCM scm_i_make_continuation (int *first,
|
||||
struct scm_vm *vp,
|
||||
SCM vm_cont);
|
||||
SCM_INTERNAL void scm_i_check_continuation (SCM cont);
|
||||
SCM_INTERNAL void scm_i_reinstate_continuation (SCM cont);
|
||||
|
||||
SCM_INTERNAL SCM scm_i_continuation_to_frame (SCM cont);
|
||||
SCM_INTERNAL SCM scm_i_contregs_vm (SCM contregs);
|
||||
SCM_INTERNAL struct scm_vm* scm_i_contregs_vp (SCM contregs);
|
||||
SCM_INTERNAL SCM scm_i_contregs_vm_cont (SCM contregs);
|
||||
|
||||
SCM_API void *scm_c_with_continuation_barrier (void *(*func)(void*), void *);
|
||||
|
|
|
@ -894,7 +894,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
|
|||
|
||||
SYNC_IP ();
|
||||
scm_i_check_continuation (contregs);
|
||||
vm_return_to_continuation (scm_i_contregs_vm (contregs),
|
||||
vm_return_to_continuation (scm_i_contregs_vp (contregs),
|
||||
scm_i_contregs_vm_cont (contregs),
|
||||
FRAME_LOCALS_COUNT_FROM (1),
|
||||
LOCAL_ADDRESS (1));
|
||||
|
@ -1003,7 +1003,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
|
|||
copying out to the heap; and likewise, the setjmp(®isters)
|
||||
code already has the non-local return handler. But oh
|
||||
well! */
|
||||
cont = scm_i_make_continuation (&first, vm, vm_cont);
|
||||
cont = scm_i_make_continuation (&first, vp, vm_cont);
|
||||
|
||||
if (first)
|
||||
{
|
||||
|
|
|
@ -112,21 +112,19 @@ scm_i_vm_capture_stack (SCM *stack_base, SCM *fp, SCM *sp, scm_t_uint32 *ra,
|
|||
}
|
||||
|
||||
static void
|
||||
vm_return_to_continuation (SCM vm, SCM cont, size_t n, SCM *argv)
|
||||
vm_return_to_continuation (struct scm_vm *vp, SCM cont, size_t n, SCM *argv)
|
||||
{
|
||||
struct scm_vm *vp;
|
||||
struct scm_vm_cont *cp;
|
||||
SCM *argv_copy;
|
||||
|
||||
argv_copy = alloca (n * sizeof(SCM));
|
||||
memcpy (argv_copy, argv, n * sizeof(SCM));
|
||||
|
||||
vp = SCM_VM_DATA (vm);
|
||||
cp = SCM_VM_CONT_DATA (cont);
|
||||
|
||||
if (vp->stack_size < cp->stack_size + n + 3)
|
||||
scm_misc_error ("vm-engine", "not enough space to reinstate continuation",
|
||||
scm_list_2 (vm, cont));
|
||||
scm_list_1 (cont));
|
||||
|
||||
vp->sp = cp->sp;
|
||||
vp->fp = cp->fp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue