summaryrefslogtreecommitdiff
path: root/mark_rts.c
Commit message (Collapse)AuthorAgeFilesLines
* Include stdio.h and stdlib.h only from gc_priv.hIvan Maidanski2022-09-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * allchblk.c: Do not include stdio.h directly. * alloc.c: Likewise. * dyn_load.c [(DYNAMIC_LOADING || MSWIN32 || MSWINCE || CYGWIN32) && !PCR]: Likewise. * mach_dep.c [!PLATFORM_MACH_DEP && !SN_TARGET_PSP2]: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * os_dep.c: Likewise. * reclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * dbg_mlc.c [KEEP_BACK_PTRS && !LINT2]: Do not include stdlib.h directly. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise. * os_dep.c [HAIKU]: Likewise. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS]: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c [!mips || !SYSTYPE_BSD43]: Likewise. * thread_local_alloc.c: Likewise. * include/private/gc_priv.h: Include stdio.h.
* Adjust naming of Win32/64 and x86/64 words in comments and documentationIvan Maidanski2022-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ChangeLog: Replace i386 and X86 to x86; replace x86_64 and amd64 to x64; replace "Win32 pthreads" to pthreads-win32; lower case win32s, x86, x64; replace win32 to Win32; replace "MS Windows" to Windows (in documentation and comments). * NT_MAKEFILE: Likewise. * README.md: Likewise. * configure.ac: Likewise. * cord/tests/de_win.c: Likewise. * doc/README.macros: Likewise. * doc/README.solaris2: Likewise. * doc/README.win32: Likewise. * doc/README.win64: Likewise. * doc/debugging.md: Likewise. * doc/leak.md: Likewise. * doc/overview.md: Likewise. * doc/porting.md: Likewise. * extra/msvc_dbg.c: Likewise. * finalize.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/gc.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * mach_dep.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * tools/threadlibs.c: Likewise. * win32_threads.c: Likewise. * cord/tests/de.c (WIN32): Remove misleading comment. * misc.c (GC_enable_incremental): Change comment about win32s to TODO item.
* Use cast to void instead of the attribute to indicate unused argumentsIvan Maidanski2022-09-151-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Update copyright information in alloc.c and other modified files (2022)Ivan Maidanski2022-05-271-1/+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-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Support GC_remove_roots on Win32Ivan Maidanski2022-05-041-13/+14
| | | | | | | | | | | * include/gc/gc.h (GC_add_roots, GC_remove_roots): Refine comment. * include/gc/gc.h (GC_remove_roots): Remove comment that it may be unimplemented on some platforms. * mark_rts.c (GC_remove_roots_inner, GC_remove_roots): Define unconditionally. * mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_roots_inner): Replace rebuild local variable with old_n_roots.
* 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 extra parentheses in return statementIvan Maidanski2022-05-011-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) Also, replace 0 to NULL where appropriate. * allchblk.c (setup_header, GC_get_first_part, GC_allochblk_nth): Remove outermost parentheses in the expression of return statement. * alloc.c (GC_never_stop_func, GC_timeout_stop_func, GC_adj_bytes_allocd, GC_try_to_collect_inner, GC_collect_a_little, GC_stopped_mark, GC_try_to_collect_general, GC_expand_hp_inner, GC_collect_or_expand, GC_allocobj): Likewise. * blacklst.c (GC_is_black_listed, GC_number_stack_black_listed, total_stack_black_listed): Likewise. * checksums.c (GC_checksum): Likewise. * cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_len, CORD_index_access_fn, CORD_apply_access_fn, CORD_substr_checked, CORD_substr, CORD_iter5, CORD_iter, CORD_riter4, CORD_riter, CORD_concat_forest, CORD_balance, CORD__pos_fetch, CORD__prev, CORD_prev, CORD_pos_to_cord, CORD_pos_valid): Likewise. * cord/cordprnt.c (extract_conv_spec, CORD_vsprintf, CORD_sprintf, CORD_fprintf, CORD_vfprintf, CORD_printf, CORD_vprintf): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_catn, CORD_fill_proc, CORD_batched_fill_proc, CORD_cmp, CORD_ncmp, CORD_to_char_star, CORD_from_char_star, CORD_to_const_char_star, CORD_fetch, CORD_put_proc, CORD_batched_put_proc, CORD_put, CORD_chr_proc, CORD_rchr_proc, CORD_batched_chr_proc, CORD_chr, CORD_rchr, CORD_str, CORD_from_file_eager, CORD_lf_func, CORD_from_file_lazy_inner, CORD_from_file_lazy, CORD_from_file): Likewise. * cord/tests/cordtest.c (test_fn, id_cord_fn, test_basics): Likewise. * cord/tests/de.c (line_pos, add_hist, retrieve_line, beep): Likewise. * cord/tests/de_win.c (WinMain, plain_chars, control_chars, WndProc): Likewise. * dbg_mlc.c (store_debug_info, GC_debug_generic_malloc, GC_debug_generic_malloc, GC_debug_realloc, GC_make_closure): Likewise. * dyn_load.c (GC_FirstDLOpenedLinkMap): Likewise. * extra/real_malloc.c (real_malloc): Likewise. * finalize.c (GC_register_disappearing_link, GC_unregister_disappearing_link): Likewise. * gc_dlopen.c (dlopen): Likewise. * gcj_mlc.c (maybe_finalize, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * headers.c (GC_find_header, alloc_hdr, get_index, GC_install_header, GC_next_block, GC_prev_block): Likewise. * malloc.c (GC_generic_malloc): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page): Likewise. * mark.c (GC_collection_in_progress, GC_mark_some, GC_signal_mark_stack_overflow, GC_block_was_dirty, GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Likewise. * mark_rts.c (GC_is_static_root, rt_hash, GC_roots_present, GC_remove_tmp_roots, GC_approx_sp): Likewise. * misc.c (GC_default_oom_fn, GC_clear_stack_inner, GC_base, GC_write, GC_get_warn_proc, GC_call_with_alloc_lock): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * obj_map.c (GC_register_displacement_inner): Likewise. * os_dep.c (GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_get_writable_length, GC_get_writable_length, GC_get_main_stack_base, GC_FreeBSDGetDataStart, GC_unix_mmap_get_mem, GC_unix_sbrk_get_mem, os2_alloc, GC_wince_get_mem, GC_win32_get_mem, GC_push_thread_stack, GC_push_old_obj, GC_write_fault_handler, catch_exception_raise_state, catch_exception_raise_state_identity): Likewise. * pthread_support.c (GC_new_thread, GC_lookup_thread, GC_get_nprocs, pthread_sigmask, pthread_create): Likewise. * ptr_chck.c (GC_same_obj, GC_default_is_visible_print_proc, GC_default_is_valid_displacement_print_proc, GC_is_visible, GC_pre_incr, GC_post_incr): Likewise. * reclaim.c (GC_block_empty, GC_reclaim_uninit, GC_n_set_marks, GC_reclaim_all): Likewise. * tests/cpp.cc (main): Likewise. * tests/gctest.c (fake_gcj_mark_proc, reverse1, reverse, ints, gcj_reverse1, gcj_reverse, gcj_ints, uncollectable_ints, mktree, alloc8bytes, main, test): Likewise. * tools/if_mach.c (main): Likewise. * tools/if_not_there.c (main): Likewise. * tools/setjmp_t.c (getpagesize, main, g): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_add_ext_descriptor, GC_double_descr, GC_make_array_descriptor, GC_make_sequence_descriptor, GC_typed_mark_proc, GC_descr_obj_size, GC_push_complex_descriptor, GC_array_mark_proc, GC_make_descriptor, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_get_stack_min, GC_pthread_create, GC_pthread_start_inner): Likewise. * allchblk.c (GC_get_first_part, GC_allochblk_nth): Replace 0 to NULL where appropriate. * alloc.c (GC_allocobj): Likewise. * blacklst.c (GC_is_black_listed): Likewise. * cord/cordbscs.c (CORD_from_fn_inner, CORD_substr_checked): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_to_char_star, CORD_from_char_star, CORD_lf_func, CORD_from_file_lazy_inner): Likewise. * dbg_mlc.c (store_debug_info, GC_debug_generic_malloc, GC_debug_generic_malloc): Likewise. * dyn_load.c (GC_FirstDLOpenedLinkMap): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * headers.c (GC_next_block, GC_prev_block): Likewise. * malloc.c (GC_generic_malloc, strdup): Likewise. * mallocx.c (GC_realloc): Likewise. * misc.c (GC_default_oom_fn, GC_base): Likewise. * os_dep.c (GC_get_main_stack_base, os2_alloc, GC_win32_get_mem): Likewise. * pthread_support.c (GC_new_thread, GC_lookup_thread): Likewise. * ptr_chck.c (GC_same_obj, GC_is_visible, GC_default_is_valid_displacement_print_proc): Likewise. * tests/gctest.c (mktree): Likewise. * typd_mlc.c (GC_make_array_descriptor, GC_push_complex_descriptor, GC_array_mark_proc, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner): Likewise. * alloc.c (GC_never_stop_func, GC_timeout_stop_func): Replace 0 and 1 (in return statement) to FALSE and TRUE, respectively. * include/private/gcconfig.h: Remove outermost parentheses in the expression of return statement in comment.
* Use mmap to allocate procedure stack buffers on E2KIvan Maidanski2022-02-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit 990dcdba1) Issue #411 (bdwgc). This commit prevents stack overflow in case of a big procedure stack to be saved. If a procedure stack requires less than 1 memory page for the buffer, then the buffer is still allocated on the local stack. * include/private/gc_priv.h [E2K] (PS_ALLOCA_BUF, ALLOCA_SAFE_LIMIT, FREE_PROCEDURE_STACK_LOCAL): Define macro. * include/private/gc_priv.h [E2K] (PROCEDURE_STACK_ALLOCA_AND_STORE): Rename to GET_PROCEDURE_STACK_LOCAL; update comment; modify implementation to call GC_mmap_procedure_stack_buf (and GC_unmap_procedure_stack_buf) if size > ALLOCA_SAFE_LIMIT. * include/private/gc_priv.h [E2K] (GC_mmap_procedure_stack_buf, GC_unmap_procedure_stack_buf): Declare function. * include/private/gc_priv.h [E2K && THREADS] (GC_alloc_and_get_procedure_stack): Refine comment. * mach_dep.c [E2K]: Include sys/mman.h. * mach_dep.c [E2K] (GC_mmap_procedure_stack_buf, GC_unmap_procedure_stack_buf): Implement. * mark_rts.c [E2K && !THREADS] (GC_push_current_stack): Rename PROCEDURE_STACK_ALLOCA_AND_STORE to GET_PROCEDURE_STACK_LOCAL; call FREE_PROCEDURE_STACK_LOCAL() when bs_lo is not needed. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_suspend_handler_inner, GC_push_all_stacks): Likewise.
* Fix recursive malloc during pthread_create (E2K)Ivan Maidanski2022-02-011-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit 9ddbbae8e) Issue #411 (bdwgc). Use of malloc/free inside an asynchronous signal is not safe and may lead to a crash inside malloc, e.g. if the signal occurs when malloc is called from pthread_create. Also, malloc cannot be used by the code executed during stop-the-world if the collector is built with enabled malloc redirection. This commit replaces malloc/free used to get procedure (register) stack with alloca or GC_INTERNAL_MALLOC (the latter is not used during stop-the-world). This commit also prevents accessing freed procedure stack buffers from GC_push_all_stacks when the world is not stopped. * include/private/gc_priv.h [E2K] (GC_get_procedure_stack): Change the arguments to accept buf and its size; update the comment. * include/private/gc_priv.h [E2K] (PROCEDURE_STACK_ALLOCA_AND_STORE): Define macro. * include/private/gc_priv.h [E2K && THREADS] (GC_alloc_and_get_procedure_stack): New function declaration. * include/private/pthread_support.h [E2K || IA64] (GC_Thread_Rep.backing_store_end): Add comment. * mach_dep.c [E2K] (GC_get_procedure_stack): Change the implementation to according to the updated declaration (do allocate the buffer internally); remove FIXME. * mach_dep.c [E2K && THREADS] (GC_alloc_and_get_procedure_stack): Implement. * mark_rts.c [!THREADS] (GC_push_current_stack): Use PROCEDURE_STACK_ALLOCA_AND_STORE() instead of GC_get_procedure_stack(); do no call free(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_push_all_stacks): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_store_stack_ptr): Do not declare bs_lo and stack_size local variables; do not call GC_get_procedure_stack(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_suspend_handler_inner): Declare bs_lo and stack_size local variables; call PROCEDURE_STACK_ALLOCA_AND_STORE(); set backing_store_end and backing_store_ptr fields of me (and clear these fields before function return); do not call free(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_push_all_stacks): Define is_stopped local variable; move stack_size local variable declaration to the innermost scope (where it is used); do not call GC_push_all_register_sections() if the procedure stack buffer has been already freed. * pthread_support.c (first_thread): Update comment; move upper to be before GC_push_thread_structures. * pthread_support.c [E2K] (GC_push_thread_structures): Push also first_thread.backing_store_end. * pthread_support.c [E2K] (GC_do_blocking_inner, GC_call_with_gc_active): Do no declare bs_lo local variable; call GC_alloc_and_get_procedure_stack (holding the lock) instead of GC_get_procedure_stack; call GC_INTERNAL_FREE() instead of free(); update comment.
* Revert "Free E2K procedure stack in a single function"Ivan Maidanski2022-01-301-8/+8
| | | | | | This reverts commit 8c2f91a8065d9fb7b238d5c3709bc95dcc727566. There is a simpler solution - the buffer is allocated on stack (mostly).
* Free E2K procedure stack in a single functionIvan Maidanski2022-01-171-8/+8
| | | | | | | | | | | | | | | | | | | | | (refactoring) Issue #413 (bdwgc). * include/private/gc_priv.h [E2K] (GC_get_procedure_stack): Document that the function mgiht be called from a signal handler. * include/private/gc_priv.h [E2K] (GC_free_procedure_stack): New function prototype. * mach_dep.c [E2K] (GC_free_procedure_stack): Implement (just call free() for now). * mark_rts.c [!THREADS && !IA64 && E2K] (GC_push_current_stack): Call GC_free_procedure_stack() instead of free(). * pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Likewise. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Likewise. * pthread_support.c [E2K] (GC_do_blocking_inner, GC_call_with_gc_active): Likewise. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Move stack_size local variable declaration to the innermost scope of its usage.
* Add I_HOLD_LOCK assertion to scratch_alloc/recycle and their callersIvan Maidanski2022-01-171-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * allchblk.c (setup_header, GC_get_first_part, GC_allochblk_nth): Add assertion that the GC lock is held (I_HOLD_LOCK). * alloc.c (GC_add_to_heap, GC_scratch_recycle_inner): Likewise. * backgraph.c (push_in_progress, backwards_height): Likewise. * blacklst.c (GC_bl_init_no_interiors, GC_bl_init): Likewise. * dyn_load.c (GC_register_dynamic_libraries): Likewise. * finalize.c (push_and_mark_object): Likewise. * finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (GC_mark_togglerefs): Likewise. * headers.c (GC_scratch_alloc, alloc_hdr, GC_init_headers, GC_install_header): Likewise. * include/private/gc_pmark.h (GC_MARK_FO): Likewise. * malloc.c (GC_alloc_reclaim_list): Likewise. * mark.c (GC_mark_some_inner, alloc_mark_stack): Likewise. * mark_rts.c [DYNAMIC_LOADING || MSWIN32 || MSWINCE || PCR || CYGWIN32] (GC_remove_tmp_roots): Likewise. * mark_rts.c (GC_cond_register_dynamic_libraries, GC_push_roots): Likewise. * obj_map.c [MARK_BIT_PER_GRANULE] (GC_add_map_entry): Likewise. * os_dep.c [NEED_PROC_MAPS && IA64] (backing_store_base_from_proc): Likewise. * os_dep.c [LINUX_STACKBOTTOM && IA64] (GC_get_register_stack_base): Likewise. * os_dep.c [MSWIN32] (GC_register_root_section): Likewise. * os_dep.c [!OS2 && !MSWIN32 && !MSWINCE && !CYGWIN32] (GC_register_data_segments): Likewise. * os_dep.c [GWW_VDB] (GC_gww_dirty_init, GC_gww_read_dirty): Likewise. * os_dep.c (GC_dirty_init): Likewise. * os_dep.c [PROC_VDB] (GC_proc_read_dirty): Likewise. * os_dep.c [SOFT_VDB] (soft_dirty_init, GC_soft_read_dirty): Likewise. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_read_dirty): Likewise. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Round up size of buf local variable to multiple of 8 bytes. * headers.c (GC_install_header): Use EXPECT(). * malloc.c (GC_alloc_reclaim_list): Likewise. * obj_map.c [MARK_BIT_PER_GRANULE] (GC_add_map_entry): Likewise. * mark_rts.c [DYNAMIC_LOADING || MSWIN32 || MSWINCE || PCR || CYGWIN32] (GC_remove_tmp_roots, GC_push_roots): Remove redundant comment. * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Wrap calls of GC_get_main_stack_base(), GC_get_register_stack_base(), GC_init_headers(), GC_dirty_init(), GC_register_data_segments(), GC_bl_init(), GC_mark_init() into LOCK/UNLOCK. * os_dep.c [OPENBSD] (GC_skip_hole_openbsd): Move sysconf() call to be after the assertion that the GC lock is held. * os_dep.c [HPUX_STACKBOTTOM] (GC_get_register_stack_base): Add assertion that GC_stackbottom is set.
* Fix GC_approx_sp compilation by Clang on E2KIvan Maidanski2022-01-121-2/+5
| | | | | | | Issue #411 (bdwgc). * mark_rts.c [E2K && __clang__ && !CPPCHECK] (GC_approx_sp): Set sp to &sp (instead of __builtin_frame_address(0)); update comment.
* Support Elbrus 2000 (Linux/e2k)Ilya Kurdyukov2022-01-121-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (a port of altlinux libgc-e2k.patch (8ed786c)) Issue #411 (bdwgc). * include/gc/gc.h [__GNUC__ && !__INTEL_COMPILER && __e2k__] (GC_reachable_here): Specify "r" contraint for ptr. * include/gc/gc.h [__e2k__] (GC_stack_base): Declare reg_base field. * include/private/gc_priv.h [E2K] (GC_push_all_register_sections, GC_save_regs_in_stack, GC_get_procedure_stack): Declare. * include/private/gc_priv.h [E2K && __ptr64__] (LOAD_TAGGED_VALUE): Define macro. * include/private/gc_priv.h (LOAD_WORD_OR_CONTINUE): Likewise. * include/private/gcconfig.h [LINUX && __e2k__] (E2K, mach_type_known): Likewise. * include/private/gcconfig.h [E2K] (MACH_TYPE, CPP_WORDSZ, ALIGNMENT, HBLKSIZE): Likewise. * include/private/gcconfig.h [E2K && LINUX] (DATASTART): Likewise. * mach_dep.c [E2K] (VA_SIZE, E2K_PSHTP_SIZE, get_stack_index): Likewise. * include/private/gcconfig.h [GC_GNUC_PREREQ(2,8)] (HAVE_BUILTIN_UNWIND_INIT): Do not define if E2K. * include/private/gcconfig.h [E2K && LINUX] (__dso_handle): Declare extern variable. * include/private/pthread_support.h [E2K] (GC_Thread_Rep): Declare backing_store_end and backing_store_ptr fields. * mach_dep.c [E2K]: Include errno.h, sys/syscall.h, asm/e2k_syswork.h. * mach_dep.c [E2K] (e2k_rwap_lo_fields, e2k_rwap_hi_fields): Declare struct. * mach_dep.c [E2K] (e2k_rwap_lo_u, e2k_rwap_hi_u): Declare union. * mach_dep.c [E2K] (GC_get_procedure_stack, GC_save_regs_in_stack): Implement. * mach_dep.c [E2K] (GC_with_callee_saves_pushed): Call GC_save_regs_in_stack() (not saving the result). * mark.c (GC_mark_from, GC_push_all_eager): Use LOAD_WORD_OR_CONTINUE() instead of direct dereference of current_p. * mark.c [!SMALL_CONFIG] (GC_mark_from): Do not prefetch if E2K. * mark_rts.c [E2K] (GC_push_all_register_sections): Implement but ignore traced_stack_sect (add TODO item). * mark_rts.c [!THREADS && E2K] (GC_push_current_stack): Call GC_get_procedure_stack() and GC_push_all_register_sections(). * misc.c [E2K] (GC_call_with_stack_base): Initialize reg_base to 0. * misc.c [!THREADS && E2K] (GC_do_blocking_inner, GC_get_my_stackbottom): Likewise. * os_dep.c [((HAVE_PTHREAD_ATTR_GET_NP || HAVE_PTHREAD_GETATTR_NP) && THREADS || !HAVE_GET_STACK_BASE) && E2K] (GC_get_stack_base): Likewise. * pthread_support.c [E2K] (GC_get_my_stackbottom): Likewise. * pthread_stop_world.c [E2K] (GC_suspend_handler): Call GC_with_callee_saves_pushed(). * pthread_stop_world.c [E2K] (GC_store_stack_ptr): Call GC_save_regs_in_stack() and GC_get_procedure_stack(). * pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Call free(me->backing_store_end) before return. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Declare bs_lo, bs_hi, stack_size local variables; call GC_save_regs_in_stack() and GC_get_procedure_stack() (and free() at the end) for self thread; call GC_push_all_register_sections(). * pthread_support.c [E2K] (GC_do_blocking_inner): Call GC_save_regs_in_stack(); add FIXME.
* Adjust spaces around '=' in printed messagesIvan Maidanski2021-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Update copyright information in alloc.c and other modified files (2021)Ivan Maidanski2021-09-091-0/+1
| | | | | | | | | | | | | | | | | | | | | * README.QUICK (Copyright): Update year (2019 to 2020). * README.md (Copyright): Likewise. * alloc.c (Copyright, GC_copyright): Likewise. * configure.ac (Copyright): Likewise. * include/private/gc_priv.h (Copyright): Likewise. * mark.c (Copyright): Likewise. * misc.c (Copyright): Likewise. * os_dep.c (Copyright): Likewise. * pthread_support.c (Copyright): Likewise. * win32_threads.c (Copyright): Likewise. * CMakeLists.txt: Update (add Ivan Maidanski). * dyn_load.c (Copyright): Likewise. * include/private/gc_alloc_ptrs.h (Copyright): Likewise. * include/private/gcconfig.h (Copyright): Likewise. * mallocx.c (Copyright): Likewise. * mark_rts.c (Copyright): Likewise. * reclaim.c (Copyright): Likewise. * tests/test.c (Copyright): Likewise.
* Do not scan static roots pages unless dirty if SOFT_VDB (Linux)Ivan Maidanski2021-08-261-11/+2
| | | | | | | | | | | | | | | | | | | | | | Issue #265 (bdwgc). * include/private/gc_priv.h (GC_push_conditional_static): Declare (as a macro or function). * include/private/gcconfig.h [!PROC_VDB && !NO_VDB_FOR_STATIC_ROOTS] (NO_VDB_FOR_STATIC_ROOTS): Do not define if SOFT_VDB. * mark.c [!GC_DISABLE_INCREMENTAL && !NO_VDB_FOR_STATIC_ROOTS && !PROC_VDB] (GC_static_page_was_dirty): New STATIC function. * mark.c [!GC_DISABLE_INCREMENTAL && !NO_VDB_FOR_STATIC_ROOTS] (GC_push_conditional_static): New function (uses GC_static_page_was_dirty unless PROC_VDB). * mark_rts.c (GC_PUSH_CONDITIONAL_STATIC): Remove. * mark_rts.c (GC_PUSH_CONDITIONAL): Use GC_push_conditional_static instead of GC_PUSH_CONDITIONAL_STATIC. * os_dep.c (SOFT_VDB): Update comment about implementation. * os_dep.c [SOFT_VDB && CHECKSUMS] (GC_soft_read_dirty): Call GC_or_pages() only unless output_unneeded, remove assertion about it. * os_dep.c [SOFT_VDB && !NO_VDB_FOR_STATIC_ROOTS] (GC_soft_read_dirty): Call soft_set_grungy_pages() for every element of GC_static_roots.
* Do not call GC_push_conditional unless PROC_VDBIvan Maidanski2021-08-251-7/+12
| | | | | | | | | | | | | | | As of now, only PROC_VDB can determine whether a static root page is dirty. Thus, GC_push_all could be used (instead of GC_push_conditional) in mark_rts.c for other VDB implementations. * include/private/gcconfig.h [!PROC_VDB] (NO_VDB_FOR_STATIC_ROOTS): New macro; add comment. * mark_rts.c (GC_PUSH_CONDITIONAL_STATIC): New internal macro; move comment from GC_PUSH_CONDITIONAL; mark "all" argument as used. * mark_rts.c (GC_PUSH_CONDITIONAL): Use GC_PUSH_CONDITIONAL_STATIC(); do not test GC_DISABLE_INCREMENTAL directly. * mark_rts.c (GC_push_conditional_with_exclusions): Remove GC_ATTR_UNUSED for "all" argument.
* Move GC state pointer variables into GC_arraysIvan Maidanski2020-07-191-25/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is intended to simplify GC reinitialization. GC_push_finalizer_structures() and GC_push_typed_structures() are called now regardless of GC_no_dls and GC_roots_were_cleared values. * finalize.c (dl_hashtbl_s, fnlz_roots_s): Move struct to gc_priv.h. * typd_mlc.c (typed_ext_descr_t): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_dl_hashtbl, GC_fnlz_roots): Remove static variable. * finalize.c [!GC_NO_FINALIZATION && !GC_LONG_REFS_NOT_NEEDED] (GC_ll_hashtbl): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_arr): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcjobjfreelist): Likewise. * headers.c (GC_all_bottom_indices, GC_all_bottom_indices_end, GC_scratch_free_ptr, GC_hdr_free_list): Likewise. * mark.c (GC_scan_ptr): Likewise. * mark.c [PARALLEL_MARK] (GC_main_local_mark_stack): Likewise. * typd_mlc.c (GC_ext_descriptors): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GCToggleRef): Define type as an alias to union toggle_ref_u. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_mark_togglerefs): Remove TODO item. * include/private/gc_priv.h (disappearing_link, finalizable_object): Declare struct. * include/private/gc_priv.h (GC_arrays): Add _all_bottom_indices, _all_bottom_indices_end, _scratch_free_ptr, _hdr_free_list, _scan_ptr, _ext_descriptors fields. * include/private/gc_priv.h [PARALLEL_MARK] (GC_arrays): Add _main_local_mark_stack field. * include/private/gc_priv.h [GC_GCJ_SUPPORT] (GC_arrays): Add _gcjobjfreelist field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && GC_LONG_REFS_NOT_NEEDED] (GC_arrays): Add _ll_hashtbl field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (GC_arrays): Add _dl_hashtbl, _fnlz_roots fields. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_arrays): Add _toggleref_arr field. * include/private/gc_priv.h (GC_arrays._roots_were_cleared): Define field only if THREADS. * mark_rts.c (GC_clear_roots): Set GC_roots_were_cleared only if THREADS. * mark_rts.c (GC_push_gc_structures): Remove static function. * mark_rts.c (GC_push_roots): Do not call GC_push_gc_structures. * mark_rts.c [!GC_NO_FINALIZATION] (GC_push_roots): Call GC_push_finalizer_structures (regardless of GC_no_dls and GC_roots_were_cleared). * mark_rts.c [THREADS] (GC_push_roots): If GC_no_dls or GC_roots_were_cleared then call GC_push_thread_structures. * mark_rts.c (GC_push_roots): If GC_push_typed_structures is non-null then call GC_push_typed_structures (regardless of GC_no_dls and GC_roots_were_cleared).
* Move GC state non-pointer variables into GC_arraysIvan Maidanski2020-07-101-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) This commit is intended to simplify GC reinitialization. * alloc.c (GC_n_heap_sects, GC_fo_entries): Remove variable definition. * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_log_fo_table_size): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_array_size, GC_toggleref_array_capacity): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_kind): Likewise. * mark.c (GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked): Likewise. * mark.c [PARALLEL_MARK] (GC_first_nonempty): Likewise. * mark.c [TRACE_BUF] (GC_trace_buf_ptr): Likewise. * mark_rts.c (n_root_sets, GC_roots_were_cleared, GC_excl_table_entries): Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_n_heap_bases): Likewise. * typd_mlc.c (GC_ed_size, GC_avail_descr, GC_explicit_typing_initialized): Likewise. * extra/MacOS.c (GC_fo_entries): Remove variable declaration. * include/private/gc_pmark.h (GC_mark_stack_size, GC_mark_stack_too_small, GC_mark_state): Likewise. * include/private/gc_priv.h (GC_n_heap_sects, GC_fo_entries): Likewise. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * include/private/gc_pmark.h (mark_state_t): Move typedef to gc_priv.h. * include/private/gc_priv.h (_GC_arrays._scratch_end_ptr, _GC_arrays._scratch_last_end_ptr): Document. * include/private/gc_priv.h [PARALLEL_MARK] (_GC_arrays): Add _first_nonempty field. * include/private/gc_priv.h (_GC_arrays): Add _mark_stack_size, _mark_state, _mark_stack_too_small, _objects_are_marked, _n_heap_sects, _n_memory, _fo_entries, _n_root_sets, _excl_table_entries, _roots_were_cleared, _explicit_typing_initialized, _ed_size, _avail_descr fields. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (_GC_arrays): Add _n_memory field. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (_GC_arrays): Add _n_heap_bases field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (_GC_arrays): Add _log_fo_table_size field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (_GC_arrays): Add _toggleref_array_size, _toggleref_array_capacity fields. * include/private/gc_priv.h [TRACE_BUF] (_GC_arrays): Add _trace_buf_ptr field. * include/private/gc_priv.h [ENABLE_DISCLAIM] (_GC_arrays): Add _finalized_kind field. * include/private/gc_priv.h (GC_first_nonempty, GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked, GC_n_heap_sects, GC_n_memory, GC_n_heap_bases, GC_fo_entries, GC_log_fo_table_size, GC_toggleref_array_size, GC_toggleref_array_capacity, GC_trace_buf_ptr, GC_finalized_kind, n_root_sets, GC_excl_table_entries, GC_roots_were_cleared, GC_explicit_typing_initialized, GC_ed_size, GC_avail_descr): Define macro.
* Add GC_ prefix to scan_ptr and some other static variablesIvan Maidanski2020-06-211-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) The following variables are prefixed: scratch_free_ptr, hdr_free_list, scan_ptr, main_local_mark_stack, roots_were_cleared. * doc/gcdescr.md (Mark phase): Add GC_ prefix to scan_ptr. * headers.c (scratch_free_ptr, hdr_free_list): Add GC_ prefix to name; change static to STATIC. * mark.c (scan_ptr): Likewise. * mark.c [PARALLEL_MARK] (main_local_mark_stack): Likewise. * mark_rts.c (roots_were_cleared): Likewise. * headers.c (GC_scratch_alloc): Add GC_ prefix to scratch_free_ptr. * headers.c (alloc_hdr, free_hdr): Add GC_ prefix to hdr_free_list. * headers.c (GC_init_headers): Add assertion that GC_all_nils is null on entry. * include/private/gc_pmark.h (MS_PUSH_RESCUERS, MS_PUSH_UNCOLLECTABLE, MS_PARTIALLY_INVALID): Add GC_ prefix to scan_ptr. * mark.c (GC_clear_marks, GC_initiate_gc, alloc_mark_stack): Likewise. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Likewise. * mark.c [PARALLEL_MARK] (GC_wait_for_markers_init, GC_do_parallel_mark): Add GC_ prefix to main_local_mark_stack. * mark_rts.c (GC_clear_roots, GC_push_roots): Add GC_ prefix to roots_were_cleared. * mark_rts.c (GC_next_exclusion): Add assertion that GC_excl_table_entries is positive.
* New API function to clear GC exclusion tableJosh Peterson2020-05-181-0/+5
| | | | | | | | | (part of commit 8b95edbd6 from Unity-Technologies/bdwgc) * include/gc.h (GC_clear_exclusion_table): Declare new API function. * mark_rts.c (GC_clear_exclusion_table): Implement. * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call GC_clear_exclusion_table.
* Workaround clang-3.8/s390x bug when processing __builtin_frame_addressIvan Maidanski2020-04-101-2/+5
| | | | | | | | | | This prevents a crash in llvm::SystemZTargetLowering::LowerOperation of libLLVM-3.8 when generating code for mark_rts.c targeting s390x. Clang-8 does not have such a bug. * mark_rts.c [S390 && !CPPCHECK && __clang_major__<8] (GC_approx_sp): return address of sp local variable (instead of __builtin_frame_address(0)); add comment.
* Remove redundant GC_with_callee_saves_pushed call in multi-threaded buildsIvan Maidanski2019-09-241-17/+13
| | | | | | | | | | | | | In GC_push_regs_and_stack, if cold_gc_frame is null and threads support is on then there is no need to call GC_with_callee_saves_pushed(GC_push_current_stack) as GC_push_current_stack is no-op in this case. * mark_rts.c (GC_push_current_stack): Reformat title comment. * mark_rts.c [THREADS] (GC_push_current_stack): Do not check that cold_gc_frame is non-zero; add comment about it. * mark_rts.c [THREADS] (GC_push_regs_and_stack): If cold_gc_frame is null then do not call GC_with_callee_saves_pushed().
* Reformat code of GC_push_rootsIvan Maidanski2019-09-231-67/+63
| | | | | * mark_rts.c (GC_push_roots): Refine title comment; reformat comments; adjust code and comments indentation.
* Replace some FIXME items with TODO onesIvan Maidanski2018-08-311-1/+1
| | | | | | | | | | | | | | | | | | (code refactoring) * alloc.c (GC_maybe_gc, GC_collect_a_little_inner, GC_finish_collection): Replace FIXME item with TODO one. * gcj_mlc.c (maybe_finalize): Likewise. * include/gc.h [!GC_DEBUG || !__GNUC__] (GC_PTR_ADD): Likewise. * include/private/gcconfig.h [X86_64 && LINUX && __GLIBC__ && !__UCLIBC__] (GETCONTEXT_FPU_EXCMASK_BUG): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * mark_rts.c (GC_push_current_stack): Likewise. * misc.c [MSWIN32 || MSWINCE] (WRITE): Likewise. * os_dep.c [ECOS] (ecos_gc_memory): Likewise. * os_dep.c (GC_get_stack_base, GC_page_was_ever_dirty): Likewise. * reclaim.c (GC_reclaim_clear): Likewise. * include/private/gcconfig.h [OPENBSD && m68k]: Remove FIXME item.
* New API to turn on manual VDB at runtimeIvan Maidanski2018-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 incorrect roots order after root removal in remove_roots_subregionIvan Maidanski2018-08-031-10/+28
| | | | | | | | | | | | | | (fix of commits 38d194a, e849b45) Issue #218 (bdwgc). * mark_rts.c [USE_PROC_FOR_LIBRARIES] (swap_static_roots): New inline function. * mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Use swap_static_roots (after GC_add_roots_inner); if there is a temporary root after GC_remove_root_at_pos then swap it with the appropriate non-temporary one to ensure all temporary roots are grouped at the end.
* Fix the build for EmscriptenJosh Peterson2018-08-021-1/+2
| | | | | | | | | (part of commit 0f9ef2d from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * mark_rts.c [!CPPCHECK && __GNUC__>=4] (GC_approx_sp): Do not use __builtin_frame_address if STACK_NOT_SCANNED.
* Fix assertion violation and partial overlapping in remove_roots_subregionIvan Maidanski2018-05-081-12/+48
| | | | | | | | | | | | | | (fix of commit 38d194a) Issue #218 (bdwgc). * mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Update comment; add assertion that b and e pointers are word-aligned; handle also cases of partial overlapping with the existing roots; call GC_rebuild_root_index() only when needed; update existing root instead of removing old and adding new one (where possible); move newly static added root to precede dynamic ones (if any); process all static roots even if an intersection is already found.
* Do not merge dynamic root with the existing static one in add_roots_innerIvan Maidanski2018-05-081-5/+11
| | | | | | | | * mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_add_roots_inner): If the root already exists and it is static then set the found root to static (if not yet); if dynamic root with the same r_start but different r_tmp is found then add a new root starting from r_end of the found root (instead of extending the found root).
* Fix infinite restarting of mark_some when a static root disappeared (Linux)Ivan Maidanski2018-05-071-0/+43
| | | | | | | | | | | | Issue #218 (bdwgc). * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call GC_remove_roots_subregion for each region which has prot starting with "---"; add comment. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Declare function. * mark_rts.c[USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Implement.
* Do not rebuild_root_index unless remove_root_at_pos is calledIvan Maidanski2018-05-051-2/+10
| | | | | | * mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_tmp_roots, GC_remove_roots_inner): Call GC_rebuild_root_index() only if GC_remove_root_at_pos() is called at least once.
* Declare all internal functions in private headers instead of .c filesIvan Maidanski2018-02-281-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) Issue #206 (bdwgc). * include/private/darwin_stop_world.h [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Declare function. * include/private/gc_priv.h [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * include/private/gc_priv.h [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise. * include/private/gc_priv.h (GC_collect_or_expand): Likewise. * include/private/gc_priv.h [MPROTECT_VDB && USE_MUNMAP] (GC_mprotect_dirty_init, GC_has_unmapped_memory): Likewise. * include/private/gc_priv.h [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault): Likewise. * include/private/gc_priv.h [CHECKSUMS] (GC_check_dirty): Likewise. * include/private/gc_priv.h [GC_WIN32_THREADS && WRAP_MARK_SOME && !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise. * include/private/gc_priv.h [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Likewise. * include/private/gc_priv.h [NEED_PROC_MAPS && (IA64 || INCLUDE_LINUX_THREAD_DESCR)] (GC_enclosing_mapping): Likewise. * include/private/pthread_support.h (GC_inner_start_routine): Likewise. * include/private/thread_local_alloc.h [GC_ASSERTIONS] (GC_is_thread_tsd_valid, GC_check_tls_for): Likewise. * include/private/thread_local_alloc.h [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. * include/private/gc_priv.h [HEURISTIC2 || SEARCH_FOR_DATA_START || !STACKBOTTOM && HEURISTIC2 || (SVR4 || AIX || DGUX || LINUX && SPARC) && !PCR] (NEED_FIND_LIMIT): Collapse multiple definitions. * malloc.c (GC_collect_or_expand): Remove prototype. * mark.c [CHECKSUMS] (GC_check_dirty): Likewise. * mark.c [GC_WIN32_THREADS && !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise. * mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * mark_rts.c [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise. * os_dep.c [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Likewise. * os_dep.c [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault): Likewise. * os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_has_unmapped_memory, GC_mprotect_dirty_init): Likewise. * os_dep.c [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Likewise. * pthread_support.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise. * pthread_support.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. * pthread_support.c [INCLUDE_LINUX_THREAD_DESCR] (GC_enclosing_mapping): Likewise. * pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2] (GC_inner_start_routine): Likewise. * thread_local_alloc.c [GC_ASSERTIONS] (GC_is_thread_tsd_valid): Likewise. * win32_threads.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise. * win32_threads.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise.
* Eliminate C++ warnings about deprecated register keyword (GC source)Jay Krell2018-02-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #206 (bdwgc). * blacklst.c (GC_number_stack_black_listed, total_stack_black_listed): Remove register keyword for local variables. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Likewise. * extra/pcr_interface.c [PCR] (GC_enumerate_block): Likewise. * finalize.c (GC_grow_table): Likewise. * headers.c (alloc_hdr, GC_init_headers, GC_remove_counts, GC_prev_block): Likewise. * include/private/gc_pmark.h (PUSH_OBJ): Likewise. * mach_dep.c [!HAVE_PUSH_REGS && !HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed): Likewise. * mark.c (clear_marks_for_block): Likewise. * mark_rts.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_add_roots_inner): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB] (GC_page_was_dirty): Likewise. * os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages, GC_page_was_ever_dirty): Likewise. * os_dep.c (GC_write_fault_handler): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * os_dep.c [SAVE_CALL_CHAIN && NARGS>0] (GC_save_callers): Likewise. * pthread_stop_world.c [!NACL] (GC_start_world): Likewise. * pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Likewise. * typd_mlc.c (GC_push_complex_descriptor): Likewise. * win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread): Likewise.
* Convert GC source files to valid C++ codeIvan Maidanski2018-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #206 (bdwgc). * alloc.c (GC_copyright): Change type from char* const to const char* const. * alloc.c (GC_set_fl_marks, GC_clear_fl_marks, GC_finish_collection, GC_allocobj): Add missing explicit casts from void* to ptr_t. * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Likewise. * blacklst.c (GC_default_print_heap_obj_proc, GC_print_blacklisted_ptr): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_store_debug_info_inner, GC_store_debug_info, GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable, GC_debug_free, GC_debug_free_inner, GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Likewise. * finalize.c (GC_grow_table, push_and_mark_object, ensure_toggleref_capacity, GC_dump_finalization_links, GC_dump_finalization, GC_make_disappearing_links_disappear, GC_remove_dangling_disappearing_links, GC_finalize): Likewise. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise. * mallocx.c (GC_memalign): Likewise. * mark.c (GC_mark_from, GC_mark_and_push, GC_push_all_eager, GC_push_all_stack, GC_push_marked1, GC_push_marked2, GC_push_marked4): Likewise. * mark_rts.c (GC_exclude_static_roots_inner): Likewise. * misc.c (GC_base): Likewise. * new_hblk.c (GC_new_hblk): Likewise. * pthread_support.c (GC_register_altstack, GC_thr_init, GC_record_stack_base): Likewise. * ptr_chck.c (GC_is_visible): Likewise. * reclaim.c (GC_reclaim_small_nonempty_block, GC_disclaim_and_reclaim_or_free_small_block): Likewise. * thread_local_alloc.c (GC_mark_thread_local_fls_for): Likewise. * typd_mlc.c (GC_typed_mark_proc, GC_malloc_explicitly_typed_ignore_off_page): Likewise. * win32_threads.c (GC_record_stack_base, GC_get_stack_min, GC_push_stack_for): Likewise. * blacklst.c (GC_copy_bl): Rename "new" argument to "dest". * dbg_mlc.c (GC_store_debug_info_inner, GC_print_smashed_obj): Change type of p argument from ptr_t to void*. * include/private/gc_priv.h (GC_is_heap_base, GC_is_static_root): Likewise. * mark_rts.c [!THREADS] (GC_is_static_root): Likewise. * os_dep.c (GC_is_malloc_heap_base, GC_is_heap_base): Likewise. * ptr_chck.c (GC_on_stack): Likewise. * dbg_mlc.c (GC_print_obj): Change type of kind_str local variable from char* to const char*. * dbg_mlc.c (GC_debug_strdup, GC_debug_strndup): Cast result of GC_debug_malloc_atomic() to char*. * mallocx.c (GC_strdup, GC_strndup): Likewise. * dbg_mlc.c (GC_debug_wcsdup): Cast result of GC_debug_malloc_atomic() to wchar_t*. * mallocx.c (GC_wcsdup): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_register_dynamic_libraries): Cast p local variable to char*. * os_dep.c (GC_register_data_segments): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Cast masked fc_word to struct GC_finalizer_closure* (instead of void*). * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Cast result of GC_malloc_kind() to word*. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed): Likewise. * include/private/gc_priv.h (WARN): Cast away const qualifier for msg (and the string literal). * misc.c (GC_default_on_abort): Remove cast to void* for WRITE() buf argument. * misc.c (GC_new_free_list_inner): Cast result local variable to void**. * misc.c (GC_new_free_list): Change type of result local variable from void* to void**. * pthread_support.c (GC_start_rtn_prepare_thread): Cast arg to struct start_info*. * win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Likewise. * reclaim.c (GC_print_free_list): Replace ptr_t flh to void *flh_next local variable; remove redundant casts. * tools/if_mach.c (EXECV_ARGV_T): New macro; add comment. * tools/if_not_there.c (EXECV_ARGV_T): Likewise. * tools/if_mach.c (main): Use EXECV_ARGV_T instead of void* for execvp() argument. * tools/if_not_there.c (main): Likewise. * typd_mlc.c (LeafDescriptor, ComplexArrayDescriptor, SequenceDescriptor): Move struct definition out of union ComplexDescriptor. * typd_mlc.c (GC_add_ext_descriptor): Rename "new" local variable to newExtD. * win32_threads.c (GC_CreateThread, GC_beginthreadex): Cast result of GC_malloc_uncollectable() to thread_args*. * win32_threads.c [PARALLEL_MARK && !MSWINCE && __cplusplus] (GC_thr_init): Do not cast GetProcessAffinityMask() arguments to void*.
* Change pointer arguments of push_all[_eager]/conditional API to void* typeJay Krell2018-02-131-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Receiving void* instead of char* is easier to use, as it requires no casting. A small downside of this change is that anyone using decltype(GC_push) in C++ function signatures would get a different name mangling. * include/gc_mark.h (GC_push_all, GC_push_all_eager, GC_push_conditional): Change type of bottom and top arguments from char* to void*. * mark.c (GC_push_all, GC_push_conditional, GC_push_all_eager): Likewise. * include/private/gc_priv.h (GC_PUSH_ALL_SYM): Cast away volatile qualifier for &sym. * mark.c (GC_push_all): Remove "register" keyword for length local variable. * mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_selected): Remove unneeded casts for GC_push_all arguments. * mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Change type of bottom and top arguments from ptr_t to void*. * mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * mark_rts.c (GC_PUSH_CONDITIONAL): Remove unneeded casts for GC_push_all and GC_push_conditional arguments.
* Workaround 'address of auto-variable returned' cppcheck errorIvan Maidanski2018-01-301-1/+2
| | | | | | * mark_rts.c [CPPCHECK] (GC_approx_sp): Use __builtin_frame_address. * mark_rts.c (GC_approx_sp): Replace GC_GNUC_PREREQ(4,0) with __GNUC__>=4; add TODO item.
* Initial support of Xbox One (DURANGO) targetJonathan Chambers2018-01-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/private/gc_priv.h [THREADS && MSWIN_XBOX1] (GC_write_cs): Declare. * include/private/gcconfig.h [(_MSC_VER && _M_IX86 >= 300 || _WIN32) && _XBOX_ONE] (MSWIN_XBOX1): Define (instead of MSWIN32). * include/private/gcconfig.h [X86_64 && MSWIN_XBOX1] (NO_GETENV, DATASTART, DATAEND, STACKBOTTOM, GETPAGESIZE, USE_MMAP, PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC, MAP_PRIVATE, MAP_FIXED, MAP_FAILED): Define. * include/private/gcconfig.h [X86_64 && MSWIN_XBOX1] (durango_get_stack_bottom): Declare external function. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD && MSWIN_XBOX1] (MUNMAP_THRESHOLD): Define to 2; update comment. * include/private/gcconfig.h [GC_WIN32_THREADS && !CYGWIN32 && !MSWIN32 && !MSWINCE]: Do not issue #error if MSWIN_XBOX1. * include/private/gcconfig.h [MSWIN_XBOX1] (durango_get_mem): Declare function. * include/private/gcconfig.h [MSWIN_XBOX1] (GET_MEM): Define. * mark_rts.c [DYNAMIC_LOADING] (GC_cond_register_dynamic_libraries): Do not call GC_remove_tmp_roots and GC_register_dynamic_libraries if MSWIN_XBOX1 (set GC_no_dls to true instead). * misc.c [MSWIN_XBOX1 && THREADS] (GC_write_cs): Define variable. * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !AMIGA && !SN_TARGET_ORBIS && !__CC_ARM]: Do not include unistd.h if MSWIN_XBOX1. * os_dep.c [!OS2 && !PCR && !AMIGA && !MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM && !MSWIN32]: Likewise. * os_dep.c [MMAP_SUPPORTED && MSWIN_XBOX1] (durango_get_mem): Define new internal function. * os_dep.c [!MSWINCE && USE_WINALLOC] (GLOBAL_ALLOC_TEST, GC_mem_top_down, GC_win32_get_mem, GC_win32_free_heap): Do not define if MSWIN_XBOX1. * win32_threads.c [!CYGWIN32 && !MSWINCE] (GC_beginthreadex): Likewise. * os_dep.c [USE_MUNMAP && !NN_PLATFORM_CTR && !MSWIN32 && !MSWINCE]: Do not include unistd.h, sys/mman.h, sys/stat.h, sys/types.h if MSWIN_XBOX1. * win32_threads.c [GC_ASSERTIONS] (GC_write_disabled): Define only if MSWIN32 or MSWINCE. * win32_threads.c [GC_ASSERTIONS] (GC_stop_world): Do not use GC_write_disabled if MSWIN_XBOX1. * win32_threads.c [PARALLEL_MARK && !GC_PTHREADS_PARAMARK && MSWIN_XBOX1] (GC_start_mark_threads_inner): Use CreateThread() instead of _beginthreadex().
* Do not disable parallel mark for WRAP_MARK_SOMEIvan Maidanski2017-09-261-0/+18
| | | | | | | | | | | | | | | | | | | Issue #179 (bdwgc). Now, if there is a chance of unmapping of root segments, the latter ones are scanned immediately by GC_push_roots thus preventing memory protection faults in GC_mark_local. * include/private/gc_priv.h (GC_PUSH_CONDITIONAL): Move definition to mark_rts.c. * include/private/gcconfig.h [WRAP_MARK_SOME && PARALLEL_MARK] (PARALLEL_MARK): Do not undefine; remove TODO item. * mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): New internal function; add TODO item. * mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Declare function. * mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_PUSH_CONDITIONAL): Define to GC_push_conditional_eager if GC_parallel.
* Define CLANG/GNUC_PREREQ macros to check gcc/clang minimum versionIvan Maidanski2017-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * cord/cordxtra.c (CORD_ATTR_UNUSED): Use GC_GNUC_PREREQ() instead of direct use of __GNUC[_MINOR]__. * gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Likewise. * include/gc_config_macros.h (GC_API, GC_ATTR_MALLOC, GC_ATTR_ALLOC_SIZE, GC_ATTR_NONNULL, GC_ATTR_DEPRECATED, GC_RETURN_ADDR, GC_RETURN_ADDR_PARENT, GC_PTHREAD_EXIT_ATTRIBUTE): Likewise. * include/gc_cpp.h (GC_NO_OPERATOR_NEW_ARRAY): Likewise. * include/gc_inline.h (GC_EXPECT, GC_PREFETCH_FOR_WRITE): Likewise. * include/new_gc_alloc.h: Likewise. * include/private/gc_priv.h (GC_INNER, GC_ATTR_UNUSED, EXPECT, GC_INLINE, GC_ATTR_NOINLINE, GC_API_OSCALL, GC_ATTR_FORMAT_PRINTF, NONNULL_ARG_NOT_NULL): Likewise. * include/private/gc_priv.h [CANCEL_SAFE] (GC_cancel_disable_count): Likewise. * include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT, PREFETCH, GC_PREFETCH_FOR_WRITE): Likewise. * include/private/gcconfig.h [I386 && LINUX && __ELF__] (GC_NO_SIGSETJMP): Likewise. * include/private/gcconfig.h [X86_64 && MSWIN32] (MPROTECT_VDB): Likewise. * include/private/thread_local_alloc.h [CYGWIN32] (USE_PTHREAD_SPECIFIC): Likewise. * include/private/thread_local_alloc.h [LINUX && !ARM32 && !AVR32 || PLATFORM_ANDROID && !__clang__] (USE_COMPILER_TLS): Likewise. * mark.c [MSWIN32 || MSWINCE] (GC_mark_some): Likewise. * mark_rts.c (GC_approx_sp): Likewise. * tests/test_cpp.cc (ATTR_UNUSED): Likewise. * tools/setjmp_t.c (nested_sp): Likewise. * include/gc_config_macros.h (GC_GNUC_PREREQ): New macro (not for public use). * include/private/gc_priv.h (GC_CLANG_PREREQ): New private macro. * include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT): Refine comment. * include/private/thread_local_alloc.h [LINUX && !ARM32 && !AVR32 || PLATFORM_ANDROID && !__clang__] (USE_COMPILER_TLS): Use GC_CLANG_PREREQ() instead of direct use of __clang_major__ and __clang_minor__. * mark.c [MSWIN32 || MSWINCE] (GC_mark_some): Likewise.
* Fix a typo in push_roots commentIvan Maidanski2016-12-291-1/+1
| | | | * mark_rts.c (GC_push_roots): Fix a typo in comment ("GC_push_one").
* Fix '~' operator application to unsigned values shorter than wordIvan Maidanski2016-12-071-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without the fix, unsigned result of "~" operator is zero-extended to a wide type (word) thus the result has leading zeros (which is not expected to be). * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback): Cast (sizeof(word)-1) to word before "~" operation. * mark.c (GC_mark_from): Likewise. * mark_rts.c (GC_add_roots_inner, GC_exclude_static_roots): Likewise. * mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_roots_inner): Likewise. * os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC] (GC_SysVGetDataStart): Likewise. * os_dep.c [!MSWIN32 && DATASTART_USES_BSDGETDATASTART] (GC_FreeBSDGetDataStart): Likewise. * dyn_load.c [(MSWIN32 || MSWINCE || CYGWIN32) && !GC_WIN32_THREADS] (GC_cond_add_roots): Cast (dwAllocationGranularity-1) to word before "~" operation. * include/private/gc_priv.h (HBLKPTR): Cast (HBLKSIZE-1) to word before "~" operation. * os_dep.c [USE_WINALLOC || CYGWIN32] (GC_win32_get_mem): Likewise. * mark.c (GC_mark_from): Change type of new_size local variable from int to word. * os_dep.c [OPENBSD] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Change type of pgsz local variable from size_t to word (to avoid implicit unsigned value extension after "~" operation). * os_dep.c [PROC_VDB] (GC_read_dirty): Cast (sizeof(long)-1) to word before "~" operation.
* Fix 'incompatible ptr-to-int conversion' compiler warning in push_all_stackIvan Maidanski2016-11-171-1/+1
| | | | | * mark_rts.c [TRACE_BUF] (GC_push_all_stack_partially_eager): Add explicit cast to word for GC_add_trace_entry bottom/top arguments.
* Enable GC_is_tmp_root for all platformsIvan Maidanski2016-10-291-4/+3
| | | | | * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Define for any platform (not only for Win32); update comment.
* Export GC_is_tmp_root() and GC_print_trace[_inner]()Ivan Maidanski2016-10-291-1/+1
| | | | | | | | | | | | | Note: these 3 functions are not used by GC itself. * include/gc_mark.h (GC_is_tmp_root, GC_print_trace, GC_print_trace_inner): New public API prototype. * mark.c [TRACE_BUF] (GC_print_trace_inner, GC_print_trace): Define as public (GC_API+GC_CALL). * mark_rts.c [MSWIN32 && !NO_DEBUGGING] (GC_is_tmp_root): Likewise. * mark_rts.c [MSWIN32 && !NO_DEBUGGING] (GC_is_tmp_root): Replace GC_bool return type with int, replace ptr_t argument type to void* (because GC_bool and ptr_t are not exported from GC).
* Eliminate 'value of NEED_FIXUP_POINTER unknown' cppcheck info messagesIvan Maidanski2016-10-211-2/+5
| | | | | | | | | | * include/private/gc_pmark.h: Replace #if NEED_FIXUP_POINTER to #ifdef NEED_FIXUP_POINTER. * include/private/gcconfig.h (NEED_FIXUP_POINTER): If FIXUP_POINTER then define to empty else leave undefined. * mark.c (GC_push_all_stack): Replace if(!NEED_FIXUP_POINTER) to #ifndef NEED_FIXUP_POINTER. * mark_rts.c (GC_push_all_stack_partially_eager): Likewise.
* Eliminate 'printf format specifies type void*' GCC pedantic warningsIvan Maidanski2016-10-211-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.