summaryrefslogtreecommitdiff
path: root/darwin_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-12-11 11:16:30 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-12-11 11:23:02 +0300
commit7eb49a4e623cd6a73c595b077697702e345ce00a (patch)
tree615efaa3981369764c8278c29834882a5941c232 /darwin_stop_world.c
parent99a571390d13d93f4fe321c40bd22759518e4ca4 (diff)
downloadbdwgc-7eb49a4e623cd6a73c595b077697702e345ce00a.tar.gz
Move stack-related fields out of GC_thread to GC_stack_context_t
(refactoring) Issue #362 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Define and crtn local variable; use crtn instead of p to access stack_ptr, topOfStack, stack_end, altstack, altstack_size, normstack, normstack_size, backing_store_end, backing_store_ptr. * pthread_stop_world.c [!NACL] (GC_suspend_handler_inner, GC_push_all_stacks): Likewise. * pthread_support.c [!GC_NO_FINALIZATION] (GC_reset_finalizer_nested, GC_check_finalizer_nested): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack): Likewise. * pthread_support.c (do_blocking_enter, do_blocking_leave, GC_set_stackbottom, GC_get_my_stackbottom, GC_call_with_gc_active): Likewise. * win32_threads.c (GC_push_stack_for, GC_get_next_stack): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Use p->crtn instead of p to access traced_stack_sect. * win32_threads.c (GC_suspend, GC_stop_world, GC_start_world): Likewise. * include/private/pthread_support.h (GC_StackContext_Rep): New struct type (move dummy, stack_end, stack_ptr, last_stack_min, initial_stack_base, topOfStack, backing_store_end, backing_store_ptr, altstack, altstack_size, normstack, normstack_size, finalizer_nested, finalizer_skipped, traced_stack_sect from GC_Thread_Rep). * include/private/pthread_support.h [!GC_NO_THREADS_DISCOVERY && GC_WIN32_THREADS] (GC_StackContext_Rep.stack_end): Add volatile. * include/private/pthread_support.h [!GC_NO_FINALIZATION] (GC_StackContext_Rep.fnlz_pad): New field. * include/private/pthread_support.h (GC_stack_context_t): New type. * include/private/pthread_support.h (GC_Thread_Rep.crtn, GC_Thread_Rep.flags_pad): New field. * include/private/pthread_support.h [GC_NO_FINALIZATION] (GC_Thread_Rep.no_fnlz_pad): Remove field. * include/private/pthread_support.h (GC_threads): Move (and refine) comment from GC_Thread_Rep. * include/private/pthread_support.h [GC_WIN32_THREADS] (GC_record_stack_base): Change me argument to crtn. * pthread_stop_world.c [!NACL] (GC_store_stack_ptr): Likewise. * pthread_support.c (GC_record_stack_base): Likewise. * pthread_stop_world.c [NACL] (NACL_STORE_REGS, nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Use p->crtn instead of p to access stack_ptr. * pthread_support.c (first_crtn): New static variable. * pthread_support.c (first_thread): Update comment. * pthread_support.c (first_thread_used): Remove variable. * pthread_support.c (GC_push_thread_structures): Push first_thread.crtn symbol * pthread_support.c (GC_push_thread_structures): Push first_crtn.backing_store_end instead of that in first_thread. * pthread_support.c [MPROTECT_VDB && GC_WIN32_THREADS] (GC_win32_unprotect_thread): Call GC_remove_protection() for t->crtn. * pthread_support.c (GC_new_thread): Use first_thread.crtn!=0 instead of first_thread_used; set first_thread.crtn to &first_crtn; allocate GC_StackContext_Rep object using GC_INTERNAL_MALLOC() and store the pointer to result->crtn. * pthread_support.c [CPPCHECK] (GC_new_thread): Call GC_noop1() for first_thread.flags_pad, for first_crtn.dummy instead of result->dummy, and for first_crtn.fnlz_pad instead of result->no_fnlz_pad. * pthread_support.c (GC_delete_thread): Call GC_INTERNAL_FREE(p->crtn) along with that for p. * pthread_support.c [CAN_HANDLE_FORK && (!THREAD_SANITIZER || !CAN_CALL_ATFORK)] (GC_remove_all_threads_but_me): Likewise. * pthread_support.c [GC_PTHREADS] (GC_pthread_join, GC_pthread_detach): Likewise. * pthread_support.c (GC_segment_is_thread_stack, GC_greatest_stack_base_below): Use p->crtn instead of p to access stack_end. * pthread_support.c (GC_call_with_gc_active): Move assertions about me fields to be after LOCK; add assertion that me->crtn==crtn. * win32_threads.c (dll_thread_table): Make it static. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (dll_crtn_table): New static variable. * win32_threads.c (GC_register_my_thread_inner): Reformat comment; set me->crtn. * win32_threads.c (GC_push_stack_for): Define stack_end local variable; immediately return (zero) if stack_end is NULL. * win32_threads.c (GC_push_all_stacks): Call GC_push_stack_for() (and increment nthreads) even if stack_end is NULL. * win32_threads.c (GC_get_next_stack): Rename s local variable to stack_end.
Diffstat (limited to 'darwin_stop_world.c')
-rw-r--r--darwin_stop_world.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index 35d2aaa5..5debf480 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -142,6 +142,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
mach_port_t my_thread, ptr_t *paltstack_lo,
ptr_t *paltstack_hi, GC_bool *pfound_me)
{
+ GC_stack_context_t crtn = p -> crtn;
ptr_t lo;
if (thread == my_thread) {
@@ -152,9 +153,9 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
# endif
*pfound_me = TRUE;
} else if (p != NULL && (p -> flags & DO_BLOCKING) != 0) {
- lo = p -> stack_ptr;
+ lo = crtn -> stack_ptr;
# ifndef DARWIN_DONT_PARSE_STACK
- *phi = p -> topOfStack;
+ *phi = crtn -> topOfStack;
# endif
} else {
@@ -326,14 +327,14 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
UNUSED_ARG(paltstack_hi);
# else
/* p is guaranteed to be non-NULL regardless of GC_query_task_threads. */
- *phi = EXPECT((p->flags & MAIN_THREAD) == 0, TRUE) ? p->stack_end
+ *phi = EXPECT((p -> flags & MAIN_THREAD) == 0, TRUE) ? crtn -> stack_end
: GC_stackbottom;
- if (p->altstack != NULL && (word)p->altstack <= (word)lo
- && (word)lo <= (word)p->altstack + p->altstack_size) {
+ if (crtn -> altstack != NULL && (word)(crtn -> altstack) <= (word)lo
+ && (word)lo <= (word)(crtn -> altstack) + crtn -> altstack_size) {
*paltstack_lo = lo;
- *paltstack_hi = p->altstack + p->altstack_size;
- lo = p->normstack;
- *phi = lo + p->normstack_size;
+ *paltstack_hi = crtn -> altstack + crtn -> altstack_size;
+ lo = crtn -> normstack;
+ *phi = lo + crtn -> normstack_size;
} else
# endif
/* else */ {
@@ -404,7 +405,7 @@ GC_INNER void GC_push_all_stacks(void)
if (lo) {
GC_ASSERT((word)lo <= (word)hi);
total_size += hi - lo;
- GC_push_all_stack_sections(lo, hi, p->traced_stack_sect);
+ GC_push_all_stack_sections(lo, hi, p -> crtn -> traced_stack_sect);
}
if (altstack_lo) {
total_size += altstack_hi - altstack_lo;