summaryrefslogtreecommitdiff
path: root/pthread_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-09-30 07:51:42 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-09-30 07:51:42 +0300
commit48a01ee1c93817eb1dfc772f77ac4abbd5fa0a56 (patch)
tree061d35ae13e4fe45ecee815325ec7d13063525cc /pthread_stop_world.c
parent6a584e0afb6f7ed74d6b8d57b198b65427403d3a (diff)
downloadbdwgc-48a01ee1c93817eb1dfc772f77ac4abbd5fa0a56.tar.gz
Consistent naming of GC_thread local variables
(refactoring) Also, change "while" to "for" statement to iterate over GC_threads. * darwin_stop_world.c (GC_stack_range_for): Add pfound_me argument; update comment; set *pfound_me to TRUE if thread is my_thread. * win32_threads.c (GC_push_stack_for): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Do not define listcount local variable if DARWIN_DONT_PARSE_STACK. * darwin_stop_world.c (GC_push_all_stacks): Pass &found_me to GC_stack_range_for (instead of setting it to TRUE directly). * win32_threads.c (GC_push_all_stacks): Likewise. * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK] (GC_push_all_stacks): Do not initialize act_list and listcount local variables. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && THREAD_SANITIZER] (GC_lookup_thread_async): Change while statement to for one. * pthread_support.c [DEBUG_THREADS] (GC_count_threads): Likewise. * pthread_support.c (GC_lookup_thread): Likewise. * win32_threads.c (GC_lookup_thread_inner, GC_delete_thread): Likewise. * pthread_stop_world.c (GC_push_all_stacks): Define and use is_self local variable. * win32_threads.c (GC_push_stack_for): Likewise. * pthread_support.c [DEBUG_THREADS] (GC_count_threads): Rename th local variable to p. * win32_threads.c (GC_Thread_Rep.thread_blocked_sp, GC_lookup_pthread): Refine comment. * win32_threads.c (GC_new_thread, GC_delete_thread): Rename id argument to thread_id. * win32_threads.c (GC_lookup_pthread): Remove GC_lookup_pthread label. * win32_threads.c (GC_lookup_thread_inner): Reformat comment. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_lookup_thread_inner): Define and use t local variable. * win32_threads.c (GC_stop_world, GC_start_world, GC_push_all_stacks, GC_get_next_stack): Rename t to p local variable. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_stop_world): Change type of t local from GC_vthread to GC_thread.
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r--pthread_stop_world.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index 77f4b77d..01292fac 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -291,8 +291,9 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy, void *context);
{
GC_thread p = GC_threads[THREAD_TABLE_INDEX(id)];
- while (p != NULL && !THREAD_EQUAL(p->id, id))
- p = p->next;
+ for (; p != NULL; p = p -> next) {
+ if (THREAD_EQUAL(p -> id, id)) break;
+ }
return p;
}
#else
@@ -797,6 +798,8 @@ GC_INNER void GC_push_all_stacks(void)
# endif
for (i = 0; i < THREAD_TABLE_SZ; i++) {
for (p = GC_threads[i]; p != 0; p = p -> next) {
+ GC_bool is_self = FALSE;
+
if (p -> flags & FINISHED) continue;
++nthreads;
traced_stack_sect = p -> traced_stack_sect;
@@ -818,6 +821,7 @@ GC_INNER void GC_push_all_stacks(void)
}
# endif
# endif
+ is_self = TRUE;
found_me = TRUE;
} else {
lo = (ptr_t)AO_load((volatile AO_t *)&p->stop_info.stack_ptr);
@@ -872,11 +876,10 @@ GC_INNER void GC_push_all_stacks(void)
# endif
# ifdef E2K
if ((GC_stop_count & THREAD_RESTARTED) != 0
- && (p -> flags & DO_BLOCKING) == 0
# ifdef GC_ENABLE_SUSPEND_THREAD
&& (p -> stop_info.ext_suspend_cnt & 1) == 0
# endif
- && !THREAD_EQUAL(p -> id, self))
+ && !is_self && (p -> flags & DO_BLOCKING) == 0)
continue; /* procedure stack buffer has already been freed */
# endif
# if defined(E2K) || defined(IA64)
@@ -885,15 +888,14 @@ GC_INNER void GC_push_all_stacks(void)
(void *)p->id, (void *)bs_lo, (void *)bs_hi);
# endif
GC_ASSERT(bs_lo != NULL && bs_hi != NULL);
- /* FIXME: This (if p->id==self) may add an unbounded number of */
- /* entries, and hence overflow the mark stack, which is bad. */
- GC_push_all_register_sections(bs_lo, bs_hi,
- THREAD_EQUAL(p -> id, self),
+ /* FIXME: This (if is_self) may add an unbounded number of */
+ /* entries, and hence overflow the mark stack, which is bad. */
+ GC_push_all_register_sections(bs_lo, bs_hi, is_self,
traced_stack_sect);
total_size += bs_hi - bs_lo; /* bs_lo <= bs_hi */
# endif
# ifdef E2K
- if (THREAD_EQUAL(p -> id, self))
+ if (is_self)
FREE_PROCEDURE_STACK_LOCAL(bs_lo, (size_t)(bs_hi - bs_lo));
# endif
}