diff options
author | Andy Wingo <wingo@pobox.com> | 2018-06-27 18:21:04 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-06-27 18:21:04 +0200 |
commit | 18431e6e63243eebefa3e77684d7b75e69c0fcb5 (patch) | |
tree | 9d96e3884db7276af43bdf72fcf515473db824f5 | |
parent | fd4eb1475106c4b8140634955e336a012787e28a (diff) | |
download | guile-18431e6e63243eebefa3e77684d7b75e69c0fcb5.tar.gz |
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.
-rw-r--r-- | libguile/control.c | 2 | ||||
-rw-r--r-- | libguile/eval.c | 6 | ||||
-rw-r--r-- | libguile/threads.h | 5 | ||||
-rw-r--r-- | libguile/throw.c | 6 | ||||
-rw-r--r-- | libguile/vm.c | 6 | ||||
-rw-r--r-- | libguile/vm.h | 4 |
6 files changed, 14 insertions, 15 deletions
diff --git a/libguile/control.c b/libguile/control.c index 3068f6a83..2e10b583c 100644 --- a/libguile/control.c +++ b/libguile/control.c @@ -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; } diff --git a/libguile/eval.c b/libguile/eval.c index 242759b27..589a297d8 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -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); diff --git a/libguile/threads.h b/libguile/threads.h index 5ed4c65d2..733b6dbf2 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -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) diff --git a/libguile/throw.c b/libguile/throw.c index 8a6f0f8e1..f1f854015 100644 --- a/libguile/throw.c +++ b/libguile/throw.c @@ -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 diff --git a/libguile/vm.c b/libguile/vm.c index 3a603e4b9..442bd72c3 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -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; } diff --git a/libguile/vm.h b/libguile/vm.h index cf777a6ca..a5cdacbf0 100644 --- a/libguile/vm.h +++ b/libguile/vm.h @@ -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 */ }; |