summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-06-25 10:52:16 +0200
committerAndy Wingo <wingo@pobox.com>2018-06-25 17:50:28 +0200
commit08bf4aba30d6365d5fc73fe5ced5f83ff819205c (patch)
tree113f0bce3c5c60b2ea1bcdd43ded25bc4ced0d37 /libguile/vm-engine.c
parent8e5755e7719b2bab69c509e4bf0ab2e8bcdc8a10 (diff)
downloadguile-08bf4aba30d6365d5fc73fe5ced5f83ff819205c.tar.gz
Add push-interrupt-frame VM intrinsic
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add push-interrupt-frame. * libguile/vm.c (push_interrupt_frame): New intrinsic. Goal is to reduce the amount of inline code the JIT will generate for handling interrupts. * libguile/vm-engine.c (handle-interrupts): Call out to the push_interrupt_frame intrinsic in the slow case.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r--libguile/vm-engine.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 6eb047472..56c5ec177 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -2443,6 +2443,8 @@ VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume)
*/
VM_DEFINE_OP (183, handle_interrupts, "handle-interrupts", OP1 (X32))
{
+ struct scm_vm_intrinsics *i = (void*)intrinsics;
+
if (SCM_LIKELY (scm_is_null
(scm_atomic_ref_scm (&thread->pending_asyncs))))
NEXT (1);
@@ -2450,33 +2452,12 @@ VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume)
if (thread->block_asyncs > 0)
NEXT (1);
- {
- union scm_vm_stack_element *old_fp;
- size_t old_frame_size = FRAME_LOCALS_COUNT ();
- SCM proc = scm_i_async_pop (thread);
-
- /* No PUSH_CONTINUATION_HOOK, as we can't usefully
- POP_CONTINUATION_HOOK because there are no return values. */
-
- /* Three slots: two for RA and dynamic link, one for proc. */
- ALLOC_FRAME (old_frame_size + 3);
-
- /* Set up a frame that will return right back to this
- handle-interrupts opcode to handle any additional
- interrupts. */
- old_fp = VP->fp;
- VP->fp = SCM_FRAME_SLOT (old_fp, old_frame_size + 1);
- SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp);
- SCM_FRAME_SET_RETURN_ADDRESS (VP->fp, ip);
-
- SP_SET (0, proc);
-
- ip = (uint32_t *) vm_handle_interrupt_code;
-
- APPLY_HOOK ();
-
- NEXT (0);
- }
+ SYNC_IP ();
+ i->push_interrupt_frame (thread);
+ CACHE_SP ();
+ ip = (uint32_t *) vm_handle_interrupt_code;
+ APPLY_HOOK ();
+ NEXT (0);
}
/* return-from-interrupt _:24