summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-06-26 11:25:07 +0200
committerAndy Wingo <wingo@pobox.com>2018-06-26 11:25:07 +0200
commit51e35158bad42b8db28e9272ebb279f17b76dbe4 (patch)
tree02370d3b367571aed28154df7cfc23d0b7dd5bf7 /libguile/vm-engine.c
parent185d19dfb1a570c3075fa8f1a653334412ae6b85 (diff)
downloadguile-51e35158bad42b8db28e9272ebb279f17b76dbe4.tar.gz
Refactor continuation capture in VM
* libguile/continuations.h: * libguile/continuations.c (scm_i_make_continuation): Refactor to expect registers to already be captured. * libguile/scm.h (scm_i_thread): Add forward decl. * libguile/threads.h (struct scm_i_thread): Just fill in the struct type. * libguile/vm-engine.c (call/cc); Use the registers already captured before entering the VM.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r--libguile/vm-engine.c37
1 files changed, 11 insertions, 26 deletions
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