summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
Diffstat (limited to 'libguile')
-rw-r--r--libguile/continuations.c21
-rw-r--r--libguile/continuations.h4
-rw-r--r--libguile/scm.h2
-rw-r--r--libguile/threads.h4
-rw-r--r--libguile/vm-engine.c37
5 files changed, 19 insertions, 49 deletions
diff --git a/libguile/continuations.c b/libguile/continuations.c
index c99e0eb43..172168e61 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -166,18 +166,12 @@ restore_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation)
#endif
}
-/* this may return more than once: the first time with the escape
- procedure, then subsequently with SCM_UNDEFINED (the vals already having been
- placed on the VM stack). */
-#define FUNC_NAME "scm_i_make_continuation"
SCM
-scm_i_make_continuation (int *first, struct scm_vm *vp, SCM vm_cont)
+scm_i_make_continuation (jmp_buf *registers, scm_i_thread *thread, SCM vm_cont)
{
- scm_i_thread *thread = SCM_I_CURRENT_THREAD;
SCM cont;
scm_t_contregs *continuation;
long stack_size;
- const void *saved_cookie;
SCM_STACKITEM * src;
SCM_FLUSH_REGISTER_WINDOWS;
@@ -193,23 +187,14 @@ scm_i_make_continuation (int *first, struct scm_vm *vp, SCM vm_cont)
#endif
continuation->offset = continuation->stack - src;
memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
+ memcpy (continuation->jmpbuf, registers, sizeof (*registers));
continuation->vm_cont = vm_cont;
- saved_cookie = vp->resumable_prompt_cookie;
capture_auxiliary_stack (thread, continuation);
SCM_NEWSMOB (cont, tc16_continuation, continuation);
- *first = !setjmp (continuation->jmpbuf);
- if (*first)
- return make_continuation_trampoline (cont);
- else
- {
- vp->resumable_prompt_cookie = saved_cookie;
- scm_gc_after_nonlocal_exit ();
- return SCM_UNDEFINED;
- }
+ return make_continuation_trampoline (cont);
}
-#undef FUNC_NAME
int
scm_i_continuation_to_frame (SCM continuation, struct scm_frame *frame)
diff --git a/libguile/continuations.h b/libguile/continuations.h
index 6b52f2649..9e044c48c 100644
--- a/libguile/continuations.h
+++ b/libguile/continuations.h
@@ -67,8 +67,8 @@ typedef struct
-SCM_INTERNAL SCM scm_i_make_continuation (int *first,
- struct scm_vm *vp,
+SCM_INTERNAL SCM scm_i_make_continuation (jmp_buf *registers,
+ scm_i_thread *thread,
SCM vm_cont);
SCM_INTERNAL void scm_i_reinstate_continuation (SCM cont) SCM_NORETURN;
diff --git a/libguile/scm.h b/libguile/scm.h
index 9996ec47b..99b20fc32 100644
--- a/libguile/scm.h
+++ b/libguile/scm.h
@@ -827,7 +827,7 @@ typedef int32_t scm_t_wchar;
struct scm_frame;
struct scm_vm;
union scm_vm_stack_element;
-
+typedef struct scm_i_thread scm_i_thread; /* FIXME: Rename. */
diff --git a/libguile/threads.h b/libguile/threads.h
index 50d4ba158..9f0ccc5aa 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -48,7 +48,7 @@ SCM_API scm_t_bits scm_tc16_condvar;
struct scm_thread_wake_data;
-typedef struct scm_i_thread {
+struct scm_i_thread {
struct scm_i_thread *next_thread;
SCM handle;
@@ -105,7 +105,7 @@ typedef struct scm_i_thread {
struct scm_vm vm;
SCM_STACKITEM *base;
jmp_buf regs;
-} scm_i_thread;
+};
#define SCM_I_IS_THREAD(x) SCM_SMOB_PREDICATE (scm_tc16_thread, x)
#define SCM_I_THREAD_DATA(x) ((scm_i_thread *) SCM_SMOB_DATA (x))
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 6f2e09320..0fdbf003e 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -758,7 +758,6 @@ VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume)
{
SCM vm_cont, cont;
scm_t_dynstack *dynstack;
- int first;
SYNC_IP ();
dynstack = scm_dynstack_capture_all (&thread->dynstack);
@@ -768,35 +767,21 @@ VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume)
SCM_FRAME_RETURN_ADDRESS (VP->fp),
dynstack,
0);
- /* FIXME: Seems silly to capture the registers here, when they are
- already captured in the registers local, which here we are
- copying out to the heap; and likewise, the setjmp(&registers)
- code already has the non-local return handler. But oh
- well! */
- cont = scm_i_make_continuation (&first, VP, vm_cont);
-
- if (first)
- {
- RESET_FRAME (2);
-
- SP_SET (1, SP_REF (0));
- SP_SET (0, cont);
+ cont = scm_i_make_continuation (registers, thread, vm_cont);
- if (SCM_LIKELY (SCM_PROGRAM_P (SP_REF (1))))
- ip = SCM_PROGRAM_CODE (SP_REF (1));
- else
- ip = (uint32_t *) vm_apply_non_program_code;
+ RESET_FRAME (2);
- APPLY_HOOK ();
+ SP_SET (1, SP_REF (0));
+ SP_SET (0, cont);
- NEXT (0);
- }
+ if (SCM_LIKELY (SCM_PROGRAM_P (SP_REF (1))))
+ ip = SCM_PROGRAM_CODE (SP_REF (1));
else
- {
- CACHE_REGISTER ();
- ABORT_CONTINUATION_HOOK ();
- NEXT (0);
- }
+ ip = (uint32_t *) vm_apply_non_program_code;
+
+ APPLY_HOOK ();
+
+ NEXT (0);
}
/* abort _:24