mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
scm_call_n avoids double TLS lookup
* libguile/vm-engine.c (VM_NAME): Take the current thread as an argument. * libguile/vm.c (scm_i_capture_current_stack): Call thread_vm. (thread_vm): New helper. (scm_the_vm): Call thread_vm. (scm_call_n): Call thread_vm. Avoids a double TLS lookup.
This commit is contained in:
parent
350930756c
commit
b85cd20f80
2 changed files with 23 additions and 13 deletions
|
@ -424,7 +424,8 @@
|
||||||
((scm_t_uintptr) (ptr) % alignof_type (type) == 0)
|
((scm_t_uintptr) (ptr) % alignof_type (type) == 0)
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
VM_NAME (struct scm_vm *vp, SCM program, SCM *argv, size_t nargs_)
|
VM_NAME (scm_i_thread *current_thread, struct scm_vm *vp,
|
||||||
|
SCM program, SCM *argv, size_t nargs_)
|
||||||
{
|
{
|
||||||
/* Instruction pointer: A pointer to the opcode that is currently
|
/* Instruction pointer: A pointer to the opcode that is currently
|
||||||
running. */
|
running. */
|
||||||
|
@ -439,7 +440,6 @@ VM_NAME (struct scm_vm *vp, SCM program, SCM *argv, size_t nargs_)
|
||||||
register scm_t_uint32 op;
|
register scm_t_uint32 op;
|
||||||
|
|
||||||
/* Cached variables. */
|
/* Cached variables. */
|
||||||
scm_i_thread *current_thread = SCM_I_CURRENT_THREAD;
|
|
||||||
scm_i_jmp_buf registers; /* used for prompts */
|
scm_i_jmp_buf registers; /* used for prompts */
|
||||||
|
|
||||||
#ifdef HAVE_LABELS_AS_VALUES
|
#ifdef HAVE_LABELS_AS_VALUES
|
||||||
|
|
|
@ -150,6 +150,7 @@ vm_return_to_continuation (struct scm_vm *vp, SCM cont, size_t n, SCM *argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct scm_vm * thread_vm (scm_i_thread *t);
|
||||||
SCM
|
SCM
|
||||||
scm_i_capture_current_stack (void)
|
scm_i_capture_current_stack (void)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +158,7 @@ scm_i_capture_current_stack (void)
|
||||||
struct scm_vm *vp;
|
struct scm_vm *vp;
|
||||||
|
|
||||||
thread = SCM_I_CURRENT_THREAD;
|
thread = SCM_I_CURRENT_THREAD;
|
||||||
vp = scm_the_vm ();
|
vp = thread_vm (thread);
|
||||||
|
|
||||||
return scm_i_vm_capture_stack (vp->stack_base, vp->fp, vp->sp, vp->ip,
|
return scm_i_vm_capture_stack (vp->stack_base, vp->fp, vp->sp, vp->ip,
|
||||||
scm_dynstack_capture_all (&thread->dynstack),
|
scm_dynstack_capture_all (&thread->dynstack),
|
||||||
|
@ -705,7 +706,7 @@ initialize_default_stack_size (void)
|
||||||
#undef VM_USE_HOOKS
|
#undef VM_USE_HOOKS
|
||||||
#undef VM_NAME
|
#undef VM_NAME
|
||||||
|
|
||||||
typedef SCM (*scm_t_vm_engine) (struct scm_vm *vp,
|
typedef SCM (*scm_t_vm_engine) (scm_i_thread *current_thread, struct scm_vm *vp,
|
||||||
SCM program, SCM *argv, size_t nargs);
|
SCM program, SCM *argv, size_t nargs);
|
||||||
|
|
||||||
static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] =
|
static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] =
|
||||||
|
@ -787,23 +788,32 @@ vm_stack_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
|
||||||
#endif /* VM_ENABLE_PRECISE_STACK_GC_SCAN */
|
#endif /* VM_ENABLE_PRECISE_STACK_GC_SCAN */
|
||||||
|
|
||||||
|
|
||||||
SCM
|
static struct scm_vm *
|
||||||
scm_call_n (SCM proc, SCM *argv, size_t nargs)
|
thread_vm (scm_i_thread *t)
|
||||||
{
|
{
|
||||||
struct scm_vm *vp = scm_the_vm ();
|
if (SCM_UNLIKELY (!t->vp))
|
||||||
SCM_CHECK_STACK;
|
t->vp = make_vm ();
|
||||||
return vm_engines[vp->engine](vp, proc, argv, nargs);
|
|
||||||
|
return t->vp;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct scm_vm *
|
struct scm_vm *
|
||||||
scm_the_vm (void)
|
scm_the_vm (void)
|
||||||
{
|
{
|
||||||
scm_i_thread *t = SCM_I_CURRENT_THREAD;
|
return thread_vm (SCM_I_CURRENT_THREAD);
|
||||||
|
}
|
||||||
|
|
||||||
if (SCM_UNLIKELY (!t->vp))
|
SCM
|
||||||
t->vp = make_vm ();
|
scm_call_n (SCM proc, SCM *argv, size_t nargs)
|
||||||
|
{
|
||||||
|
scm_i_thread *thread;
|
||||||
|
struct scm_vm *vp;
|
||||||
|
|
||||||
return t->vp;
|
thread = SCM_I_CURRENT_THREAD;
|
||||||
|
vp = thread_vm (thread);
|
||||||
|
|
||||||
|
SCM_CHECK_STACK;
|
||||||
|
return vm_engines[vp->engine](thread, vp, proc, argv, nargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scheme interface */
|
/* Scheme interface */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue