mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
less overhead for handling interrupts in the vm
* libguile/__scm.h (SCM_ASYNC_TICK): Add some branch prediction. (SCM_ASYNC_TICK_WITH_CODE): New helper for when BUILDING_LIBGUILE, runs code only if we're going to call async_click(). * libguile/vm-engine.h (VM_HANDLE_INTERRUPTS): New helper, uses SCM_ASYNC_TICK_WITH_CODE to only save regs if we'll handle an interrupt. * libguile/vm-i-system.c (call, goto/args, return): use VM_HANDLE_INTERRUPTS.
This commit is contained in:
parent
aa3819aa34
commit
e8c3777214
3 changed files with 26 additions and 12 deletions
|
@ -498,12 +498,24 @@ SCM_API void scm_async_tick (void);
|
|||
#ifdef BUILDING_LIBGUILE
|
||||
|
||||
/* FIXME: should change names */
|
||||
# define SCM_ASYNC_TICK \
|
||||
do \
|
||||
{ \
|
||||
if (SCM_I_CURRENT_THREAD->pending_asyncs) \
|
||||
scm_async_click (); \
|
||||
} \
|
||||
# define SCM_ASYNC_TICK \
|
||||
do \
|
||||
{ \
|
||||
if (SCM_UNLIKELY (SCM_I_CURRENT_THREAD->pending_asyncs)) \
|
||||
scm_async_click (); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* SCM_ASYNC_TICK_WITH_CODE is only available to Guile itself */
|
||||
# define SCM_ASYNC_TICK_WITH_CODE(stmt) \
|
||||
do \
|
||||
{ \
|
||||
if (SCM_UNLIKELY (SCM_I_CURRENT_THREAD->pending_asyncs)) \
|
||||
{ \
|
||||
stmt; \
|
||||
scm_async_click (); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#else /* !BUILDING_LIBGUILE */
|
||||
|
|
|
@ -228,6 +228,9 @@
|
|||
#define EXIT_HOOK() RUN_HOOK (SCM_VM_EXIT_HOOK)
|
||||
#define RETURN_HOOK() RUN_HOOK (SCM_VM_RETURN_HOOK)
|
||||
|
||||
#define VM_HANDLE_INTERRUPTS \
|
||||
SCM_ASYNC_TICK_WITH_CODE (SYNC_REGISTER ())
|
||||
|
||||
|
||||
/*
|
||||
* Stack operation
|
||||
|
|
|
@ -747,8 +747,7 @@ VM_DEFINE_INSTRUCTION (54, call, "call", 1, -1, 1)
|
|||
vm_call:
|
||||
x = sp[-nargs];
|
||||
|
||||
SYNC_REGISTER ();
|
||||
SCM_TICK; /* allow interrupt here */
|
||||
VM_HANDLE_INTERRUPTS;
|
||||
|
||||
/*
|
||||
* Subprogram call
|
||||
|
@ -813,8 +812,7 @@ VM_DEFINE_INSTRUCTION (55, goto_args, "goto/args", 1, -1, 1)
|
|||
vm_goto_args:
|
||||
x = sp[-nargs];
|
||||
|
||||
SYNC_REGISTER ();
|
||||
SCM_TICK; /* allow interrupt here */
|
||||
VM_HANDLE_INTERRUPTS;
|
||||
|
||||
/*
|
||||
* Tail call
|
||||
|
@ -1085,8 +1083,9 @@ VM_DEFINE_INSTRUCTION (63, return, "return", 0, 1, 1)
|
|||
vm_return:
|
||||
EXIT_HOOK ();
|
||||
RETURN_HOOK ();
|
||||
SYNC_REGISTER ();
|
||||
SCM_TICK; /* allow interrupt here */
|
||||
|
||||
VM_HANDLE_INTERRUPTS;
|
||||
|
||||
{
|
||||
SCM ret;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue