1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Eagerly initialize thread VM; remove scm_the_vm

* libguile/threads.c (thread_mark): Unconditionally call
  scm_i_vm_mark_stack.
  (guilify_self_1): Eagerly prepare the thread stack, before entering
  Guile mode.  It's only a page of mmap, after all.
* libguile/vm.c (scm_i_vm_prepare_stack): Rename from init_vm.
  (thread_vm, scm_the_vm): Remove.
  (VM_DEFINE_HOOK, scm_vm_trace_level, scm_set_vm_trace_level_x)
  (scm_vm_engine, scm_c_set_vm_engine_x, scm_i_capture_current_stack)
  (scm_call_n, scm_call_with_stack_overflow_handler): Adapt to get VM
  from thread.
  (scm_i_vm_free_stack): Memset the whole thing to 0 when we're done.
* libguile/control.c (scm_abort_to_prompt_star)
* libguile/eval.c (eval):
* libguile/throw.c (catch, abort_to_prompt): Get VM from thread.
This commit is contained in:
Andy Wingo 2018-06-24 09:32:11 +02:00
parent 2480761bde
commit 7f7169847e
6 changed files with 62 additions and 71 deletions

View file

@ -431,7 +431,7 @@ eval (SCM x, SCM env)
case SCM_M_CALL_WITH_PROMPT:
{
struct scm_vm *vp;
scm_i_thread *t;
SCM k, handler, res;
jmp_buf registers;
const void *prev_cookie;
@ -439,32 +439,32 @@ eval (SCM x, SCM env)
k = EVAL1 (CAR (mx), env);
handler = EVAL1 (CDDR (mx), env);
vp = scm_the_vm ();
t = SCM_I_CURRENT_THREAD;
saved_stack_depth = vp->stack_top - vp->sp;
saved_stack_depth = t->vm.stack_top - t->vm.sp;
/* Push the prompt onto the dynamic stack. */
scm_dynstack_push_prompt (&SCM_I_CURRENT_THREAD->dynstack,
scm_dynstack_push_prompt (&t->dynstack,
SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY,
k,
vp->stack_top - vp->fp,
t->vm.stack_top - t->vm.fp,
saved_stack_depth,
vp->ip,
t->vm.ip,
&registers);
prev_cookie = vp->resumable_prompt_cookie;
prev_cookie = t->vm.resumable_prompt_cookie;
if (setjmp (registers))
{
/* The prompt exited nonlocally. */
vp->resumable_prompt_cookie = prev_cookie;
t->vm.resumable_prompt_cookie = prev_cookie;
scm_gc_after_nonlocal_exit ();
proc = handler;
args = scm_i_prompt_pop_abort_args_x (vp, saved_stack_depth);
args = scm_i_prompt_pop_abort_args_x (&t->vm, saved_stack_depth);
goto apply_proc;
}
res = scm_call_0 (eval (CADR (mx), env));
scm_dynstack_pop (&SCM_I_CURRENT_THREAD->dynstack);
scm_dynstack_pop (&t->dynstack);
return res;
}