summaryrefslogtreecommitdiff
path: root/darwin_stop_world.c
Commit message (Collapse)AuthorAgeFilesLines
* Add assertion to verify GC_threads hash table entries are chained properlyIvan Maidanski2023-04-061-1/+3
| | | | | | | | | (refactoring) * darwin_stop_world.c (GC_push_all_stacks): Add assertion that thread entry is located in the proper hash table chain (by id). * pthread_stop_world.c (GC_push_all_stacks): Likewise. * win32_threads.c (GC_push_all_stacks): Likewise.
* Remove MAIN_THREAD flag in GC_threadIvan Maidanski2023-03-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Do not check MAIN_THREAD bit of p->flags. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Likewise. * darwin_stop_world.c (GC_stack_range_for): Do not use GC_stackbottom. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_get_my_stackbottom): Likewise. * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Do not check GC_stackbottom if THREADS. * include/gc/gc.h (GC_stackbottom): Refine comment (mention that it could be change only before GC initialization if multi-threaded, mention GC_set_stackbottom). * include/private/gcconfig.h [IA64 && (HPUX || LINUX)] (BACKING_STORE_BASE): Remove. * include/private/pthread_support.h [!GC_WIN32_THREADS] (MAIN_THREAD): Likewise. * mark_rts.c [!THREADS && IA64] (GC_push_current_stack): Use GC_register_stackbottom instead of BACKING_STORE_BASE. * pthread_stop_world.c [IA64] (GC_push_all_stacks): Do not use BACKING_STORE_BASE (GC_register_stackbottom). * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Do not set MAIN_THREAD bit of me->flags. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom): Move crtn local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom): Do not set GC_stackbottom (and GC_register_stackbottom) if GC is initialized. * pthread_support.c [!GC_WIN32_THREADS && IA64] (GC_get_my_stackbottom): Do not use GC_register_stackbottom. * pthread_support.c (GC_call_with_gc_active): Move stack_end local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Do not use and set GC_stackbottom.
* Fix 'unused crtn var' and 'possible null dereference' cppcheck warningsIvan Maidanski2023-01-011-1/+6
| | | | | | | | | | | (fix of commits 7eb49a4e6, 128c0ec3) Issue #362 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Define crtn local variable only if DARWIN_DONT_PARSE_STACK. * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK && CPPCHECK] (GC_stack_range_for): Call ABORT if p is NULL (before crtn = p->crtn).
* Fix possible null pointer dereference in GC_stack_range_forIvan Maidanski2022-12-111-3/+4
| | | | | | | | | | (fix of commit 7eb49a4e6) Issue #362 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Do not set crtn local variable value until p is guaranteed to be non-NULL (i.e., do not set crtn value unless DARWIN_DONT_PARSE_STACK).
* Move stack-related fields out of GC_thread to GC_stack_context_tIvan Maidanski2022-12-111-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Use EXPECT() in checks of MAIN_THREAD bitIvan Maidanski2022-10-141-2/+2
| | | | | | | | | | | | (refactoring) * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK] (GC_stack_range_for): Expect (p->flags&MAIN_THREAD)==0. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom, GC_call_with_gc_active): Likewise. * pthread_support.c [E2K] (GC_get_my_stackbottom): Avoid code duplication (sb->reg_base=NULL).
* Move GC_NO_THREADS_DISCOVERY definition to gcconfig.hIvan Maidanski2022-10-061-1/+1
| | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_use_threads_discovery): Do not check DARWIN_DONT_PARSE_STACK. * include/private/gcconfig.h [!GC_NO_THREADS_DISCOVERY] (GC_NO_THREADS_DISCOVERY): Define macro (where the mode is unsupported); move comment from win32_threads.c. * include/private/gcconfig.h [GC_DISCOVER_TASK_THREADS && GC_NO_THREADS_DISCOVERY && !CPPCHECK]: Issue error. * win32_threads.c: Replace ((GC_DLL||GC_INSIDE_DLL) && !NO_CRT && !GC_NO_THREADS_DISCOVERY && !MSWINCE && !THREAD_LOCAL_ALLOC && !GC_PTHREADS) with !GC_NO_THREADS_DISCOVERY.
* Change GC_Thread_Rep in pthread_support.h to match that of win32_threads.cIvan Maidanski2022-10-061-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for, GC_push_all_stacks, GC_stop_world, GC_start_world): Remove "stop_info." prefix. * pthread_stop_world.c (GC_store_stack_ptr, GC_suspend_handler_inner, GC_push_all_stacks, GC_suspend_all, GC_stop_world): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_self_inner, GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended, GC_suspend_self_blocked): Likewise. * pthread_support.c (GC_restart_all, GC_delete_thread, GC_delete_gc_thread, GC_remove_all_threads_but_me, GC_thr_init, do_blocking_enter, GC_do_blocking_inner, GC_call_with_gc_active, GC_record_stack_base, GC_register_my_thread_inner): Likewise. * darwin_stop_world.c (GC_push_all_stacks, GC_stop_world, GC_start_world): Replace p->next to p->tm.next. * pthread_stop_world.c [THREAD_SANITIZER] (GC_lookup_thread_async): Likewise. * pthread_stop_world.c (GC_suspend_all, GC_restart_all): Likewise. * pthread_support.c (GC_mark_thread_local_free_lists, GC_check_tls, GC_count_threads, GC_new_thread, GC_delete_thread, GC_delete_gc_thread, GC_lookup_thread, GC_remove_all_threads_but_me, GC_segment_is_thread_stack, GC_greatest_stack_base_below): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Replace p->flags&FINISHED to KNOWN_FINISHED(p). * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (GC_mark_thread_local_free_lists, GC_check_tls, GC_count_threads, GC_remove_all_threads_but_me, GC_set_stackbottom, GC_unregister_my_thread_inner, pthread_join, pthread_detach, GC_register_my_thread_inner): Likewise. * include/private/pthread_support.h [GC_DARWIN_THREADS || PTHREAD_STOP_WORLD_IMPL] (thread_stop_info): Remove struct. * include/private/pthread_support.h [GC_DARWIN_THREADS] (GC_FindTopOfStack, GC_is_mach_marker): Move declaration down. * include/private/pthread_support.h [PTHREAD_STOP_WORLD_IMPL] (GC_stop_init): Likewise. * include/private/pthread_support.h (thread_id_t): New type. * include/private/pthread_support.h (GC_Thread_Rep): Refine comment. * include/private/pthread_support.h (GC_Thread_Rep.next): Put field into union tm. * include/private/pthread_support.h (GC_Thread_Rep.id): Change type from pthread_t to thread_id_t. * pthread_support.c (main_pthread_id): Likewise. * include/private/pthread_support.h (GC_Thread_Rep.stack_end): Move field upper. * include/private/pthread_support.h [GC_DARWIN_THREADS && !DARWIN_DONT_PARSE_STACK] (GC_Thread_Rep.topOfStack): Likewise. * include/private/pthread_support.h (GC_Thread_Rep.stop_info): Replace with stack_ptr, mach_thread (if GC_DARWIN_THREADS), last_stop_count (if SIGNAL_BASED_STOP_WORLD), ext_suspend_cnt (if SIGNAL_BASED_STOP_WORLD and GC_ENABLE_SUSPEND_THREAD). * include/private/pthread_support.h [!GC_NO_FINALIZATION] (finalizer_skipped, finalizer_nested): Move fields upper (to be right before flags one). * include/private/pthread_support.h (KNOWN_FINISHED): New macro (copied from win32_threads.c). * include/private/pthread_support.h [NACL] (NACL_GC_REG_STORAGE_SIZE, GC_Thread_Rep.reg_storage, GC_Thread_Rep.registers): Move from stop_info. * include/private/pthread_support.h (GC_lookup_thread): Change argument type from pthread_t to thread_id_t. * pthread_stop_world.c [THREAD_SANITIZER] (GC_lookup_thread_async): Likewise. * pthread_support.c (GC_delete_thread, GC_lookup_thread): Likewise. * pthread_support.c (GC_new_thread): Do not set id field (to match that in win32_threads.c); update comment. * pthread_support.c (GC_delete_gc_thread, GC_thread_is_registered, GC_register_altstack, GC_remove_all_threads_but_me, GC_thr_init, GC_get_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread): Change type of id local variable from pthread_t to thread_id_t. * pthread_support.c (GC_lookup_thread): Refine comment. * pthread_support.c (do_blocking_enter): Rename stack_ptr local variable to bs_hi. * pthread_support.c (GC_register_my_thread_inner): Rename my_pthread argument to self.
* Remove private pthread_stop_world.h and darwin_stop_world.hIvan Maidanski2022-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * Makefile.direct (SRCS): Remove pthread_stop_world.h and darwin_stop_world.h items. * include/include.am (dist_noinst_HEADERS): Likewise. * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY && MPROTECT_VDB] (GC_darwin_register_mach_handler_thread): Change to no-argument GC_darwin_register_self_mach_handler(). * include/private/darwin_stop_world.h: Remove. * include/private/pthread_stop_world.h: Likewise. * include/private/gc_priv.h [GC_DARWIN_THREADS && MPROTECT_VDB] (GC_mprotect_stop, GC_mprotect_resume): Move declaration from darwin_stop_world.h. * include/private/gc_priv.h [GC_DARWIN_THREADS && MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Move declaration from darwin_stop_world.h and change to GC_darwin_register_self_mach_handler(). * include/private/pthread_support.h [GC_DARWIN_THREADS]: Move include of mach.h and thread_act.h from darwin_stop_world.h. * include/private/pthread_support.h [GC_DARWIN_THREADS]: Do not include darwin_stop_world.h. * os_dep.c [GC_DARWIN_THREADS && MPROTECT_VDB]: Likewise. * include/private/pthread_support.h [GC_DARWIN_THREADS] (thread_stop_info, GC_FindTopOfStack, GC_is_mach_marker): Move from darwin_stop_world.h. * include/private/pthread_support.h [!GC_DARWIN_THREADS && PTHREAD_STOP_WORLD_IMPL]: Do not include pthread_stop_world.h. * include/private/pthread_support.h [!GC_DARWIN_THREADS && PTHREAD_STOP_WORLD_IMPL] (thread_stop_info, GC_stop_init): Move from pthread_stop_world.h. * os_dep.c [MPROTECT_VDB && DARWIN && THREADS && !GC_NO_THREADS_DISCOVERY] (GC_mprotect_thread): Call GC_darwin_register_self_mach_handler() instead of GC_darwin_register_mach_handler_thread(mach_thread_self()).
* Rename stack[_size] in GC_Thread_Rep and GC_register_altstackIvan Maidanski2022-10-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK] (GC_stack_range_for): Rename p->stack[_size] to p->normstack[_size]. * pthread_support.c (GC_thr_init): Likewise. * include/gc/gc.h (GC_register_altstack): Rename stack_start to normstack and stack_size to normstack_size in comment, respectively. * include/private/pthread_support.h (GC_Thread_Rep.stack): Rename to normstack. * include/private/pthread_support.h (GC_Thread_Rep.stack_size): Rename to normstack_size. * pthread_support.c (main_stack): Rename to main_normstack. * pthread_support.c (main_stack_size): Rename to main_normstack_size. * pthread_support.c (GC_register_altstack): Rename stack to normstack and stack_size to normstack_size arguments, respectively. * win32_threads.c (GC_register_altstack): Likewise. * pthread_support.c [(HAVE_PTHREAD_ATTR_GET_NP || HAVE_PTHREAD_GETATTR_NP) && IA64]: Change stack_base to "stack base" in comment.
* Consistent naming of GC_thread local variablesIvan Maidanski2022-09-301-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Use cast to void instead of the attribute to indicate unused argumentsIvan Maidanski2022-09-151-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * CMakeLists.txt [BORLAND] (add_compile_options): Remove "/w-par"; reorder options. * CMakeLists.txt [!BORLAND && MSVC] (add_compile_options): Remove "/wd4100"; update comment. * NT_MAKEFILE (.c.obj): Likewise. * allchblk.c [!NO_DEBUGGING || GC_ASSERTIONS] (add_hb_sz): Use UNUSED_ARG() instead of GC_ATTR_UNUSED. * allchblk.c [USE_MUNMAP] (GC_adjust_num_unmapped): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (pop_in_progress, reset_back_edge, update_max_height): Likewise. * checksums.c [CHECKSUMS] (GC_add_block): Likewise. * darwin_stop_world.c (GC_stack_range_for): Likewise. * dbg_mlc.c (GC_store_debug_info_inner, GC_debug_change_stubborn, GC_check_heap_block): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_null_finalize_mark_proc): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_fake_mark_proc): Likewise. * mallocx.c [!CPPCHECK] (GC_change_stubborn): Likewise. * mark.c (GC_noop6, clear_marks_for_block): Likewise. * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (mark_ex_handler): Likewise. * mark.c [GC_DISABLE_INCREMENTAL] (GC_push_conditional): Likewise. * mark_rts.c (GC_push_current_stack, GC_push_roots): Likewise. * misc.c (GC_default_oom_fn, GC_set_handle_fork): Likewise. * misc.c [THREADS && !SIGNAL_BASED_STOP_WORLD] (GC_set_suspend_signal, GC_set_thr_restart_signal): Likewise. * misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (callee_saves_pushed_dummy_fn): Likewise. * misc.c [!THREADS] (GC_do_blocking_inner): Likewise. * misc.c [!PARALLEL_MARK] (GC_set_markers_count): Likewise. * os_dep.c [OPENBSD] (GC_fault_handler_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || WRAP_MARK_SOME && !MSWIN32 && !MSWINCE || USE_PROC_FOR_LIBRARIES && THREADS] (GC_fault_handler): Likewise. * os_dep.c [!HAVE_GET_STACK_BASE && !NEED_FIND_LIMIT] (GC_get_stack_base): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state, catch_exception_raise_state_identity, catch_exception_raise): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && !SUSPEND_HANDLER_NO_CONTEXT] (GC_suspend_sigaction): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_suspend_handler_inner): Likewise. * pthread_support.c (GC_do_blocking_inner): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Likewise. * tests/gctest.c [!DBG_HDRS_ALL] (fail_proc1): Likewise. * tests/gctest.c [(MSWIN32 && !__MINGW32__ || MSWINCE) && !NO_WINMAIN_ENTRY] (WinMain): Likewise. * tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK && RTEMS] (Init): Likewise. * tests/gctest.c [GC_WIN32_THREADS && !GC_PTHREADS] (thr_run_one_test): Likewise. * tests/gctest.c [MSWINCE] (thr_window): Likewise. * tests/gctest.c [GC_PTHREADS] (thr_run_one_test): Likewise. * typd_mlc.c (GC_array_mark_proc): Likewise. * win32_threads.c (GC_register_altstack, GC_do_blocking_inner): Likewise. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * cord/cordxtra.c (CORD_ATTR_UNUSED): Remove. * include/private/gc_priv.h [!GC_ATTR_UNUSED] (GC_ATTR_UNUSED): Likewise. * cord/cordxtra.c (CORD_nul_func): Cast unused argument to void instead of using CORD_ATTR_UNUSED. * cord/cordxtra.c [!GC_NO_FINALIZATION] (CORD_lf_close_proc): Likewise. * include/private/gc_priv.h [!UNUSED_ARG] (UNUSED_ARG): Define macro.
* Call GC_init_parallel only from GC_initIvan Maidanski2022-05-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY && !DARWIN_DONT_PARSE_STACK] (GC_use_threads_discovery): Call GC_init() instead of GC_init_parallel(). * pthread_support.c (pthread_create): Likewise. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_use_threads_discovery): Likewise. * win32_threads.c (GC_CreateThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * include/private/gc_priv.h [THREADS] (GC_init, GC_init_parallel): Add comment. * misc.c (GC_init): Replace GC_PTHREADS||GC_WIN32_THREADS with THREADS. * misc.c [THREADS] (GC_init): Call GC_init_parallel() even if no parallel marker support or thread-local allocations; update comment. * pthread_support.c (parallel_initialized): Remove. * win32_threads.c (parallel_initialized): Likewise. * pthread_support.c (GC_init_parallel): Update comment; do not use parallel_initialized; do not call GC_init(); * win32_threads.c (GC_init_parallel): Likewise. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Declare and use me local variable. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Remove assertion that the GC lock is not hold; add assertion that GC_is_initialized is set. * win32_threads.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Likewise. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_register_my_thread, GC_start_rtn_prepare_thread): Remove redundant parentheses in GC_init_thread_local() argument. * win32_threads.c [THREAD_LOCAL_ALLOC] (GC_register_my_thread): Likewise. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_use_threads_discovery): Check GC_is_initialized value instead of parallel_initialized one. * win32_threads.c (GC_CreateThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * win32_threads.c [THREAD_LOCAL_ALLOC] (GC_register_my_thread_inner): Add comment. * win32_threads.c [!GC_ALWAYS_MULTITHREADED && !PARALLEL_MARK && !GC_NO_THREADS_DISCOVERY] (GC_allow_register_threads): Do not set parallel_initialized. * win32_threads.c (GC_init_parallel): Call set_need_to_lock() after GC_init_thread_local().
* Update copyright information in alloc.c and other modified files (2022)Ivan Maidanski2022-05-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CMakeLists.txt: Update year in copyright comment (2021 to 2022). * alloc.c: Likewise. * configure.ac: Likewise. * dyn_load.c: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/gctest.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Update year (2021 to 2022). * allchblk.c: Add copyright line in header comment. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * finalize.c: Update year in copyright comment (2020 to 2022). * include/gc/gc.h: Likewise. * pthread_stop_world.c: Likewise.
* Ensure GC is initialized when GC_push_all_stacks() is calledIvan Maidanski2022-05-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Replace comments about GC is held or not with relevant assertionsIvan Maidanski2022-05-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_default_stop_func): Refine comment about the allocation lock. * alloc.c (GC_finish_collection): Remove comment that the allocation lock is held because the assertion about it already exists. * finalize.c (GC_grow_table, GC_mark_fo, GC_finalize): Likewise. * finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED] (GC_move_disappearing_link_inner): Likewise. * mark.c (GC_mark_some_inner): Likewise. * mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Likewise. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES && THREADS] (GC_find_limit_with_bound): Likewise. * os_dep.c (GC_register_data_segments): Likewise. * os_dep.c [MPROTECT_VDB || PROC_VDB || SOFT_VDB] (GC_dirty_init): Likewise. * pthread_stop_world.c (GC_start_world): Likewise. * pthread_support.c (GC_new_thread): Likewise. * thread_local_alloc.c (return_freelists): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_delete_gc_thread_no_free): Likewise. * blacklst.c (GC_promote_black_lists): Remove comment that the allocation lock is held, and add the corresponding assertion to the beginning of the function. * blacklst.c [!PARALLEL_MARK] (GC_add_to_black_list_normal, GC_add_to_black_list_stack): Likewise. * darwin_stop_world.c (GC_stop_world, GC_start_world): Likewise. * mark_rts.c (GC_remove_root_at_pos, GC_remove_roots_inner, GC_exclude_static_roots_inner): Likewise. * pthread_stop_world.c (GC_push_all_stacks, GC_suspend_all): Likewise. * pthread_support.c (GC_check_finalizer_nested): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * win32_threads.c (GC_check_finalizer_nested, GC_push_all_stacks): Likewise. * blacklst.c (GC_is_black_listed): Refine comment about the allocation lock. * darwin_stop_world.c (GC_push_all_stacks): Add assertion that the lock is held on entrance. * gcj_mlc.c (maybe_finalize): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove, GC_init_dyld): Remove comment the allocation lock should not be held, and add the corresponding assertion to the beginning of the function. * finalize.c (GC_invoke_finalizers): Likewise. * mark.c [PARALLEL_MARK] (GC_help_marker): Likewise. * pthread_support.c (GC_init_parallel): Likewise. * win32_threads.c (GC_lookup_pthread, GC_init_parallel): Likewise. * finalize.c (GC_finalize_all): Remove comment that the lock is not held on entrance. * gcj_mlc.c (GC_init_gcj_malloc): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Likewise. * include/gc/javaxfc.h (GC_finalize_all): Add comment the function acquires the allocation lock. * mallocx.c (GC_generic_malloc_many): Adjust comment about GC lock. * new_hblk.c (GC_build_fl): Likewise. * pthread_support.c (GC_new_thread): Move the assertion about the allocation lock closer to the beginning of the function. * win32_threads.c (GC_new_thread): Likewise.
* Remove extra space after comma in license termsIvan Maidanski2022-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reformatting) * CMakeLists.txt: Remove an extra space after comma in license header comment. * Makefile.am: Likewise. * allchblk.c: Likewise. * alloc.c: Likewise. * backgraph.c: Likewise. * blacklst.c: Likewise. * checksums.c: Likewise. * configure.ac: Likewise. * cord/cordbscs.c: Likewise. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_cmds.h: Likewise. * cord/tests/de_win.c: Likewise. * cord/tests/de_win.h: Likewise. * cord/tests/de_win.rc: Likewise. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * dyn_load.c: Likewise. * extra/gc.c: Likewise. * extra/msvc_dbg.c: Likewise. * extra/pcr_interface.c: Likewise. * extra/real_malloc.c: Likewise. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gc_badalc.cc: Likewise. * gc_cpp.cc: Likewise. * gc_dlopen.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/cord_pos.h: Likewise. * include/gc/ec.h: Likewise. * include/gc/gc.h: Likewise. * include/gc/gc_backptr.h: Likewise. * include/gc/gc_config_macros.h: Likewise. * include/gc/gc_disclaim.h: Likewise. * include/gc/gc_gcj.h: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/gc/gc_pthread_redirects.h: Likewise. * include/gc/gc_tiny_fl.h: Likewise. * include/gc/gc_typed.h: Likewise. * include/gc/gc_version.h: Likewise. * include/gc/javaxfc.h: Likewise. * include/gc/leak_detector.h: Likewise. * include/include.am: Likewise. * include/private/darwin_semaphore.h: Likewise. * include/private/darwin_stop_world.h: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_alloc_ptrs.h: Likewise. * include/private/gc_atomic_ops.h: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * m4/gc_set_version.m4: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * obj_map.c: Likewise. * os_dep.c: Likewise. * pthread_start.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * ptr_chck.c: Likewise. * reclaim.c: Likewise. * specific.c: Likewise. * tests/atomicops.c: Likewise. * tests/cpp.cc: Likewise. * tests/disclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * tests/tests.am: Likewise. * tests/weakmap.c: Likewise. * thread_local_alloc.c: Likewise. * tools/setjmp_t.c: Likewise. * tools/threadlibs.c: Likewise. * typd_mlc.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Remove an extra space after comma in license terms.
* Remove thread_blocked field in GC_threadIvan Maidanski2022-04-171-16/+10
| | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Remove thread_blocked argument; replace thread_blocked with !p||!(p->flags&DO_BLOCKING). * darwin_stop_world.c (GC_push_all_stacks): Remove thread_blocked argument in GC_stack_range_for() call. * darwin_stop_world.c (GC_stop_world, GC_start_world): Replace p->thread_blocked with p->flags&DO_BLOCKING. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Likewise. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_stop_world.c [!NACL] (GC_suspend_all, GC_restart_all): Likewise. * pthread_support.c (do_blocking_enter, do_blocking_leave, GC_set_stackbottom, GC_call_with_gc_active): Likewise. * include/private/pthread_support.h (GC_Thread_Rep.thread_blocked): Remove field. * include/private/pthread_support.h (DO_BLOCKING): Define macro; copy comment from thread_blocked. * pthread_support.c (GC_new_thread): Do not use thread_blocked.
* Workaround 'info is not assigned' cppcheck FP if assertions on (OS X)Ivan Maidanski2021-12-031-1/+1
| | | | | | | | (fix of commit 9aa26e0b5) * darwin_stop_world.c [CPPCHECK] (GC_thread_resume): Initialize info.run_state value (to 0) before thread_info() call even if not DEBUG_THREADS.
* Adjust spaces around '=' in printed messagesIvan Maidanski2021-09-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * checksums.c (GC_check_blocks): Remove space before '=' and add a space (if missing) after '=' in printed message. * darwin_stop_world.c [DEBUG_THREADS_EXTRA] (GC_FindTopOfStack): Likewise. * dbg_mlc.c (GC_print_obj, GC_debug_print_heap_obj_proc): Likewise. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX || HPUX] (GC_register_dynamic_libraries): Likewise. [DEBUG_VIRTUALQUERY] (GC_dump_meminfo): Likewise. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Likewise. * os_dep.c [PROC_VDB] (GC_proc_read_dirty): Likewise. * os_dep.c [SOFT_VDB] (soft_read_dirty): Likewise. * pthread_support.c (set_marker_thread_name, GC_start_mark_threads_inner): Likewise. * pthread_support.c [DEBUG_THREADS] (GC_delete_thread, GC_unregister_my_thread_inner, GC_unregister_my_thread, GC_thread_exit_proc, GC_start_rtn_prepare_thread): Likewise. * pthread_support.c [GC_LINUX_THREADS] (GC_get_nprocs): Likewise. * tests/disclaim_weakmap_test.c [DEBUG_DISCLAIM_WEAKMAP] (weakmap_add, weakmap_disclaim): Likewise. * tests/subthread_create.c (run_one_test): Likewise. * win32_threads.c (GC_delete_thread, GC_push_stack_for, GC_get_next_stack): Likewise. * darwin_stop_world.c [DEBUG_THREADS] (GC_stack_range_for): Remove '=' in printed message and/or improve message. * mark.c (GC_signal_mark_stack_overflow): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_print_static_roots): Likewise. * pthread_stop_world.c [DEBUG_THREADS] (GC_push_all_stacks, GC_suspend_all): Likewise. * pthread_support.c (GC_thr_init): Likewise. * tests/disclaim_test.c (pair_dct, pair_new): Likewise. * tests/disclaim_weakmap_test.c (pair_check_rec): Likewise. * tests/initsecondarythread.c (main): Likewise. * tests/subthread_create.c (entry, main): Likewise. * tests/test.c [THREADS] (fork_a_thread, main): Likewise. * tests/test.c [MSWINCE] (thr_window): Likewise. * tests/test.c [NTHREADS>0] (main): Likewise. * tests/threadkey_test.c (main): Likewise. * dyn_load.c [ALPHA && OSF1 && DL_VERBOSE] (GC_register_dynamic_libraries): Reformat printed messages. * tests/disclaim_test.c (main): Remove space after '#' in printed message.
* Add loop to handle abort error like in suspend logic on DarwinJonathan Chambers2021-07-121-4/+6
| | | | | | | (a cherry-pick of commit 60d0e0b7d from Unity-Technologies/bdwgc) * darwin_stop_world.c (GC_stack_range_for): Retry thread_get_state(GC_MACH_THREAD_STATE) while KERN_ABORTED.
* Add comment to stack_range_for that particular regs are skipped (Darwin)Ivan Maidanski2021-06-131-1/+2
| | | | | * darwin_stop_world.c [X86_64 || POWERPC] (GC_stack_range_for): Add comment that rsp and r1 registers are skipped.
* Workaround 'possible null dereference in frame->savedSP' cppcheck FPIvan Maidanski2019-10-221-0/+3
| | | | | | * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && !POWERPC && !ARM32 && !AARCH64 && CPPCHECK] (GC_FindTopOfStack): Call GC_noop1(&frame) before ABORT().
* Workaround 'uninitialized variable: info' cppcheck false positive (OS X)Ivan Maidanski2019-02-141-0/+3
| | | | | * darwin_stop_world.c [DEBUG_THREADS && CPPCHECK] (GC_thread_resume): Initialize info.run_state value (to 0) before thread_info() call.
* Fix thread_info() count argument value (OS X)Ivan Maidanski2019-02-141-1/+2
| | | | | | * darwin_stop_world.c [DEBUG_THREADS || GC_ASSERTIONS] (GC_thread_resume): Set outCount to THREAD_BASIC_INFO_COUNT (instead of THREAD_INFO_MAX) to match the size of info passed to thread_info().
* Fix concurrent bitmap update in GC_dirtyIvan Maidanski2018-09-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #235 (bdwgc). * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_suspend_thread_list): Call GC_acquire_dirty_lock and GC_release_dirty_lock around thread_suspend(). * darwin_stop_world.c (GC_stop_world): Likewise. * include/private/gc_priv.h (set_pht_entry_from_index_safe): Remove unused macro. * include/private/gc_priv.h [THREADS] (GC_acquire_dirty_lock, GC_release_dirty_lock): Define new macro; move comment from win32_threads.c. * include/private/gc_priv.h [THREADS && !GC_DISABLE_INCREMENTAL] (GC_fault_handler_lock): Declare global variable (even if not MPROTECT_VDB). * os_dep.c [!GC_DISABLE_INCREMENTAL] (async_set_pht_entry_from_index): Define even if not MPROTECT_VDB; reformat comments. * os_dep.c [!GC_DISABLE_INCREMENTAL && AO_HAVE_test_and_set_acquire] (GC_fault_handler_lock): Likewise. * os_dep.c [THREADS && AO_HAVE_test_and_set_acquire] (async_set_pht_entry_from_index): Use GC_acquire_dirty_lock and GC_release_dirty_lock; remove wrong comment. * os_dep.c [THREADS && !AO_HAVE_test_and_set_acquire] (currently_updating, async_set_pht_entry_from_index): Remove incorrect implementation. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Call async_set_pht_entry_from_index instead of set_pht_entry_from_index; remove FIXME. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Refine comment for AO_store_release call; call GC_acquire_dirty_lock and GC_release_dirty_lock around a block of RAISE_SIGNAL() and sem_wait(). * pthread_stop_world.c [GC_OPENBSD_UTHREADS] (GC_suspend_all): Call GC_acquire_dirty_lock and GC_release_dirty_lock around pthread_suspend_np(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS] (GC_suspend_all): Add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): If GC_manual_vdb then call GC_acquire_dirty_lock and GC_release_dirty_lock around a block of GC_suspend_all() and suspend_restart_barrier(); add comment. * win32_threads.c (GC_suspend): Use GC_acquire_dirty_lock and GC_release_dirty_lock (regardless of MPROTECT_VDB).
* Fix start_world not resuming all threads on DarwinDemyan Kimitsa2018-08-301-85/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #231 (bdwgc). This happens due mach thread ports are released in GC_stop_world as a result in some cases the system creates new one and GC_start_world will not find the thread to resume; in turn, the threads will stay suspended. When this happens to GDC threads, the application is terminated as the message loop is halt. The high-level description of the change: thread mach port is not deallocated when thread is saved in GC_mach_threads as it causes thread not being resumed as thread port object can be changed; threads are now being suspended without check of suspend_count (as it can be suspended by client); the logic of resume is changed, now the primary cycle iterates threads to resume in GC_mach_threads. * darwin_stop_world.c (struct GC_mach_thread): Rename already_suspended filed to suspended. * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_suspend_thread_list): Add my_task argument; remove info an outCount local variables; call mach_port_deallocate uless threaded is added to GC_mach_threads; do not call thread_info; update the relevant comments. * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_stop_world): Remove i local variable; do not call mach_port_deallocate for prevlist items; add comment. * darwin_stop_world.c (GC_thread_resume): Call WARN instead of ABORT if thread_resume failed. * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_start_world): Initialize j to listcount; iterate over GC_mach_threads in the outer loop; if thread is suspended then find it in act_list; if found then resume thread; call mach_port_deallocate for act_list items.
* New API to turn on manual VDB at runtimeIvan Maidanski2018-08-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Manual VDB is now enabled by GC_set_manual_vdb_allowed(1) if called before entering the GC incremental mode. * alloc.c (GC_allocobj): Expand TRUE_INCREMENTAL macro. * darwin_stop_world.c [MPROTECT_VDB] (GC_stop_world, GC_start_world): Use GC_auto_incremental instead of GC_incremental. * mark.c (alloc_mark_stack): Likewise. * mark.c [PROC_VDB] (GC_push_all): Likewise. * mark.c [!NEED_FIXUP_POINTER && THREADS && MPROTECT_VDB] (GC_push_all_stack): Likewise. * pthread_support.c [CAN_HANDLE_FORK && GC_DARWIN_THREADS && MPROTECT_VDB] (GC_atfork_prepare): Likewise. * win32_threads.c [MPROTECT_VDB && !CYGWIN32] (GC_register_my_thread_inner): Likewise. * win32_threads.c [MPROTECT_VDB] (UNPROTECT_THREAD): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Update documentation for the manual VDB. * include/gc.h (GC_end_stubborn_change): Update comment. * mark_rts.c (GC_push_all_stack_partially_eager): Likewise. * include/gc.h (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): New public function. * include/private/gc_priv.h (GC_grungy_pages, GC_dirty_pages): Define for all VDB modes. * include/private/gc_priv.h (GC_auto_incremental, GC_manual_vdb): Define. * include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL] (GC_dirty): Use GC_manual_vdb instead of GC_incremental. * include/private/gcconfig.h (GWW_VDB, MPROTECT_VDB, PCR_VDB): Do not undefine if MANUAL_VDB. * mallocx.c (GC_generic_malloc_many): Always allocate a single object (and call GC_dirty_inner/REACHABLE_AFTER_DIRTY) if GC_manual_vdb. * misc.c [!CAN_HANDLE_FORK && DARWIN && MPROTECT_VDB && !THREADS && !SMALL_CONFIG] (GC_set_handle_fork): Do not ABORT if GC_manual_vdb. * misc.c [!SMALL_CONFIG] (manual_vdb_allowed): New static variable. * misc.c [!SMALL_CONFIG] (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): Implement. * misc.c [!CHECKSUMS && !SMALL_CONFIG] (GC_init, GC_enable_incremental): Set GC_manual_vdb and GC_incremental to true if manual_vdb_allowed; do not call GC_dirty_init if manual_vdb_allowed. * os_dep.c: Update comment about MANUAL_VDB. * os_dep.c [MANUAL_VDB] (GC_dirty_init, async_set_pht_entry_from_index): Remove. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_manual_vdb): Define global variable. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Define regardless of the VDB mode; add FIXME. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_read_dirty, GC_page_was_dirty, GC_remove_protection): Implement for the case of GC_manual_vdb is true; do not depend on MANUAL_VDB. * tests/disclaim_test.c [TEST_MANUAL_VDB] (main): Call GC_set_manual_vdb_allowed(1) before GC_INIT. * tests/staticrootslib.c [TEST_MANUAL_VDB] (libsrl_init): Likewise. * tests/test_cpp.cc [TEST_MANUAL_VDB] (main): Likewise. * tests/test.c (INIT_MANUAL_VDB_ALLOWED): New macro. * tests/test.c (GC_COND_INIT): Invoke INIT_MANUAL_VDB_ALLOWED (before GC_OPT_INIT). * tests/test.c [!SMALL_CONFIG] (main): Call GC_get_manual_vdb_allowed.
* Fix compilation of darwin_stop_world for iOS 8+Jonas Echterhoff2018-08-011-1/+1
| | | | | | | | | | (part of commit c6e7e36 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_stack_range_for): Set state to unified_state instead of unified_state.ts_32.
* Fix suspend_thread_list in case of thread_suspend is interruptedIvan Maidanski2018-07-271-1/+3
| | | | | | | | (fix of commit e8cdc7c) * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_suspend_thread_list): Retry thread_suspend if failed with KERN_ABORTED.
* Perform thread_suspend in loop as it may be interrupted (Darwin)Jonathan Chambers2018-07-271-1/+3
| | | | | * darwin_stop_world.c (GC_stop_world): Retry thread_suspend() on KERN_ABORTED.
* Change Darwin-specific code to comply with C++11 standardJay Krell2018-02-261-5/+5
| | | | | | | | | | | | | | | | | Issue #206 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Cast pointer which is assinged to lo local variable to ptr_t (instead of void*). * os_dep.c [GC_DARWIN_THREADS && MPROTECT_VDB]: Include darwin_stop_world.h (so that GC_mprotect_stop and GC_mprotect_resume to be declared and later defined as extern "C"). * os_dep.c [MPROTECT_VDB && DARWIN] (exc_server, exception_raise, exception_raise_state): Wrap into extern "C" block; refine comment. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state, catch_exception_raise_state_identity): Declare as extern "C" (before the definition). * os_dep.c [MPROTECT_VDB && DARWIN && THREADS] (GC_mprotect_state): Initialize to GC_MP_NORMAL (instead of integer 0).
* Do not push 'cpsr' register on Darwin/armIvan Maidanski2018-02-021-2/+1
| | | | | | | | ARM cpsr stands for Control Program State Register. It cannot contain a pointer. * darwin_stop_world.c [ARM32] (GC_stack_range_for): Ignore cpsr register; update comment.
* Do not push frame pointer on Darwin/arm and Darwin/arm64Jonathan Chambers2018-02-021-7/+8
| | | | | | | | | | | | | | | | | (part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && ARM32] (GC_stack_range_for): Pass r[7] (instead of sp register) to GC_FindTopOfStack(). * darwin_stop_world.c [ARM32] (GC_stack_range_for): Do not push r[7] register (as it holds frame pointer on iOS); add comment. * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && AARCH64] (GC_stack_range_for): Pass fp (instead of sp) register to GC_FindTopOfStack(). * darwin_stop_world.c [AARCH64] (GC_stack_range_for): Do not push fp register.
* Implement FindTopOfStack(0) for ARM and AArch64 (Darwin)Jonathan Chambers2018-02-021-0/+8
| | | | | | | | | | (part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && (ARM32 || AARCH64)] (GC_FindTopOfStack): Set proper frame value (using asm instruction) if stack_start is zero (instead of ABORT).
* Always fail if FindTopOfStack(0) is not implemented but called (Darwin)Ivan Maidanski2018-02-021-9/+6
| | | | | | | | * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_FindTopOfStack): Initialize frame local variable first (to stack_start). * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && !POWERPC] (GC_FindTopOfStack): Call ABORT with the appropriate message (instead of GC_ASSERT) if stack_start iz zero.
* Fix 'bogus LR' detection in FindTopOfStack (Darwin)Ivan Maidanski2016-12-071-1/+1
| | | | | | | | | (fix commit 5742f86) * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_FindTopOfStack): Use "UL" suffix (instead of "U") for 0x3 (on the right side of the comparison) to avoid implicit unsigned int-to-long value extension of "~" operator result.
* Workaround 'possible null pointer dereference' cppcheck warning (Darwin)Ivan Maidanski2016-10-271-0/+3
| | | | | * darwin_stop_world.c [CPPCHECK] (GC_stack_range_for): Call ABORT if p is NULL and thread_blocked is true.
* Fix null dereference in GC_stack_range_for if not DARWIN_DONT_PARSE_STACKIvan Maidanski2016-10-271-6/+9
| | | | | | | | | | | (fix commit 4ceae609) * darwin_stop_world.c (GC_stack_range_for): Use GC_ATTR_UNUSED for paltstack_hi argument (because the latter is not used currently if !DARWIN_DONT_PARSE_STACK); do not access p->altstack[_size] unless DARWIN_DONT_PARSE_STACK; add TODO item. * darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_push_all_stacks): Do not use altstack_hi and altstack_lo; add TODO item.
* Workaround 'value of macro unknown' cppcheck info messagesIvan Maidanski2016-10-241-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The messages are eliminated for the macros: __int64, _SIGRTMIN, ARM_THREAD_STATE32, ARM_UNIFIED_THREAD_STATE, FIXUP_POINTER, GC_COLLECT_AT_MALLOC, GC_FREE_SPACE_DIVISOR, GC_FULL_FREQ, GC_INITIAL_HEAP_SIZE, GC_MAX_RETRIES, GC_MAXIMUM_HEAP_SIZE, GC_MIN_MARKERS, GC_SIG_SUSPEND, GC_SIG_THR_RESTART, GC_TIME_LIMIT, HEURISTIC2_LIMIT, MAP_ANONYMOUS, RTLD_DI_LINKMAP, SAVE_CALL_COUNT, SIZE_MAX. * alloc.c (GC_full_freq, GC_free_space_divisor, GC_time_limit): Define to default immediate value if CPPCHECK. * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_ARM_UNIFIED_THREAD_STATE): New macro (defined to ARM_UNIFIED_THREAD_STATE unless CPPCHECK). * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_stack_range_for): Use GC_ARM_UNIFIED_THREAD_STATE; do not use value of ARM_THREAD_STATE32 if CPPCHECK. * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_RTLD_DI_LINKMAP): New macro (defined to RTLD_DI_LINKMAP unless CPPCHECK). * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Use GC_RTLD_DI_LINKMAP. * include/gc.h (GC_word, GC_signed_word): Do not define to __int64 if CPPCHECK. * include/gc.h (GC_INIT_CONF_MAX_RETRIES, GC_INIT_CONF_FREE_SPACE_DIVISOR, GC_INIT_CONF_FULL_FREQ, GC_INIT_CONF_TIME_LIMIT, GC_INIT_CONF_SUSPEND_SIGNAL, GC_INIT_CONF_THR_RESTART_SIGNAL, GC_MAXIMUM_HEAP_SIZE, GC_INITIAL_HEAP_SIZE): Define to empty if CPPCHECK. * include/private/gc_priv.h [SIZE_MAX] (GC_SIZE_MAX): Do not define to SIZE_MAX if CPPCHECK. * include/private/gc_priv.h [DARWIN && ARM32 && ARM_UNIFIED_THREAD_STATE] (GC_MACH_THREAD_STATE): Do not define to ARM_UNIFIED_THREAD_STATE if CPPCHECK. * include/private/gc_priv.h [GC_PTHREADS && _SIGRTMIN] (SIG_SUSPEND): Do not define to _SIGRTMIN if CPPCHECK. * pthread_stop_world.c [!SIG_THR_RESTART && _SIGRTMIN] (SIG_THR_RESTART): Likewise. * include/private/gcconfig.h [SAVE_CALL_CHAIN && SAVE_CALL_COUNT] (NFRAMES): Define to immediate value (do not use value of SAVE_CALL_COUNT) if CPPCHECK. * include/private/gcconfig.h [!FIXUP_POINTER && POINTER_MASK] (FIXUP_POINTER): Define to a sample expression (not using values of POINTER_MASK and POINTER_SHIFT) if CPPCHECK. * malloc.c [GC_COLLECT_AT_MALLOC] (GC_dbg_collect_at_malloc_min_lb): Define to sample value (not using value of GC_COLLECT_AT_MALLOC) if CPPCHECK. * misc.c [GC_INITIAL_HEAP_SIZE] (GC_init): Define to default immediate value if CPPCHECK. * os_dep.c [!BEOS && !OS2 && !SWIN32 && !GC_OPENBSD_THREADS && !STACKBOTTOM && HEURISTIC2_LIMIT] (GC_get_main_stack_base): Do not use value of HEURISTIC2_LIMIT if CPPCHECK. * os_dep.c [USE_MMAP_ANON && MAP_ANONYMOUS] (OPT_MAP_ANON): Do not use value of MAP_ANONYMOUS if CPPCHECK. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_TIME_LIMIT] (GC_TIME_LIMIT): Do not define. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_brief_async_signal_safe_sleep): Do not use value of GC_TIME_LIMIT if CPPCHECK. * pthread_support.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init): Do not use value of GC_MIN_MARKERS if CPPCHECK. * win32_threads.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init): Likewise. * tests/test.c [GC_DEBUG && SAVE_CALL_CHAIN && SAVE_CALL_COUNT] (check_heap_stats): Use NFRAMES instead of SAVE_CALL_COUNT (i.e. do not use value of SAVE_CALL_COUNT).
* Eliminate 'printf format specifies type void*' GCC pedantic warningsIvan Maidanski2016-10-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Explicitly cast pointer arguments (passed to printf and ABORT_ARGn) to void* to match %p format specifier. * allchblk.c [!NO_DEBUGGING] (GC_dump_regions): Cast arguments to void* those printf format specifier is %p. * alloc.c [!NO_DEBUGGING] (GC_print_heap_sects): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (backwards_height): Likewise. * blacklst.c (GC_default_print_heap_obj_proc): Likewise. * blacklst.c [PRINT_BLACK_LIST] (GC_print_blacklisted_ptr): Likewise. * cord/cordbscs.c (CORD_dump_inner): Likewise. * darwin_stop_world.c [DEBUG_THREADS_EXTRA] (GC_FindTopOfStack): Likewise. * darwin_stop_world.c [DEBUG_THREADS] (GC_stack_range_for): Likewise. * dbg_mlc.c (GC_print_obj): Likewise. * dbg_mlc.c [!SHORT_DBG_HDRS] (GC_print_smashed_obj): Likewise. * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynamic_libraries_dl_iterate_phdr): Likewise. * dyn_load.c [IRIX5] (GC_register_dynamic_libraries): Likewise. * finalize.c [!NO_DEBUGGING] (GC_dump_finalization_links, GC_dump_finalization): Likewise. * include/private/gc_pmark.h [MARK_BIT_PER_GRANULE || MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR): Likewise. * mark.c [ENABLE_TRACE] (GC_mark_from): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_print_static_roots): Likewise. * mark_rts.c [DEBUG_ADD_DEL_ROOTS] (GC_add_roots_inner, GC_remove_root_at_pos): Likewise. * misc.c [ENABLE_TRACE] (GC_init): Likewise. * os_dep.c [LINUX || HURD] (GC_init_linux_data_start): Likewise. * os_dep.c [!OS2 && !MSWIN32] (GC_register_data_segments): Likewise. * os_dep.c [USE_MUNMAP && !USE_WINALLOC && !NACL] (GC_remap): Likewise. * os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE] (GC_write_fault_handler): Likewise. * os_dep.c [PROC_VDB && DEBUG_DIRTY_BITS] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN && BROKEN_EXCEPTION_HANDLING] (catch_exception_raise): Likewise. * pthread_stop_world.c [DEBUG_THREADS] (GC_push_all_stacks): Likewise. * pthread_support.c [DEBUG_THREADS] (GC_unregister_my_thread_inner, GC_unregister_my_thread, GC_start_rtn_prepare_thread): Likewise. * reclaim.c [!NO_DEBUGGING] (GC_print_free_list): Likewise. * specific.c [USE_CUSTOM_SPECIFIC && GC_ASSERTIONS] (GC_check_tsd_marks): Likewise. * win32_threads.c [DEBUG_THREADS] (GC_push_stack_for): Likewise. * win32_threads.c [GC_PTHREADS && DEBUG_THREADS] (GC_pthread_join, GC_pthread_create, GC_pthread_start_inner, GC_thread_exit_proc): Likewise. * dbg_mlc.c: Remove duplicate check of SHORT_DBG_HDRS. * include/private/gc_pmark.h [MARK_BIT_PER_GRANULE || MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR): Add missing parentheses around "source" argument when casting it to ptr_t.
* Eliminate more 'scope of variable can be reduced' cppcheck style warningsIvan Maidanski2016-10-141-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c [MARK_BIT_PER_GRANULE] (setup_header): Move local variable declarations to the inner scope where the variables are actually used. * alloc.c [!SMALL_CONFIG] (GC_try_to_collect_inner, GC_finish_collection): Likewise. * alloc.c (GC_stopped_mark): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (add_edge): Likewise. * darwin_stop_world.c [GC_DARWIN_THREADS] (GC_push_all_stacks, GC_stop_world, GC_thread_resume): Likewise. * dyn_load.c [USE_PROC_FOR_LIBRARIES] (sort_heap_sects): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX] (GC_register_dynamic_libraries): Likewise. * dyn_load.c [DARWIN] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * extra/AmigaOS.c (GC_amiga_free_all_mem, GC_amiga_allocwrapper_any): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * include/new_gc_alloc.h (single_client_gc_alloc_template::deallocate, single_client_gc_alloc_template::ptr_free_deallocate, single_client_traceable_alloc_template::deallocate, single_client_traceable_alloc_template::ptr_free_deallocate): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * mark_rts.c (GC_add_roots_inner): Likewise. * misc.c (GC_clear_stack): Likewise. * os_dep.c [GWW_VDB] (GC_gww_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB] (GC_protect_heap): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * pthread_stop_world.c [GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Likewise. * pthread_support.c [!GC_NO_PTHREAD_SIGMASK] (pthread_sigmask): Likewise. * reclaim.c [!SMALL_CONFIG] (GC_reclaim_all): Likewise. * tests/test.c (run_one_test): Likewise. * tests/test.c [MACOS] (SetMinimumStack): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (return_single_freelist): Likewise. * typd_mlc.c (GC_make_descriptor): Likewise. * win32_threads.c (GC_start_world, GC_CreateThread): Likewise. * win32_threads.c [!GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner): Likewise. * win32_threads.c [!MSWINCE && !CYGWIN32] (GC_beginthreadex): Likewise.
* Workaround more '#error' cppcheck error messagesIvan Maidanski2016-10-131-0/+2
| | | | | | | | | | | | | | | | | | | | * darwin_stop_world.c (GC_stack_range_for): Skip #error pragma if CPPCHECK. * dyn_load.c [DYNAMIC_LOADING && !PCR && !DARWIN]: Likewise. * dyn_load.c [SOLARISDL && !PCR && !GC_SOLARIS_THREADS && THREADS]: Likewise. * include/private/gc_priv.h [!POWERPC && !I386 && !X86_64 && !ARM32 && !AARCH64] (GC_THREAD_STATE_T): Likewise. * include/private/gcconfig.h [GC_IRIX_THREADS && !IRIX5 || ...]: Likewise. * include/private/gcconfig.h [PARALLEL_MARK && !THREADS]: Likewise. * include/private/gcconfig.h [MARK_BIT_PER_GRANULE && MARK_BIT_PER_OBJ || ...]: Likewise. * pcr_interface.c [PCR] (GC_enumerate_block): Likewise. * win32_threads.c [!I386 && !X86_64 && !ARM32 && !SHx && !MIPS && !PPC && !ALPHA] (GC_push_stack_for): Likewise. * darwin_stop_world.c (GC_stack_range_for): Initialize "lo" local variable even if platform unsupported.
* Eliminate 'cast to void* from int' compiler warnings (Darwin/x64)Ivan Maidanski2016-08-191-11/+14
| | | | | | | | * darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list, GC_stop_world, GC_thread_resume, GC_start_world): Cast thread variable to pointer via word type. * darwin_stop_world.c (GC_stop_world): Cast stop_info.mach_thread to pointer via word type.
* Code refactoring of 'alt-stack registration support'Ivan Maidanski2015-07-271-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * darwin_stop_world.c (GC_stack_range_for, GC_push_all_stacks): Reformat code dealing with alt-stack. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * darwin_stop_world.c (GC_stack_range_for): Cast pointers to word when compared. * GC_push_all_stacks (GC_push_all_stacks): Likewise. * include/gc.h (GC_register_altstack): Reformat comment; decorate with GC_CALL; comment out argument names; change type of altstack_size and stack_size to word. * include/private/pthread_support.h (altstack, altstack_size, stack, stack_size): Refine and reformat comment. * include/private/pthread_support.h (altstack_size, stack_size): Change type from int to word. * pthread_support.c (main_stack_size, main_altstack_size): Likewise. * pthread_support.c (main_pthread_self): Rename to main_pthread_id. * pthread_support.c (GC_register_altstack): Decorate with GC_API and GC_CALL. * win32_threads.c (GC_register_altstack): Likewise. * pthread_support.c (GC_register_altstack): Rename "thread" local variable to "me"; new local variable "self"; use DCL_LOCK_STATE; reformat code. * pthread_support.c (GC_thr_init): New local variable "self"; compare thread id using THREAD_EQUAL; reformat code. * win32_threads.c (GC_register_altstack): Add GC_ATTR_UNUSED to all arguments to avoid compiler warning (while the function is unimplemented); add TODO.
* Add alt-stack registration supportZoltan Varga2015-07-241-10/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Apply commit ff4ec56 from 'mono_libgc' branch.) Fix altstack support in libgc by registering the bounds of the normal stack and the altstack with it. * darwin_stop_world.c (GC_stack_range_for): Add paltstack_lo, paltstack_hi argments; set *paltstack_lo, *paltstack_hi, adjust lo and hi if p->altstack set. * darwin_stop_world.c (GC_push_all_stacks): Declare altstack_lo, altstack_hi local variables; pass &altstack_lo, &altstack_hi to GC_stack_range_for; do not call GC_push_all_stack(lo, hi) and adjust total_size by hi-lo if lo is NULL; call GC_push_all_stack(altstack_lo, altstack_hi) and increment total_size by altstack_hi-altstack_lo if altstack_lo is non-NULL. * include/gc.h (GC_register_altstack): New API function declaration. * include/private/pthread_support.h (GC_Thread_Rep): Add altstack, altstack_size, stack, stack_size fields. * pthread_stop_world.c (GC_push_all_stacks): Adjust hi value if p->altstack set. * pthread_support.c (main_pthread_self, main_stack, main_altstack, main_stack_size, main_altstack_size): New static variables. * pthread_support.c (GC_register_altstack): New function. * pthread_support.c (GC_thr_init): Set altstack, altstack_size, stack, stack_size fields from values saved by GC_register_altstack (if called before GC_thr_init). * win32_threads.c (GC_register_altstack): New function (unimplemented).
* Standalone profiling callback for threads suspend/resumeIvan Maidanski2015-06-231-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_on_collection_event, GC_set_on_collection_event, GC_get_on_collection_event): Move from misc.c. * alloc.c (GC_on_collection_event): Make STATIC. * include/private/gc_priv.h (GC_on_collection_event): Remove declaration. * include/gc.h (GC_on_collection_event_proc): Remove 2nd argument of the callback. * alloc.c (GC_try_to_collect_inner, GC_stopped_mark): Likewise. * darwin_stop_world.c (GC_suspend_thread_list, GC_stop_world, GC_thread_resume): Use GC_on_thread_event instead of GC_on_collection_event. * pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise. * win32_threads.c (GC_suspend, GC_start_world): Likewise. * include/gc.h (GC_on_collection_event_proc): Update comment. * include/gc.h (GC_set_on_collection_event, GC_get_on_collection_event): Add comment. * include/gc.h (GC_on_thread_event_proc): New callback type (only if GC_THREADS). * include/gc.h (GC_set_on_thread_event, GC_get_on_thread_event): New API function declaration (only if GC_THREADS). * include/private/gc_priv.h (GC_on_thread_event): New variable declaration (only if THREADS). * misc.c (GC_on_thread_event): New global variable (only if THREADS). * misc.c (GC_set_on_thread_event, GC_get_on_thread_event): New API function (only if THREADS).
* Adjust places where profiling callbacks invoked (to match Mono GC)Ivan Maidanski2015-06-201-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_try_to_collect_inner): Move sending of GC_EVENT_START to the beginning of function (i.e. send right after GC_dont_gc check); move sending of GC_EVENT_END from GC_finish_collection to the end of this function (send it only if collection completed successfully); add TODO note about GC_EVENT_ABANDON notification. * alloc.c (start_world_inner): Remove. * alloc.c (GC_stopped_mark): Send GC_EVENT_PRE_STOP_WORLD, GC_EVENT_POST_STOP_WORLD, GC_EVENT_PRE_START_WORLD, GC_EVENT_POST_START_WORLD only if THREADS. * alloc.c (GC_stopped_mark): Send GC_EVENT_MARK_START before minimizing junk left in registers/stack (instead of after). * alloc.c (GC_stopped_mark): Do not send GC_EVENT_MARK_END in case of abandoned collection (add TODO note about GC_EVENT_MARK_ABANDON). * alloc.c (GC_stopped_mark): Send GC_EVENT_MARK_END after checking debugged objects for consistency (instead of before it). * darwin_stop_world.c (GC_suspend_thread_list): Send GC_EVENT_THREAD_SUSPENDED (in addition to that in GC_stop_world). * darwin_stop_world.c (GC_thread_resume): Move sending of GC_EVENT_THREAD_UNSUSPENDED from GC_start_world(). * pthread_stop_world.c (GC_suspend_all, GC_start_world): Do not send GC_EVENT_THREAD_SUSPENDED if pthread_kill/android_thread_kill failed. * pthread_stop_world.c (GC_start_world): Send GC_EVENT_THREAD_UNSUSPENDED after pthread_resume_np (in case of GC_OPENBSD_UTHREADS). * win32_threads.c (GC_stop_world): Move sending of GC_EVENT_THREAD_SUSPENDED to GC_suspend(). * win32_threads.c (GC_suspend, GC_start_world): Remove redundant cast to void* of THREAD_HANDLE().
* Merge branch 'profiling-callbacks'Ivan Maidanski2015-05-171-0/+6
|\
| * Code refactoring of "event callbacks" functionalityIvan Maidanski2015-05-171-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_on_collection_event): Remove declaration (moved to gc_priv.h). * darwin_stop_world.c (GC_on_collection_event): Likewise. * pthread_stop_world.c (GC_on_collection_event): Likewise. * win32_threads.c (GC_on_collection_event): Likewise. * alloc.c (start_world): Rename to start_world_inner; inline it. * darwin_stop_world.c (GC_start_world): Wrap long code lines. * pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise. * win32_threads.c (GC_stop_world, GC_start_world): Likewise. * include/gc.h: Remove trailing space at EOLn. * include/private/gc_priv.h (GC_on_collection_event): Declare global variable (using GC_EXTERN). * misc.c (GC_on_collection_event): Add GC_INNER; replace NULL to 0.