mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
Refactor handling of active VM registers
* libguile/threads.h (scm_thread): Remove unused jmp_buf regs member. * libguile/vm.h (struct scm_vm): Rename resumable_prompt_cookie to just "registers"; we know it's a jmp_buf pointer. * libguile/vm.c (scm_call_n): * libguile/throw.c (catch): * libguile/eval.c (eval): * libguile/control.c (scm_suspendable_continuation_p): Adapt to cookie renaming.
This commit is contained in:
parent
fd4eb14751
commit
18431e6e63
6 changed files with 14 additions and 15 deletions
|
@ -124,7 +124,7 @@ scm_suspendable_continuation_p (SCM tag)
|
|||
|
||||
if (scm_dynstack_find_prompt (&thread->dynstack, tag, &flags,
|
||||
NULL, NULL, NULL, ®isters))
|
||||
return scm_from_bool (registers == thread->vm.resumable_prompt_cookie);
|
||||
return scm_from_bool (registers == thread->vm.registers);
|
||||
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ eval (SCM x, SCM env)
|
|||
scm_thread *t;
|
||||
SCM k, handler, res;
|
||||
jmp_buf registers;
|
||||
const void *prev_cookie;
|
||||
jmp_buf *prev_registers;
|
||||
ptrdiff_t saved_stack_depth;
|
||||
|
||||
k = EVAL1 (CAR (mx), env);
|
||||
|
@ -457,11 +457,11 @@ eval (SCM x, SCM env)
|
|||
t->vm.ip,
|
||||
®isters);
|
||||
|
||||
prev_cookie = t->vm.resumable_prompt_cookie;
|
||||
prev_registers = t->vm.registers;
|
||||
if (setjmp (registers))
|
||||
{
|
||||
/* The prompt exited nonlocally. */
|
||||
t->vm.resumable_prompt_cookie = prev_cookie;
|
||||
t->vm.registers = prev_registers;
|
||||
scm_gc_after_nonlocal_exit ();
|
||||
proc = handler;
|
||||
args = scm_i_prompt_pop_abort_args_x (&t->vm, saved_stack_depth);
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "libguile/procs.h"
|
||||
#include "libguile/throw.h"
|
||||
#include "libguile/dynstack.h"
|
||||
|
@ -101,10 +99,9 @@ struct scm_thread {
|
|||
SCM continuation_root;
|
||||
SCM_STACKITEM *continuation_base;
|
||||
|
||||
/* For keeping track of the stack and registers. */
|
||||
/* VM state for this thread. */
|
||||
struct scm_vm vm;
|
||||
SCM_STACKITEM *base;
|
||||
jmp_buf regs;
|
||||
};
|
||||
|
||||
#define SCM_I_IS_THREAD(x) SCM_SMOB_PREDICATE (scm_tc16_thread, x)
|
||||
|
|
|
@ -86,7 +86,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
|
|||
scm_t_dynstack *dynstack = &t->dynstack;
|
||||
scm_t_dynamic_state *dynamic_state = t->dynamic_state;
|
||||
jmp_buf registers;
|
||||
const void *prev_cookie;
|
||||
jmp_buf *prev_registers;
|
||||
ptrdiff_t saved_stack_depth;
|
||||
|
||||
if (!scm_is_eq (tag, SCM_BOOL_T) && !scm_is_symbol (tag))
|
||||
|
@ -109,7 +109,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
|
|||
scm_c_vector_set_x (eh, 1, prompt_tag);
|
||||
scm_c_vector_set_x (eh, 2, pre_unwind_handler);
|
||||
|
||||
prev_cookie = t->vm.resumable_prompt_cookie;
|
||||
prev_registers = t->vm.registers;
|
||||
saved_stack_depth = t->vm.stack_top - t->vm.sp;
|
||||
|
||||
/* Push the prompt and exception handler onto the dynamic stack. */
|
||||
|
@ -128,7 +128,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
|
|||
/* A non-local return. */
|
||||
SCM args;
|
||||
|
||||
t->vm.resumable_prompt_cookie = prev_cookie;
|
||||
t->vm.registers = prev_registers;
|
||||
scm_gc_after_nonlocal_exit ();
|
||||
|
||||
/* FIXME: We know where the args will be on the stack; we could
|
||||
|
|
|
@ -1411,7 +1411,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
|
|||
{
|
||||
jmp_buf registers;
|
||||
int resume;
|
||||
const void *prev_cookie = vp->resumable_prompt_cookie;
|
||||
jmp_buf *prev_registers = thread->vm.registers;
|
||||
SCM ret;
|
||||
|
||||
resume = setjmp (registers);
|
||||
|
@ -1422,9 +1422,9 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
|
|||
vm_dispatch_abort_hook (vp);
|
||||
}
|
||||
|
||||
vp->resumable_prompt_cookie = ®isters;
|
||||
thread->vm.registers = ®isters;
|
||||
ret = vm_engines[vp->engine](thread, ®isters, resume);
|
||||
vp->resumable_prompt_cookie = prev_cookie;
|
||||
thread->vm.registers = prev_registers;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#ifndef _SCM_VM_H_
|
||||
#define _SCM_VM_H_
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <libguile/gc.h>
|
||||
#include <libguile/programs.h>
|
||||
|
||||
|
@ -56,7 +58,7 @@ struct scm_vm {
|
|||
union scm_vm_stack_element *stack_top; /* highest address in allocated stack */
|
||||
SCM overflow_handler_stack; /* alist of max-stack-size -> thunk */
|
||||
SCM hooks[SCM_VM_NUM_HOOKS]; /* hooks */
|
||||
const void *resumable_prompt_cookie; /* opaque cookie */
|
||||
jmp_buf *registers; /* registers captured at latest vm entry */
|
||||
int engine; /* which vm engine we're using */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue