summaryrefslogtreecommitdiff
path: root/typd_mlc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Always include gc_atomic_ops.h unless threads are disabledIvan Maidanski2018-02-261-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Issue #error if AO_HAVE_load or AO_HAVE_store is not defined after include atomic_ops.h. * include/private/gc_locks.h: Do not include gc_atomic_ops.h. * include/private/specific.h: Likewise. * pthread_stop_world.c: Likewise. * tests/test.c [THREADS && (GC_BUILTIN_ATOMIC || PARALLEL_MARK || !GC_WIN32_THREADS)]: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]: Likewise. * win32_threads.c [(GC_DLL || GC_INSIDE_DLL) && !THREAD_LOCAL_ALLOC && !GC_NO_THREADS_DISCOVERY && !MSWINCE && !GC_PTHREADS]: Likewise. * include/private/gc_priv.h [THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2]: Include gc_atomic_ops.h (after GC_INLINE definition). * include/private/gc_priv.h (counter_t): Do not define. * include/private/gc_priv.h (hblkhdr): Change type of hb_n_marks to either volatile AO_t (if PARALLEL_MARK) or size_t * mark.c (GC_noop6): Check AO_CLEAR macro presence instead of GC_PTHREADS and !GC_WIN32_THREADS or PARALLEL_MARK. * tests/test_atomic_ops.c [_WIN32 || _MSC_VER || __CYGWIN__ || __MINGW32__] (main): Do not skip the test.
* Eliminate C++ warnings about deprecated register keyword (GC source)Jay Krell2018-02-221-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 type of hb_sz field (of hblkhdr) from size_t to wordIvan Maidanski2018-02-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is needed to make the size of hb_sz to be the same as of AO_t. * allchblk.c [USE_MUNMAP] (GC_unmap_old): Cast hhdr->hb_sz to size_t when passed to GC_unmap(). * allchblk.c (GC_allochblk_nth): Cast hhdr->hb_sz to signed_word when assigned to size_avail. * allchblk.c [USE_MUNMAP] (GC_allochblk_nth): Cast hhdr->hb_sz to size_t when passed to GC_remap(). * alloc.c (GC_set_fl_marks, GC_clear_fl_marks): Change type of sz and bit_no local variables from size_t/unsigned to word. * dbg_mlc.c (GC_check_heap_block): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (per_object_helper): Cast hhdr->hb_sz to size_t; change type of i local variables from int to size_t. * checksums.c [CHECKSUMS] (GC_on_free_list): Change type of sz local variable from size_t to word. * mark.c (GC_push_marked, GC_push_unconditionally, GC_block_was_dirty): Likewise. * reclaim.c (GC_reclaim_small_nonempty_block, GC_disclaim_and_reclaim_or_free_small_block, GC_reclaim_block, GC_n_set_marks): Likewise. * checksums.c [CHECKSUMS] (GC_add_block): Remove bytes local variable (to avoid casting of hhdr->hb_sz). * dbg_mlc.c (GC_debug_free): Change type of i and obj_sz local variables from size_t to word. * dbg_mlc.c (GC_check_leaked): Likewise. * extra/pcr_interface.c (GC_enumerate_block): Change type of sz local variable from int to size_t. * extra/pcr_interface.c (GC_enumerate_block): Cast hhdr->hb_sz to size_t when assigned to sz. * mallocx.c (GC_realloc): Likewise. * mark.c (GC_set_hdr_marks): Likewise. * reclaim.c (GC_do_enumerate_reachable_objects): Likewise. * include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR): Cast hhdr->hb_sz to size_t in assignment of obj_displ. * include/private/gc_priv.h (struct hblkhdr): Change type of hb_sz from size_t to word. * include/private/gc_priv.h (MARK_BIT_NO): Cast offset argument to word instead of unsigned. * malloc.c (GC_free): Cast hhdr->hb_sz to size_t. * mallocx.c (GC_get_kind_and_size): Likewise. * mark.c (GC_clear_hdr_marks): Likewise. * misc.c (GC_size): Likewise. * misc.c (GC_do_blocking): Remove redundant cast of hhdr->hb_sz. * reclaim.c (GC_reclaim_clear, GC_reclaim_uninit, GC_disclaim_and_reclaim, GC_continue_reclaim): Change type of sz argument from size_t to word. * typd_mlc.c (GC_array_mark_proc): Change type of sz and nwords local variables from size_t to word.
* Fix data race in make_descriptor when setting explicit_typing_initializedIvan Maidanski2017-11-291-20/+18
| | | | | | | | | | | | | | | (fix commit 5f350a0) * typd_mlc.c [AO_HAVE_load_acquire] (GC_explicit_typing_initialized): Add volatile qualifier. * typd_mlc.c [AO_HAVE_load_acquire] (GC_make_descriptor): Remove cast of &GC_explicit_typing_initialized; do not check THREADS macro; fallback to locked checking of GC_explicit_typing_initialized if AO_HAVE_store_release is not defined; use AO_store_release to set GC_explicit_typing_initialized (to true). * typd_mlc.c (GC_make_descriptor): Reformat code dealing with GC_explicit_typing_initialized (check whether AO_HAVE_load_acquire is defined only once).
* Revert 'Eliminate TSan warning about data race in make_descriptor'Ivan Maidanski2017-11-291-6/+1
| | | | | | This reverts commit a3ee14468b807ecf2d6fa279699b7a9879443bdf. Because it just hides a potential data race.
* Remove some redundant macro definitions from gc_atomic_ops.hIvan Maidanski2017-11-291-2/+1
| | | | | | | | | | | | | | | | | | (fix commit 46a2411) * include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC] (AO_HAVE_load, AO_HAVE_store, AO_HAVE_store_release_write): Remove. * include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC && AO_REQUIRE_CAS] (AO_HAVE_compare_and_swap): Likewise. * include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Add comment. * include/private/gc_priv.h (word_ptr_ao_u): Replace "ifdef AO_HAVE_load" to "ifdef PARALLEL_MARK". * tests/test_atomic_ops.c [AO_HAVE_compare_and_swap_release] (main): Do not check whether AO_REQUIRE_CAS and AO_HAVE_compare_and_swap are defined. * typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC] (include gc_atomic_ops.h): Do not check whether AO_HAVE_load_acquire is defined.
* Eliminate TSan warning about data race in make_descriptorIvan Maidanski2017-11-211-1/+6
| | | | | | * typd_mlc.c [THREADS) && AO_HAVE_load_acquire && AO_HAVE_store] (GC_make_descriptor): Use AO_store for setting GC_explicit_typing_initialized (to true).
* Remove GENERAL_MALLOC internal macroIvan Maidanski2017-11-141-0/+5
| | | | | | | | | | (code refactoring) * alloc.c: Update comment (about GC_allocobj usage). * include/private/gc_priv.h (GENERAL_MALLOC): Remove. * include/private/gc_priv.h (GENERAL_MALLOC_IOP): Move to typd_mlc.c. * malloc.c (GC_malloc_kind_global): Expand GENERAL_MALLOC macro; copy the comment from gc_priv.h.
* Fix data race when getting object size in explicitly-typed allocatorsIvan Maidanski2017-11-101-4/+7
| | | | | | | | | | * typd_mlc.c (COMPLEX): Reformat comment. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Always use BYTES_TO_GRANULES(GC_size(op)) instead of GC_size_map[lb] to determine size of the allocated object in granules (because the value of GC_size_map[lb] might be updated by another thread since the value use in GC_malloc_kind); add comment.
* Fix array_mark_proc to request global mark stack growth on overflowIvan Maidanski2017-08-091-2/+2
| | | | | | | | | (fix commit 3f06655) * typd_mlc.c [PARALLEL_MARK] (GC_array_mark_proc): Set GC_mark_stack_too_small to true if GC_push_complex_descriptor() returned null and mark_stack_limit belongs to the global mark stack (even if GC_parallel is true).
* Fix push_complex_descriptor to avoid unlimited global mark stack growthIvan Maidanski2017-07-121-1/+7
| | | | | | | | | Global mark stack should not grow in parallel marker mode (as fixed-size local_mark_stack is used instead). * typd_mlc.c [PARALLEL_MARK] (GC_array_mark_proc): Do not set GC_mark_stack_too_small if GC_parallel (and new_mark_stack_ptr is null); add comment.
* Eliminate 'label not used' cppcheck false warnings in GC_mark_XIvan Maidanski2017-02-281-1/+1
| | | | | | | | | | | | | | | | | | | (code refactoring of PUSH_CONTENTS[_HDR] to eliminate 'goto' statement) * include/private/gc_hdrs.h (HC_GET_HDR): Remove exit_label argument; replace goto with break; remove do-while(0) (as break is now used to pass control to some place of the caller). * include/private/gc_pmark.h (SET_MARK_BIT_EXIT_IF_SET): Likewise. * include/private/gc_pmark.h [!USE_MARK_BYTES] (OR_WORD_EXIT_IF_SET): Likewise. * include/private/gc_pmark.h (PUSH_CONTENTS, PUSH_CONTENTS_HDR): Remove exit_label argument (and the comment about it). * include/private/gc_pmark.h (SET_MARK_BIT_EXIT_IF_SET): Refine comment about the exit. * mark.c (GC_mark_from): Remove PUSH_CONTENTS exit<N> argument. * typd_mlc.c (GC_typed_mark_proc): Likewise. * mark.c (GC_mark_and_push, GC_mark_and_push_stack): Remove PUSH_CONTENTS_HDR label argument and the label itself.
* Add AO primitives implementation to GC based on C11 atomic intrinsicIvan Maidanski2017-01-251-2/+3
| | | | | | | | | | | | | | | | | | | | * Makefile.direct (SRCS): Add include/private/gc_atomic_ops.h. * include/include.am (dist_noinst_HEADERS): Likewise. * include/private/gc_atomic_ops.h: New file; define needed AO entities if GC_BUILTIN_ATOMIC, otherwise include atomic_ops.h. * include/private/gc_locks.h [THREADS && GC_PTHREADS && !GC_WIN32_THREADS]: Include gc_atomic_ops.h instead of atomic_ops.h. * include/private/gc_priv.h [PARALLEL_MARK || THREADS && MPROTECT_VDB]: Likewise. * include/private/specific.h: Likewise. * pthread_stop_world.c: Include private/gc_atomic_ops.h instead of atomic_ops.h. * tests/subthread_create.c: Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT]: Likewise. * typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]: Likewise. * win32_threads.c [GC_DLL && !GC_NO_THREADS_DISCOVERY && !MSWINCE]: Likewise.
* Remove HIGH_BIT macro duplicating SIGNBIvan Maidanski2016-12-221-3/+2
| | | | | | | (code refactoring) * typd_mlc.c (HIGH_BIT) Remove macro. * typd_mlc.c (GC_make_descriptor): Use SIGNB instead of HIGH_BIT.
* Fix '32-bit value shift followed by expansion to 64-bit' code defectIvan Maidanski2016-12-071-1/+1
| | | | | | | | | | | | * 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.
* Ensure oom_fn callback executed on out-of-memory in callocIvan Maidanski2016-11-181-4/+2
| | | | | | | | | | | (fix commits e10c1eb, 4e1a6f9) * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (calloc): Call oom_fn(SIZE_MAX) (instead of returning NULL) if n*lb overflows. * typd_mlc.c (GC_calloc_explicitly_typed): Likewise. * typd_mlc.c (GC_calloc_explicitly_typed): If register_disappearing_link failed due to lack of memory then call oom_fn(lb) instead of GC_malloc(lb); update comment.
* Eliminate 'dereference of null' CSA false warning in array_mark_procIvan Maidanski2016-10-261-0/+3
| | | | | | | | | | The exact warning message is: Access to field 'mse_start' results in a dereference of a null pointer (loaded from variable 'new_mark_stack_ptr'). Note: the warning is eliminated regardless of assertion checking status. * typd_mlc.c (GC_array_mark_proc): Call ABORT if mark_stack_ptr is NULL (thus orig_mark_stack_ptr is ensured to be non-NULL after the check).
* Revert "Eliminate CSA false warning about null deref in array_mark_proc"Ivan Maidanski2016-10-261-1/+0
| | | | | | | This reverts commit fc339c65ad0fffc2e5bc8332bab9c1c70329c04e. Because that commit does not eliminate CSA false warning if GC_ASSERTIONS is off.
* Workaround 'struct member is never used' cppcheck style warningsIvan Maidanski2016-10-181-1/+1
| | | | | | | | | | * os_dep.c [OS2] (GC_register_data_segments): Assign 0 to hdrdos.padding, hdr386.exe_format_level/os/padding1/padding2, seg.pagemap/mapsize/reserved fields if CPPCHECK; add comment. * os_dep.c [MPROTECT_VDB && DARWIN] (GC_mprotect_thread): Assign 0 to the first element of reply.data, msg.data fields if CPPCHECK; add comment. * typd_mlc.c (TAG): Define to ad.ad_tag (instead of ld.ld_tag).
* Eliminate more 'scope of variable can be reduced' cppcheck style warningsIvan Maidanski2016-10-141-1/+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-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Fix 'shift count >= width of type' compiler warning in GC_SQRT_SIZE_MAXIvan Maidanski2016-09-211-1/+1
| | | | | | | (fix commits 83231d0, 4e1a6f9) * malloc.c (GC_SQRT_SIZE_MAX): Change type from unsigned to size_t. * typd_mlc.c (GC_SQRT_SIZE_MAX): Likewise.
* Adjust code indentation of calloc_explicitly_typedIvan Maidanski2016-09-151-26/+26
| | | | * typd_mlc.c (GC_calloc_explicitly_typed): Adjust code indentation.
* Fix calloc_explicitly_typed in case of lb*n overflowIvan Maidanski2016-09-151-3/+15
| | | | | | | | | * typd_mlc.c: Include limits.h (for SIZE_MAX). * typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): New macro (same as in malloc.c). * typd_mlc.c (GC_calloc_explicitly_typed): Return NULL if lb * n overflows (same algorithm as in calloc defined in malloc.c); eliminate lb *= n code duplication.
* Fix double multiplication of lb by n in calloc_explicitly_typedIvan Maidanski2016-09-151-1/+1
| | | | | | * typd_mlc.c (GC_calloc_explicitly_typed): Do not multiply lb by n twice (when passed to GC_malloc in case of GC_general_register_disappearing_link fails).
* Eliminate CSA false warning about null dereference in array_mark_procIvan Maidanski2016-08-261-0/+1
| | | | | | | | The exact warning message is: Access to field 'mse_start' results in a dereference of a null pointer (loaded from variable 'new_mark_stack_ptr'). * typd_mlc.c (GC_array_mark_proc): Add assertion that mark_stack_ptr is non-NULL (thus orig_mark_stack_ptr is non-NULL too).
* Remove code commented out by 'ifdef UNDEFINED'Ivan Maidanski2016-07-251-17/+0
| | | | | | | * finalize.c [UNDEFINED] (GC_invoke_finalizers): Remove GC_free(curr_fo) call; update comment. * include/private/gcconfig.h [UNDEFINED] (_etext, DATASTART): Remove. * typd_mlc.c [UNDEFINED] (GC_make_complex_array_descriptor): Likewise.
* Enable thread-local storage usage for GC_malloc/calloc_explicitly_typedThomas Linder Puls2016-07-221-64/+24
| | | | | | | | | | | | | | | | | Use GC_malloc_kind instead of explicit allocation algorithm implementation. * typd_mlc.c: Include gc_inline.h to declare GC_malloc_kind. * typd_mlc.c (GC_arobjfreelist): Remove. * typd_mlc.c (GC_init_explicit_typing): Do not use GC_arobjfreelist. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed): Change type of "op" local variable from ptr_t to word*. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed): Use GC_malloc_kind instead of explicit allocator (those implementation was same as for GC_malloc_kind). * typd_mlc.c (GC_calloc_explicitly_typed): Remove"register" keyword for "descr_type" local variable; reformat code slightly; use EXPECT to check GC_general_register_disappearing_link result for out-of-memory.
* Fix integer shift undefined behavior in GC_init_explicit_typingIvan Maidanski2016-07-201-1/+2
| | | | | | * typd_mlc.c (GC_init_explicit_typing): Avoid left-shift by WORDSZ (which is an undefined behavior), initialize GC_bm_table[0] to GC_DS_BITMAP explicitly.
* Fix data race in GC_init_explicit_typingIvan Maidanski2015-09-011-15/+36
| | | | | | | | | | | | | | | | | | | * typd_mlc.c: Force include atomic_ops.h if GC_FORCE_INCLUDE_ATOMIC_OPS (by default it is included if PARALLEL_MARK or pthreads are used). * typd_mlc.c (GC_explicit_typing_initialized): Use AO_t if AO_load_acquire() available. * typd_mlc.c (GC_init_explicit_typing): Move locking (and GC_explicit_typing_initialized access) outside to the caller (GC_make_descriptor); remove comment; remove "register" keyword for local variable. * typd_mlc.c (GC_make_descriptor): Use AO_load_acquire (if available) to fetch GC_explicit_typing_initialized value (to avoid data race and avoid lock acquiring on each call). * typd_mlc.c (GC_explicit_typing_initialized, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Add assertion on GC_explicit_typing_initialized is true.
* Code refactoring of GC_push_finalizer/thread/typed_structuresIvan Maidanski2015-08-261-2/+1
| | | | | | | | | | * finalize.c (GC_push_finalizer_structures): Replace GC_push_all with GC_PUSH_ALL_SYM invocation. * pthread_support.c (GC_push_thread_structures): Likewise. * typd_mlc.c (GC_push_typed_structures_proc): Likewise. * win32_threads.c (GC_push_thread_structures): Likewise. * include/private/gc_priv.h (GC_PUSH_ALL_SYM): New macro (handy one to push a symbol content).
* GC_make_descriptor code refactoring (eliminate two local variables)Ivan Maidanski2015-08-171-9/+4
| | | | | * typd_mlc.c (GC_make_descriptor): Remove "all_bits_set", "index" local variables; collapse "return result" statements.
* Replace non-API occurrences of GC_word to wordIvan Maidanski2015-07-281-1/+1
| | | | | | | | | | | | | | | | (code refactoring) * finalize.c (last_finalizer_notification): Use "word" type instead of GC_word. * include/private/dbg_mlc.h (HIDE_BACK_PTR): Likewise. * include/private/gc_priv.h (WARN): Likewise. * include/private/gcconfig.h (POINTER_MASK): Likewise. * mark.c (GC_push_marked): Likewise. * misc.c (GC_init, GC_set_max_retries): Likewise. * os_dep.c (GC_unmap, GC_remap, GC_unmap_gap): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Likewise. * include/private/gcconfig.h (GC_amiga_get_mem, ps3_get_mem): Rename argument to bytes.
* Fix MS VC redefinition warning for functions declared with GC_ATTR_MALLOCIvan Maidanski2014-04-231-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-13/+7
| | | | | | | | | | | | | | | (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.
* Fix typos in commentsOndrej Bilka2013-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * blacklst.c: Fix typo ("even though"). * cord/cordbscs.c: Fix typo ("exponentially"). * cord/cordxtra.c: Fix typo ("represented"). * dyn_load.c: Fix typos ("uncollectible", "occurred"). * extra/AmigaOS: Fix typos ("specific", "necessary", "always", "effectiveness"). * finalize.c: Fix typo ("descendants"). * include/cord.h: Fix typo ("idiosyncrasies"). * include/gc.h: Fix typo ("collectible"). * include/gc_allocator.h: Fix typos ("allocator", "[un]collectible"). * mach_dep.c: Fix typo ("erroneously"). * malloc.c: Fix typos ("[un]collectible", "pointer-free", "initialization"). * mallocx.c: Fix typos ("largely", "pointer-free", "uncollectible"). * mark.c: Fix typos ("[un]collectible", "even though"). * misc.c: Fix typo ("erroneously"). * os_dep.c: Fix typos ("non-addressable", "happening", "pointer-free"). * tests/test.c: Fix typos ("uncollectible", "reversed"). * tests/test_cpp.cc: Fix typos ("[un]collectible"). * typd_mlc.c: Fix typo ("copyright"). * win32_threads.c: Fix typos ("optimization", "uncollectible").
* Fix GC_malloc_explicitly_typed_ignore_off_page for large allocationsReimer Behrends2012-12-081-1/+1
| | | | | | * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Use BYTES_TO_GRANULES instead of BYTES_TO_WORDS when calculating "lg" local variable value.
* Eliminate warning and simplify expression in GC_init_explicit_typingIvan Maidanski2012-10-231-4/+2
| | | | | | | | | | * typd_mlc.c (GC_init_explicit_typing): Cast -1 argument of WORDS_TO_BYTES() to word (instead of casting its result) to avoid "overflow in signed shift operation" warning (issued by some static code analysis tools). * typd_mlc.c (GC_init_explicit_typing): Simplify expression for computing GC_bm_table elements (remove redundant right shift of unsigned -1 before left shift for the same amount of bits).
* 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).
* Replace pointer relational comparisons with non-pointer onesIvan Maidanski2012-03-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_dump_regions, GC_allochblk_nth): Cast pointers to word type in relational (less-greater) comparisons. * alloc.c (GC_add_to_heap, GC_print_heap_sects, GC_expand_hp_inner): Likewise. * backgraph.c (ensure_struct, add_back_edges): Likewise. * blacklst.c (GC_number_stack_black_listed): Likewise. * checksums.c (GC_checksum, GC_check_dirty): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_print_smashed_obj, GC_check_heap_block): Likewise. * dyn_load.c (sort_heap_sects, GC_register_map_entries, GC_register_dynlib_callback, GC_register_dynamic_libraries_dl_iterate_phdr, GC_register_dynamic_libraries, GC_cond_add_roots): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc): Likewise. * headers.c (GC_scratch_alloc, GC_install_counts, GC_remove_counts): Likewise. * include/private/gc_pmark.h (PUSH_OBJ, PUsH_CONTENTS_HDR, GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP, GC_mark_stack_empty): Likewise. * include/private/gc_priv.h (MAKE_COOLER, COOLER_THAN): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * malloc.c (calloc, free): Likewise. * mark.c (GC_mark_some_inner, GC_mark_from, GC_steal_mark_stack, GC_return_mark_stack, GC_do_local_mark, GC_mark_local, GC_push_all, GC_push_selected, GC_push_all_eager, GC_push_marked1, GC_push_marked2, GC_push_marked4, GC_push_marked, GC_push_unconditionally): Likewise. * mark_rts.c (GC_is_static_root, GC_add_roots_inner, GC_remove_roots_inner, GC_is_tmp_root, GC_exclude_static_roots_inner, GC_push_conditional_with_exclusions, GC_push_all_register_sections, GC_push_all_stack_sections, GC_push_all_stack_partially_eager, GC_push_all_stack_part_eager_sections, GC_push_current_stack): Likewise. * misc.c (GC_clear_stack_inner, GC_clear_stack, GC_base, GC_call_with_gc_active): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * os_dep.c (GC_enclosing_mapping, GC_text_mapping, tiny_sbrk, GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_find_limit_with_bound, GC_get_main_stack_base, GC_get_stack_base, GC_least_described_address, GC_register_root_section, GC_register_data_segments, GC_unmap_start, GC_gww_read_dirty, GC_remove_protection, GC_protect_heap, GC_unprotect_range, GC_read_dirty, GC_page_was_dirty, GC_save_callers, GC_print_callers): Likewise. * pcr_interface.c (GC_enumerate_block): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_segment_is_thread_stack, GC_greatest_stack_base_below, GC_call_with_gc_active): Likewise. * ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_on_stack, GC_is_visible): Likewise. * reclaim.c (GC_reclaim_clear, GC_reclaim_uninit, GC_disclaim_and_reclaim, GC_reclaim_check, GC_start_reclaim): Likewise. * tests/test.c (cons): Likewise. * tools/setjmp_t.c (main): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * win32_threads.c (GC_is_thread_tsd_valid, GC_call_with_gc_active, GC_push_stack_for, GC_get_next_stack): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress, GetDescriptionFromStack): Cast pointers to GC_ULONG_PTR in relational comparisons. * include/gc.h (GC_DATASTART, GC_DATAEND): Cast pointers to GC_word in relational comparisons. * misc.c (GC_init): Remove static assertion on ((ptr_t)-1 > 0) since no longer required; add the comment. * pcr_interface.c: Expand tabs to spaces.
* Add assertion ensuring proper alignment of 'pushed' GC symbolsIvan Maidanski2012-02-161-0/+1
| | | | | | | | | | | | * finalize.c (GC_push_finalizer_structures): Assert word alignment of dl_head, fo_head, GC_finalize_now. * pthread_support.c (GC_thr_init): Assert word alignment of GC_threads (passed to GC_push_all). * win32_threads.c (GC_thr_init): Likewise. * thread_local_alloc.c (GC_init_thread_local): Assert word alignment of GC_thread_key. * typd_mlc.c (GC_add_ext_descriptor): Assert word alignment of GC_ext_descriptors.
* Allow to exclude finalization support by GC_NO_FINALIZATION macroIvan Maidanski2012-02-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/README.macros (GC_NO_FINALIZATION): Document. * alloc.c (GC_finish_collection): Do not call GC_finalize and GC_print_finalization_stats if GC_NO_FINALIZATION. * dbg_mlc.c (closure, GC_make_closure, GC_debug_invoke_finalizer, OFN_UNSET, store_old, GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Do not define if GC_NO_FINALIZATION. * finalize.c: Skip all definitions if GC_NO_FINALIZATION. * finalize.c (GC_call_with_alloc_lock): Move to misc.c. * include/private/gc_priv.h (GC_INVOKE_FINALIZERS): Define to empty if GC_NO_FINALIZATION. * include/private/gc_priv.h (GC_notify_or_invoke_finalizers, GC_push_finalizer_structures, GC_finalize, GC_print_finalization_stats): Do not declare if GC_NO_FINALIZATION. * mark_rts.c (GC_push_gc_structures): Do not call GC_push_finalizer_structures if GC_NO_FINALIZATION. * misc.c (GC_call_with_alloc_lock): Move from "finalize" module. * tests/test.c (mktree): Do not declare "my_index" and "new_link" local variables, do not update live_indicators_count, do not call GC_REGISTER_FINALIZER, GC_GENERAL_REGISTER_DISAPPEARING_LINK, GC_move_disappearing_link, GC_unregister_disappearing_link if GC_NO_FINALIZATION. * tests/test.c (check_heap_stats): Do not declare "still_live", "late_finalize_count" local variables and do not check finalization for failures if GC_NO_FINALIZATION.
* Use union of AO_t and word for mse_descr to avoid type castingIvan Maidanski2012-01-291-5/+5
| | | | | | | | | | | | | | | | | (which breaks 'strict-aliasing' compiler optimization) * include/private/gc_pmark.h (GC_ms_entry): Change type of mse_descr from word to word_ptr_ao_u. * include/private/gc_pmark.h (GC_mark_stack_top): Add FIXME. * include/private/gc_pmark.h (OR_WORD_EXIT_IF_SET): Add 'volatile' keyword to type cast for AO_or argument. * include/private/gc_priv.h (counter_t): Add 'volatile' in case of defining as AO_t (replace typedef with a macro). * include/private/gc_priv.h (word_ptr_ao_u): New union type. * include/private/gc_pmark.h (PUSH_OBJ): Add ".w" suffix to mse_descr. * mark.c (GC_mark_from, GC_steal_mark_stack, GC_push_all): Likewise. * mark.c (GC_steal_mark_stack): Use "ao" element of union to load and clear mse_descr atomically; remove pointer type casts.
* Replace ABORTs followed by statement with ABORT_RET having dummyIvan Maidanski2012-01-231-4/+4
| | | | | | | | | | | | | | 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-3/+6
| | | | | | | | | | | * 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.
* Add 'const' qualifier for GC_make_descriptor bitmap argumentIvan Maidanski2012-01-101-2/+2
| | | | | | | | * include/gc_typed.h (GC_make_descriptor): Make bm pointer const (replace GC_bitmap type with "const GC_word*"). * typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor): Likewise. * tests/test.c (bm_huge): Make array const to test updated GC_make_descriptor declaration.
* Use EXPECT for checking various 'initialized' boolean variablesIvan Maidanski2011-12-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Resolve "comparison of signed and unsigned values" compiler warnings.Ivan Maidanski2011-08-211-3/+4
| | | | | | | | | | | | | | | | | * allchblk.c (GC_allochblk_nth): Cast MAX_BLACK_LIST_ALLOC and HBLKSIZE to signed_word. * mallocx.c (GC_generic_malloc_many): Cast my_bytes_allocd to word. * mark.c (GC_do_local_mark): Cast the result of local_top minus local_mark_stack to word (since is non-negative). * misc.c (GC_base): Declare sz as unsigned word. * misc.c (GC_enable_incremental): Cast bytes_written to size_t in comparison to len. * obj_map.c (GC_initialize_offsets): Declare 'i' as unsigned. * os_dep.c (GC_or_pages): Ditto. * typd_mlc.c (GC_init_explicit_typing): Ditto. * ptr_chck.c (GC_is_visible): Cast the result of p minus base to word. * typd_mlc.c (GC_make_descriptor): Cast last_set_bit to word (since non-negative) when compared to BITMAP_BITS.