From 30613f4eb38d6aeed4f9f5ade274909c3cf838e2 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 15 May 2018 10:35:59 +0300 Subject: Remove stubborn objects allocation code completely (code refactoring) * README.md (Incremental/Generational Collection): Remove information about stubborn objects; add information about GC_end_stubborn_change usage. * alloc.c [STUBBORN_ALLOC] (GC_finish_collection): Do not call GC_clean_changing_list. * checksums.c (NSUMS, GC_check_dirty): Remove comment related to stubborn objects. * checksums.c [STUBBORN_ALLOC] (GC_on_free_list): Remove. * doc/README.macros (STUBBORN_ALLOC): Likewise. * include/private/gc_priv.h [STUBBORN_ALLOC] (GC_sobjfreelist, GC_arrays._sobjfreelist, GC_changed_pages, GC_arrays._changed_pages, GC_prev_changed_pages, GC_arrays._prev_changed_pages): Likewise. * include/private/gc_priv.h (GC_read_changed, GC_page_was_changed, GC_clean_changing_list, GC_stubborn_init): Likewise. * tests/test.c (stubborn_count): Likewise. * checksums.c (GC_n_changed_errors): Likewise. * checksums.c [STUBBORN_ALLOC] (GC_update_check_page, GC_check_dirty): Do not update GC_n_changed_errors value. * checksums.c (GC_check_dirty): Do not check/print GC_n_changed_errors value. * configure.ac (checksums): Update help message (remove information about stubborn objects). * dbg_mlc.c (GC_print_obj, GC_debug_end_stubborn_change, GC_debug_realloc, GC_debug_generic_or_special_malloc): Do not handle STUBBORN object kind specially. * mallocx.c (GC_generic_or_special_malloc, GC_realloc): Likewise. * mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_next_marked_dirty): Likewise. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Redirect to GC_debug_malloc; remove GC_ATTR_MALLOC. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_change_stubborn): Change to no-op. * doc/README.amiga (WHATS NEW): Do not reference GC_malloc_stubborn. * doc/README.macros (CHECKSUMS): Update (remove information about stubborn objects). * doc/gcdescr.md (Allocation, Generational Collection and Dirty Bits): Likewise. * doc/gcinterface.md (C/C++ Interface): Likewise. * doc/leak.md (Using the Garbage Collector as Leak Detector): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Add information about MANUAL_VDB. * include/gc.h (GC_malloc, GC_free, GC_realloc): Update comment (remove information about stubborn objects). * malloc.c (GC_generic_malloc_inner): Likewise. * tests/test.c (reverse_test_inner): Likewise. * include/gc.h (GC_malloc_stubborn, GC_debug_malloc_stubborn): Add GC_ATTR_DEPRECATED; remove GC_ATTR_MALLOC and GC_ATTR_ALLOC_SIZE. * include/gc.h (GC_MALLOC_STUBBORN, GC_NEW_STUBBORN): Redirect to normal GC_MALLOC/NEW; add comment that stubborn objects allocation is deprecated. * include/gc.h [GC_DEBUG] (GC_CHANGE_STUBBORN): Redirect to GC_change_stubborn (not GC_debug_change_stubborn). * include/gc.h (GC_change_stubborn): Add GC_ATTR_DEPRECATED. * include/gc.h [!CPPCHECK] (GC_debug_change_stubborn): Likewise. * include/gc.h (GC_change_stubborn, GC_debug_change_stubborn): Remove GC_ATTR_NONNULL. * include/gc.h (GC_end_stubborn_change): Add comment related to usage when the library is built with MANUAL_VDB defined. * include/gc.h [_AMIGA && !GC_AMIGA_MAKINGLIB] (GC_malloc_stubborn): Remove macro. * include/private/gc_priv.h (STUBBORN_ALLOC): Remove comment. * include/private/gc_priv.h (STUBBORN): Replace with GC_N_KINDS_INITIAL_VALUE definition. * mark.c (GC_obj_kinds): Remove initialization for STUBBORN_ALLOC element. * mark.c (GC_N_KINDS_INITIAL_VALUE): Move to gc_priv.h. * mark.c (GC_n_rescuing_pages): Define only if GC_DISABLE_INCREMENTAL. * mark.c [STUBBORN_ALLOC] (GC_initiate_gc): Do not call GC_read_changed. * misc.c [STUBBORN_ALLOC] (GC_init): Do not call GC_stubborn_init. * stubborn.c (GC_malloc_stubborn): Remove GC_ATTR_MALLOC. * tests/test.c [!VERY_SMALL_CONFIG] (cons): Replace GC_MALLOC_STUBBORN with GC_MALLOC call; update collectable_count instead of stubborn_count. * tests/test.c (check_heap_stats): Do not print stubborn_count value. --- dbg_mlc.c | 54 ++++-------------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) (limited to 'dbg_mlc.c') diff --git a/dbg_mlc.c b/dbg_mlc.c index 80b1bc9e..04716623 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -406,9 +406,6 @@ STATIC void GC_print_obj(ptr_t p) kind_str = "ATOMIC_UNCOLLECTABLE"; break; # endif - case STUBBORN: - kind_str = "STUBBORN"; - break; default: kind_str = NULL; /* The alternative is to use snprintf(buffer) but it is */ @@ -615,42 +612,13 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS) } #endif /* DBG_HDRS_ALL */ -#ifdef STUBBORN_ALLOC - GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_stubborn(size_t lb, - GC_EXTRA_PARAMS) - { - void * result = GC_malloc_stubborn(SIZET_SAT_ADD(lb, DEBUG_BYTES)); - - return store_debug_info(result, lb, "GC_debug_malloc_stubborn", - OPT_RA s, i); - } - - GC_API void GC_CALL GC_debug_change_stubborn(const void *p) - { - const void * q = GC_base_C(p); - hdr * hhdr; - - if (q == 0) { - ABORT_ARG1("GC_debug_change_stubborn: bad arg", ": %p", p); - } - hhdr = HDR(q); - if (hhdr -> hb_obj_kind != STUBBORN) { - ABORT_ARG1("GC_debug_change_stubborn: arg not stubborn", ": %p", p); - } - GC_change_stubborn(q); - } - -#else /* !STUBBORN_ALLOC */ - - GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_stubborn(size_t lb, - GC_EXTRA_PARAMS) - { +GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS) +{ return GC_debug_malloc(lb, OPT_RA s, i); - } +} - GC_API void GC_CALL GC_debug_change_stubborn( +GC_API void GC_CALL GC_debug_change_stubborn( const void * p GC_ATTR_UNUSED) {} -#endif /* !STUBBORN_ALLOC */ GC_API void GC_CALL GC_debug_end_stubborn_change(const void *p) { @@ -659,11 +627,6 @@ GC_API void GC_CALL GC_debug_end_stubborn_change(const void *p) if (NULL == q) { ABORT_ARG1("GC_debug_end_stubborn_change: bad arg", ": %p", p); } -# ifdef STUBBORN_ALLOC - if (HDR(q) -> hb_obj_kind != STUBBORN) - ABORT_ARG1("GC_debug_end_stubborn_change: arg not stubborn", - ": %p", p); -# endif GC_end_stubborn_change(q); } @@ -885,11 +848,6 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS) } hhdr = HDR(base); switch (hhdr -> hb_obj_kind) { -# ifdef STUBBORN_ALLOC - case STUBBORN: - result = GC_debug_malloc_stubborn(lb, OPT_RA s, i); - break; -# endif case NORMAL: result = GC_debug_malloc(lb, OPT_RA s, i); break; @@ -927,10 +885,6 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_generic_or_special_malloc(size_t lb, int knd, GC_EXTRA_PARAMS) { switch (knd) { -# ifdef STUBBORN_ALLOC - case STUBBORN: - return GC_debug_malloc_stubborn(lb, OPT_RA s, i); -# endif case PTRFREE: return GC_debug_malloc_atomic(lb, OPT_RA s, i); case NORMAL: -- cgit v1.2.1