Ivan Maidanski [Wed, 1 Mar 2017 23:23:32 +0000 (02:23 +0300)]
Add Makefile target to run all tests without test-driver
This could be used to catch errors reported by MemorySanitizer
(the traditional "make check" shows the tests with MSan errors as
skipped, so it does not lead to a non-zero exit code of make itself).
* cord/cord.am (check-without-test-driver): New phony target (to
compile, link and execute the tests not using test-driver).
* tests/tests.am (check-without-test-driver): Likewise.
Ivan Maidanski [Wed, 1 Mar 2017 22:10:29 +0000 (01:10 +0300)]
Update shared libraries version info to differentiate against v7.6
There are no API/implementation changes in libcord and libgccpp against
release-7_6 for now, so the corresponding version info is made the same.
There some implementation changes in libgc (without API changes) against
release-7_6, so the version info is made not the same (although there
are no API changes, 4:x:2 is already in use/reserved for release-7_6).
* Makefile.am (LIBGC_VER_INFO): Change version info to 5:0:3
(release-7_6 is supposed to use 4:x:2).
* Makefile.am (LIBGCCPP_VER_INFO): Change version info to 4:0:3
(the same one as release-7_6 uses at present).
* cord/cord.am (LIBCORD_VER_INFO): Likewise.
Ivan Maidanski [Wed, 1 Mar 2017 08:10:00 +0000 (11:10 +0300)]
Move libraries version info to the beginning of Makefile.am
(code refactoring)
* Makefile.am (LIBGC_VER_INFO, LIBGCCPP_VER_INFO): New variable; add
comment about the version update rule.
* cord/cord.am (LIBCORD_VER_INFO): Likewise.
* Makefile.am (libgc_la_LDFLAGS, libgccpp_la_LDFLAGS): Use
LIBGC[CPP]_VER_INFO instead the direct hard-coding of version info.
* cord/cord.am (libcord_la_LDFLAGS): Likewise.
Ivan Maidanski [Tue, 28 Feb 2017 22:25:34 +0000 (01:25 +0300)]
Eliminate 'checking unsigned variable < 0' cppcheck warning in gc_inline
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Replace
(word)my_entry<=num_direct with (signed_word)my_entry-num_direct<=0
to avoid "checking unsigned var < 0" warning if num_direct==0
(no overflow is expected in (signed_word)my_entry-num_direct as it is
guaranteed that (word)my_entry<=num_direct+GC_TINY_FREELISTS+1).
* doc/README.macros (GC_BUILTIN_ATOMIC): Document.
* doc/porting.html (atomic_ops): Replace GC7+ with GC v7; remove note
that libatomic_ops contains more primitives than needed by GC; remove
note about GC_test_and_set of older GC versions (pre-v7); add note
about gc_atomic_ops.h file (optional replacement of libatomic_ops).
Ivan Maidanski [Tue, 28 Feb 2017 20:41:03 +0000 (23:41 +0300)]
Define GC_PREFETCH_FOR_WRITE to __builtin_prefetch in gc_inline.h (GCC)
Also add GC_ prefix to NO_PREFETCH_FOR_WRITE.
* include/gc_inline.h [!GC_PREFETCH_FOR_WRITE] (GC_PREFETCH_FOR_WRITE):
Copy the definition from gcconfig.h.
* include/private/gcconfig.h (NO_PREFETCH_FOR_WRITE): Rename to
GC_NO_PREFETCH_FOR_WRITE.
Ivan Maidanski [Tue, 28 Feb 2017 20:02:55 +0000 (23:02 +0300)]
Eliminate 'label not used' cppcheck false warnings in GC_mark_X
(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.
Ivan Maidanski [Tue, 31 Jan 2017 23:30:18 +0000 (02:30 +0300)]
Fix enable_parallel_mark condition in CMake script
* CMakeLists.txt [enable_parallel_mark] (ADD_DEFINITIONS): Add
-DPARALLEL_MARK; remove ADD_DEFINITIONS("-DPARALLEL_MARK") in other
places; remove ${} for enable_parallel_mark in IF.
Ivan Maidanski [Thu, 26 Jan 2017 08:01:08 +0000 (11:01 +0300)]
Fix AO_compiler_barrier definition in gc_atomic_ops private header
(fix commit 46a2411)
See AO_compiler_barrier definition in gcc/generic.h of libatomic_ops.
* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC]
(AO_compiler_barrier): Use __atomic_signal_fence(__ATOMIC_SEQ_CST)
instead of atomic_thread_fence.
Because it breaks gctest "list reversal" if compiled with
GC_GCJ_SUPPORT for MinGW/x86. This is caused by the fact that static
data roots could be between two GC heap regions thus GC with the patch
skips scanning of a reachable GCJ object with a descriptor located in
the static data roots.
To fix the issue (#92) of mistaking the free list pointers in free
objects for being type descriptor pointers, another approach should be
taken (e.g. marking objects in free lists).
Ivan Maidanski [Thu, 19 Jan 2017 07:45:22 +0000 (10:45 +0300)]
Add assertion to allocobj that live unmarked object cannot be reclaimed
* alloc.c (GC_allocobj): Add assertion before GC_continue_reclaim call
that either GC_is_full_gc is FALSE or the corresponding ok_reclaim_list
element is NULL (i.e. GC_continue_reclaim call is a no-op).
Paul Bone [Sat, 14 Jan 2017 07:02:54 +0000 (10:02 +0300)]
New API function (GC_dump_named) to produce named dumps
gc_dump() now prints a label (name) for the dump, by default the name
is created using the current garbage collection number (GC_get_gc_no).
An arbitrary name could be provided using GC_dump_named() instead.
The naming makes it easier to work with multiple dumps in a single log.
* include/gc.h (GC_dump_named): New public API function declaration.
* include/gc.h (GC_dump): Update comment (the current collection number
is printed at the beginning of the dump).
* misc.c [!NO_DEBUGGING] (GC_dump): Just call GC_dump_named(NULL).
* misc.c [!NO_DEBUGGING] (GC_dump_named): Move code from GC_dump;
start dump with the "GC Dump" followed by either the name specified or
the current collection number (if name is null).
Ivan Maidanski [Wed, 11 Jan 2017 08:26:11 +0000 (11:26 +0300)]
Fix gc_backptr.h, gc_mark.h, GC_DS_TAGS names in documentation
* doc/debugging.html: Rename backptr.h to gc_backptr.h.
* include/gc_mark.h (GC_DS_PER_OBJECT): Rename DS_TAGS to GC_DS_TAGS in
the comment.
* include/private/gc_priv.h (hblkhdr.hb_descr): Rename mark.h to
gc_mark.h in the comment.
* tools/if_mach.c (main): Cast the 2nd argument of execvp to void* (to
avoid compiler warning as the argument of execvp() prototype could be
of "const char* const*" or "char**" type).
* tools/if_not_there.c (main): Likewise.
Ivan Maidanski [Thu, 22 Dec 2016 22:00:28 +0000 (01:00 +0300)]
Eliminate 'array vs singleton' code defect in typed_test (gctest)
Taking address of bmX yields a singleton pointer but GC_make_descriptor
expects an array (of words).
* tests/test.c (typed_test): Define bm3, bm2, bm_large as 1-element
arrays (instead of values of a primitive type), and remove
"&" operator when passing them to GC_make_descriptor.
Ivan Maidanski [Thu, 22 Dec 2016 21:39:10 +0000 (00:39 +0300)]
Fix bm_huge initialization for 64-bit targets (gctest)
* tests/test.c (bm_huge): Make array size depend on word size
(5 elements for 64-bit targets); initialize elements (except the last
one) to -1 instead of 0xffffffff (so that all bits are ones even on
a 64-bit target); initialize last element to ((word)-1)>>8 instead of
0x00ffffff value.
* tests/test.c (typed_test): Fail if bm_huge descriptor contains wrong
bit values at certain positions (as it had before this fix).
Ivan Maidanski [Tue, 20 Dec 2016 07:41:40 +0000 (10:41 +0300)]
Workaround 'resource leak' false positives in alloc_MS, bl/envfile_init
* blacklst.c (GC_bl_init): Add assertion that GC_old_stack_bl and
GC_incomplete_stack_bl are both null prior to their assignment (to the
result of GC_scratch_alloc).
* mark.c (alloc_mark_stack): Replace GC_mark_stack_size!=0 with
GC_mark_stack!=NULL (to ensure no memory leak when GC_mark_stack is
assigned for the first time).
* misc.c [GC_READ_ENV_FILE && (MSWIN32 || MSWINCE || CYGWIN32)]
(GC_envfile_init): Add assertion that GC_envfile_content is null prior
to its assignment.
Ivan Maidanski [Tue, 20 Dec 2016 07:21:07 +0000 (10:21 +0300)]
Fix (adjust) GC_scratch_alloc actual argument type
* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Do not cast GC_scratch_alloc argument
to word type (it should be of size_t).
* headers.c (alloc_hdr, GC_init_headers, get_index): Likewise.
* os_dep.c [PROC_VDB] (GC_proc_buf_size): Change type from word to size_t.
* os_dep.c [PROC_VDB] (GC_read_dirty): Change type of new_size local
variable (which is passed to GC_scratch_alloc) from word to size_t.
Ivan Maidanski [Mon, 19 Dec 2016 21:54:32 +0000 (00:54 +0300)]
Fix storage class of local variable in register_dynamic_libraries (Irix)
* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Remove "static" for needed_sz local
variable (and initialize it to zero).
Ivan Maidanski [Sat, 17 Dec 2016 15:43:00 +0000 (18:43 +0300)]
Workaround 'value of AO_compiler_barrier unknown' cppcheck info message
(fix commit e3ec4a5)
* mark.c (GC_noop6): Call AO_compiler_barrier() only if PARALLEL_MARK
or GC_PTHREADS and not GC_WIN32_THREADS (do not use
"#ifdef AO_compiler_barrier").
Ivan Maidanski [Sat, 17 Dec 2016 15:15:02 +0000 (18:15 +0300)]
Disable implicit multi-threaded mode for Win32 to avoid LOCK crash
(fix commit d5c6531)
* include/private/gc_locks.h [GC_ALWAYS_MULTITHREADED] (GC_need_to_lock):
Do not define to TRUE unless USE_PTHREAD_LOCKS or USE_SPIN_LOCK; issue
#error otherwise (excluding CPPCHECK case) as PCR and Windows-based
lock implementation requires it to be initialized first.
* include/private/gc_locks.h [UNCOND_LOCK && !LOCK && LINT2] (LOCK,
UNLOCK): Define (to UNCOND_[UN]LOCK) only if USE_PTHREAD_LOCKS.
The tool complains whether (alloc(size)+ofs) is intentional instead of
(alloc(size+ofs)). In our case, it is a false alarm (the offset is
added to the result to align the allocation at HBLKSIZE boundary).
* os_dep.c [USE_WINALLOC && MSWIN32] (GC_win32_get_mem): Store result
of GlobalAlloc() to "result" local variable first (then, perform result
alignment in a standalone statement); add comment.