summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/vm-engine.c4
-rw-r--r--libguile/vm.c32
2 files changed, 23 insertions, 13 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index b50751116..72bdd53aa 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -424,7 +424,8 @@
((scm_t_uintptr) (ptr) % alignof_type (type) == 0)
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
running. */
@@ -439,7 +440,6 @@ VM_NAME (struct scm_vm *vp, SCM program, SCM *argv, size_t nargs_)
register scm_t_uint32 op;
/* Cached variables. */
- scm_i_thread *current_thread = SCM_I_CURRENT_THREAD;
scm_i_jmp_buf registers; /* used for prompts */
#ifdef HAVE_LABELS_AS_VALUES
diff --git a/libguile/vm.c b/libguile/vm.c
index 3bc1f4a18..0430a0558 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -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_i_capture_current_stack (void)
{
@@ -157,7 +158,7 @@ scm_i_capture_current_stack (void)
struct scm_vm *vp;
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,
scm_dynstack_capture_all (&thread->dynstack),
@@ -705,7 +706,7 @@ initialize_default_stack_size (void)
#undef VM_USE_HOOKS
#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);
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 */
-SCM
-scm_call_n (SCM proc, SCM *argv, size_t nargs)
+static struct scm_vm *
+thread_vm (scm_i_thread *t)
{
- struct scm_vm *vp = scm_the_vm ();
- SCM_CHECK_STACK;
- return vm_engines[vp->engine](vp, proc, argv, nargs);
+ if (SCM_UNLIKELY (!t->vp))
+ t->vp = make_vm ();
+
+ return t->vp;
}
struct scm_vm *
scm_the_vm (void)
{
- scm_i_thread *t = SCM_I_CURRENT_THREAD;
+ return thread_vm (SCM_I_CURRENT_THREAD);
+}
- if (SCM_UNLIKELY (!t->vp))
- t->vp = make_vm ();
+SCM
+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 */