mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-06 17:40:29 +02:00
Refactor relationship between gc_mutator_roots and threads
* libguile/threads.c (guilify_self_1): * libguile/whippet-embedder.h (gc_trace_mutator_pinned_roots): Make the roots contain the thread. This way sizeof(*thread) is the total allocation size; if you pad the allocation with extra words, some of the self-checks in nofl get borked.
This commit is contained in:
parent
e23adeafd3
commit
75f1f20031
2 changed files with 5 additions and 13 deletions
|
@ -359,22 +359,15 @@ static int thread_count;
|
|||
|
||||
static SCM default_dynamic_state;
|
||||
|
||||
struct scm_thread_and_roots
|
||||
{
|
||||
struct scm_thread thread;
|
||||
struct gc_mutator_roots roots;
|
||||
};
|
||||
|
||||
/* Perform first stage of thread initialisation, in non-guile mode.
|
||||
*/
|
||||
static void
|
||||
guilify_self_1 (struct gc_mutator *mut, struct gc_stack_addr base,
|
||||
int needs_unregister)
|
||||
{
|
||||
struct scm_thread_and_roots *thread_and_roots =
|
||||
gc_allocate (mut, sizeof (*thread_and_roots), GC_ALLOCATION_TAGGED);
|
||||
scm_thread *t = &thread_and_roots->thread;
|
||||
struct gc_mutator_roots *roots = &thread_and_roots->roots;
|
||||
struct gc_mutator_roots *roots =
|
||||
gc_allocate (mut, sizeof (*roots), GC_ALLOCATION_TAGGED);
|
||||
scm_thread *t = &roots->thread;
|
||||
|
||||
/* We'll be referring to this object from thread-locals and other
|
||||
places that are gnarly to relocate. */
|
||||
|
@ -410,7 +403,6 @@ guilify_self_1 (struct gc_mutator *mut, struct gc_stack_addr base,
|
|||
scm_i_current_thread = t;
|
||||
#endif
|
||||
|
||||
roots->thread = t;
|
||||
gc_mutator_set_roots (mut, roots);
|
||||
|
||||
scm_i_pthread_mutex_lock (&thread_admin_mutex);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
struct scm_thread;
|
||||
struct gc_mutator_roots {
|
||||
struct scm_thread *thread;
|
||||
struct scm_thread thread;
|
||||
};
|
||||
|
||||
#define GC_EMBEDDER_EPHEMERON_HEADER uintptr_t tag;
|
||||
|
@ -129,7 +129,7 @@ gc_trace_mutator_pinned_roots (struct gc_mutator_roots *roots,
|
|||
void *trace_data),
|
||||
struct gc_heap *heap,
|
||||
void *trace_data) {
|
||||
scm_trace_thread_roots (roots->thread, trace_pinned, trace_ambiguous,
|
||||
scm_trace_thread_roots (&roots->thread, trace_pinned, trace_ambiguous,
|
||||
heap, trace_data);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue