summaryrefslogtreecommitdiff
path: root/gcj_mlc.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid code duplication in IGNORE_OFF_PAGE-specific malloc functionsIvan Maidanski2023-03-241-35/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c: Update comment regarding GC_generic_malloc_inner usage. * alloc.c (GC_collect_or_expand): Replace ignore_off_page argument to flags (check IGNORE_OFF_PAGE bit only in it); update comment. * alloc.c (GC_allocobj): Pass 0 as flags to GC_collect_or_expand. * dbg_mlc.c (GC_debug_generic_malloc, GC_debug_generic_or_special_malloc): Rename knd argument to k. * mallocx.c (GC_generic_or_special_malloc): Likewise. * dbg_mlc.c (GC_debug_generic_malloc): Use GC_generic_malloc_aligned() instead of GC_generic_malloc(). * dbg_mlc.c (GC_debug_generic_malloc_inner): Add flags argument. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc): Likewise. * include/private/gc_priv.h (C_generic_malloc_aligned, GC_generic_malloc_inner): Likewise. * include/private/gc_priv.h [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_core_gcj_malloc): Likewise. * include/private/gc_priv.h [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Likewise. * malloc.c (GC_generic_malloc_inner, GC_generic_malloc_aligned): Likewise. * dbg_mlc.c (GC_debug_generic_malloc_inner): Use GC_generic_malloc_inner() instead of GC_generic_malloc_inner_ignore_off_page(). * dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner_ignore_off_page): Remove GC_INNER function. * include/private/gc_priv.h [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * include/private/gc_priv.h [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner_ignore_off_page): Likewise. * malloc.c [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT && !THREAD_LOCAL_ALLOC] (GC_gcj_malloc): Define as STATIC GC_core_gcj_malloc. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc): Reformat comment; pass flags to GC_generic_malloc_inner(). * gcj_mlc.c [GC_GCJ_SUPPORT && !THREAD_LOCAL_ALLOC] (GC_gcj_malloc): Redirect to GC_core_gcj_malloc() passing 0 to flags argument. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_gcj_malloc): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc_ignore_off_page): Redirect to GC_core_gcj_malloc() passing IGNORE_OFF_PAGE. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_debug_gcj_malloc): Pass 0 as flags to GC_generic_malloc_inner(). * include/private/gc_priv.h (GC_generic_malloc_inner): Update comment. * mallocx.c (GC_generic_malloc_many): Likewise. * include/private/gc_priv.h (GC_collect_or_expand): Replace GC_bool ignore_off_page argument to unsigned flags. * include/private/gc_priv.h (GC_INTERNAL_MALLOC, GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE): Specify macro arguments. * include/private/gc_priv.h (GC_INTERNAL_MALLOC): Pass 0 as flags argument to GC_[debug_]generic_malloc_inner(). * include/private/gc_priv.h (GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE): Pass IGNORE_OFF_PAGE to GC_[debug_]generic_malloc_inner(). * malloc.c (GC_alloc_large): Pass flags (instead of flags!=0) to GC_collect_or_expand(). * malloc.c (GC_generic_malloc_inner_small): New STATIC function (move most of code from GC_generic_malloc_inner). * malloc.c (GC_generic_malloc_inner): Move comment to gc_priv.h; call GC_generic_malloc_inner_small(). * malloc.c (GC_generic_malloc_aligned): Call GC_generic_malloc_inner_small() instead of GC_generic_malloc_inner(); pass flags (instead of 0) to GC_alloc_large(); do not cast result of GC_alloc_large() to ptr_t. * malloc.c (GC_generic_malloc): Pass 0 as flags to GC_generic_malloc_aligned(). * malloc.c (GC_memalign): Likewise. * malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable): Call GC_generic_malloc_aligned() instead of GC_generic_malloc(). * mallocx.c (GC_generic_malloc_many): Likewise. * malloc.c (free_internal): Rename knd local variable to k. * mallocx.c (GC_generic_malloc_ignore_off_page, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page): Redirect to GC_generic_malloc_aligned() passing IGNORE_OFF_PAGE. * typd_mlc.c (GC_generic_malloc_ignore_off_page): Likewise. * tests/gctest.c (run_one_test): Call GC_generic_malloc_ignore_off_page() (with size larger than HBLKSIZE); increment collectable_count.
* Avoid code duplication in GC_core_gcj_mallocIvan Maidanski2023-03-221-25/+9
| | | | | | | | | | (refactoring) * gcj_mlc.c (GENERAL_MALLOC_INNER): Remove. * gcj_mlc.c (GC_core_gcj_malloc): Change type of lg local variable from word to size_t and move it to outermost scope; call LOCK() before SMALL_OBJ(lb); compute and set lg and op local variable inside a conditional expression; expand GENERAL_MALLOC_INNER macro.
* Redirect GC_gcj_malloc_ignore_off_page to GC_gcj_malloc for small objectsIvan Maidanski2023-01-301-33/+15
| | | | | | | | | | | | (refactoring) * gcj_mlc.c (GENERAL_MALLOC_INNER_IOP): Remove. * gcj_mlc.c (GC_core_gcj_malloc): Do not cast lb to word when passed to GENERAL_MALLOC_INNER_IOP(). * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Remove function title comment; add comment about small objects; redirect to GC_gcj_malloc() if SMALL_OBJ(lb); replace GENERAL_MALLOC_INNER_IOP() call to GC_clear_stack(GC_generic_malloc_inner_ignore_off_page()) one.
* Remove unused DCL_LOCK_STATEIvan Maidanski2023-01-301-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_set_disable_automatic_collection, GC_set_stop_func, GC_get_disable_automatic_collection, GC_get_stop_func, GC_set_start_callback, GC_get_start_callback, GC_set_on_collection_event, GC_get_on_collection_event, GC_collect_a_little, GC_try_to_collect_general, GC_expand_hp): Remove DCL_LOCK_STATE. * alloc.c [!GC_DISABLE_INCREMENTAL] (GC_start_incremental_collection): Likewise. * dbg_mlc.c (GC_generate_random_backtrace, store_debug_info, GC_debug_register_displacement): Likewise. * dyn_load.c [DARWIN_DEBUG && !NO_DEBUGGING] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * finalize.c (GC_register_disappearing_link_inner, GC_unregister_disappearing_link, GC_complete_ongoing_collection, GC_set_toggleref_func, GC_get_toggleref_func, GC_toggleref_add, GC_set_await_finalize_proc, GC_get_await_finalize_proc, GC_unregister_long_link, GC_move_disappearing_link, GC_move_long_link, GC_register_finalizer_inner, GC_finalize, GC_invoke_finalizers, GC_notify_or_invoke_finalizers): Likewise. * fnlz_mlc.c (GC_init_finalized_malloc): Likewise. * gc_dlopen.c [!USE_PROC_FOR_LIBRARIES] (disable_gc_for_dlopen): Likewise. * gcj_mlc.c (GC_init_gcj_malloc, maybe_finalize, GC_core_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_alloc_large, GC_generic_malloc_inner, GC_generic_malloc_aligned, GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_free): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * mark.c (GC_print_trace): Likewise. * mark_rts.c (GC_add_roots, GC_clear_roots, GC_remove_roots): Likewise. * misc.c (GC_get_heap_usage_safe, GC_get_heap_usage_safe, GC_is_init_called, GC_init, GC_enable_incremental, GC_start_mark_threads, GC_set_warn_proc, GC_get_warn_proc, GC_set_abort_func, GC_get_abort_func, GC_enable, GC_disable, GC_new_free_list, GC_new_kind, GC_new_proc, GC_call_with_alloc_lock, GC_dump, GC_get_memory_use, GC_alloc_lock, GC_set_on_thread_event, GC_get_on_thread_event, GC_set_oom_fn, GC_get_oom_fn, GC_set_on_heap_resize, GC_get_on_heap_resize, GC_set_finalizer_notifier, GC_get_finalizer_notifier, GC_set_all_interior_pointers): Likewise. * obj_map.c (GC_register_displacement): Likewise. * os_dep.c (GC_get_stack_base, GC_print_callers): Likewise. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_thread_is_registered, GC_register_altstack, GC_wait_for_gc_completion, GC_init_parallel, GC_do_blocking_inner, GC_suspend_self_blocked, GC_get_my_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_pthread_cancel, GC_pthread_exit, GC_allow_register_threads, GC_register_my_thread, GC_thread_exit_proc, GC_pthread_join, GC_pthread_detach, GC_start_rtn_prepare_thread): Likewise. * ptr_chck.c (GC_set_same_obj_print_proc, GC_get_same_obj_print_proc, GC_set_is_valid_displacement_print_proc, GC_set_is_visible_print_proc, GC_get_is_valid_displacement_print_proc, GC_get_is_visible_print_proc): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * alloc.c (GC_max_retries): Change type from GC_word to word. * include/private/gc_locks.h: Remove DCL_LOCK_STATE from comment, * include/private/gc_locks.h (DCL_LOCK_STATE): Do not define.
* Do not mention FASTLOCK in commentIvan Maidanski2023-01-301-3/+1
| | | | | | | | (fix of commit 3c50a689c) * gcj_mlc.c [GC_GCJ_SUPPORT]: Remove FASTLOCK in comment. * include/private/gc_locks.h [PCR && !CPPCHECK] (DCL_LOCK_STATE): Do not define GC_fastLockRes variable.
* Use cast to void instead of the attribute to indicate unused argumentsIvan Maidanski2022-09-151-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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-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.
* Replace comments about GC is held or not with relevant assertionsIvan Maidanski2022-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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 extra parentheses in return statementIvan Maidanski2022-05-011-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Move public header files to include/gc in source treeIvan Maidanski2021-11-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, include/extra public header files (for the redirection) are moved to include directory. This is have the same directories structure of public headers in the source tree as that of the installed "include" directory. * doc/finalization.md: Remove "include/" prefix for cord.h. * LICENSE: Rename include/gc_allocator.h to gc/gc_allocator.h. * Makefile.direct (CORD_SRCS, CORD_INCLUDE_FILES): Add "gc/" prefix for cord.h, ec.h, cord_pos.h. * CMakeLists.txt [install_headers]: Likewise. * cord/cord.am (pkginclude_HEADERS): Likewise. * Makefile.direct (SRCS, tests/test.o, dyn_load.o, dyn_load_sunos53.o, mark.o, typd_mlc.o, finalize.o, ptr_chck.o, specific.o, alloc.o, pthread_support.o, thread_local_alloc.o, win32_threads.o): Add "gc/" prefix for gc_typed.h, gc_tiny_fl.h, gc_version.h, gc_inline.h, gc_mark.h, gc_disclaim.h, gc_allocator.h, javaxfc.h, gc_backptr.h, gc_gcj.h, leak_detector.h, gc_pthread_redirects.h, gc_config_macros.h. * NT_MAKEFILE (test.obj): Add gc\ prefix for gc_mark.h, gc_disclaim.h. * NT_MAKEFILE (cord\tests\de.obj, cord\tests\de_win.obj): Add gc\ prefix for cord.h, cord_pos.h. * OS2_MAKEFILE (cord\cordbscs.obj, cord\cordxtra.obj, cord\cordprnt.obj, cordtest.exe): Likewise. * cord/cordbscs.c: Add "gc/" prefix in include for cord.h, ec.h; reorder includes. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_win.c: Likewise. * extra/gc.c: Add "gc/" prefix in include for gc_inline.h, gc_pthread_redirects.h, javaxfc.h, gc_disclaim.h, gc_gcj.h, gc_backptr.h, gc_mark.h, gc_tiny_fl.h, leak_detector.h., gc_typed.h. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gcj_mlc.c: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/disclaim_test.c: Likewise. * tests/disclaim_weakmap_test.c: Likewise. * tests/leak_test.c: Likewise. * tests/staticrootstest.c: Likewise. * tests/test.c: Likewise. * tests/thread_leak_test.c: Likewise. * tests/trace_test.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * tests/test_cpp.cc: Add "gc/" prefix in include for gc_allocator.h. * include/extra/gc.h: Move to include folder; replace include<> to include "". * include/extra/gc_cpp.h: Likewise. * include/cord.h: Move to include/gc folder. * include/cord_pos.h: Likewise. * include/ec.h: Likewise. * include/gc.h: Likewise. * include/gc_allocator.h: Likewise. * include/gc_backptr.h: Likewise. * include/gc_config_macros.h: Likewise. * include/gc_cpp.h: Likewise. * include/gc_disclaim.h: Likewise. * include/gc_gcj.h: Likewise. * include/gc_inline.h: Likewise. * include/gc_mark.h: Likewise. * include/gc_pthread_redirects.h: Likewise. * include/gc_tiny_fl.h: Likewise. * include/gc_typed.h: Likewise. * include/gc_version.h: Likewise. * include/javaxfc.h: Likewise. * include/leak_detector.h: Likewise. * include/include.am (pkginclude_HEADERS): Add "gc/" prefix for gc.h, gc_backptr.h, gc_config_macros.h, gc_inline.h, gc_mark.h, gc_tiny_fl.h, gc_typed.h, gc_version.h, javaxfc.h, leak_detector.h, gc_disclaim.h, gc_gcj.h, gc_pthread_redirects.h, gc_allocator.h, gc_cpp.h. * CMakeLists.txt [install_headers]: Likewise. * include/include.am (include_HEADERS): Remove "extra/" prefix for gc_cpp.h, gc.h. * CMakeLists.txt [install_headers]: Likewise.
* Move GC state pointer variables into GC_arraysIvan Maidanski2020-07-191-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Remove GC_gcj_malloc_initialized variableIvan Maidanski2020-06-211-18/+8
| | | | | | | | | | | | | | | (code refactoring) GC_gcjobjfreelist is non-null if GC_init_gcj_malloc() has been called. * gcj_mlc.c (GC_gcj_malloc_initialized): Remove variable. * gcj_mlc.c (GC_init_gcj_malloc): Check GC_gcjobjfreelist is non-null instead of GC_gcj_malloc_initialized. * thread_local_alloc.c [GC_GCJ_SUPPORT && GC_ASSERTIONS] (GC_gcj_malloc): Likewise. * gcj_mlc.c (GC_init_gcj_malloc): Do not set GC_gcj_malloc_initialized. * include/private/gc_priv.h [GC_GCJ_SUPPORT && GC_ASSERTIONS] (GC_gcj_malloc_initialized): Remove declaration.
* 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.
* Eliminate 'condition is always true' cppcheck warning in init_gcj_mallocIvan Maidanski2018-07-111-2/+5
| | | | | | * gcj_mlc.c (GC_init_gcj_malloc): Define ignore_gcj_info as macro if GC_IGNORE_GCJ_INFO; undefine ignore_gcj_info at the end of the function.
* Add GC_reachable_here after GC_dirty in GC sourceIvan Maidanski2018-06-231-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commits 73d30d2b4, e5fb574cf) * README.md (Incremental Collection): Add note about bugs caused by a missing GC_reachable_here call. * doc/gcdescr.md (Generational Collection): Mention GC_reachable_here for MANUAL_VDB mode. * finalize.c (GC_register_disappearing_link_inner, GC_register_finalizer_inner): Move GC_dirty(new_dl) call to be before unlocking (so that to ensure no collection occurs between initialization of new_dl and GC_dirty() call). * finalize.c (GC_finalize): Call GC_dirty() immediately after updating GC_fnlz_roots.fo_head (instead of setting needs_barrier) if GC_object_finalized_proc is set. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Call REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr) after GC_dirty(op). * include/gc.h (GC_end_stubborn_change): Mention GC_reachable_here in comment. * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call GC_reachable_here(next) after GC_end_stubborn_change(my_fl); remove GC_end_stubborn_change() call when a non-pointer is stored to my_fl; remove GC_end_stubborn_change() after GC_generic_malloc_many() call. * include/gc_inline.h (GC_CONS): Call GC_reachable_here for the stored pointers after GC_end_stubborn_change call. * include/private/gc_priv.h (REACHABLE_AFTER_DIRTY): New macro. * mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): If GC_is_heap_ptr(result) then call GC_dirty(result) and REACHABLE_AFTER_DIRTY(op) after storing op pointer. * typd_mlc.c (GC_make_sequence_descriptor): Call REACHABLE_AFTER_DIRTY for the stored pointers after GC_dirty(result). * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Call REACHABLE_AFTER_DIRTY(d) after GC_dirty(op). * win32_threads.c (GC_CreateThread, GC_beginthreadex, GC_pthread_create): Call REACHABLE_AFTER_DIRTY for the stored pointer after GC_dirty.
* Fix missing GC_dirty calls for GC-allocated objects used internallyIvan Maidanski2018-05-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change matters only in case of MANUAL_VDB mode. * finalize.c (GC_grow_table, GC_register_disappearing_link, GC_unregister_disappearing_link_inner, GC_process_togglerefs, GC_toggleref_add, GC_move_disappearing_link_inner, GC_register_finalizer_inner, ITERATE_DL_HASHTBL_END, DELETE_DL_HASHTBL_ENTRY, GC_finalize, GC_enqueue_all_finalizers): Call GC_dirty where needed. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * pthread_start.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_inner_start_routine): Likewise. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_new_thread, GC_delete_thread, GC_delete_gc_thread): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific, GC_remove_specific_after_fork): Likewise. * typd_mlc.c (GC_make_sequence_descriptor, GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_delete_gc_thread_no_free, GC_delete_thread, GC_CreateThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create, GC_pthread_start_inner): Likewise. * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call GC_end_stubborn_change(my_fl) after GC_FAST_M_AO_STORE() call unless kind is GC_I_PTRFREE. * include/gc_inline.h (GC_CONS): Call GC_end_stubborn_change(result).
* Remove code duplication in gcj_malloc and malloc_explicitly_typedIvan Maidanski2018-05-161-4/+2
| | | | | | | | | (code refactoring) * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Store ptr_to_struct_containing_descr in a single place of code. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Store d (to the object) in a single place of code.
* Fix the collector hang when it is configured with --enable-gc-debugIvan Maidanski2018-03-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #205 (bdwgc). * dbg_mlc.c (GC_store_debug_info_inner): Remove comment (as it exists in the header); change from STATIC to GC_INNER. * dbg_mlc.c (STORE_DEBUG_INFO): New macro. * dbg_mlc.c (GC_store_debug_info): Change from GC_INNER to static; remove GC_ prefix; replace ptr_t to void*; add fn argument; replace "const char *string, int linenum" with GC_EXTRA_PARAMS; change "word sz" argument to "size_t lb"; allow p to be null (print error message in this case); call GC_start_debugging_inner unless GC_debugging_started; call ADD_CALL_CHAIN. * dbg_mlc.c (GC_start_debugging): Remove. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable): Call STORE_DEBUG_INFO() instead of checking result for null and calling GC_start_debugging, ADD_CALL_CHAIN, GC_store_debug_info. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Likewise. * dbg_mlc.c [GC_ATOMIC_UNCOLLECTABLE] (GC_debug_malloc_atomic_uncollectable): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_debug_gcj_malloc): Call ADD_CALL_CHAIN while holding the lock; call GC_store_debug_info_inner (holding the lock) instead of GC_store_debug_info. * include/private/dbg_mlc.h (ADD_CALL_CHAIN): Update comment. * include/private/gc_priv.h (GC_store_debug_info): Replace with GC_store_debug_info_inner; update comment; change ptr_t to void*. * os_dep.c [SAVE_CALL_CHAIN] (GC_save_callers): Add assertion that the allocation lock is held; add comment.
* Avoid potential race when accessing size_map tableHans Boehm2018-02-261-2/+4
| | | | | | | | | | | | | | | | | | There is again a data race between GC_extend_size_map and GC_size_map[] readers, though it is again not likely to fail in practice. It is feasible to just move all of the GC_size_map accesses under the lock, and this does not look to incur a substantial penalty. * gcj_mlc.c (GC_gcj_malloc, GC_gcj_malloc_ignore_off_page): Move lg=GC_size_map[lb] to be right after LOCK() instead of preceding it. * malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Likewise. * include/gc.h (GC_get_size_map_at): Update comment to note that the client should use synchronization when calling the function. * include/private/gc_priv.h (_GC_arrays._size_map): Add comment about synchronization.
* Convert GC source files to valid C++ codeIvan Maidanski2018-02-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*.
* Eliminate TSan warning about data race when accessing GC_debugging_startedIvan Maidanski2017-11-171-2/+2
| | | | | | | | | | | | | | | | Now GC_debugging_started variable is double-checked with the allocation lock held before calling GC_start_debugging_inner. * dbg_mlc.c (GC_start_debugging_inner): Define as GC_INNER (instead of STATIC). * dbg_mlc.c [THREADS] (GC_start_debugging): Define as STATIC; do not call GC_start_debugging_inner() if GC_debugging_started. * dbg_mlc.c [!THREADS] (GC_start_debugging): Define as macro (redirect to GC_start_debugging_inner). * gcj_mlc.c (GC_debug_gcj_malloc): Call GC_start_debugging_inner (holding the lock) instead of GC_start_debugging. * include/private/gc_priv.h (GC_start_debugging): Rename to GC_start_debugging_inner; improve usage comment.
* Fix '32-bit value shift followed by expansion to 64-bit' code defectIvan Maidanski2016-12-071-2/+2
| | | | | | | | | | | | * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page): Cast lg local variable to word before passing it to GRANULES_TO_BYTES (so that value type widening does not occur after the value left shift). * malloc.c (GC_generic_malloc_inner, GC_malloc_kind_global, GC_generic_malloc_uncollectable): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Likewise. * misc.c (block_add_size): Cast hhdr->hb_sz to word before passing it to WORDS_TO_BYTES; cast HBLKSIZE-1 to word before "~" operation.
* Eliminate more 'scope of variable can be reduced' cppcheck style warningsIvan Maidanski2016-10-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Fix malloc routines to prevent size value wrap-aroundIvan Maidanski2016-09-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See issue #135 on Github. * allchblk.c (GC_allochblk, GC_allochblk_nth): Use OBJ_SZ_TO_BLOCKS_CHECKED instead of OBJ_SZ_TO_BLOCKS. * malloc.c (GC_alloc_large): Likewise. * alloc.c (GC_expand_hp_inner): Type of "bytes" local variable changed from word to size_t; cast ROUNDUP_PAGESIZE argument to size_t; prevent overflow when computing GC_heapsize+bytes > GC_max_heapsize. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc, GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable): Use SIZET_SAT_ADD (instead of "+" operator) to add extra bytes to lb value. * fnlz_mlc.c (GC_finalized_malloc): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES, ADD_SLOP, ROUNDUP_PAGESIZE): Likewise. * include/private/gcconfig.h (GET_MEM): Likewise. * mallocx.c (GC_malloc_many, GC_memalign): Likewise. * os_dep.c (GC_wince_get_mem, GC_win32_get_mem): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * headers.c (GC_scratch_alloc): Change type of bytes_to_get from word to size_t (because ROUNDUP_PAGESIZE_IF_MMAP result type changed). * include/private/gc_priv.h: Include limits.h (unless SIZE_MAX already defined). * include/private/gc_priv.h (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Move from malloc.c file. * include/private/gc_priv.h (SIZET_SAT_ADD): New macro (defined before include gcconfig.h). * include/private/gc_priv.h (EXTRA_BYTES, GC_page_size): Change type to size_t. * os_dep.c (GC_page_size): Likewise. * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES, ADD_SLOP, ROUNDUP_PAGESIZE): Add comment about the argument. * include/private/gcconfig.h (GET_MEM): Likewise. * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES, ADD_SLOP, OBJ_SZ_TO_BLOCKS, ROUNDUP_PAGESIZE, ROUNDUP_PAGESIZE_IF_MMAP): Rename argument to "lb". * include/private/gc_priv.h (OBJ_SZ_TO_BLOCKS_CHECKED): New macro. * include/private/gcconfig.h (GC_win32_get_mem, GC_wince_get_mem, GC_unix_get_mem): Change argument type from word to int. * os_dep.c (GC_unix_mmap_get_mem, GC_unix_get_mem, GC_unix_sbrk_get_mem, GC_wince_get_mem, GC_win32_get_mem): Likewise. * malloc.c (GC_alloc_large_and_clear): Call OBJ_SZ_TO_BLOCKS only if no value wrap around is guaranteed. * malloc.c (GC_generic_malloc): Do not check for lb_rounded < lb case (because ROUNDED_UP_GRANULES and GRANULES_TO_BYTES guarantees no value wrap around). * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * misc.c (GC_init_size_map): Change "i" local variable type from int to size_t. * os_dep.c (GC_write_fault_handler, catch_exception_raise): Likewise. * misc.c (GC_envfile_init): Cast len to size_t when passed to ROUNDUP_PAGESIZE_IF_MMAP. * os_dep.c (GC_setpagesize): Cast GC_sysinfo.dwPageSize and GETPAGESIZE() to size_t (when setting GC_page_size). * os_dep.c (GC_unix_mmap_get_mem, GC_unmap_start, GC_remove_protection): Expand ROUNDUP_PAGESIZE macro but without value wrap-around checking (the argument is of word type). * os_dep.c (GC_unix_mmap_get_mem): Replace -GC_page_size with ~GC_page_size+1 (because GC_page_size is unsigned); remove redundant cast to size_t. * os_dep.c (GC_unix_sbrk_get_mem): Add explicit cast of GC_page_size to SBRK_ARG_T. * os_dep.c (GC_wince_get_mem): Change type of res_bytes local variable to size_t. * typd_mlc.c: Do not include limits.h. * typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Remove (as defined in gc_priv.h now).
* Remove unused GC_gcjdebugobjfreelistIvan Maidanski2016-07-261-6/+1
| | | | | | | | (code refactoring) * gcj_mlc.c (GC_gcjdebugobjfreelist): Remove. * gcj_mlc.c (GC_init_gcj_malloc): Do not store GC_new_free_list_inner result to GC_gcjdebugobjfreelist.
* Workaround 'identical expr on both sides of bitwise op' warningIvan Maidanski2016-02-091-1/+1
| | | | | | | * gcj_mlc.c (GC_init_gcj_malloc): Comment out "0 |" (in the expression of "0 | GC_DS_LENGTH"). * mark.c (GC_obj_kinds, GC_push_marked, GC_push_unconditionally): Likewise.
* Fix MS VC redefinition warning for functions declared with GC_ATTR_MALLOCIvan Maidanski2014-04-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_strdup, GC_debug_strndup, GC_debug_wcsdup, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable, GC_debug_generic_or_special_malloc, GC_debug_malloc_replacement): Add GC_ATTR_MALLOC attribute to API function definition (to avoid MS VC warning about redefinition of a symbol previously declared with __declspec). * fnlz_mlc.c (GC_finalized_malloc): Likewise. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc, GC_malloc_atomic, GC_malloc, GC_malloc_uncollectable): Likewise. * mallocx.c (GC_generic_or_special_malloc, GC_generic_malloc_ignore_off_page, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, GC_malloc_many, GC_memalign, GC_malloc_atomic_uncollectable, GC_strdup, GC_strndup, GC_wcsdup): Likewise. * stubborn.c (GC_malloc_stubborn): Likewise. * thread_local_alloc.c (GC_malloc, GC_malloc_atomic, GC_gcj_malloc): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise.
* Remove 'opp' local variable in GC_malloc_XIvan Maidanski2013-12-151-9/+5
| | | | | | | | | | | | | | | (code refactoring) * alloc.c: Update comment (about free lists). * fnlz_mlc.c (GC_finalized_malloc): Remove "opp" local variable (replace *opp with <kind>freelist[lg]). * gcj_mlc.c (GC_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_malloc_atomic, GC_malloc, GC_malloc_uncollectable): Likewise. * mallocx.c (GC_malloc_atomic_uncollectable): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise.
* Replace conditional GC_log_printf calls with GC_COND/VERBOSE_LOG_PRINTFIvan Maidanski2012-11-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * allchblk.c (GC_freehblk): Replace "if (GC_print_stats) GC_log_printf" with GC_COND_LOG_PRINTF. * alloc.c (GC_timeout_stop_func, GC_maybe_gc, GC_try_to_collect_inner, GC_stopped_mark, GC_finish_collection, GC_expand_hp_inner, GC_collect_or_expand): Likewise. * backgraph.c (backwards_height, GC_print_back_graph_stats): Likewise. * checksums.c (GC_check_blocks, GC_check_dirty): Likewise. * dyn_load.c (GC_register_dynamic_libraries): Likewise. * finalize.c (GC_general_register_disappearing_link, GC_register_finalizer_inner): Likewise. * gcj_mlc.c (GC_init_gcj_malloc): Likewise. * headers.c (GC_scratch_alloc): Likewise. * mark.c (GC_mark_some_inner, GC_mark_some, GC_signal_mark_stack_overflow, GC_return_mark_stack, alloc_mark_stack): Likewise. * obj_map.c (GC_add_map_entry): Likewise. * os_dep.c (GC_get_maps, backing_store_base_from_proc, GC_register_data_segments, detect_GetWriteWatch, GC_add_current_malloc_heap, GC_remap, PROTECT, GC_write_fault_handler, GC_dirty_init, GC_mprotect_thread): Likewise. * pthread_stop_world.c (GC_stop_world, GC_start_world, GC_stop_init): Likewise. * pthread_support.c (start_mark_threads, GC_thr_init): Likewise. * win32_threads.c (GC_register_my_thread_inner, GC_thr_init): Likewise. * alloc.c (GC_finish_collection): Replace "if (GC_print_stats == VERBOSE) GC_log_printf" with GC_VERBOSE_LOG_PRINTF. * blacklst.c (GC_promote_black_lists): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Likewise. * mark.c (GC_mark_local, GC_do_parallel_mark): Likewise. * os_dep.c (GC_dirty_init): Likewise. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * win32_threads.c (GC_push_all_stacks): Likewise. * include/private/gc_priv.h (GC_COND_LOG_PRINTF, GC_VERBOSE_LOG_PRINTF): New macro (check GC_print_stats and call GC_log_printf if enabled). * os_dep.c (GC_dirty_init, GC_read_dirty): Replace "if (GC_print_stats) GC_err_printf" with WARN.
* Improve GC error printing atomicity in GC_debug_X and GC_print_objIvan Maidanski2012-11-081-4/+2
| | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_generate_random_backtrace_no_gc): Refine comment. * dbg_mlc.c (GC_print_type): Replace multiple code fragments calling GC_err_puts with a single invocation of GC_err_puts (or GC_err_printf) at the routine end (code refactoring). * dbg_mlc.c (IF_NOT_SHORTDBG_HDRS, COMMA_IFNOT_SHORTDBG_HDRS): New macro (used by GC_print_obj). * dbg_mlc.c (GC_print_obj, GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable): Replace adjacent GC_err_printf and GC_err_puts calls with a single GC_err_printf invocation (for output atomicity). * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * os_dep.c (GC_register_data_segments): Likewise. * dbg_mlc.c (GC_malloc_stubborn): Fix printed function name.
* Enable 'Force GC at every GC_malloc' debug-related functionalityIvan Maidanski2012-09-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * doc/README.environment (GC_COLLECT_AT_MALLOC): Document. * doc/README.macros (GC_COLLECT_AT_MALLOC): Likewise. * fnlz_mlc.c (GC_core_finalized_malloc): Insert GC_DBG_COLLECT_AT_MALLOC invocation (before LOCK). * gcj_mlc.c (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc, GC_malloc_atomic, GC_malloc, GC_malloc_uncollectable): Likewise. * mallocx.c (GC_generic_malloc_ignore_off_page, GC_generic_malloc_many, GC_malloc_atomic_uncollectable): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page): Likewise. * include/private/gc_priv.h (GC_COLLECT_AT_MALLOC): Recognize new macro. (GC_dbg_collect_at_malloc_min_lb): New global variable declaration (only if GC_COLLECT_AT_MALLOC defined). (GC_DBG_COLLECT_AT_MALLOC): Define new macro (invoking GC_gcollect). * malloc.c (GC_dbg_collect_at_malloc_min_lb): New global variable (only if GC_COLLECT_AT_MALLOC defined). * misc.c (GC_init): Test "GC_COLLECT_AT_MALLOC" environment variable and alter default GC_dbg_collect_at_malloc_min_lb value (only if GC_COLLECT_AT_MALLOC macro defined).
* Adjust GC_log_printf format specifiers (regarding signed/unsigned long)Ivan Maidanski2012-01-281-1/+1
| | | | | | | | | | | | | | | | | | | | * alloc.c (GC_maybe_gc, GC_expand_hp_inner): Change printf "%ld" format specifier to "%lu" one according to printed value. * backgraph.c (GC_print_back_graph_stats): Likewise. * blacklst.c (GC_default_print_heap_obj_proc, GC_promote_black_lists): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * mark_rts.c (GC_print_static_roots): Likewise. * alloc.c (GC_stopped_mark): Correct logged GC number. * dbg_mlc.c (GC_print_backtrace): Cast printed value to proper type. * mark.c (GC_mark_from): Likewise. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable): Change printf "%ld" format specifier for line number to "%d" one. * malloc.c (GC_free): Improve logged message (if LOG_ALLOCS). * thread_local_alloc.c (GC_malloc): Likewise. * os_dep.c (GC_dirty_init): Improve logged message (for VERBOSE level).
* Replace ABORTs followed by statement with ABORT_RET having dummyIvan Maidanski2012-01-231-1/+1
| | | | | | | | | | | | | | condition (to suppress 'statement unreachable' compiler warnings caused by abort tagged as 'no-return') * dbg_mlc.c (GC_debug_realloc): Replace ABORT() with ABORT_RET(). * gcj_mlc.c (mark_stack_limit): Likewise. * os_dep.c (catch_exception_raise_state, catch_exception_raise_state_identity): Likewise. * typd_mlc.c (GC_descr_obj_size, GC_push_complex_descriptor): Likewise. * include/private/gc_priv.h (ABORT_RET): New macro. * mark.c (GC_mark_from): Put ABORT_RET instead of "cannot happen" comment.
* Use EXPECT in malloc result testing for NULLIvan Maidanski2012-01-181-1/+2
| | | | | | | | | | | * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Use EXPECT to test "op" value for NULL. * malloc.c (GC_generic_malloc_inner, GC_malloc_uncollectable): Likewise. * mallocx.c (GC_generic_malloc_many, GC_posix_memalign): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise.
* Use EXPECT for checking various 'initialized' boolean variablesIvan Maidanski2011-12-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_try_to_collect_general, GC_expand_hp): Use "expect true" for GC_is_initialized value. * gcj_mlc.c (maybe_finalize): Likewise. * malloc.c (GC_alloc_large, GC_generic_malloc_inner, malloc): Likewise. * mallocx.c (GC_generic_malloc_many): Likewise. * mark_rts.c (GC_add_roots, GC_clear_roots): Likewise. * misc.c (GC_base, GC_init): Likewise. * ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_is_visible): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Use "expect true" for GC_thr_initialized value. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (pthread_create): Likewise. * dyn_load.c (GC_register_dynamic_libraries_dl_iterate_phdr): Use "expect true" for excluded_segs value. * include/private/gc_priv.h (COND_DUMP): Use "expect false" for GC_dump_regularly value. * malloc.c (GC_generic_malloc): Use "expect false" for GC_have_errors value. * mallocx.c (GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * malloc.c (calloc): Use "expect true" for lib_bounds_set value. * os_dep.c (GC_unix_mmap_get_mem): Use "expect true" for "initialized" value. * pthread_stop_world.c (GC_nacl_initialize_gc_thread): Use "expect true" for GC_nacl_thread_parking_inited value. * pthread_support.c (INIT_REAL_SYMS): Use "expect true" for GC_syms_initialized value; remove redundant trailing ';'. * pthread_support.c (GC_new_thread): Use "expect true" for first_thread_used value. * win32_threads.c (GC_new_thread): Likewise. * pthread_support.c (pthread_create): Use "expect true" for parallel_initialized value. * win32_threads.c (GC_CreateThread, GC_beginthreadex, GC_pthread_join, GC_pthread_create, GC_pthread_sigmask, GC_pthread_detach): Likewise. * pthread_support.c (pthread_create): Use "expect false" for "si" value to be NULL. * thread_local_alloc.c (GC_init_thread_local): Use "expect true" for keys_initialized value. * typd_mlc.c (GC_make_descriptor): Use "expect true" for GC_explicit_typing_initialized value.
* Replace ARGSUSED comment-based annotation with GCC 'unused' attribute.Ivan Maidanski2011-09-141-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turn on unused-parameter checking for GCC. * alloc.c (GC_try_to_collect_general): Add GC_ATTR_UNUSED attribute to an argument. * tests/test.c (tiny_reverse_test, thr_run_one_test): Likewise. * backgraph.c (reset_back_edge, update_max_height): Replace ARGSUSED annotation with GC_ATTR_UNUSED attribute for some arguments. * checksums.c (GC_add_block): Likewise. * dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change, GC_check_heap_block): Likewise. * finalize.c (GC_null_finalize_mark_proc): Likewise. * gcj_mlc.c (GC_gcj_fake_mark_proc): Likewise. * mark.c (GC_noop, clear_marks_for_block, GC_mark_and_push): Likewise. * mark_rts.c (GC_push_conditional_with_exclusions, GC_push_current_stack): Likewise. * misc.c (GC_default_oom_fn, GC_do_blocking_inner): Likewise. * os_dep.c (GC_fault_handler_openbsd, GC_fault_handler, GC_remove_protection, GC_page_was_dirty, GC_page_was_ever_dirty): Likewise. * pthread_stop_world.c (GC_suspend_handler, GC_suspend_handler_inner): Likewise. * pthread_support.c (GC_do_blocking_inner): Likewise. * stubborn.c (GC_change_stubborn, GC_end_stubborn_change): Likewise. * tests/test.c (fail_proc1): Likewise. * typd_mlc.c (GC_array_mark_proc): Likewise. * win32_threads.c (GC_do_blocking_inner, DllMain): Likewise. * include/private/gc_priv.h (GC_ATTR_UNUSED): Define new macro. * cordxtra.c (CORD_ATTR_UNUSED): Likewise. * cordxtra.c (CORD_nul_func, CORD_lf_close_proc): Replace ARGSUSED annotation with CORD_ATTR_UNUSED attribute for an argument. * mach_dep.c (GC_clear_stack_inner): Remove ARGSUSED annotation and use "limit" argument in the function (to suppress compiler warning). * misc.c (GC_clear_stack_inner): Remove ARGSUSED. * tests/threadkey_test.c (on_thread_exit_inner, on_thread_exit): Use all function arguments (to suppress compiler warning). * configure.ac (CFLAGS): Remove "-Wno-unused-parameter" option.
* 2011-05-31 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_add_current_malloc_heap, GC_build_back_graph, GC_traverse_back_graph): Move prototype to gc_priv.h. * checksums.c (GC_page_was_ever_dirty): Ditto. * dbg_mlc.c (GC_default_print_heap_obj_proc): Ditto. * dyn_load.c (GC_parse_map_entry, GC_get_maps, GC_segment_is_thread_stack, GC_roots_present, GC_is_heap_base, GC_get_next_stack): Ditto. * finalize.c (GC_reset_finalizer_nested, GC_check_finalizer_nested): Ditto. * gcj_mlc.c (GC_start_debugging, GC_store_debug_info): Ditto. * malloc.c (GC_extend_size_map, GC_text_mapping): Ditto. * mark_rts.c (GC_mark_thread_local_free_lists): Ditto. * misc.c (GC_register_main_static_data, GC_init_win32, GC_setpagesize, GC_init_linux_data_start, GC_set_and_save_fault_handler, GC_init_dyld, GC_init_netbsd_elf, GC_initialize_offsets, GC_bl_init, GC_do_blocking_inner, GC_bl_init_no_interiors): Ditto. * os_dep.c (GC_greatest_stack_base_below, GC_push_all_stacks): Ditto. * reclaim.c (GC_check_leaked): Ditto. * win32_threads.c (GC_gww_dirty_init): Ditto. * darwin_stop_world.c (GC_is_mach_marker, GC_mprotect_stop, GC_mprotect_resume): Move prototype to darwin_stop_world.h. * pthread_support.c (GC_FindTopOfStack): Ditto. * dyn_load.c (GC_cond_add_roots): Merge adjacent definitions. * mark.c (GC_page_was_ever_dirty): Remove (as already declared). * mark_rts.c (GC_roots_present): Change return type to void pointer (to match the prototype); return NULL instead of FALSE. * mark_rts.c (GC_add_roots_inner): Cast GC_roots_present() result. * os_dep.c (NEED_PROC_MAPS): Move definition to gcconfig.h. * os_dep.c (GC_write_fault_handler): Make STATIC. * os_dep.c (GC_set_write_fault_handler): New function (only if GC_WIN32_THREADS). * pthread_start.c (GC_start_rtn_prepare_thread, GC_thread_exit_proc): Move prototype to pthread_support.h. * pthread_support.c (GC_nacl_initialize_gc_thread, GC_nacl_shutdown_gc_thread, GC_unblock_gc_signals): Ditto. * pthread_support.c (GC_stop_init): Move prototype to pthread_stop_world.h. * thread_local_alloc.c (GC_check_tls_for): Reformat comment. * win32_threads.c (GC_write_fault_handler): Remove prototype. * win32_threads.c (GC_register_my_thread_inner): Call GC_set_write_fault_handler instead of SetUnhandledExceptionFilter (only if MPROTECT_VDB). * doc/README.win32: Add information about DMC. * include/private/gc_priv.h (GC_set_write_fault_handler): New prototype (only if GC_WIN32_THREADS and MPROTECT_VDB).
* 2011-05-03 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+2
| | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_store_debug_info_inner, GC_store_debug_info): Rename "integer" argument to "linenum"; change the type of the argument to int. * gcj_mlc.c (GC_store_debug_info): Ditto. * dbg_mlc.c (GET_OH_LINENUM): New macro. * dbg_mlc.c (GC_print_obj, GC_print_smashed_obj): Use GET_OH_LINENUM; adjust print format specifier. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable): Remove unnecessary cast of "i". * gcj_mlc.c (GC_debug_gcj_malloc): Ditto.
* 2011-04-10 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+6
| | | | | | | | | | | | | | | | | * gcj_mlc.c (GC_gcj_malloc_initialized): Use STATIC unless GC_ASSERTIONS. * include/private/gc_priv.h (GC_gcj_malloc_initialized): Don't declare (as external) unless GC_ASSERTIONS. * os_dep.c (GC_win32_free_heap): Clear GC_heap_bases[] also for Cygwin; add FIXME. * include/private/gcconfig.h: Include <sys/unistd.h> for RTEMS. * include/private/gcconfig.h: Add "#error" for every "-->" mark. * include/private/gcconfig.h (CLEAR_DOUBLE): Turn the code into an expression. * include/private/pthread_support.h (SUSPENDED_EXT): Add new flag (which existed previously as SUSPENDED and still exists in GCJ). * include/private/pthread_support.h (DISABLED_GC): Change the value (as it is already used by SUSPENDED_EXT).
* 2011-04-09 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+7
| | | | | | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_register_finalizer_no_order): Remove redundant declaration. * dbg_mlc.c (GC_debug_malloc_replacement, GC_debug_realloc_replacement): Rename RA to GC_DBG_RA. * malloc.c (GC_debug_malloc_replacement): Ditto. * mallocx.c (GC_debug_realloc_replacement): Ditto. * dbg_mlc.c (GC_store_debug_info): Move proto from dbg_mlc.h. * malloc.c (GC_strdup, GC_strndup, GC_wcsdup): Move to mallocx.c. * malloc.c: Include errno.h only REDIRECT_MALLOC; remove redundant includes of string.h. * mallocx.c: Include string.h (for GC_strdup). * include/private/dbg_mlc.h (GC_store_debug_info): Move declaration to dbg_mlc.c. * include/private/gc_locks.h (UNCOND_LOCK, UNCOND_UNLOCK): Remove redundant trailing ';'. * include/private/gc_priv.h (START_WORLD, COND_DUMP): Ditto. * include/private/gc_locks.h (LOCK, UNLOCK): Place opening '{' properly. * include/private/gc_priv.h (GC_DBG_RA): Move from dbg_mlc.c, malloc.c, mallocx.c.
* 2011-03-13 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | | | | | | | | | * finalize.c (GC_register_finalizer_inner): Fix a typo in a comment. *include/private/gcconfig.h (STACKBOTTOM): Ditto. * gcj_mlc.c (GC_core_gcj_malloc): Replace 0/1 with TRUE/FALSE in EXPECT (the 2nd argument). * malloc.c (GC_core_malloc_atomic, GC_core_malloc, GC_free): Ditto. * mark.c (GC_mark_and_push, GC_mark_and_push_stack): Ditto. * thread_local_alloc.c (GC_malloc, GC_malloc_atomic): Ditto. * include/private/gc_hdrs.h (HC_GET_HDR): Ditto. * include/private/gc_priv.h (SMALL_OBJ): Ditto. * include/private/specific.h (getspecific): Ditto. * pthread_support.c (LOCK_STATS): Add a comment.
* 2010-12-26 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | | | | | | | | | | | * alloc.c (GC_collect_or_expand): Replace NIL with NULL in message. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable): Ditto. * gcj_mlc.c (GC_debug_gcj_malloc): Ditto. * dbg_mlc.c (GC_check_annotated_obj): Replace NIL with NULL in a comment. * dyn_load.c (GC_FirstDLOpenedLinkMap): Ditto. * mark_rts.c (GC_roots_present): Ditto. * doc/README: Ditto. * include/private/gc_hdrs.h (IS_FORWARDING_ADDR_OR_NIL): Ditto. * include/private/gc_priv.h (_GC_arrays): Ditto.
* 2010-03-05 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_set_stop_func, GC_get_stop_func): Add DCL_LOCK_STATE. * finalize.c (GC_notify_or_invoke_finalizers): Ditto. * gc_dlopen.c (disable_gc_for_dlopen): Ditto. * gcj_mlc.c (maybe_finalize, GC_debug_gcj_malloc): Ditto. * mark.c (GC_print_trace): Ditto. * misc.c (GC_set_warn_proc, GC_get_warn_proc, GC_enable, GC_disable, GC_new_free_list, GC_new_kind, GC_new_proc, GC_set_oom_fn, GC_get_oom_fn, GC_set_finalizer_notifier, GC_get_finalizer_notifier): Ditto. * os_dep.c (GC_get_stack_base, GC_print_callers): Ditto. * pthread_support.c (GC_is_thread_tsd_valid, GC_wait_for_gc_completion, GC_init_parallel, GC_do_blocking_inner, GC_call_with_gc_active, GC_unregister_my_thread, pthread_join, pthread_detach, GC_register_my_thread, GC_inner_start_routine, pthread_create): Ditto. * reclaim.c (GC_print_all_errors): Ditto. * win32_threads.c (GC_is_thread_tsd_valid, GC_register_my_thread, GC_unregister_my_thread, GC_do_blocking_inner, GC_call_with_gc_active, GC_lookup_pthread, GC_pthread_join, GC_pthread_start_inner, GC_thread_exit_proc, GC_pthread_detach, GC_init_parallel): Ditto.
* 2009-10-22 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_unmap_old, GC_merge_unmapped, GC_allochblk, GC_freehblk): Use GC_INNER for the function definition. * alloc.c (GC_never_stop_func, GC_should_collect, GC_try_to_collect_inner, GC_collect_a_little_inner, GC_set_fl_marks, GC_add_to_our_memory, GC_add_to_heap, GC_expand_hp_inner, GC_collect_or_expand, GC_allocobj): Ditto. * backgraph.c (GC_build_back_graph, GC_traverse_back_graph): Ditto. * blacklst.c (GC_default_print_heap_obj_proc, GC_bl_init, GC_promote_black_lists, GC_unpromote_black_lists, GC_add_to_black_list_normal, GC_add_to_black_list_stack, GC_is_black_listed): Ditto. * darwin_stop_world.c (GC_push_all_stacks, GC_push_all_stacks, GC_stop_init, GC_stop_world, GC_start_world): Ditto. * dbg_mlc.c (GC_has_other_debug_info, GC_store_back_pointer, GC_marked_for_finalization, GC_generate_random_backtrace_no_gc, GC_store_debug_info, GC_start_debugging, GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page, GC_debug_malloc_uncollectable, GC_debug_free_inner): Ditto. * dyn_load.c (GC_register_dynamic_libraries, GC_register_main_static_data, GC_init_dyld): Ditto. * finalize.c (GC_push_finalizer_structures, GC_finalize, GC_notify_or_invoke_finalizers, GC_print_finalization_stats): Ditto. * gcj_mlc.c (GC_core_gcj_malloc): Ditto. * headers.c (GC_find_header, GC_header_cache_miss, GC_scratch_alloc, GC_init_headers, GC_install_header, GC_install_counts, GC_remove_header, GC_remove_counts, GC_next_used_block, GC_prev_block): Ditto. * mach_dep.c (GC_with_callee_saves_pushed): Ditto. * malloc.c (GC_collect_or_expand, GC_alloc_large, GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page, GC_core_malloc_atomic, GC_core_malloc, GC_free_inner): Ditto. * mallocx.c (GC_generic_malloc_ignore_off_page): Ditto. * mark.c (GC_collection_in_progress, GC_clear_hdr_marks, GC_set_hdr_marks, GC_set_mark_bit, GC_clear_mark_bit, GC_clear_marks, GC_initiate_gc, GC_mark_some, GC_mark_stack_empty, GC_invalidate_mark_state, GC_signal_mark_stack_overflow, GC_mark_from, GC_help_marker, GC_mark_init, GC_push_all, GC_push_conditional, GC_mark_and_push_stack, GC_push_all_eager, GC_push_all_stack): Ditto. * mark_rts.c (GC_is_static_root, GC_roots_present, GC_approx_sp, GC_exclude_static_roots_inner, GC_push_all_register_frames, GC_push_all_stack_frames, GC_cond_register_dynamic_libraries, GC_push_roots): Ditto. * misc.c (GC_extend_size_map, GC_clear_stack, GC_err_write): Ditto. * new_hblk.c (GC_build_fl, GC_new_hblk): Ditto. * obj_map.c (GC_register_displacement_inner, GC_add_map_entry, GC_initialize_offsets): Ditto. * os_dep.c (GC_get_maps, GC_parse_map_entry, GC_text_mapping, GC_init_linux_data_start, GC_init_netbsd_elf, GC_setpagesize, GC_set_and_save_fault_handler, GC_setup_temporary_fault_handler, GC_reset_fault_handler, GC_get_register_stack_base, GC_init_win32, GC_add_current_malloc_heap, GC_is_heap_base, GC_unmap, GC_remap, GC_unmap_gap, GC_push_all_stacks, GC_gww_dirty_init, GC_dirty_init, GC_read_dirty, GC_page_was_dirty, GC_page_was_ever_dirty, GC_remove_protection, GC_write_fault_handler, GC_mprotect_stop, GC_mprotect_resume, GC_save_callers, GC_print_callers): Ditto. * pthread_stop_world.c (GC_push_all_stacks, GC_stop_world, GC_start_world, GC_stop_init): Ditto. * pthread_support.c (GC_mark_thread_local_free_lists, GC_lookup_thread, GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_segment_is_thread_stack, GC_greatest_stack_base_below, GC_thr_init, GC_init_parallel, GC_do_blocking_inner, GC_lock, GC_acquire_mark_lock, GC_release_mark_lock, GC_wait_for_reclaim, GC_notify_all_builder, GC_wait_marker, GC_notify_all_marker): Ditto. * reclaim.c (GC_print_all_errors, GC_block_empty, GC_reclaim_generic, GC_start_reclaim, GC_continue_reclaim, GC_reclaim_all): Ditto. * thread_local_alloc.c (GC_init_thread_local, GC_destroy_thread_local, GC_mark_thread_local_fls_for): Ditto. * win32_threads.c (GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_do_blocking_inner, GC_stop_world, GC_start_world, GC_push_all_stacks, GC_get_next_stack, GC_acquire_mark_lock, GC_release_mark_lock, GC_wait_for_reclaim, GC_notify_all_builder, GC_wait_marker, GC_notify_all_marker, GC_thr_init, GC_init_parallel, GC_lock, GC_mark_thread_local_free_lists): Ditto. * alloc.c (GC_add_current_malloc_heap, GC_build_back_graph, GC_traverse_back_graph): Use GC_INNER for the function prototype. * darwin_stop_world.c (GC_mprotect_stop, GC_mprotect_resume): Ditto. * dbg_mlc.c (GC_default_print_heap_obj_proc): Ditto. * dyn_load.c (GC_parse_map_entry, GC_get_maps, GC_segment_is_thread_stack, GC_roots_present, GC_is_heap_base, GC_get_next_stack): Ditto. * finalize.c (GC_reset_finalizer_nested, GC_check_finalizer_nested): Ditto. * gcj_mlc.c (GC_start_debugging): Ditto. * include/private/dbg_mlc.h (GC_save_callers, GC_print_callers, GC_has_other_debug_info, GC_store_debug_info): Ditto. * include/private/gc_hdrs.h (GC_header_cache_miss): Ditto. * include/private/gc_locks.h (GC_lock): Ditto. * include/private/gc_pmark.h (GC_signal_mark_stack_overflow, GC_mark_from): Ditto. * include/private/pthread_support.h (GC_lookup_thread, GC_stop_init): Ditto. * include/private/thread_local_alloc.h (GC_init_thread_local, GC_destroy_thread_local, GC_mark_thread_local_fls_for): Ditto. * malloc.c (GC_extend_size_map, GC_text_mapping): Ditto. * mark.c (GC_page_was_ever_dirty): Ditto. * mark_rts.c (GC_mark_thread_local_free_lists): Ditto. * misc.c (GC_register_main_static_data, GC_init_win32, GC_setpagesize, GC_init_linux_data_start, GC_set_and_save_fault_handler, GC_init_dyld, GC_init_netbsd_elf, GC_do_blocking_inner): Ditto. * os_dep.c (GC_greatest_stack_base_below): Ditto. * win32_threads.c (GC_write_fault_handler, GC_gww_dirty_init): Ditto. * include/private/gc_priv.h: Ditto (for most prototypes). * include/private/gc_priv.h (GC_INNER): Update the comment. * doc/README.macros (GC_DLL): Update.
* 2009-10-21 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (DEBUG): Remove macro (since unused). * allchblk.c: Include private/gc_priv.h before other includes and definitions. * alloc.c: Ditto. * gc_dlopen.c: Ditto. * headers.c: Ditto. * mallocx.c: Ditto. * mark_rts.c: Ditto. * new_hblk.c: Ditto. * reclaim.c: Ditto. * mark.c: Include private/gc_pmark.h before other includes. * misc.c: Ditto. * dyn_load.c (_GNU_SOURCE): Move the definition to gc_priv.h. * pthread_support.c (_USING_POSIX4A_DRAFT10): Ditto. * pthread_support.c (_POSIX4A_DRAFT10_SOURCE): Remove (since already defined in gc_config_macros.h). * dyn_load.c (GC_init_dyld): Remove parameter cast for _dyld_register_func_for_add_image() and _dyld_register_func_for_remove_image(); add the comment about possible warnings; add FIXME for the deprecated _dyld_bind_fully_image_containing_address(). * include/private/gc_priv.h: Include gc.h before the standard headers inclusion. * tests/test.c: Ditto. * include/private/gcconfig.h (DebugBreak): Update the comment. * typd_mlc.c (ED_INITIAL_SIZE): Remove ';'. * alloc.c: Reformat the code (partly adjust indentation). * backgraph.c: Ditto. * blacklst.c: Ditto. * checksums.c: Ditto. * finalize.c: Ditto. * gcj_mlc.c: Ditto. * mach_dep.c: Ditto. * mark_rts.c: Ditto. * obj_map.c: Ditto. * os_dep.c: Ditto. * ptr_chck.c: Ditto. * stubborn.c: Ditto. * thread_local_alloc.c: Ditto. * typd_mlc.c: Ditto.
* 2009-10-19 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/private/gc_priv.h (GC_INNER): New macro (for GC-scope variable definitions). * include/private/gc_priv.h (GC_EXTERN): Update the comment. * allchblk.c (GC_unmap_threshold): Define as GC_INNER. * alloc.c (GC_incremental, GC_world_stopped, GC_n_heap_sects, GC_n_memory, GC_fail_count): Ditto. * blacklst.c (GC_black_list_spacing, GC_print_heap_obj): Ditto. * gcj_mlc.c (GC_gcj_malloc_initialized, GC_gcjobjfreelist): Ditto. * mach_dep.c (GC_save_regs_ret_val): Ditto. * mark.c (GC_n_mark_procs, GC_obj_kinds, GC_n_kinds, GC_mark_stack, GC_mark_stack_limit, GC_mark_stack_size, GC_mark_stack_top, GC_mark_state, GC_mark_stack_too_small, GC_mark_no, GC_markers): Ditto. * mark_rts.c (GC_root_size, GC_push_typed_structures): Ditto. * misc.c (GC_allocate_ml, GC_debugging_started, GC_check_heap, GC_print_all_smashed, GC_print_back_height, GC_dump_regularly, GC_backtraces, GC_force_unmap_on_gcollect, GC_large_alloc_warn_interval, GC_is_initialized, GC_write_cs, GC_current_warn_proc, GC_blocked_sp, GC_activation_frame): Ditto. * os_dep.c (GC_page_size, GC_dont_query_stack_min, GC_no_win32_dlls, GC_wnt, GC_sysinfo, GC_push_other_roots, GC_dirty_maintained, GC_fault_handler_lock): Ditto. * pthread_support.c (GC_allocate_ml, GC_lock_holder, GC_need_to_lock, GC_thr_initialized, GC_threads, GC_in_thread_creation, GC_collecting, GC_allocate_lock, GC_mark_lock_holder): Ditto. * reclaim.c (GC_bytes_found, GC_fl_builder_count, GC_have_errors): Ditto. * win32_threads.c (GC_allocate_ml, GC_lock_holder, GC_need_to_lock, GC_mark_lock_holder, GC_collecting): Ditto. * extra/gc.c (GC_INNER, GC_EXTERN): Define as STATIC. * mach_dep.c (GC_with_callee_saves_pushed): Remove redundant {}. * os_dep.c (GC_init_win32): Reformat the comment.
* 2009-10-18 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-5/+0
| | | | | | | | | | | | | | | | * backgraph.c (GC_quiet): Remove the declaration (not needed anymore since gc_priv.h is always included). * checksums.c (GC_quiet): Ditto. * gcj_mlc.c (GC_quiet): Ditto. * headers.c (GC_hdr_cache_hits, GC_hdr_cache_misses): Add the comment. * include/private/gc_hdrs.h (GC_hdr_cache_hits, GC_hdr_cache_misses): Ditto. * mark.c (GC_first_nonempty): Make the volatile variable STATIC. * pthread_stop_world.c (GC_stop_count, GC_world_is_stopped): Ditto. * win32_threads.c (GC_please_stop, GC_max_thread_index, GC_mark_mutex_waitcnt): Ditto.
* 2009-09-30 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_large_alloc_warn_interval): Move declaration from gc_priv.h. * allchblk.c (GC_large_alloc_warn_suppressed): Move definition from misc.c; define as STATIC. * include/private/gc_priv.h (GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed): Remove declaration. * alloc.c (GC_bytes_found): Add "defined in" comment. * mallocx.c (GC_bytes_found): Ditto. * misc.c (GC_unmap_threshold): Ditto. * os_dep.c (GC_old_allocator): Ditto. * pthread_support.c (GC_markers): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist, GC_gcj_malloc_initialized, GC_gcj_kind): Ditto. * win32_threads.c (GC_markers): Ditto. * alloc.c (GC_start_time): Explicitly initialize to 0 or NULL (to be distinctive from a variable declaration). * backgraph.c (GC_max_height, GC_deepest_obj): Ditto. * blacklst.c (GC_old_normal_bl, GC_incomplete_normal_bl, GC_old_stack_bl, GC_incomplete_stack_bl): Ditto. * checksums.c (GC_faulted, GC_n_dirty_errors, GC_n_faulted_dirty_errors, GC_n_changed_errors, GC_n_clean, GC_n_dirty, GC_bytes_in_used_blocks): Ditto. * dbg_mlc.c (GC_smashed): Ditto. * finalize.c (GC_old_dl_entries): Ditto. * gcj_mlc.c (GC_gcj_kind, GC_gcj_debug_kind, GC_gcjobjfreelist, GC_gcjdebugobjfreelist): Ditto. * mach_dep.c (GC_save_regs_ret_val): Ditto. * mark.c (GC_n_rescuing_pages, GC_mark_stack, GC_mark_stack_limit, GC_mark_stack_top): Ditto. * misc.c (GC_min_sp, GC_high_water, GC_bytes_allocd_at_reset): Ditto. * os_dep.c (GC_data_start, GC_page_size, GC_sysinfo, GC_old_segv_handler, GC_old_bus_handler, GC_old_bus_handler_used_si, GC_old_segv_handler_used_si, GC_proc_buf, GC_proc_fd, GC_vd_base): Ditto. * pthread_stop_world.c (GC_stop_count, GC_stopping_pid): Ditto. * reclaim.c (GC_leaked): Ditto. * typd_mlc.c (GC_explicit_kind, GC_array_kind, GC_ext_descriptors, GC_typed_mark_proc_index, GC_array_mark_proc_index, GC_eobjfreelist, GC_arobjfreelist): Ditto. * win32_threads.c (GC_pthread_map_cache, GC_marker_cv, GC_marker_Id): Ditto. * dbg_mlc.c (GC_smashed, GC_n_smashed): Define as STATIC. * gcj_mlc.c (GC_gcjdebugobjfreelist): Ditto. * os_dep.c (GC_vd_base): Ditto. * pthread_support.c (GC_mark_threads): Ditto. * reclaim.c (GC_leaked): Ditto. * typd_mlc.c (GC_bm_table): Ditto. * mark_rts.c (GC_save_regs_ret_val): Change declaration type to that of definition; add "defined in" comment. * mark_rts.c (GC_push_current_stack): Remove unnecessary cast for GC_save_regs_ret_val. * misc.c (GC_check_heap, GC_print_all_smashed, GC_start_call_back): Remove unnecessary cast (of 0). * misc.c (GC_LARGE_ALLOC_WARN_INTERVAL): New tuning macro. * misc.c (GC_large_alloc_warn_interval): Initialize to GC_LARGE_ALLOC_WARN_INTERVAL value. * misc.c (GC_tmp): Change to "static". * os_dep.c (GC_setpagesize): Reformat the code (collapse multiple function definitions). * os_dep.c (GC_mprotect_state): Define as static. * pthread_support.c (dummy_thread_local): Prefix with "GC_". * win32_threads.c (WinMain): Remove FIXME for WinCE.
* 2009-09-26 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.direct: Document EMPTY_GETENV_RESULTS. * gcj_mlc.c (GC_clear_stack): Remove declaration. * malloc.c (GC_clear_stack): Ditto. * mallocx.c (GC_clear_stack): Ditto. * typd_mlc.c (GC_clear_stack): Ditto. * gcj_mlc.c (GENERAL_MALLOC, GENERAL_MALLOC_IOP): Rename to GENERAL_MALLOC_INNER and GENERAL_MALLOC_INNER_IOP, respectively; remove "lb" unnecessary cast to word. * include/private/gc_priv.h (GC_clear_stack): Add declaration. * include/private/gc_priv.h (GENERAL_MALLOC, GENERAL_MALLOC_IOP): Move common declaration from typd_mlc.c and malloc.c; remove unnecessary result and "lb" parameter casts. * include/private/thread_local_alloc.h: Guard against duplicate header file inclusion. * os_dep.c (USE_MUNMAP): Replace "-->" with an error directive for the case when USE_MMAP is not defined. * pthread_support.c (GC_is_thread_tsd_valid): New internal function (only if GC_ASSERTIONS and THREAD_LOCAL_ALLOC); move the code from thread-local GC_malloc(); add FIXME for the condition. * win32_threads.c (GC_is_thread_tsd_valid): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist): Change the type (to match that of its definition). * thread_local_alloc.c (GC_destroy_thread_local): Add a cast for GC_gcjobjfreelist. * thread_local_alloc.c (GC_lookup_thread, GC_lookup_thread_inner): Remove unused declaration; don't include pthread.h. * thread_local_alloc.c (GC_is_thread_tsd_valid): New declaration (only if GC_ASSERTIONS). * thread_local_alloc.c (GC_malloc): Use GC_is_thread_tsd_valid() instead of GC_lookup_thread(). * win32_threads.c (GC_lookup_thread_inner): Define as STATIC. * win32_threads.c (UNPROTECT): Rename to UNPROTECT_THREAD (to have id different from that in os_dep.c).