summaryrefslogtreecommitdiff
path: root/mallocx.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix GC_bytes_allocd incrementation in case of allocation failureIvan Maidanski2016-09-271-22/+20
| | | | | | | * malloc.c (GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc): Increment GC_bytes_allocd only if the allocation successful (op != NULL). * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.
* Fix malloc routines to prevent size value wrap-aroundIvan Maidanski2016-09-231-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Merge branch 'generalize-alloc-via-ok_freelist'Ivan Maidanski2016-06-301-4/+4
|\ | | | | | | * mark.c (GC_n_kinds): Resolve merge conflict.
| * Revert "Refactoring of GC_Xobjfreelist" partiallyIvan Maidanski2016-06-301-4/+4
| | | | | | | | | | | | This reverts commit 41871b970c8fd9704835c1a221a8f9f1deea707a partially (GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_destroy_thread_local are not reverted).
* | Fix GC_REALLOC to call GC_FREE if new size is zero and pointer is non-NULLIvan Maidanski2016-04-051-0/+6
| | | | | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_debug_realloc): Call GC_debug_free (and return NULL) if lb is zero and p is non-NULL. * extra/AmigaOS.c (GC_amiga_realloc): Do not retry and do not call WARN if new_size_in_bytes is zero. * include/gc.h (GC_realloc): Refine comment (better document the cases of NULL and/or zero arguments). * mallocx.c (GC_realloc): Call GC_free (skip it if IGNORE_FREE) and return NULL if lb is zero and p is non-NULL.
* | Remove code duplication in GC_reallocIvan Maidanski2016-03-021-25/+15
| | | | | | | | | | * mallocx.c (GC_realloc): Avoid code duplication for shrink and grow cases.
* | Fix 'statement unreachable' compiler warning in memalignIvan Maidanski2016-03-021-1/+2
|/ | | | | | * mallocx.c (GC_memalign): Do not handle case of offset >= VALID_OFFSET_SZ; add assertion for offset; add static assertion for VALID_OFFSET_SZ value.
* GC_malloc[_atomic] global and thread-local generalization with kindAlessandro Bruni2016-01-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/gc_inline.h (GC_malloc_kind, GC_malloc_kind_global): New public function declaration. * include/gc_inline.h (GC_MALLOC_WORDS_KIND): New public macro. * include/gc_inline.h (GC_MALLOC_WORDS, GC_MALLOC_ATOMIC_WORDS): Use GC_MALLOC_WORDS_KIND. * include/gc_inline.h (GC_CONS): Use GC_malloc_kind (instead of GC_malloc); reformat code. * include/private/gc_priv.h (MAXOBJKINDS): Allow user-defined values. * include/private/gc_priv.h (GC_core_malloc, GC_core_malloc_atomic): Remove prototype. * malloc.c: Include gc_inline.h (to get GC_malloc_kind prototype). * mallocx.c: Likewise. * malloc.c (GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc): Add assertion on "k" (kind) argument (should be less than MAXOBJKINDS). * mallocx.c (GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * malloc.c (GC_generic_malloc_uncollectable): Add assertion on "k" argument (should be less than PREDEFINED_KINDS). * malloc.c (GC_core_malloc_atomic, GC_core_malloc): Replace with GC_malloc_kind_global. * malloc.c (GC_malloc_atomic, GC_malloc): Define as a wrapper around GC_malloc_kind_global. * malloc.c (GC_malloc_kind): Redirect to GC_malloc_kind_global if not defined in gc_inline.h (as a macro) or in thread_local_alloc.c. * mallocx.c (GC_generic_or_special_malloc): Call GC_malloc_kind instead of GC_malloc_kind and GC_malloc. * thread_local_alloc.c (GC_malloc, GC_malloc_atomic): Replace with GC_malloc_kind; remove tiny_fl local variable; call GC_malloc_kind_global instead of GC_core_malloc and GC_core_malloc_atomic. * thread_local_alloc.c (GC_destroy_thread_local): Adjust static assert to guard against global _freelists overrun.
* GC_malloc_[atomic_]uncollectable generalizationIvan Maidanski2016-01-151-55/+1
| | | | | | | | | | | * include/gc_mark.h (GC_generic_malloc_uncollectable): New public function declaration. * malloc.c (GC_generic_malloc_uncollectable): New function (imlementation mostly copied from GC_malloc_uncollectable). * malloc.c (GC_malloc_uncollectable, GC_malloc_atomic_uncollectable, calloc): Use GC_malloc_atomic_uncollectable. * mallocx.c (GC_generic_or_special_malloc): Likewise. * mallocx.c (GC_malloc_atomic_uncollectable): Move to malloc.c.
* Refactoring of GC_XobjfreelistAlessandro Bruni2016-01-051-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (use single array to keep free lists of all kinds) * alloc.c: Update comment (replace GC_objfreelist with GC_freelists[NORMAL]). * checksums.c (GC_on_free_list): Replace GC_sobjfreelist with GC_freelists[STUBBORN]. * mark.c (GC_obj_kinds): Likewise. * include/private/gc_priv.h (PTRFREE, NORMAL, UNCOLLECTABLE, AUNCOLLECTABLE, STUBBORN, IS_UNCOLLECTABLE): Move definition upper to be before _GC_arrays declaration. * include/private/gc_priv.h (PREDEFINED_KINDS): New macro. * include/private/gc_priv.h (GC_freelists): New macro (of global variable if SEPARATE_GLOBALS). * include/private/gc_priv.h (_GC_arrays): Replace _objfreelist, _aobjfreelist, _uobjfreelist, _auobjfreelist, _sobjfreelist fields with single _freelists[] field. * include/private/gc_priv.h (GC_objfreelist, GC_aobjfreelist, GC_auobjfreelist, GC_sobjfreelist, GC_uobjfreelist, beginGC_objfreelist, endGC_objfreelist, beginGC_aobjfreelist, endGC_aobjfreelist): Remove macro. * include/private/gc_priv.h (GC_objfreelist, GC_aobjfreelist): Replace variable declarations with single GC_freelists[] one (if SEPARATE_GLOBALS). * malloc.c (GC_malloc_atomic): Replace GC_aobjfreelist with GC_freelists[PTRFREE]. * mallocx.c (GC_aobjfreelist_ptr): Likewise. * mark.c (GC_obj_kinds): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * malloc.c (GC_malloc): Replace GC_objfreelist with GC_freelists[NORMAL]. * mallocx.c (GC_objfreelist_ptr): Likewise. * mark.c (GC_obj_kinds): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * malloc.c (GC_malloc_uncollectable): Replace GC_uobjfreelist with GC_freelists[UNCOLLECTABLE]. * mallocx.c (GC_uobjfreelist_ptr): Likewise. * mark.c (GC_obj_kinds): Likewise. * mallocx.c (GC_auobjfreelist_ptr, GC_malloc_atomic_uncollectable): Replace GC_auobjfreelist with GC_freelists[AUNCOLLECTABLE]. * mark.c (GC_obj_kinds): Likewise. * misc.c (GC_init): Exclude whole GC_freelists from scanning instead of beginGC_objfreelist and beginGC_aobjfreelist (if SEPARATE_GLOBALS).
* Fix lock assert violation in GC_gcollect_inner if GC_ALWAYS_MULTITHREADEDIvan Maidanski2015-10-221-1/+1
| | | | | | | | | | | * alloc.c (GC_expand_hp): Do not hold the allocation lock when calling GC_init. * malloc.c (GC_alloc_large, GC_generic_malloc_inner): Likewise. * mallocx.c (GC_generic_malloc_many): Likewise. * misc.c (GC_enable_incremental): Likewise. * misc.c (GC_init): Surround GC_gcollect_inner call with LOCK/UNLOCK (only if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED otherwise redundant).
* Recognize REDIRECT_MALLOC_IN_HEADER macroIvan Maidanski2015-05-111-4/+6
| | | | | | | | | | | | | | | * include/private/gcconfig.h: Do not issue error on REDIRECT_MALLOC and THREADS if REDIRECT_MALLOC_IN_HEADER defined. * malloc.c (malloc, calloc, strdup, strndup, free): Do not define if REDIRECT_MALLOC_IN_HEADER. * mallocx.c (realloc): Likewise. Conflicts: include/gc.h include/private/gcconfig.h malloc.c mallocx.c
* Rename ATOMIC_UNCOLLECTABLE to GC_ATOMIC_UNCOLLECTABLEIvan Maidanski2015-05-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | (code refactoring) * Makefile.direct (CFLAGS): Add GC_ prefix to ATOMIC_UNCOLLECTABLE. * SMakefile.amiga: Likewise. * configure.ac (enable_atomic_uncollectible): Likewise. * dbg_mlc.c (GC_print_obj, GC_debug_malloc_atomic_uncollectable, GC_debug_free, GC_debug_realloc): Likewise. * doc/README.Mac: Likewise. * doc/README.macros (ATOMIC_UNCOLLECTABLE): Likewise. * extra/AmigaOS.c (GC_amiga_allocwrapper_any): Likewise. * include/new_gc_alloc.h: Likewise. * include/private/gc_priv.h (struct _GC_arrays, AUNCOLLECTABLE): Likewise. * mallocx.c (GC_auobjfreelist_ptr, GC_generic_or_special_malloc, GC_malloc_atomic_uncollectable): Likewise. * mark.c (GC_obj_kinds, GC_N_KINDS_INITIAL_VALUE): Likewise. * include/private/gc_priv.h (GC_ATOMIC_UNCOLLECTABLE): Define if ATOMIC_UNCOLLECTABLE defined (for compatibility with the clients that do not use GC makefiles).
* Fix crash when using GC_malloc_many() as first allocation callBruce Hoult2014-05-311-2/+3
| | | | | * mallocx.c (GC_CALL GC_generic_malloc_many): Do not dereference ok_reclaim_list if it is NULL.
* Fix MS VC redefinition warning for functions declared with GC_ATTR_MALLOCIvan Maidanski2014-04-231-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Define ROUNDUP_PAGESIZE, ROUNDUP_GRANULE_SIZE macros (code refactoring)Ivan Maidanski2014-03-301-2/+2
| | | | | | | | | | | | | | | * alloc.c (GC_expand_hp_inner): Use ROUNDUP_PAGESIZE(). * checksums.c (GC_record_fault, GC_was_faulted): Likewise. * os_dep.c (GC_unix_mmap_get_mem, GC_wince_get_mem, GC_unmap_start, GC_remove_protection): Likewise. * headers.c (GC_scratch_alloc): Use ROUNDUP_GRANULE_SIZE(). * malloc.c (GC_alloc_large): Likewise. * mallocx.c (GC_malloc_many): Likewise. * headers.c (GC_scratch_alloc): Use ROUNDUP_PAGESIZE() (only if USE_MMAP). * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDUP_PAGESIZE): Define macro to round up a value to a multiple of a granule or a page, respectively.
* Define public GC_GENERIC_OR_SPECIAL_MALLOC and GC_get_kind_and_sizeIvan Maidanski2014-03-101-1/+10
| | | | | | | | | | | | | | | * dbg_mlc.c (GC_debug_generic_malloc, GC_debug_generic_or_special_malloc): New function. * mallocx.c (GC_get_kind_and_size): Likewise. * tests/test.c (test_generic_malloc_or_special): Likewise. * include/gc_mark.h (GC_generic_or_special_malloc, GC_debug_generic_or_special_malloc, GC_get_kind_and_size): New API prototype. * include/gc_mark.h (GC_GENERIC_OR_SPECIAL_MALLOC): New public macro. * mallocx.c (GC_generic_or_special_malloc): Turn into API function. * tests/test.c (reverse_test_inner, run_one_test): Invoke test_generic_malloc_or_special (to test GC_GENERIC_OR_SPECIAL_MALLOC and GC_get_kind_and_size).
* Remove redundant casts in GC_generic_or_special_malloc and similarIvan Maidanski2014-02-211-9/+9
| | | | | | | | | | | | | | (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 hb_large_block field (use 1 extra bit of hb_flags instead)Ivan Maidanski2013-12-211-2/+2
| | | | | | | | | | * allchblk.c (setup_header): Use (hb_flags & LARGE_BLOCK) != 0 instead of hb_large_block. * private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise. * mallocx.c (GC_realloc): Likewise. * include/private/gc_priv.h (struct hblkhdr): Remove hb_large_block; define LARGE_BLOCK to access corresponding bit in hb_flags (only if MARK_BIT_PER_GRANULE).
* Remove 'opp' local variable in GC_malloc_XIvan Maidanski2013-12-151-6/+4
| | | | | | | | | | | | | | | (code refactoring) * alloc.c: Update comment (about free lists). * fnlz_mlc.c (GC_finalized_malloc): Remove "opp" local variable (replace *opp with <kind>freelist[lg]). * gcj_mlc.c (GC_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_malloc_atomic, GC_malloc, GC_malloc_uncollectable): Likewise. * mallocx.c (GC_malloc_atomic_uncollectable): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise.
* Replace GC_DBG_RA with GC_DBG_EXTRAS macroIvan Maidanski2013-08-251-1/+1
| | | | | | | | | | | | * dbg_mlc.c (GC_debug_malloc_replacement, GC_debug_realloc_replacement): Use GC_DBG_EXTRAS (instead of "GC_DBG_RA NULL, 0"). * malloc.c (GC_debug_malloc_replacement): Likewise. * mallocx.c (GC_debug_realloc_replacement): Likewise. * include/private/gc_priv.h (GC_DBG_EXTRAS): New macro (similar to GC_EXTRAS but pass NULL/0 instead of __FILE__and __LINE__); pass "unknown" instead of NULL unless GC_ADD_CALLER. * include/private/gc_priv.h (GC_DBG_RA): Remove.
* Adjust GC_debug_malloc/realloc_replacement macro to match the API functionIvan Maidanski2013-08-251-2/+1
| | | | | | | * malloc.c (GC_debug_malloc_replacement): Pass NULL (instead of "unknown") to "s" argument of GC_debug_malloc to match that replacement definition in dbg_mlc.c. * mallocx.c (GC_debug_realloc_replacement): Likewise.
* Fix more typos in commentsOndrej Bilka2013-07-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * darwin_stop_world.c (GC_use_threads_discovery): Fix a typo in comment ("stopped"). * doc/porting.html: Fix typos in comment ("defining", "support"). * include/gc.h (GC_get_prof_stats): Fix a typo in comment ("entries"). * include/private/gc_priv.h (GC_have_errors): Fix a typo in comment ("OK"). * include/private/gcconfig.h: Fix a typo in comment ("SPARC). * ChangeLog: Likewise. * os_dep.c (GC_linux_main_stack_base): Likewise. * include/private/gcconfig.h: Fix a typo in comment ("release"). * mallocx.c (GC_generic_malloc_many): Fix a typo in comment ("reacquiring"). * mallocx.c (GC_memalign): Fix a typo in comment ("OK"). * os_dep.c (GC_win32_free_heap): Likewise. * pthread_support.c (GC_remove_all_threads_but_me): Likewise. * win32_threads.c (GC_remove_all_threads_but_me): Likewise. * doc/README.Mac: Likewise. * mark.c (GC_push_unconditionally): Fix a typo in comment ("pointers"). * pthread_support.c: Fix a typo in comment ("which"). * win32_threads.c: Fix a typo in comment ("losing").
* Fix typos in commentsOndrej Bilka2013-07-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * 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").
* Make GC_generic_malloc_ignore_off_page() publicIvan Maidanski2012-12-081-3/+2
| | | | | | | | | | | | | | * include/gc_mark.h (GC_generic_malloc): Refine comment. * include/gc_mark.h (GC_generic_malloc_ignore_off_page): Move prototype from gc_priv.h and make it public; add GC_ATTR_MALLOC attribute. * include/private/gc_priv.h (GC_generic_malloc): Move comment to gc_mark.h. * include/private/gc_priv.h (GC_generic_malloc_ignore_off_page): Remove GC-inner prototype. * include/private/gc_priv.h (GC_generic_malloc_inner): Update comment. * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * mallocx.c (GC_generic_malloc_ignore_off_page): Make public.
* Enable 'Force GC at every GC_malloc' debug-related functionalityIvan Maidanski2012-09-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | * 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).
* Use memcpy (BCOPY) instead of strcpy (to suppress GCC warning)Ivan Maidanski2012-07-201-6/+1
| | | | | | | | | | | | * cord/cordbscs.c (CORD_from_fn, CORD_substr_checked): Use memcpy instead of strcpy (to suppress GCC/ld warning "strcpy() is almost always misused"). * dbg_mlc.c (GC_debug_strdup): Replace strcpy and memcpy with cross-platform BCOPY (with reversed order of "src" and "dest" arguments). * mallocx.c (GC_strdup): Likewise. * misc.c (GC_envfile_init, GC_CreateLogFile): Likewise. * os_dep.c (GC_print_callers): Likewise.
* Add comment in GC_memalignIvan Maidanski2012-06-081-0/+2
| | | | * mallocx.c (GC_memalign): Add comment for GC_malloc invocation result.
* Fix assertion in GC_malloc_[atomic_]uncollectable (THREADS case only)Ivan Maidanski2012-05-161-1/+3
| | | | | | * malloc.c (GC_malloc_uncollectable): Do not check assertion on hb_n_marks to be zero if multi-threaded; add comment. * mallocx.c (GC_malloc_atomic_uncollectable): Likewise.
* Fix allocation size overflows due to rounding.Xi Wang2012-03-151-0/+2
| | | | | | * malloc.c (GC_generic_malloc): Check if the allocation size is rounded to a smaller value. * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.
* Add missing 'volatile' for AO_t variable definitionsIvan Maidanski2012-01-291-9/+8
| | | | | | | | | | | | | | | | | | | | | | (to minimize number of casts breaking strict-aliasing rules) * mallocx.c (GC_bytes_allocd_tmp): Change type from signed_word to AO_t. * mallocx.c (GC_generic_malloc_many): Use AO_load to get GC_bytes_allocd_tmp value; remove type cast for GC_bytes_allocd_tmp passed to AO_fetch_and_add. * pthread_support.c (GC_spin_count, GC_block_count, GC_unlocked_count): Add "volatile" for AO_t global variable (defined only if LOCK_STATS). * win32_threads.c (GC_attached_thread, GC_block_count, GC_unlocked_count): Likewise. * win32_threads.c (GC_Thread_Rep): Add "volatile" for "in_use" AO_t field. * win32_threads.c (GC_started_thread_while_stopped): Remove "result" local variable; use AO_compare_and_swap_release (if available) instead of AO_nop_full/load/store for GC_attached_thread. * win32_threads.c (GC_stop_world): Clear GC_attached_thread using AO_store.
* Use EXPECT in malloc result testing for NULLIvan Maidanski2012-01-181-2/+4
| | | | | | | | | | | * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Use EXPECT to test "op" value for NULL. * malloc.c (GC_generic_malloc_inner, GC_malloc_uncollectable): Likewise. * mallocx.c (GC_generic_malloc_many, GC_posix_memalign): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise.
* Use EXPECT for checking various 'initialized' boolean variablesIvan Maidanski2011-12-291-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Resolve "comparison of signed and unsigned values" compiler warnings.Ivan Maidanski2011-08-211-1/+1
| | | | | | | | | | | | | | | | | * 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.
* 2011-04-09 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-51/+0
| | | | | * mallocx.c (GC_malloc_uncollectable): Move to malloc.c (since it is used internally in some places).
* 2011-04-09 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-6/+62
| | | | | | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_register_finalizer_no_order): Remove redundant declaration. * dbg_mlc.c (GC_debug_malloc_replacement, GC_debug_realloc_replacement): Rename RA to GC_DBG_RA. * malloc.c (GC_debug_malloc_replacement): Ditto. * mallocx.c (GC_debug_realloc_replacement): Ditto. * dbg_mlc.c (GC_store_debug_info): Move proto from dbg_mlc.h. * malloc.c (GC_strdup, GC_strndup, GC_wcsdup): Move to mallocx.c. * malloc.c: Include errno.h only REDIRECT_MALLOC; remove redundant includes of string.h. * mallocx.c: Include string.h (for GC_strdup). * include/private/dbg_mlc.h (GC_store_debug_info): Move declaration to dbg_mlc.c. * include/private/gc_locks.h (UNCOND_LOCK, UNCOND_UNLOCK): Remove redundant trailing ';'. * include/private/gc_priv.h (START_WORLD, COND_DUMP): Ditto. * include/private/gc_locks.h (LOCK, UNLOCK): Place opening '{' properly. * include/private/gc_priv.h (GC_DBG_RA): Move from dbg_mlc.c, malloc.c, mallocx.c.
* 2011-03-27 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dbg_mlc.c (GC_debug_strdup, GC_debug_free): Output a portability warning if the argument is NULL and GC is in leaks detection mode. * dbg_mlc.c (GC_debug_strndup, GC_debug_wcsdup): New public function definition. * malloc.c (GC_strndup, GC_wcsdup, strndup): Ditto. * mallocx.c (GC_posix_memalign): Ditto. * malloc.c (strdup): Fix string size value; rename "len" to "lb". * mallocx.c: Include errno.h unless WinCE (otherwise include windows.h for Win32 error constants). * win32_threads.c: Define WIN32_LEAN_AND_MEAN and NOSERVICE before windows.h inclusion. * misc.c (GC_init): Register at-exit callback if GC_find_leak (even if GC_FIND_LEAK macro is unset). * pthread_stop_world.c (NACL_STORE_REGS, __nacl_suspend_thread_if_needed, GC_nacl_initialize_gc_thread): Use BCOPY() instead of memcpy(). * pthread_support.c (GC_init_real_syms): Ditto. * doc/README: Update year in copyright. * include/gc.h: Ditto. * doc/README.macros (GC_DEBUG_REPLACEMENT, GC_REQUIRE_WCSDUP): Document new macro. * doc/README.macros (REDIRECT_MALLOC): Update documentation. * include/gc.h (GC_strndup, GC_posix_memalign, GC_debug_strndup): New API function prototype. * include/gc.h (GC_MALLOC, GC_REALLOC): Redirect to GC_debug_malloc/realloc_replacement() if GC_DEBUG_REPLACEMENT. * include/gc.h (GC_STRDUP): Remove redundant parentheses. * include/leak_detector.h (realloc, strdup): Ditto. * include/gc.h (GC_STRNDUP): New API macro. * include/gc.h (GC_NEW, GC_NEW_ATOMIC, GC_NEW_STUBBORN, GC_NEW_UNCOLLECTABLE): Add missing parentheses. * include/gc.h (GC_wcsdup, GC_debug_wcsdup): New API function prototype (only if GC_REQUIRE_WCSDUP). * include/gc.h (GC_WCSDUP): New API macro (only if GC_REQUIRE_WCSDUP). * include/leak_detector.h: Add copyright header; add usage comment; include stdlib.h and string.h after gc.h (unless GC_DONT_INCLUDE_STDLIB). * include/leak_detector.h (malloc, calloc, free, realloc): Undefine symbol before its redefinition. * include/leak_detector.h (strndup, memalign, posix_memalign): Redefine to the corresponding GC function. * include/leak_detector.h (wcsdup): Redefine to GC_WCSDUP (only if GC_REQUIRE_WCSDUP). * include/leak_detector.h (CHECK_LEAKS): Add comment; don't define the macro if already defined.
* 2010-02-04 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-8/+4
| | | | | | * mallocx.c (GC_generic_malloc_many, GC_malloc_many): Define even if THREADS is undefined. * include/gc.h (GC_malloc_many): Update the comment.
* 2009-10-22 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_unmap_old, GC_merge_unmapped, GC_allochblk, GC_freehblk): Use GC_INNER for the function definition. * alloc.c (GC_never_stop_func, GC_should_collect, GC_try_to_collect_inner, GC_collect_a_little_inner, GC_set_fl_marks, GC_add_to_our_memory, GC_add_to_heap, GC_expand_hp_inner, GC_collect_or_expand, GC_allocobj): Ditto. * backgraph.c (GC_build_back_graph, GC_traverse_back_graph): Ditto. * blacklst.c (GC_default_print_heap_obj_proc, GC_bl_init, GC_promote_black_lists, GC_unpromote_black_lists, GC_add_to_black_list_normal, GC_add_to_black_list_stack, GC_is_black_listed): Ditto. * darwin_stop_world.c (GC_push_all_stacks, GC_push_all_stacks, GC_stop_init, GC_stop_world, GC_start_world): Ditto. * dbg_mlc.c (GC_has_other_debug_info, GC_store_back_pointer, GC_marked_for_finalization, GC_generate_random_backtrace_no_gc, GC_store_debug_info, GC_start_debugging, GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page, GC_debug_malloc_uncollectable, GC_debug_free_inner): Ditto. * dyn_load.c (GC_register_dynamic_libraries, GC_register_main_static_data, GC_init_dyld): Ditto. * finalize.c (GC_push_finalizer_structures, GC_finalize, GC_notify_or_invoke_finalizers, GC_print_finalization_stats): Ditto. * gcj_mlc.c (GC_core_gcj_malloc): Ditto. * headers.c (GC_find_header, GC_header_cache_miss, GC_scratch_alloc, GC_init_headers, GC_install_header, GC_install_counts, GC_remove_header, GC_remove_counts, GC_next_used_block, GC_prev_block): Ditto. * mach_dep.c (GC_with_callee_saves_pushed): Ditto. * malloc.c (GC_collect_or_expand, GC_alloc_large, GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page, GC_core_malloc_atomic, GC_core_malloc, GC_free_inner): Ditto. * mallocx.c (GC_generic_malloc_ignore_off_page): Ditto. * mark.c (GC_collection_in_progress, GC_clear_hdr_marks, GC_set_hdr_marks, GC_set_mark_bit, GC_clear_mark_bit, GC_clear_marks, GC_initiate_gc, GC_mark_some, GC_mark_stack_empty, GC_invalidate_mark_state, GC_signal_mark_stack_overflow, GC_mark_from, GC_help_marker, GC_mark_init, GC_push_all, GC_push_conditional, GC_mark_and_push_stack, GC_push_all_eager, GC_push_all_stack): Ditto. * mark_rts.c (GC_is_static_root, GC_roots_present, GC_approx_sp, GC_exclude_static_roots_inner, GC_push_all_register_frames, GC_push_all_stack_frames, GC_cond_register_dynamic_libraries, GC_push_roots): Ditto. * misc.c (GC_extend_size_map, GC_clear_stack, GC_err_write): Ditto. * new_hblk.c (GC_build_fl, GC_new_hblk): Ditto. * obj_map.c (GC_register_displacement_inner, GC_add_map_entry, GC_initialize_offsets): Ditto. * os_dep.c (GC_get_maps, GC_parse_map_entry, GC_text_mapping, GC_init_linux_data_start, GC_init_netbsd_elf, GC_setpagesize, GC_set_and_save_fault_handler, GC_setup_temporary_fault_handler, GC_reset_fault_handler, GC_get_register_stack_base, GC_init_win32, GC_add_current_malloc_heap, GC_is_heap_base, GC_unmap, GC_remap, GC_unmap_gap, GC_push_all_stacks, GC_gww_dirty_init, GC_dirty_init, GC_read_dirty, GC_page_was_dirty, GC_page_was_ever_dirty, GC_remove_protection, GC_write_fault_handler, GC_mprotect_stop, GC_mprotect_resume, GC_save_callers, GC_print_callers): Ditto. * pthread_stop_world.c (GC_push_all_stacks, GC_stop_world, GC_start_world, GC_stop_init): Ditto. * pthread_support.c (GC_mark_thread_local_free_lists, GC_lookup_thread, GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_segment_is_thread_stack, GC_greatest_stack_base_below, GC_thr_init, GC_init_parallel, GC_do_blocking_inner, GC_lock, GC_acquire_mark_lock, GC_release_mark_lock, GC_wait_for_reclaim, GC_notify_all_builder, GC_wait_marker, GC_notify_all_marker): Ditto. * reclaim.c (GC_print_all_errors, GC_block_empty, GC_reclaim_generic, GC_start_reclaim, GC_continue_reclaim, GC_reclaim_all): Ditto. * thread_local_alloc.c (GC_init_thread_local, GC_destroy_thread_local, GC_mark_thread_local_fls_for): Ditto. * win32_threads.c (GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_do_blocking_inner, GC_stop_world, GC_start_world, GC_push_all_stacks, GC_get_next_stack, GC_acquire_mark_lock, GC_release_mark_lock, GC_wait_for_reclaim, GC_notify_all_builder, GC_wait_marker, GC_notify_all_marker, GC_thr_init, GC_init_parallel, GC_lock, GC_mark_thread_local_free_lists): Ditto. * alloc.c (GC_add_current_malloc_heap, GC_build_back_graph, GC_traverse_back_graph): Use GC_INNER for the function prototype. * darwin_stop_world.c (GC_mprotect_stop, GC_mprotect_resume): Ditto. * dbg_mlc.c (GC_default_print_heap_obj_proc): Ditto. * dyn_load.c (GC_parse_map_entry, GC_get_maps, GC_segment_is_thread_stack, GC_roots_present, GC_is_heap_base, GC_get_next_stack): Ditto. * finalize.c (GC_reset_finalizer_nested, GC_check_finalizer_nested): Ditto. * gcj_mlc.c (GC_start_debugging): Ditto. * include/private/dbg_mlc.h (GC_save_callers, GC_print_callers, GC_has_other_debug_info, GC_store_debug_info): Ditto. * include/private/gc_hdrs.h (GC_header_cache_miss): Ditto. * include/private/gc_locks.h (GC_lock): Ditto. * include/private/gc_pmark.h (GC_signal_mark_stack_overflow, GC_mark_from): Ditto. * include/private/pthread_support.h (GC_lookup_thread, GC_stop_init): Ditto. * include/private/thread_local_alloc.h (GC_init_thread_local, GC_destroy_thread_local, GC_mark_thread_local_fls_for): Ditto. * malloc.c (GC_extend_size_map, GC_text_mapping): Ditto. * mark.c (GC_page_was_ever_dirty): Ditto. * mark_rts.c (GC_mark_thread_local_free_lists): Ditto. * misc.c (GC_register_main_static_data, GC_init_win32, GC_setpagesize, GC_init_linux_data_start, GC_set_and_save_fault_handler, GC_init_dyld, GC_init_netbsd_elf, GC_do_blocking_inner): Ditto. * os_dep.c (GC_greatest_stack_base_below): Ditto. * win32_threads.c (GC_write_fault_handler, GC_gww_dirty_init): Ditto. * include/private/gc_priv.h: Ditto (for most prototypes). * include/private/gc_priv.h (GC_INNER): Update the comment. * doc/README.macros (GC_DLL): Update.
* 2009-10-22 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_collection_in_progress): Move the prototype to gc_priv.h. * gc_dlopen.c (GC_collection_in_progress): Ditto. * pthread_support.c (GC_collection_in_progress): Ditto. * misc.c (GC_init_parallel): Ditto. * pthread_support.c (GC_init_parallel): Ditto. * win32_threads.c (GC_init_parallel): Ditto. * darwin_stop_world.c (GC_thr_init): Ditto. * misc.c (GC_thr_init): Ditto. * pthread_stop_world.c (GC_thr_init): Ditto. * pthread_support.c (GC_thr_init): Ditto. * blacklst.c (GC_clear_bl, GC_copy_bl, GC_number_stack_black_listed): Make STATIC. * dbg_mlc.c (GC_print_obj, GC_make_closure, GC_debug_invoke_finalizer): Ditto. * malloc.c (GC_alloc_large_and_clear): Ditto. * mark.c (GC_push_selected, GC_push_marked1, GC_push_marked2, GC_push_marked4, GC_push_marked, GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Ditto. * misc.c (GC_clear_stack_inner): Ditto. * os_dep.c (GC_repeat_read, GC_default_push_other_roots): Ditto. * darwin_stop_world.c (FindTopOfStack): Make static; define only if not DARWIN_DONT_PARSE_STACK. * dbg_mlc.c (GC_debug_free_inner): Define only if DBG_HDRS_ALL. * dyn_load.c (GC_repeat_read): Remove unused prototype. * include/private/gc_pmark.h (GC_find_start): Ditto. * misc.c (GC_read, GC_register_finalizer_no_order): Ditto. * dyn_load.c (GC_segment_is_thread_stack): Add prototype (only if THREADS). * dyn_load.c (GC_register_main_static_data): Define only if DYNAMIC_LOADING. * finalize.c (GC_enqueue_all_finalizers): Remove unnecessary tail "return" statement. * gc_dlopen.c (GC_SOLARIS_THREADS): Don't recognize (since implies GC_PTHREADS). * include/gc.h: Fix a typo. * include/gc_inline.h (GC_ASSERT): Define (if not defined) since the header is public. * include/gc_inline.h (GC_generic_malloc_many): New public function declaration. * mallocx.c (GC_generic_malloc_many): Make public. * include/private/gc_priv.h (GC_INNER): Use visibility attribute (if available). * include/private/gc_priv.h (GC_EXTERN): Define using GC_INNER. * include/private/gc_priv.h: Include atomic_ops.h if THREADS and MPROTECT_VDB. * os_dep.c: Don't include atomic_ops.h * win32_threads.c: Ditto. * include/private/gc_priv.h (GC_push_selected, GC_push_regs, GC_push_marked, GC_number_stack_black_listed, GC_alloc_large_and_clear, GC_reclaim_or_delete_all, GC_generic_malloc_many, GC_make_closure, GC_debug_invoke_finalizer, GC_print_obj, GC_page_was_ever_dirty): Remove the prototype. * mark.c (GC_page_was_ever_dirty): Add prototype (only if PROC_VDB). * include/private/gc_priv.h (GC_push_next_marked_dirty, GC_push_next_marked, GC_push_next_marked_uncollectable): Move the prototype to mark.c. * include/private/gc_priv.h (GC_is_static_root): Declare only if not THREADS. * include/private/gc_priv.h (GC_free_inner): Declare only if THREADS. * include/private/gc_priv.h (GC_debug_free_inner): Declare only if THREADS and DBG_HDRS_ALL. * include/private/gc_priv.h (GC_markers): Declare GC_markers only if PARALLEL_MARK. * include/private/gc_priv.h (GC_register_main_static_data): Move the prototype to misc.c. * mach_dep.c (GC_push_regs): Make STATIC; define only along with HAVE_PUSH_REGS definition. * mach_dep.c (GC_clear_stack_inner): Replace K&R-style function definition with the ANSI C one. * mark.c (GC_started_thread_while_stopped): Declared only if not GNU C. * win32_threads.c (GC_started_thread_while_stopped): Don't define if GNU C. * mark.c (GC_mark_from): Avoid unbalanced brackets in #if-#else-#endif blocks. * mark_rts.c (GC_is_static_root): Define only if not THREADS. * os_dep.c (GC_get_stack_base): Make public (for OpenBSD). * os_dep.c (GC_page_was_ever_dirty): Comment out the function except for PROC_VDB. * tests/test.c (main): Don't reference GC_print_obj, GC_make_closure, GC_debug_invoke_finalizer, GC_page_was_ever_dirty, GC_is_fresh (in GC_noop). * thread_local_alloc.c: Don't include "gc_inline.h". * win32_threads.c (GC_write_fault_handler): Declare only if MPROTECT_VDB.
* 2009-10-21 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (DEBUG): Remove macro (since unused). * allchblk.c: Include private/gc_priv.h before other includes and definitions. * alloc.c: Ditto. * gc_dlopen.c: Ditto. * headers.c: Ditto. * mallocx.c: Ditto. * mark_rts.c: Ditto. * new_hblk.c: Ditto. * reclaim.c: Ditto. * mark.c: Include private/gc_pmark.h before other includes. * misc.c: Ditto. * dyn_load.c (_GNU_SOURCE): Move the definition to gc_priv.h. * pthread_support.c (_USING_POSIX4A_DRAFT10): Ditto. * pthread_support.c (_POSIX4A_DRAFT10_SOURCE): Remove (since already defined in gc_config_macros.h). * dyn_load.c (GC_init_dyld): Remove parameter cast for _dyld_register_func_for_add_image() and _dyld_register_func_for_remove_image(); add the comment about possible warnings; add FIXME for the deprecated _dyld_bind_fully_image_containing_address(). * include/private/gc_priv.h: Include gc.h before the standard headers inclusion. * tests/test.c: Ditto. * include/private/gcconfig.h (DebugBreak): Update the comment. * typd_mlc.c (ED_INITIAL_SIZE): Remove ';'. * alloc.c: Reformat the code (partly adjust indentation). * backgraph.c: Ditto. * blacklst.c: Ditto. * checksums.c: Ditto. * finalize.c: Ditto. * gcj_mlc.c: Ditto. * mach_dep.c: Ditto. * mark_rts.c: Ditto. * obj_map.c: Ditto. * os_dep.c: Ditto. * ptr_chck.c: Ditto. * stubborn.c: Ditto. * thread_local_alloc.c: Ditto. * typd_mlc.c: Ditto.
* 2009-10-18 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_fail_count, GC_large_alloc_warn_interval): Move the variable declaration to gc_priv.h. * alloc.c (GC_bytes_found, GC_unmap_threshold, GC_force_unmap_on_gcollect): Ditto. * dyn_load.c (GC_no_win32_dlls, GC_wnt): Ditto. * finalize.c (GC_fail_count): Ditto. * include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder, GC_collecting, GC_mark_lock_holder, GC_need_to_lock): Ditto. * include/private/gc_pmark.h (GC_n_mark_procs, GC_mark_stack_size, GC_mark_stack_limit, GC_mark_stack_top, GC_mark_stack, GC_mark_stack_too_small, GC_mark_state): Ditto. * include/private/pthread_support.h (GC_threads, GC_thr_initialized, GC_in_thread_creation): Ditto. * mallocx.c (GC_bytes_found): Ditto. * mark_rts.c (GC_save_regs_ret_val, GC_world_stopped): Ditto. * misc.c (GC_unmap_threshold): Ditto. * os_dep.c (GC_unmap_threshold): Ditto. * pthread_support.c (GC_markers): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist, GC_gcj_malloc_initialized, GC_gcj_kind): Ditto. * win32_threads.c (GC_fault_handler_lock, GC_write_cs, GC_dont_query_stack_min, GC_markers, GC_wnt): Ditto. * include/private/gc_priv.h (GC_EXTERN): New macro (used mostly as a tag for now); defined after "gcconfig.h" inclusion. * include/private/gc_priv.h: Use GC_EXTERN instead of "extern" keyword for most global variables. * alloc.c (GC_copyright): Add the comment about the symbol visibility. * finalize.c (GC_fo_entries): Ditto. * include/private/gc_priv.h (GC_print_stats): Ditto. * misc.c (GC_quiet): Ditto. * mallocx.c (GC_bytes_allocd_tmp): Make the volatile variable STATIC. * pthread_support.c (GC_threads): Add explicit zero initializer (to make the variable definition differ from the declaration).
* 2009-10-06 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | * include/gc.h: Reformat the code (make the indentation style uniform across the file). * include/gc.h (GC_SOLARIS_THREADS): Don't check for. * include/gc.h (GC_MIN, GC_MAX): Don't define. * mallocx.c (GC_malloc_many): Add comment to #endif.
* 2009-10-01 Ivan Maidanski <ivmai@mail.ru> (really mostly Andreas Tobler)ivmai2011-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_fail_count, GC_large_alloc_warn_interval): Add "extern" keyword to a global variable declaration (some compilers require it). * alloc.c (GC_bytes_found, GC_unmap_threshold, GC_force_unmap_on_gcollect): Ditto. * dyn_load.c (GC_no_win32_dlls, GC_wnt): Ditto. * finalize.c (GC_fail_count): Ditto. * include/private/gc_hdrs.h (GC_hdr_cache_hits, GC_hdr_cache_misses): Ditto. * mallocx.c (GC_bytes_found): Ditto. * mark_rts.c (GC_save_regs_ret_val, GC_world_stopped): Ditto. * misc.c (GC_unmap_threshold): Ditto. * os_dep.c (GC_unmap_threshold, GC_old_allocator): Ditto. * pthread_support.c (GC_markers): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist, GC_gcj_malloc_initialized, GC_gcj_kind): Ditto. * win32_threads.c (GC_fault_handler_lock, GC_write_cs, GC_dont_query_stack_min, GC_markers, GC_wnt): Ditto.
* 2009-09-30 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_large_alloc_warn_interval): Move declaration from gc_priv.h. * allchblk.c (GC_large_alloc_warn_suppressed): Move definition from misc.c; define as STATIC. * include/private/gc_priv.h (GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed): Remove declaration. * alloc.c (GC_bytes_found): Add "defined in" comment. * mallocx.c (GC_bytes_found): Ditto. * misc.c (GC_unmap_threshold): Ditto. * os_dep.c (GC_old_allocator): Ditto. * pthread_support.c (GC_markers): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist, GC_gcj_malloc_initialized, GC_gcj_kind): Ditto. * win32_threads.c (GC_markers): Ditto. * alloc.c (GC_start_time): Explicitly initialize to 0 or NULL (to be distinctive from a variable declaration). * backgraph.c (GC_max_height, GC_deepest_obj): Ditto. * blacklst.c (GC_old_normal_bl, GC_incomplete_normal_bl, GC_old_stack_bl, GC_incomplete_stack_bl): Ditto. * checksums.c (GC_faulted, GC_n_dirty_errors, GC_n_faulted_dirty_errors, GC_n_changed_errors, GC_n_clean, GC_n_dirty, GC_bytes_in_used_blocks): Ditto. * dbg_mlc.c (GC_smashed): Ditto. * finalize.c (GC_old_dl_entries): Ditto. * gcj_mlc.c (GC_gcj_kind, GC_gcj_debug_kind, GC_gcjobjfreelist, GC_gcjdebugobjfreelist): Ditto. * mach_dep.c (GC_save_regs_ret_val): Ditto. * mark.c (GC_n_rescuing_pages, GC_mark_stack, GC_mark_stack_limit, GC_mark_stack_top): Ditto. * misc.c (GC_min_sp, GC_high_water, GC_bytes_allocd_at_reset): Ditto. * os_dep.c (GC_data_start, GC_page_size, GC_sysinfo, GC_old_segv_handler, GC_old_bus_handler, GC_old_bus_handler_used_si, GC_old_segv_handler_used_si, GC_proc_buf, GC_proc_fd, GC_vd_base): Ditto. * pthread_stop_world.c (GC_stop_count, GC_stopping_pid): Ditto. * reclaim.c (GC_leaked): Ditto. * typd_mlc.c (GC_explicit_kind, GC_array_kind, GC_ext_descriptors, GC_typed_mark_proc_index, GC_array_mark_proc_index, GC_eobjfreelist, GC_arobjfreelist): Ditto. * win32_threads.c (GC_pthread_map_cache, GC_marker_cv, GC_marker_Id): Ditto. * dbg_mlc.c (GC_smashed, GC_n_smashed): Define as STATIC. * gcj_mlc.c (GC_gcjdebugobjfreelist): Ditto. * os_dep.c (GC_vd_base): Ditto. * pthread_support.c (GC_mark_threads): Ditto. * reclaim.c (GC_leaked): Ditto. * typd_mlc.c (GC_bm_table): Ditto. * mark_rts.c (GC_save_regs_ret_val): Change declaration type to that of definition; add "defined in" comment. * mark_rts.c (GC_push_current_stack): Remove unnecessary cast for GC_save_regs_ret_val. * misc.c (GC_check_heap, GC_print_all_smashed, GC_start_call_back): Remove unnecessary cast (of 0). * misc.c (GC_LARGE_ALLOC_WARN_INTERVAL): New tuning macro. * misc.c (GC_large_alloc_warn_interval): Initialize to GC_LARGE_ALLOC_WARN_INTERVAL value. * misc.c (GC_tmp): Change to "static". * os_dep.c (GC_setpagesize): Reformat the code (collapse multiple function definitions). * os_dep.c (GC_mprotect_state): Define as static. * pthread_support.c (dummy_thread_local): Prefix with "GC_". * win32_threads.c (WinMain): Remove FIXME for WinCE.
* 2009-09-27 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_hblkfreelist): Define as STATIC. * blacklst.c (GC_total_stack_black_listed): Ditto. * include/private/gc_priv.h (GC_hblkfreelist, GC_stopped_mark, GC_total_stack_black_listed, GC_push_stubborn_structures): Remove declaration. * mark_rts.c (GC_stopped_mark): Add declaration (only if THREAD_LOCAL_ALLOC). * allchblk.c (GC_fail_count): Move the declaration out of GC_allochblk_nth(); remove "extern". * alloc.c (IF_THREADS): Remove unused macro. * alloc.c (GC_world_stopped): Define only if THREAD_LOCAL_ALLOC. * alloc.c (GC_stopped_mark): Set GC_world_stopped value only if THREAD_LOCAL_ALLOC. * alloc.c (GC_bytes_found, GC_collection_in_progress, GC_check_tls, GC_unmap_threshold, GC_force_unmap_on_gcollect): Remove K&R-style "extern" for the declaration. * dbg_mlc.c (GC_free_inner): Ditto. * dyn_load.c (GC_repeat_read, GC_roots_present, GC_is_heap_base, GC_get_next_stack, GC_no_win32_dlls, GC_wnt): Ditto. * finalize.c (GC_fail_count): Ditto. * include/private/gc_hdrs.h (GC_hdr_cache_hits, GC_hdr_cache_misses): Ditto. * include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder, GC_lock, GC_collecting, GC_mark_lock_holder, GC_need_to_lock): Ditto. * include/private/gc_pmark.h (GC_mark_procs, GC_n_mark_procs, GC_mark_stack_size, GC_mark_stack_limit, GC_mark_stack_top, GC_mark_stack, GC_mark_stack_too_small, GC_mark_state): Ditto. * include/private/gc_priv.h (GC_current_warn_proc, GC_obj_kinds, GC_n_kinds, GC_fo_entries, GC_n_heap_sects, GC_n_memory, GC_page_size, GC_sysinfo, GC_black_list_spacing, GC_objects_are_marked, GC_incremental, GC_dirty_maintained, GC_root_size, GC_debugging_started, GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed, GC_blocked_sp, GC_activation_frame, GC_push_other_roots, GC_push_finalizer_structures, GC_push_thread_structures, GC_push_typed_structures, GC_start_call_back, GC_is_initialized, GC_check_heap, GC_print_all_smashed, GC_print_all_errors, GC_print_heap_obj, GC_have_errors, GC_print_stats, GC_dump_regularly, GC_backtraces, GC_print_back_height, GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page, GC_fl_builder_count, GC_mark_no, GC_help_marker, GC_setup_temporary_fault_handler, GC_reset_fault_handler): Ditto. * include/private/gcconfig.h (GC_SysVGetDataStart, GC_FreeBSDGetDataStart, GC_register_stackbottom, GC_MacTemporaryNewPtr, GC_amiga_get_mem): Ditto. * include/private/pthread_support.h (GC_threads, GC_thr_initialized, GC_in_thread_creation): Ditto. * malloc.c (GC_text_mapping): Ditto. * mallocx.c (GC_bytes_found): Ditto. * mark.c (GC_check_dirty, GC_started_thread_while_stopped): Ditto. * mark_rts.c (GC_save_regs_ret_val): Ditto. * misc.c (GC_clear_stack_inner, GC_init_parallel, GC_init_win32, GC_setpagesize, GC_init_linux_data_start, GC_set_and_save_fault_handler, GC_unmap_threshold): Ditto. * os_dep.c (GC_unmap_threshold, GC_push_all_stacks, GC_darwin_register_mach_handler_thread): Ditto. * pthread_support.c (GC_markers, GC_collection_in_progress): Ditto. * tests/test.c (GC_amiga_free_all_mem): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist, GC_gcj_malloc_initialized, GC_gcj_kind): Ditto. * win32_threads.c (GC_write_fault_handler, GC_gww_dirty_init, GC_fault_handler_lock, GC_write_cs, GC_markers): Ditto. * misc.c (GC_read, GC_register_finalizer_no_order, GC_init_dyld): Move the declaration out of GC_init(); remove "extern". * os_dep.c (GC_abort): Add the comment; add workaround to suppress compiler "unreachable code" warnings for ABORT callers (where ABORT is followed by a dummy return statement). * os_dep.c (GC_old_allocator): Move the declaration out of GC_default_push_other_roots(); remove "extern". * darwin_stop_world.c (GC_mprotect_stop, GC_mprotect_resume): Move the declaration out of GC_stop_world() and GC_start_world() (only if MPROTECT_VDB); remove "extern".
* 2009-09-26 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.direct: Document EMPTY_GETENV_RESULTS. * gcj_mlc.c (GC_clear_stack): Remove declaration. * malloc.c (GC_clear_stack): Ditto. * mallocx.c (GC_clear_stack): Ditto. * typd_mlc.c (GC_clear_stack): Ditto. * gcj_mlc.c (GENERAL_MALLOC, GENERAL_MALLOC_IOP): Rename to GENERAL_MALLOC_INNER and GENERAL_MALLOC_INNER_IOP, respectively; remove "lb" unnecessary cast to word. * include/private/gc_priv.h (GC_clear_stack): Add declaration. * include/private/gc_priv.h (GENERAL_MALLOC, GENERAL_MALLOC_IOP): Move common declaration from typd_mlc.c and malloc.c; remove unnecessary result and "lb" parameter casts. * include/private/thread_local_alloc.h: Guard against duplicate header file inclusion. * os_dep.c (USE_MUNMAP): Replace "-->" with an error directive for the case when USE_MMAP is not defined. * pthread_support.c (GC_is_thread_tsd_valid): New internal function (only if GC_ASSERTIONS and THREAD_LOCAL_ALLOC); move the code from thread-local GC_malloc(); add FIXME for the condition. * win32_threads.c (GC_is_thread_tsd_valid): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist): Change the type (to match that of its definition). * thread_local_alloc.c (GC_destroy_thread_local): Add a cast for GC_gcjobjfreelist. * thread_local_alloc.c (GC_lookup_thread, GC_lookup_thread_inner): Remove unused declaration; don't include pthread.h. * thread_local_alloc.c (GC_is_thread_tsd_valid): New declaration (only if GC_ASSERTIONS). * thread_local_alloc.c (GC_malloc): Use GC_is_thread_tsd_valid() instead of GC_lookup_thread(). * win32_threads.c (GC_lookup_thread_inner): Define as STATIC. * win32_threads.c (UNPROTECT): Rename to UNPROTECT_THREAD (to have id different from that in os_dep.c).
* 2009-09-25 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | * checksums.c (GC_checksum, GC_update_check_page): Remove "register" keyword in local variable declarations (for the code used only for debugging or which is not time-critical). * dbg_mlc.c (GC_has_other_debug_info, GC_store_debug_info, GC_store_debug_info_inner, GC_check_annotated_obj, GC_print_obj, GC_print_smashed_obj, GC_debug_end_stubborn_change, GC_debug_invoke_finalizer): Ditto. * dyn_load.c (GC_register_dynamic_libraries): Ditto. * mallocx.c (GC_realloc): Ditto. * mark_rts.c (GC_print_static_roots, GC_is_static_root, GC_clear_roots): Ditto. * misc.c (GC_write): Ditto. * os_dep.c (GC_print_callers): Ditto. * dyn_load.c (GC_register_dynamic_libraries): Rename "i" local variable to "j" for the nested loop (just not to hide the similar variable in the outer one). * mark_rts.c (GC_print_static_roots): Output an error message using GC_err_printf() (instead of GC_printf()).
* 2009-09-20 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-8/+8
| | | | | | | | | * allchblk.c (GC_freehblk): Adjust local variables indentation. * mallocx.c (GC_generic_malloc_many): Ditto. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Ditto. * typd_mlc.c (GC_make_array_descriptor): Remove unnecessary brackets.
* 2009-09-16 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-279/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ChangeLog: Remove trailing spaces at EOLn; insert blank lines where missed. * doc/README: Expand all tabs to spaces; remove trailing spaces at EOLn; remove multiple trailing blank lines. * doc/README.autoconf: Ditto. * doc/README.DGUX386: Ditto. * doc/README.environment: Ditto. * doc/README.macros: Ditto. * doc/README.win32: Ditto. * tests/test.c: Ditto. * tests/test_cpp.cc: Ditto. * backgraph.c: Ditto. * blacklst.c: Ditto. * checksums.c: Ditto. * darwin_stop_world.c: Ditto. * dbg_mlc.c: Ditto. * dyn_load.c: Ditto. * finalize.c: Ditto. * gc_dlopen.c: Ditto. * gcj_mlc.c: Ditto. * headers.c: Ditto. * mach_dep.c: Ditto. * malloc.c: Ditto. * mallocx.c: Ditto. * new_hblk.c: Ditto. * obj_map.c: Ditto. * ptr_chck.c: Ditto. * real_malloc.c: Ditto. * reclaim.c: Ditto. * stubborn.c: Ditto. * thread_local_alloc.c: Ditto. * typd_mlc.c: Ditto. * gc_cpp.cc: Ditto. * include/gc_allocator.h: Ditto. * include/gc_backptr.h: Ditto. * include/gc_config_macros.h: Ditto. * include/gc_cpp.h: Ditto. * include/gc_gcj.h: Ditto. * include/gc_inline.h: Ditto. * include/gc_mark.h: Ditto. * include/gc_pthread_redirects.h: Ditto. * include/gc_typed.h: Ditto. * include/gc_version.h: Ditto. * include/javaxfc.h: Ditto. * include/new_gc_alloc.h: Ditto. * include/private/darwin_semaphore.h: Ditto. * include/private/dbg_mlc.h: Ditto. * include/private/gc_hdrs.h: Ditto. * include/private/gc_locks.h: Ditto. * include/private/gc_pmark.h: Ditto. * include/private/gcconfig.h: Ditto. * include/private/pthread_support.h: Ditto. * include/private/thread_local_alloc.h: Ditto. * darwin_stop_world.c: Add copyright header. * include/gc_backptr.h: Ditto. * include/gc_config_macros.h: Ditto. * include/gc_pthread_redirects.h: Ditto. * include/gc_version.h: Ditto. * include/javaxfc.h: Ditto. * include/private/darwin_semaphore.h: Ditto. * include/private/pthread_support.h: Ditto. * gc_cpp.cc: Make copyright header uniform across the package. * include/gc_cpp.h: Ditto.