summaryrefslogtreecommitdiff
path: root/typd_mlc.c
Commit message (Collapse)AuthorAgeFilesLines
* Move public header files to include/gc in source treeIvan Maidanski2021-11-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove useless empty statements after block ones (refactoring)Ivan Maidanski2021-09-081-1/+1
| | | | | | | | | * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Remove extra ';' after block statement ('}'). * new_hblk.c [!SMALL_CONFIG] (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4): Likewise. * typd_mlc.c (GC_double_descr): Likewise.
* Move GC state pointer variables into GC_arraysIvan Maidanski2020-07-191-12/+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_eobjfreelist variable in typd_mlc.cIvan Maidanski2020-07-181-7/+6
| | | | | | | | | | (code refactoring) * typd_mlc.c (GC_eobjfreelist): Remove static variable. * typd_mlc.c (GC_init_explicit_typing): Do not set GC_eobjfreelist. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Define opp local variable; use GC_obj_kinds[GC_explicit_kind].ok_freelist instead of GC_eobjfreelist.
* Move GC state non-pointer variables into GC_arraysIvan Maidanski2020-07-101-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) This commit is intended to simplify GC reinitialization. * alloc.c (GC_n_heap_sects, GC_fo_entries): Remove variable definition. * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_log_fo_table_size): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_array_size, GC_toggleref_array_capacity): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_kind): Likewise. * mark.c (GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked): Likewise. * mark.c [PARALLEL_MARK] (GC_first_nonempty): Likewise. * mark.c [TRACE_BUF] (GC_trace_buf_ptr): Likewise. * mark_rts.c (n_root_sets, GC_roots_were_cleared, GC_excl_table_entries): Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_n_heap_bases): Likewise. * typd_mlc.c (GC_ed_size, GC_avail_descr, GC_explicit_typing_initialized): Likewise. * extra/MacOS.c (GC_fo_entries): Remove variable declaration. * include/private/gc_pmark.h (GC_mark_stack_size, GC_mark_stack_too_small, GC_mark_state): Likewise. * include/private/gc_priv.h (GC_n_heap_sects, GC_fo_entries): Likewise. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * include/private/gc_pmark.h (mark_state_t): Move typedef to gc_priv.h. * include/private/gc_priv.h (_GC_arrays._scratch_end_ptr, _GC_arrays._scratch_last_end_ptr): Document. * include/private/gc_priv.h [PARALLEL_MARK] (_GC_arrays): Add _first_nonempty field. * include/private/gc_priv.h (_GC_arrays): Add _mark_stack_size, _mark_state, _mark_stack_too_small, _objects_are_marked, _n_heap_sects, _n_memory, _fo_entries, _n_root_sets, _excl_table_entries, _roots_were_cleared, _explicit_typing_initialized, _ed_size, _avail_descr fields. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (_GC_arrays): Add _n_memory field. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (_GC_arrays): Add _n_heap_bases field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (_GC_arrays): Add _log_fo_table_size field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (_GC_arrays): Add _toggleref_array_size, _toggleref_array_capacity fields. * include/private/gc_priv.h [TRACE_BUF] (_GC_arrays): Add _trace_buf_ptr field. * include/private/gc_priv.h [ENABLE_DISCLAIM] (_GC_arrays): Add _finalized_kind field. * include/private/gc_priv.h (GC_first_nonempty, GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked, GC_n_heap_sects, GC_n_memory, GC_n_heap_bases, GC_fo_entries, GC_log_fo_table_size, GC_toggleref_array_size, GC_toggleref_array_capacity, GC_trace_buf_ptr, GC_finalized_kind, n_root_sets, GC_excl_table_entries, GC_roots_were_cleared, GC_explicit_typing_initialized, GC_ed_size, GC_avail_descr): Define macro.
* Rename ext_descr to typed_ext_descr_tIvan Maidanski2020-06-211-11/+12
| | | | | | | | (code refactoring) * typd_mlc.c (ext_descr): Rename to typed_ext_descr_t. * typd_mlc.c (GC_ext_descriptors, GC_add_ext_descriptor): Rename ext_descr to typed_ext_descr_t.
* Eliminate 'poor global variable name' code defect in typd_mlcIvan Maidanski2018-08-301-3/+3
| | | | | | (fix of commit a825a2d) * typd_mlc.c (ld, ad, sd): Remove unused global variables.
* Add GC_reachable_here after GC_dirty in GC sourceIvan Maidanski2018-06-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+7
| | | | | | | | | (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.
* Eliminate 'boolean result used in bitwise operation' cppcheck warningIvan Maidanski2018-04-201-1/+1
| | | | | | * finalize.c (GC_push_finalizer_structures): Replace (word)&sym to (word)(&sym). * typd_mlc.c (GC_add_ext_descriptor): Likewise.
* Avoid potential race when accessing size_map tableHans Boehm2018-02-261-1/+1
| | | | | | | | | | | | | | | | | | 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.
* 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.