diff options
-rw-r--r-- | libguile/gc-inline.h | 13 | ||||
-rw-r--r-- | libguile/threads.c | 32 | ||||
-rw-r--r-- | libguile/threads.h | 17 |
3 files changed, 27 insertions, 35 deletions
diff --git a/libguile/gc-inline.h b/libguile/gc-inline.h index 62fdb9eec..a1932d65a 100644 --- a/libguile/gc-inline.h +++ b/libguile/gc-inline.h @@ -1,7 +1,7 @@ #ifndef SCM_GC_INLINE_H #define SCM_GC_INLINE_H -/* Copyright 1995-1996,1998-2004,2006-2014,2018 +/* Copyright 1995-1996,1998-2004,2006-2014,2018-2019 Free Software Foundation, Inc. This file is part of Guile. @@ -47,17 +47,6 @@ -#define SCM_INLINE_GC_GRANULE_WORDS 2 -#define SCM_INLINE_GC_GRANULE_BYTES \ - (sizeof(void *) * SCM_INLINE_GC_GRANULE_WORDS) - -/* A freelist set contains SCM_INLINE_GC_FREELIST_COUNT pointers to - singly linked lists of objects of different sizes, the ith one - containing objects i + 1 granules in size. This setting of - SCM_INLINE_GC_FREELIST_COUNT will hold freelists for allocations of - up to 256 bytes. */ -#define SCM_INLINE_GC_FREELIST_COUNT (256U / SCM_INLINE_GC_GRANULE_BYTES) - static inline size_t scm_inline_gc_bytes_to_freelist_index (size_t bytes) { diff --git a/libguile/threads.c b/libguile/threads.c index 0e010629d..86ac5e84b 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -1,4 +1,4 @@ -/* Copyright 1995-1998,2000-2014,2018 +/* Copyright 1995-1998,2000-2014,2018-2019 Free Software Foundation, Inc. This file is part of Guile. @@ -99,20 +99,16 @@ thread_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr, but GC doesn't know to trace them (as they are pointerless), so we need to do that here. See the comments at the top of libgc's gc_inline.h. */ - if (t->pointerless_freelists) + for (size_t n = 0; n < SCM_INLINE_GC_FREELIST_COUNT; n++) { - size_t n; - for (n = 0; n < SCM_INLINE_GC_FREELIST_COUNT; n++) + void *chain = t->pointerless_freelists[n]; + if (chain) { - void *chain = t->pointerless_freelists[n]; - if (chain) - { - /* The first link is already marked by the freelist vector, - so we just have to mark the tail. */ - while ((chain = *(void **)chain)) - mark_stack_ptr = GC_mark_and_push (chain, mark_stack_ptr, - mark_stack_limit, NULL); - } + /* The first link is already marked by the thread itsel, so we + just have to mark the tail. */ + while ((chain = *(void **)chain)) + mark_stack_ptr = GC_mark_and_push (chain, mark_stack_ptr, + mark_stack_limit, NULL); } } @@ -443,12 +439,6 @@ guilify_self_2 (SCM dynamic_state) t->continuation_root = scm_cons (t->handle, SCM_EOL); t->continuation_base = t->base; - { - size_t size = SCM_INLINE_GC_FREELIST_COUNT * sizeof (void *); - t->freelists = scm_gc_malloc (size, "freelists"); - t->pointerless_freelists = scm_gc_malloc (size, "atomic freelists"); - } - t->dynamic_state = scm_gc_typed_calloc (scm_t_dynamic_state); t->dynamic_state->thread_local_values = scm_c_make_hash_table (0); scm_set_current_dynamic_state (dynamic_state); @@ -508,8 +498,8 @@ on_thread_exit (void *v) /* Although this thread has exited, the thread object might still be alive. Release unused memory. */ - t->freelists = NULL; - t->pointerless_freelists = NULL; + for (size_t n = 0; n < SCM_INLINE_GC_FREELIST_COUNT; n++) + t->freelists[n] = t->pointerless_freelists[n] = NULL; t->dynamic_state = NULL; t->dynstack.base = NULL; t->dynstack.top = NULL; diff --git a/libguile/threads.h b/libguile/threads.h index d3de35b0b..337dc83a9 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -39,6 +39,19 @@ +#define SCM_INLINE_GC_GRANULE_WORDS 2 +#define SCM_INLINE_GC_GRANULE_BYTES \ + (sizeof(void *) * SCM_INLINE_GC_GRANULE_WORDS) + +/* A freelist set contains SCM_INLINE_GC_FREELIST_COUNT pointers to + singly linked lists of objects of different sizes, the ith one + containing objects i + 1 granules in size. This setting of + SCM_INLINE_GC_FREELIST_COUNT will hold freelists for allocations of + up to 256 bytes. */ +#define SCM_INLINE_GC_FREELIST_COUNT (256U / SCM_INLINE_GC_GRANULE_BYTES) + + + /* smob tags for the thread datatypes */ SCM_API scm_t_bits scm_tc16_thread; SCM_API scm_t_bits scm_tc16_mutex; @@ -60,8 +73,8 @@ struct scm_thread { not be run. */ /* Thread-local freelists; see gc-inline.h. */ - void **freelists; - void **pointerless_freelists; + void *freelists[SCM_INLINE_GC_FREELIST_COUNT]; + void *pointerless_freelists[SCM_INLINE_GC_FREELIST_COUNT]; SCM handle; scm_i_pthread_t pthread; |