summaryrefslogtreecommitdiff
path: root/libguile/threads.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-06-24 09:32:11 +0200
committerAndy Wingo <wingo@pobox.com>2018-06-25 17:49:50 +0200
commit7f7169847ee047d585b7c9ca6c56e991aaf74edc (patch)
tree3fddcad520b143bcb1da2a04ee8c85d2fffcfdcc /libguile/threads.c
parent2480761bde7d55ef05cc11eb49902ede84c70a0a (diff)
downloadguile-7f7169847ee047d585b7c9ca6c56e991aaf74edc.tar.gz
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.
Diffstat (limited to 'libguile/threads.c')
-rw-r--r--libguile/threads.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libguile/threads.c b/libguile/threads.c
index 2a318783a..69587ce52 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -114,9 +114,8 @@ thread_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
}
}
- if (t->vm.stack_bottom)
- mark_stack_ptr = scm_i_vm_mark_stack (&t->vm, mark_stack_ptr,
- mark_stack_limit);
+ mark_stack_ptr = scm_i_vm_mark_stack (&t->vm, mark_stack_ptr,
+ mark_stack_limit);
return mark_stack_ptr;
}
@@ -391,6 +390,7 @@ guilify_self_1 (struct GC_stack_base *base, int needs_unregister)
t.continuation_root = SCM_EOL;
t.continuation_base = t.base;
scm_i_pthread_cond_init (&t.sleep_cond, NULL);
+ scm_i_vm_prepare_stack (&t.vm);
if (pipe2 (t.sleep_pipe, O_CLOEXEC) != 0)
/* FIXME: Error conditions during the initialization phase are handled
@@ -491,6 +491,10 @@ on_thread_exit (void *v)
}
thread_count--;
+ /* Prevent any concurrent or future marker from visiting this
+ thread. */
+ t->handle = SCM_PACK (0);
+
/* If there's only one other thread, it could be the signal delivery
thread, so we need to notify it to shut down by closing its read pipe.
If it's not the signal delivery thread, then closing the read pipe isn't