mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
avoid tls gets when handling interrupts in the vm
* libguile/__scm.h (SCM_ASYNC_TICK_WITH_CODE): Redefine to take a scm_i_thread* as well. OK to do because it's within a BUILDING_LIBGUILE block. * libguile/vm-engine.c (vm_engine): Cache the scm_i_thread* instead of the dynstate, so we can use the thread for ticks. * libguile/vm-engine.h (VM_HANDLE_INTERRUPTS): Tick with the scm_i_thread* local var, to avoid excessive tls calls. * libguile/vm-i-system.c: Fix dynstate users to use current_thread->dynamic_state.
This commit is contained in:
parent
a2230b653b
commit
a2a6c0e319
4 changed files with 8 additions and 8 deletions
|
@ -536,10 +536,10 @@ SCM_API void scm_async_tick (void);
|
|||
while (0)
|
||||
|
||||
/* SCM_ASYNC_TICK_WITH_CODE is only available to Guile itself */
|
||||
# define SCM_ASYNC_TICK_WITH_CODE(stmt) \
|
||||
# define SCM_ASYNC_TICK_WITH_CODE(thr, stmt) \
|
||||
do \
|
||||
{ \
|
||||
if (SCM_UNLIKELY (SCM_I_CURRENT_THREAD->pending_asyncs)) \
|
||||
if (SCM_UNLIKELY (thr->pending_asyncs)) \
|
||||
{ \
|
||||
stmt; \
|
||||
scm_async_click (); \
|
||||
|
|
|
@ -52,7 +52,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
|
|||
#endif
|
||||
SCM *stack_limit = vp->stack_limit; /* stack limit address */
|
||||
|
||||
SCM dynstate = SCM_I_CURRENT_THREAD->dynamic_state;
|
||||
scm_i_thread *current_thread = SCM_I_CURRENT_THREAD;
|
||||
scm_t_int64 vm_cookie = vp->cookie++;
|
||||
|
||||
/* Internal variables */
|
||||
|
|
|
@ -244,7 +244,7 @@
|
|||
RUN_HOOK (SCM_VM_RESTORE_CONTINUATION_HOOK)
|
||||
|
||||
#define VM_HANDLE_INTERRUPTS \
|
||||
SCM_ASYNC_TICK_WITH_CODE (SYNC_REGISTER ())
|
||||
SCM_ASYNC_TICK_WITH_CODE (current_thread, SYNC_REGISTER ())
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -1635,7 +1635,7 @@ VM_DEFINE_INSTRUCTION (89, wind_fluids, "wind-fluids", 1, -1, 0)
|
|||
wf = scm_i_make_with_fluids (n, sp + 1, sp + 1 + n);
|
||||
NULLSTACK (2 * n);
|
||||
|
||||
scm_i_swap_with_fluids (wf, dynstate);
|
||||
scm_i_swap_with_fluids (wf, current_thread->dynamic_state);
|
||||
scm_i_set_dynwinds (scm_cons (wf, scm_i_dynwinds ()));
|
||||
NEXT;
|
||||
}
|
||||
|
@ -1645,7 +1645,7 @@ VM_DEFINE_INSTRUCTION (90, unwind_fluids, "unwind-fluids", 0, 0, 0)
|
|||
SCM wf;
|
||||
wf = scm_car (scm_i_dynwinds ());
|
||||
scm_i_set_dynwinds (scm_cdr (scm_i_dynwinds ()));
|
||||
scm_i_swap_with_fluids (wf, dynstate);
|
||||
scm_i_swap_with_fluids (wf, current_thread->dynamic_state);
|
||||
NEXT;
|
||||
}
|
||||
|
||||
|
@ -1655,7 +1655,7 @@ VM_DEFINE_INSTRUCTION (91, fluid_ref, "fluid-ref", 0, 1, 1)
|
|||
SCM fluids;
|
||||
|
||||
CHECK_UNDERFLOW ();
|
||||
fluids = SCM_I_DYNAMIC_STATE_FLUIDS (dynstate);
|
||||
fluids = SCM_I_DYNAMIC_STATE_FLUIDS (current_thread->dynamic_state);
|
||||
if (SCM_UNLIKELY (!SCM_FLUID_P (*sp))
|
||||
|| ((num = SCM_I_FLUID_NUM (*sp)) >= SCM_SIMPLE_VECTOR_LENGTH (fluids)))
|
||||
{
|
||||
|
@ -1683,7 +1683,7 @@ VM_DEFINE_INSTRUCTION (92, fluid_set, "fluid-set", 0, 2, 0)
|
|||
SCM val, fluid, fluids;
|
||||
|
||||
POP2 (val, fluid);
|
||||
fluids = SCM_I_DYNAMIC_STATE_FLUIDS (dynstate);
|
||||
fluids = SCM_I_DYNAMIC_STATE_FLUIDS (current_thread->dynamic_state);
|
||||
if (SCM_UNLIKELY (!SCM_FLUID_P (fluid))
|
||||
|| ((num = SCM_I_FLUID_NUM (fluid)) >= SCM_SIMPLE_VECTOR_LENGTH (fluids)))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue