From: Ivan Maidanski Date: Wed, 12 Dec 2012 16:49:07 +0000 (+0400) Subject: Replace GC_stats_log_printf with GC_DBG/INFOLOG_PRINTF X-Git-Tag: gc7_4_0~117 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cccc0f3eb47c1173be6400ee9aa197248635955f;p=platform%2Fupstream%2Flibgc.git Replace GC_stats_log_printf with GC_DBG/INFOLOG_PRINTF (minimize logging for Android when print_stats is off) * alloc.c (GC_try_to_collect_inner, GC_stopped_mark, GC_finish_collection): Use GC_log_printf instead of GC_stats_log_printf. * finalize.c (GC_print_finalization_stats): Likewise. * include/private/gc_priv.h (GC_COND_LOG_PRINTF): Likewise. * alloc.c (GC_stopped_mark): Use GC_DBGLOG_PRINTF instead of GC_COND_LOG_PRINTF (useful for Android). * alloc.c (GC_expand_hp_inner): Reformat comment. * alloc.c (GC_expand_hp_inner): Use GC_INFOLOG_PRINTF instead of GC_COND_LOG_PRINTF (useful for Android). * include/private/gc_priv.h (GC_stats_log_printf): Remove (macro and prototype). * include/private/gc_priv.h (GC_DBGLOG_PRINTF, GC_INFOLOG_PRINTF): New macro (redirecting either to GC_COND_LOG_PRINTF or to GC_log_printf/GC_info_log_printf if GC_ANDROID_LOG). * include/private/gc_priv.h (GC_info_log_printf): New prototype (only if GC_ANDROID_LOG). * misc.c (GC_stats_log_printf): Rename to GC_info_log_printf. --- diff --git a/alloc.c b/alloc.c index 37ad645..4616ba5 100644 --- a/alloc.c +++ b/alloc.c @@ -429,7 +429,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func) # ifndef SMALL_CONFIG if (GC_print_stats) { GET_TIME(start_time); - GC_stats_log_printf("Initiating full world-stop collection!\n"); + GC_log_printf("Initiating full world-stop collection!\n"); } # endif GC_promote_black_lists(); @@ -468,8 +468,8 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func) # ifndef SMALL_CONFIG if (GC_print_stats) { GET_TIME(current_time); - GC_stats_log_printf("Complete collection took %lu msecs\n", - MS_TIME_DIFF(current_time,start_time)); + GC_log_printf("Complete collection took %lu msecs\n", + MS_TIME_DIFF(current_time,start_time)); } # endif return(TRUE); @@ -638,11 +638,11 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) } GC_gc_no++; - GC_COND_LOG_PRINTF("GC #%lu reclaimed %ld bytes --> heapsize: %lu" - " bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n", - (unsigned long)GC_gc_no, (long)GC_bytes_found, - (unsigned long)GC_heapsize /*, */ - COMMA_IF_USE_MUNMAP((unsigned long)GC_unmapped_bytes)); + GC_DBGLOG_PRINTF("GC #%lu reclaimed %ld bytes --> heapsize: %lu" + " bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n", + (unsigned long)GC_gc_no, (long)GC_bytes_found, + (unsigned long)GC_heapsize /*, */ + COMMA_IF_USE_MUNMAP((unsigned long)GC_unmapped_bytes)); /* Check all debugged objects for consistency */ if (GC_debugging_started) { @@ -675,7 +675,7 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) world_stopped_total_divisor = ++divisor; GC_ASSERT(divisor != 0); - GC_stats_log_printf( + GC_log_printf( "World-stopped marking took %lu msecs (%u in average)\n", time_diff, total_time / divisor); } @@ -940,16 +940,13 @@ STATIC void GC_finish_collection(void) # ifndef SMALL_CONFIG if (GC_print_stats) { GET_TIME(done_time); - - /* A convenient place to output finalization statistics. */ # ifndef GC_NO_FINALIZATION + /* A convenient place to output finalization statistics. */ GC_print_finalization_stats(); # endif - - GC_stats_log_printf( - "Finalize plus initiate sweep took %lu + %lu msecs\n", - MS_TIME_DIFF(finalize_time,start_time), - MS_TIME_DIFF(done_time,finalize_time)); + GC_log_printf("Finalize plus initiate sweep took %lu + %lu msecs\n", + MS_TIME_DIFF(finalize_time,start_time), + MS_TIME_DIFF(done_time,finalize_time)); } # endif } @@ -1132,13 +1129,10 @@ GC_API void GC_CALL GC_set_max_heap_size(GC_word n) GC_word GC_max_retries = 0; -/* - * this explicitly increases the size of the heap. It is used - * internally, but may also be invoked from GC_expand_hp by the user. - * The argument is in units of HBLKSIZE. - * Tiny values of n are rounded up. - * Returns FALSE on failure. - */ +/* This explicitly increases the size of the heap. It is used */ +/* internally, but may also be invoked from GC_expand_hp by the user. */ +/* The argument is in units of HBLKSIZE (tiny values are rounded up). */ +/* Returns FALSE on failure. */ GC_INNER GC_bool GC_expand_hp_inner(word n) { word bytes; @@ -1165,7 +1159,7 @@ GC_INNER GC_bool GC_expand_hp_inner(word n) WARN("Failed to expand heap by %" WARN_PRIdPTR " bytes\n", bytes); return(FALSE); } - GC_COND_LOG_PRINTF( + GC_INFOLOG_PRINTF( "Increasing heap size by %lu after %lu allocated bytes\n", (unsigned long)bytes, (unsigned long)GC_bytes_allocd); /* Adjust heap limits generously for blacklisting to work better. */ diff --git a/finalize.c b/finalize.c index f50cb26..6369669 100644 --- a/finalize.c +++ b/finalize.c @@ -1093,20 +1093,20 @@ GC_INNER void GC_notify_or_invoke_finalizers(void) struct finalizable_object *fo; unsigned long ready = 0; - GC_stats_log_printf("%lu finalization entries;" - " %lu/%lu short/long disappearing links alive\n", - (unsigned long)GC_fo_entries, - (unsigned long)GC_dl_hashtbl.entries, - (unsigned long)IF_LONG_REFS_PRESENT_ELSE( + GC_log_printf("%lu finalization entries;" + " %lu/%lu short/long disappearing links alive\n", + (unsigned long)GC_fo_entries, + (unsigned long)GC_dl_hashtbl.entries, + (unsigned long)IF_LONG_REFS_PRESENT_ELSE( GC_ll_hashtbl.entries, 0)); for (fo = GC_finalize_now; 0 != fo; fo = fo_next(fo)) ++ready; - GC_stats_log_printf("%lu finalization-ready objects;" - " %ld/%ld short/long links cleared\n", - ready, - (long)GC_old_dl_entries - (long)GC_dl_hashtbl.entries, - (long)IF_LONG_REFS_PRESENT_ELSE( + GC_log_printf("%lu finalization-ready objects;" + " %ld/%ld short/long links cleared\n", + ready, + (long)GC_old_dl_entries - (long)GC_dl_hashtbl.entries, + (long)IF_LONG_REFS_PRESENT_ELSE( GC_old_ll_entries - GC_ll_hashtbl.entries, 0)); } #endif /* !SMALL_CONFIG */ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 9201a16..cb5d678 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2065,19 +2065,27 @@ GC_API_PRIV void GC_log_printf(const char * format, ...) #endif #ifndef GC_ANDROID_LOG - /* GC_stats_log_printf should be called only if GC_print_stats. */ -# define GC_stats_log_printf GC_log_printf +# define GC_DBGLOG_PRINTF GC_COND_LOG_PRINTF +# define GC_INFOLOG_PRINTF GC_COND_LOG_PRINTF /* GC_verbose_log_printf is called only if GC_print_stats is VERBOSE. */ # define GC_verbose_log_printf GC_log_printf #else - GC_INNER void GC_stats_log_printf(const char *format, ...) + extern GC_bool GC_quiet; + /* These loggers are enabled even if GC_print_stats is off. */ +# ifndef GC_DBGLOG_PRINTF +# define GC_DBGLOG_PRINTF if (GC_quiet) {} else GC_log_printf +# endif +# ifndef GC_INFOLOG_PRINTF +# define GC_INFOLOG_PRINTF if (GC_quiet) {} else GC_info_log_printf +# endif + GC_INNER void GC_info_log_printf(const char *format, ...) GC_ATTR_FORMAT_PRINTF(1, 2); GC_INNER void GC_verbose_log_printf(const char *format, ...) GC_ATTR_FORMAT_PRINTF(1, 2); #endif /* GC_ANDROID_LOG */ -/* Convenient macros for GC_stats/verbose_log_printf invocation. */ -#define GC_COND_LOG_PRINTF if (!GC_print_stats) {} else GC_stats_log_printf +/* Convenient macros for GC_[verbose_]log_printf invocation. */ +#define GC_COND_LOG_PRINTF if (!GC_print_stats) {} else GC_log_printf #define GC_VERBOSE_LOG_PRINTF \ if (GC_print_stats != VERBOSE) {} else GC_verbose_log_printf diff --git a/misc.c b/misc.c index 11e7080..398fc51 100644 --- a/misc.c +++ b/misc.c @@ -1547,7 +1547,7 @@ void GC_log_printf(const char *format, ...) #else - GC_INNER void GC_stats_log_printf(const char *format, ...) + GC_INNER void GC_info_log_printf(const char *format, ...) { char buf[BUFSZ + 1];