1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

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.
This commit is contained in:
Andy Wingo 2013-11-21 17:36:22 +01:00
parent 44ece39907
commit b44f5451f8
5 changed files with 27 additions and 28 deletions

View file

@ -78,7 +78,7 @@ make_partial_continuation (SCM vm_cont)
}
static SCM
reify_partial_continuation (SCM vm,
reify_partial_continuation (struct scm_vm *vp,
SCM *saved_fp,
SCM *saved_sp,
scm_t_uint32 *saved_ip,
@ -103,7 +103,7 @@ reify_partial_continuation (SCM vm,
could determine the stack bottom in O(1) time, but that's no longer
the case, since the thunk application doesn't occur where the
prompt is saved. */
for (bottom_fp = SCM_VM_DATA (vm)->fp;
for (bottom_fp = vp->fp;
SCM_FRAME_DYNAMIC_LINK (bottom_fp) > saved_fp;
bottom_fp = SCM_FRAME_DYNAMIC_LINK (bottom_fp));
@ -112,9 +112,9 @@ reify_partial_continuation (SCM vm,
/* Capture from the top of the thunk application frame up to the end. */
vm_cont = scm_i_vm_capture_stack (&SCM_FRAME_LOCAL (bottom_fp, 0),
SCM_VM_DATA (vm)->fp,
SCM_VM_DATA (vm)->sp,
SCM_VM_DATA (vm)->ip,
vp->fp,
vp->sp,
vp->ip,
dynstack,
flags);
@ -122,7 +122,7 @@ reify_partial_continuation (SCM vm,
}
void
scm_c_abort (SCM vm, SCM tag, size_t n, SCM *argv,
scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
scm_i_jmp_buf *current_registers)
{
SCM cont;
@ -142,8 +142,8 @@ scm_c_abort (SCM vm, SCM tag, size_t n, SCM *argv,
if (!prompt)
scm_misc_error ("abort", "Abort to unknown prompt", scm_list_1 (tag));
fp = SCM_VM_DATA (vm)->stack_base + fp_offset;
sp = SCM_VM_DATA (vm)->stack_base + sp_offset;
fp = vp->stack_base + fp_offset;
sp = vp->stack_base + sp_offset;
/* Only reify if the continuation referenced in the handler. */
if (flags & SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY)
@ -153,32 +153,28 @@ scm_c_abort (SCM vm, SCM tag, size_t n, SCM *argv,
scm_t_dynstack *captured;
captured = scm_dynstack_capture (dynstack, SCM_DYNSTACK_NEXT (prompt));
cont = reify_partial_continuation (vm, fp, sp, ip, registers, captured,
cont = reify_partial_continuation (vp, fp, sp, ip, registers, captured,
current_registers);
}
/* Unwind. */
scm_dynstack_unwind (dynstack, prompt);
/* Unwinding may have changed the current thread's VM, so use the
new one. */
vm = scm_the_vm ();
/* Restore VM regs */
SCM_VM_DATA (vm)->fp = fp;
SCM_VM_DATA (vm)->sp = sp;
SCM_VM_DATA (vm)->ip = ip;
vp->fp = fp;
vp->sp = sp;
vp->ip = ip;
/* Since we're jumping down, we should always have enough space. */
if (SCM_VM_DATA (vm)->sp + n + 1 >= SCM_VM_DATA (vm)->stack_limit)
if (vp->sp + n + 1 >= vp->stack_limit)
abort ();
/* Push vals */
*(++(SCM_VM_DATA (vm)->sp)) = cont;
*(++(vp->sp)) = cont;
for (i = 0; i < n; i++)
*(++(SCM_VM_DATA (vm)->sp)) = argv[i];
*(++(vp->sp)) = argv[i];
if (flags & SCM_F_DYNSTACK_PROMPT_PUSH_NARGS)
*(++(SCM_VM_DATA (vm)->sp)) = scm_from_size_t (n+1); /* +1 for continuation */
*(++(vp->sp)) = scm_from_size_t (n+1); /* +1 for continuation */
/* Jump! */
SCM_I_LONGJMP (*registers, 1);
@ -202,7 +198,7 @@ SCM_DEFINE (scm_abort_to_prompt_star, "abort-to-prompt*", 2, 0, 0,
for (i = 0; i < n; i++, args = scm_cdr (args))
argv[i] = scm_car (args);
scm_c_abort (scm_the_vm (), tag, n, argv, NULL);
scm_c_abort (SCM_VM_DATA (scm_the_vm ()), tag, n, argv, NULL);
/* Oh, what, you're still here? The abort must have been reinstated. Actually,
that's quite impossible, given that we're already in C-land here, so...

View file

@ -19,10 +19,12 @@
#ifndef SCM_CONTROL_H
#define SCM_CONTROL_H
#include "libguile/vm.h"
SCM_INTERNAL SCM scm_i_prompt_pop_abort_args_x (SCM vm);
SCM_INTERNAL void scm_c_abort (SCM vm, SCM tag, size_t n, SCM *argv,
SCM_INTERNAL void scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
scm_i_jmp_buf *registers) SCM_NORETURN;
SCM_INTERNAL SCM scm_abort_to_prompt_star (SCM tag, SCM args) SCM_NORETURN;

View file

@ -24,7 +24,6 @@
#include "libguile/__scm.h"
#include "libguile/control.h"

View file

@ -1043,7 +1043,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
it continues with the next instruction. */
ip++;
SYNC_IP ();
vm_abort (vm, LOCAL_REF (1), nlocals - 2, LOCAL_ADDRESS (2),
vm_abort (vp, LOCAL_REF (1), nlocals - 2, LOCAL_ADDRESS (2),
SCM_EOL, LOCAL_ADDRESS (0), &registers);
/* vm_abort should not return */

View file

@ -270,11 +270,13 @@ static void vm_dispatch_restore_continuation_hook (struct scm_vm *vp)
}
static void
vm_abort (SCM vm, SCM tag, size_t nstack, SCM *stack_args, SCM tail, SCM *sp,
vm_abort (struct scm_vm *vp, SCM tag,
size_t nstack, SCM *stack_args, SCM tail, SCM *sp,
scm_i_jmp_buf *current_registers) SCM_NORETURN;
static void
vm_abort (SCM vm, SCM tag, size_t nstack, SCM *stack_args, SCM tail, SCM *sp,
vm_abort (struct scm_vm *vp, SCM tag,
size_t nstack, SCM *stack_args, SCM tail, SCM *sp,
scm_i_jmp_buf *current_registers)
{
size_t i;
@ -293,9 +295,9 @@ vm_abort (SCM vm, SCM tag, size_t nstack, SCM *stack_args, SCM tail, SCM *sp,
argv[i] = scm_car (tail);
/* FIXME: NULLSTACK (SCM_VM_DATA (vp)->sp - sp) */
SCM_VM_DATA (vm)->sp = sp;
vp->sp = sp;
scm_c_abort (vm, tag, nstack + tail_len, argv, current_registers);
scm_c_abort (vp, tag, nstack + tail_len, argv, current_registers);
}
static void