summaryrefslogtreecommitdiff
path: root/darwin_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-05-25 08:41:37 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-05-25 09:54:42 +0300
commitfaa3bafd2da2d814b6ee1e99e38c44f3a54eed10 (patch)
tree9d9d8785e811314b1e0f25fb9d60604e24155aad /darwin_stop_world.c
parent218e2571035ac6cea9633f713b5a4137bc8f3372 (diff)
downloadbdwgc-faa3bafd2da2d814b6ee1e99e38c44f3a54eed10.tar.gz
Ensure GC is initialized when GC_push_all_stacks() is called
(refactoring) Also, remove an unnecessary lock in GC pthread_create (of pthread_support.c), and ensure that GC_thr_init() is called only once. * alloc.c (GC_try_to_collect_inner, GC_collect_a_little_inner, GC_stopped_mark, GC_collect_or_expand, GC_allocobj): Add assertion that GC is initialized. * finalize.c (GC_register_disappearing_link_inner, GC_register_finalizer_inner): Likewise. * mark.c (GC_clear_marks, GC_initiate_gc): Likewise. * mark_rts.c (GC_push_roots): Likewise. * alloc.c (GC_collect_a_little): Call GC_init if GC is not initialized. * alloc.c (GC_expand_hp): Move part of comment to gc.h. * include/gc/gc.h (GC_expand_hp): Reformat comment. * darwin_stop_world.c (GC_push_all_stacks): Replace GC_init() call with the assertion that GC_thr_initialized. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (pthread_create): Likewise. * darwin_stop_world.c (GC_stop_world): Add assertion that GC_thr_initialized. * pthread_stop_world.c (GC_stop_world): Likewise. * win32_threads.c (GC_push_all_stacks): Likewise. * finalize.c (GC_register_finalizer_inner): Add assertion (after LOCK) that obj points to the base address of the object. * include/private/pthread_support.h (GC_thr_initialized): Declare only if GC_ASSERTIONS. * pthread_support.c (GC_thr_initialized): Define only if GC_ASSERTIONS. * win32_threads.c (GC_thr_initialized): Likewise. * pthread_support.c (GC_thr_init): Add assertion that GC_thr_initialized is not set on entry; set GC_thr_initialized only if GC_ASSERTIONS. * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (pthread_create): Remove LOCK/UNLOCK around setup of si. * win32_threads.c (GC_stop_world): Replace ABORT (about GC_thr_initialized) with the assertion. * win32_threads.c (GC_CreateThread): Add assertion that GC_thr_initialized after GC_init_parallel() call. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Remove comment duplicating that in GC_CreateThread. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise.
Diffstat (limited to 'darwin_stop_world.c')
-rw-r--r--darwin_stop_world.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index d0f89a7d..bb468c1d 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -354,8 +354,7 @@ GC_INNER void GC_push_all_stacks(void)
mach_msg_type_number_t listcount = (mach_msg_type_number_t)THREAD_TABLE_SZ;
GC_ASSERT(I_HOLD_LOCK());
- if (!EXPECT(GC_thr_initialized, TRUE))
- GC_thr_init();
+ GC_ASSERT(GC_thr_initialized);
# ifndef DARWIN_DONT_PARSE_STACK
if (GC_query_task_threads) {
@@ -548,6 +547,7 @@ GC_INNER void GC_stop_world(void)
kern_return_t kern_result;
GC_ASSERT(I_HOLD_LOCK());
+ GC_ASSERT(GC_thr_initialized);
# ifdef DEBUG_THREADS
GC_log_printf("Stopping the world from thread %p\n",
(void *)(word)my_thread);