summaryrefslogtreecommitdiff
path: root/fnlz_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.
* Move GC state non-pointer variables into GC_arraysIvan Maidanski2020-07-101-2/+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.
* Fix GC_register_disclaim_proc for leak-finding modeIvan Maidanski2018-11-291-2/+6
| | | | | | | | | | | | | | | | | Issue #252 (bdwgc). This makes the behavior of GC_register_disclaim_proc() and GC_finalized_malloc() somewhat consistent with GC_register_disappearing_link() and GC_register_finalizer() when find-leak is on. The documentation is updated accordingly. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Add assertion that GC_find_leak is off. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_register_disclaim_proc): Do not assign ok_disclaim_proc, ok_mark_unconditionally fields if GC_find_leak. * include/gc_disclaim.h (GC_register_disclaim_proc, GC_finalized_malloc): Refine comment about leak-find mode and GC_free invocation.
* Fix disclaim_test failure in case of GC_DEBUGIvan Maidanski2018-09-211-0/+2
| | | | | | | | (fix of commit 21312a0) * fnlz_mlc.c [ENABLE_DISCLAIM]: Include dbg_mlc.h. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Call GC_register_displacement_inner(sizeof(oh)+FINALIZER_CLOSURE_FLAG).
* Fix marking of finalizer closure objectPetter Urkedal2018-09-191-0/+6
| | | | | | | * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Call GC_register_displacement_inner(FINALIZER_CLOSURE_FLAG); add comment. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Call GC_dirty and REACHABLE_AFTER_DIRTY after storing fclos.
* Specify register_disclaim_proc and finalized_malloc argument as non-nullIvan Maidanski2018-09-191-0/+3
| | | | | | | | | | | | | Also, a check is added that the actual finalizer closure pointer does not have FINALIZER_CLOSURE_FLAG set. * fnlz_mlc.c (GC_register_disclaim_proc): Add assertion that proc is non-null. * fnlz_mlc.c (GC_finalized_malloc): Add assertions that fclos argument is non-null and that fclos itself does not have FINALIZER_CLOSURE_FLAG set. * include/gc_disclaim.h (GC_register_disclaim_proc, GC_finalized_malloc): Add GC_ATTR_NONNULL for the pointer argument.
* Convert GC source files to valid C++ codeIvan Maidanski2018-02-161-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*.
* Update comment in finalized_disclaim to match FINALIZER_CLOSURE_FLAGIvan Maidanski2017-11-301-1/+1
| | | | | | | (fix commit 012da3f) * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Update/refine comment (about the lowest 2 bits of the first word).
* Remove done_init static variable from fnlz_mlc.cIvan Maidanski2017-11-301-5/+3
| | | | | | | | | | | | (code refactoring) GC_init_finalized_malloc!=0 is used instead of boolean done_init. * fnlz_mlc.c [ENABLE_DISCLAIM] (done_init): Remove static variable. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc, GC_finalized_malloc): Use GC_finalized_kind instead of done_init. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Add assertion that the result of GC_new_kind_inner() is non-zero.
* Fix malloc routines to prevent size value wrap-aroundIvan Maidanski2016-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 tag collision between ENABLE_DISCLAIM and KEEP_BACK_PTRSIvan Maidanski2016-07-281-3/+11
| | | | | | | * fnlz_mlc.c (FINALIZER_CLOSURE_FLAG): New macro (defined to 0x2 in case KEEP_BACK_PTRS or MAKE_BACK_GRAPH, otherwise to 0x1). * fnlz_mlc.c (GC_finalized_disclaim, GC_finalized_malloc): Use FINALIZER_CLOSURE_FLAG instead of 0x1.
* Re-implement GC_finalized_malloc using GC_malloc_kindIvan Maidanski2016-07-211-88/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * fnlz_mlc.c: Do not test THREAD_LOCAL_ALLOC; do not include thread_local_alloc.h. * fnlz_mlc.c (GC_finalized_objfreelist, GC_core_finalized_malloc): Remove. * fnlz_mlc.c [ENABLE_DISCLAIM]: Include gc_inline.h (to declare GC_malloc_kind). * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Do not use GC_finalized_objfreelist. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Call GC_malloc_kind (instead of own implementation mostly duplicating the algorithm of GC_malloc_kind[_global]); change type of "op" local variable from ptr_t to word*. * include/private/thread_local_alloc.h [ENABLE_DISCLAIM] (THREAD_FREELISTS_KINDS): Increase value by 1. * include/private/thread_local_alloc.h (thread_local_freelists.finalized_freelists, GC_finalized_objfreelist): Remove. * thread_local_alloc.c (GC_finalized_objfreelist): Remove. * thread_local_alloc.c (GC_init_thread_local, GC_destroy_thread_local, GC_mark_thread_local_fls_for, GC_check_tls_for): Do not access finalized_freelists.
* Prefix PREFETCH_FOR_WRITE with GC_ as used in gc_inline.h public headerIvan Maidanski2015-12-281-1/+1
| | | | | | | | | | * doc/porting.html: Rename PREFETCH_FOR_WRITE to GC_PREFETCH_FOR_WRITE. * fnlz_mlc.c (GC_finalized_malloc): Likewise. * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Likewise. * include/private/gcconfig.h: Likewise. * new_hblk.c (GC_build_fl_clear4, GC_build_fl4, GC_build_fl): Likewise. * include/gc_inline.h (GC_PREFETCH_FOR_WRITE): Define to no-op if undefined.
* Fix 'op_sz variable unused' warning in GC_core_finalized_mallocIvan Maidanski2014-05-311-4/+1
| | | | | | (fix commit 2a3cef3) * fnlz_mlc.c (GC_core_finalized_malloc): Remove "op_sz" local variable.
* Fix GC_finalized_malloc failure on disclaim_testPetter Urkedal2014-05-311-15/+18
| | | | | | | | | | | | | | | | | | (revert part of commit 63fd11d) The finalizer closure is placed in the first word in order to use the lower bits to distinguish live objects from objects on the free list. The downside of this is that we need one-word offset interior pointers, and that GC_base does not return the start of the user region. * fnlz_mlc.c (GC_finalized_disclaim): Move finalizer closure for finalized object kinds back to the start of objects. * fnlz_mlc.c (GC_init_finalized_malloc): Call GC_register_displacement_inner() as GC_finalized_malloc returns displaced pointer. * fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc): Store fclos in first word of created object (instead of the last word); return pointer to object displaced by 1 word.
* Fix MS VC redefinition warning for functions declared with GC_ATTR_MALLOCIvan Maidanski2014-04-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 redundant casts in GC_generic_or_special_malloc and similarIvan Maidanski2014-02-211-2/+2
| | | | | | | | | | | | | | (refactoring) * mallocx.c (GC_generic_or_special_malloc, GC_generic_malloc_ignore_off_page): Remove redundant casts for "lb" argument; remove redundant parentheses. * fnlz_mlc.c (GC_finalized_malloc): Likewise. * malloc.c (GC_generic_malloc, GC_malloc_uncollectable): Likewise. * malloc.c (GC_malloc_uncollectable): Remove redundant cast of returned value. * mallocx.c (GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page): Likewise.
* Remove 'opp' local variable in GC_malloc_XIvan Maidanski2013-12-151-4/+2
| | | | | | | | | | | | | | | (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.
* Remove nested EXPECT in GC_core_finalized_mallocIvan Maidanski2012-09-111-1/+1
| | | | | * fnlz_mlc.c (GC_core_finalized_malloc): Remove duplicate (nested) EXPECT for SMALL_OBJ (since the latter already contains the former).
* Enable 'Force GC at every GC_malloc' debug-related functionalityIvan Maidanski2012-09-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * 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).
* Fix a typo in comment inside GC_finalized_mallocIvan Maidanski2012-04-111-1/+1
|
* Fix bug in finalized allocation.Petter Urkedal2012-04-111-0/+3
| | | | | | * fnlz_mlc.c (GC_register_disclaim_proc): Make sure to re-read our GC_size_map entry after calling GC_generic_malloc, in case it had to be extended.
* Remove closure data from GC_register_disclaim_proc.Petter Urkedal2012-01-261-6/+2
| | | | | | | | * include/gc_disclaim.h, fnlz_mlc.c (GC_disclaim_proc, GC_register_disclaim_proc): Remove CD from typedef and function. * reclaim.c (GC_reclaim_uninit, GC_reclaim_block): Adjust calls. * include/private/gc_priv.h, misc.c: Remove CD from object kind struct and initializers.
* Move GC_register_disclaim_proc to fnlz_mlcIvan Maidanski2012-01-251-0/+10
| | | | | | | | | * misc.c (GC_register_disclaim_proc): Move definition to fnlz_mlc.c (to minimize linked code size in case "disclaim" finalization is unused). * misc.c: Do not include gc_disclaim.h. * fnlz_mlc.c (GC_register_disclaim_proc): Add GC_ASSERT for kind passed by the client.
* Fix GC_finalized_malloc for out-of-memory case (and for missingIvan Maidanski2012-01-181-11/+16
| | | | | | | | | | | | | | | | 'const' qualifier) * fnlz_mlc.c (GC_finalized_disclaim): Add 'const' qualifier for "fc" pointer. * fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc): Cast "op" to 'const' pointer on "fclos" storing. * fnlz_mlc.c (GC_finalized_malloc): Use GC_get_oom_fn() instead of locked read of GC_oom_fn. * fnlz_mlc.c (GC_core_finalized_malloc): Test GC_generic_malloc result for NULL (return NULL in this case). * fnlz_mlc.c (GC_core_finalized_malloc): Add assertion on GC_size returned value (at least just to outline that it might be bigger than "lb" value).
* Move finalizer closure to the end of objects.Petter Urkedal2012-01-181-8/+13
| | | | | | | * fnlz_mlc.c: Move finalizer closure for finalized object kinds to the end of objects. This way, we don't require all interior pointers, and GC_base returns the expected address. * tests/disclaim_test.c: Improve test coverage.
* Add 'const' qualifier to pointer argument of GC_clear/set_mark_bit,Ivan Maidanski2012-01-171-3/+3
| | | | | | | | | | | | | | | | | | | | | GC_finalized_malloc, GC_general_register_disappearing_link * dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change): Make argument pointer const. * finalize.c (GC_general_register_disappearing_link): Likewise. * fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc): Likewise. * include/gc.h (GC_change_stubborn, GC_end_stubborn_change, GC_debug_change_stubborn, GC_debug_end_stubborn_change, GC_general_register_disappearing_link): Likewise. * include/gc_disclaim.h (GC_finalized_malloc): Likewise. * include/gc_mark.h (GC_clear_mark_bit, GC_set_mark_bit): Likewise. * mark.c (GC_set_mark_bit, GC_clear_mark_bit): Likewise. * stubborn.c (GC_end_stubborn_change, GC_change_stubborn): Likewise. * finalize.c (GC_general_register_disappearing_link): Remove redundant pointer type casts. * tests/test.c (cons, print_int_list, mktree): Likewise. * include/gc.h (GC_GENERAL_REGISTER_DISAPPEARING_LINK): Add cast removing potential 'const' qualifier.
* Refactoring: rename GC_EXPECT to EXPECT in .c filesIvan Maidanski2011-12-291-5/+5
| | | | | | | * fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc): Rename GC_EXPECT to EXPECT; replace 0/1 with TRUE/FALSE for the 2nd argument of EXPECT. * thread_local_alloc.c (GC_gcj_malloc): Likewise.
* Fix GC_finalized_malloc to fetch GC_oom_fn value atomicallyIvan Maidanski2011-11-151-2/+8
| | | | | * fnlz_mlc.c (GC_finalized_malloc): Fetch GC_oom_fn value holding the allocation lock.
* Rename (shorten name of) finalized_mlc.c to fnlz_mlc.c fileIvan Maidanski2011-11-111-0/+146
* finalized_mlc.c: Rename to fnlz_mlc.c file. * BCC_MAKEFILE (XXXOBJS): Rename "finalized_mlc" to "fnlz_mlc". * EMX_MAKEFILE (OBJS): Likewise. * Makefile.am (libgc_la_SOURCES): Likewise. * Makefile.direct (OBJS, CSRCS): Likewise. * Makefile.dj (OBJS, CSRCS): Likewise. * NT_MAKEFILE (OBJS): Likewise. * NT_STATIC_THREADS_MAKEFILE (OBJS): Likewise. * NT_X64_STATIC_THREADS_MAKEFILE (OBJS): Likewise. * NT_X64_THREADS_MAKEFILE (OBJS): Likewise. * OS2_MAKEFILE (OBJS): Likewise. * PCR-Makefile (COBJ, CSRC): Likewise. * SMakefile.amiga (OBJS, finalized_mlc.o): Likewise. * WCC_MAKEFILE (OBJS): Likewise. * digimars.mak (OBJS, finalized_mlc.o): Likewise. * extra/gc.c: Likewise. * gc.mak: Likewise. * thread_local_alloc.c: Likewise. * windows-untested/vc60/gc.dsp (SOURCE): Likewise. * windows-untested/vc60/libgc.dsp (SOURCE): Likewise. * windows-untested/vc70/gc.vcproj: Likewise. * windows-untested/vc70/libgc.vcproj: Likewise. * windows-untested/vc70/libgcmt.vcproj: Likewise. * windows-untested/vc71/gc.vcproj: Likewise. * windows-untested/vc71/libgc.vcproj: Likewise. * windows-untested/vc71/libgcmt.vcproj: Likewise.