summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-10-25 11:45:38 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-10-25 11:45:38 +0300
commitff55290a3bcab7f9763d74214c03a7b65646f990 (patch)
tree79f681b0e484d1ec872fbe43a843c26044daac79
parent9d231fb884f33df6c285bd6c43671c13d2b26826 (diff)
downloadbdwgc-ff55290a3bcab7f9763d74214c03a7b65646f990.tar.gz
Do not use system clock consistently if NO_CLOCK
Issue #139 (bdwgc). * alloc.c (GC_try_to_collect_inner, world_stopped_total_time, world_stopped_total_divisor, MAX_TOTAL_TIME_DIVISOR, GC_stopped_mark): Replace "ifndef SMALL_CONFIG" with "ifndef NO_CLOCK". * reclaim.c (GC_reclaim_all): Likewise. * alloc.c (GC_finish_collection): Replace "ifndef SMALL_CONFIG" with "ifndef NO_CLOCK" except for GC_print_finalization_stats invocation. * doc/README.macros (NO_CLOCK): Document. * include/private/gc_priv.h (CLOCK_TYPE, GET_TIME, MS_TIME_DIFF): Do not define if NO_CLOCK. * include/private/gc_priv.h (GC_print_stats): Define as a macro (to 0) only if both NO_CLOCK and SMALL_CONFIG are defined. * misc.c (GC_print_stats): Do not define if both NO_CLOCK and SMALL_CONFIG are defined. * misc.c (GC_init): Do not set GC_print_stats only if both NO_CLOCK and SMALL_CONFIG are defined. * tests/test.c (run_one_test): Do not define start_time, reverse_time, time_diff local variables (and do not use GET_TIME, MS_TIME_DIFF) if NO_CLOCK is defined.
-rw-r--r--alloc.c29
-rw-r--r--doc/README.macros2
-rw-r--r--include/private/gc_priv.h4
-rw-r--r--misc.c12
-rw-r--r--reclaim.c4
-rw-r--r--tests/test.c54
6 files changed, 63 insertions, 42 deletions
diff --git a/alloc.c b/alloc.c
index 619d0f25..551092f7 100644
--- a/alloc.c
+++ b/alloc.c
@@ -440,7 +440,7 @@ GC_API GC_on_collection_event_proc GC_CALL GC_get_on_collection_event(void)
/* Return TRUE if we successfully completed the collection. */
GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
{
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
CLOCK_TYPE start_time = 0; /* initialized to prevent warning. */
# endif
@@ -462,7 +462,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
}
}
GC_notify_full_gc();
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_print_stats) {
GET_TIME(start_time);
GC_log_printf("Initiating full world-stop collection!\n");
@@ -503,7 +503,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
return(FALSE);
}
GC_finish_collection();
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_print_stats) {
CLOCK_TYPE current_time;
@@ -599,7 +599,7 @@ GC_API int GC_CALL GC_collect_a_little(void)
return(result);
}
-#ifndef SMALL_CONFIG
+#ifndef NO_CLOCK
/* Variables for world-stop average delay time statistic computation. */
/* "divisor" is incremented every world-stop and halved when reached */
/* its maximum (or upon "total_time" overflow). */
@@ -611,7 +611,7 @@ GC_API int GC_CALL GC_collect_a_little(void)
/* newer ones). */
# define MAX_TOTAL_TIME_DIVISOR 1000
# endif
-#endif
+#endif /* !NO_CLOCK */
#ifdef USE_MUNMAP
# define IF_USE_MUNMAP(x) x
@@ -629,7 +629,7 @@ GC_API int GC_CALL GC_collect_a_little(void)
STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
{
unsigned i;
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
CLOCK_TYPE start_time = 0; /* initialized to prevent warning. */
# endif
@@ -640,7 +640,7 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
GC_cond_register_dynamic_libraries();
# endif
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_PRINT_STATS_FLAG)
GET_TIME(start_time);
# endif
@@ -737,7 +737,7 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
GC_on_collection_event(GC_EVENT_POST_START_WORLD);
# endif
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_PRINT_STATS_FLAG) {
unsigned long time_diff;
unsigned total_time, divisor;
@@ -903,7 +903,7 @@ GC_INLINE int GC_compute_heap_usage_percent(void)
/* held, but the world is otherwise running. */
STATIC void GC_finish_collection(void)
{
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
CLOCK_TYPE start_time = 0; /* initialized to prevent warning. */
CLOCK_TYPE finalize_time = 0;
# endif
@@ -915,7 +915,7 @@ STATIC void GC_finish_collection(void)
GC_check_tls();
# endif
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_print_stats)
GET_TIME(start_time);
# endif
@@ -957,7 +957,7 @@ STATIC void GC_finish_collection(void)
GC_clean_changing_list();
# endif
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_print_stats)
GET_TIME(finalize_time);
# endif
@@ -1028,12 +1028,12 @@ STATIC void GC_finish_collection(void)
if (GC_on_collection_event)
GC_on_collection_event(GC_EVENT_RECLAIM_END);
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_print_stats) {
CLOCK_TYPE done_time;
GET_TIME(done_time);
-# ifndef GC_NO_FINALIZATION
+# if !defined(SMALL_CONFIG) && !defined(GC_NO_FINALIZATION)
/* A convenient place to output finalization statistics. */
GC_print_finalization_stats();
# endif
@@ -1041,6 +1041,9 @@ STATIC void GC_finish_collection(void)
MS_TIME_DIFF(finalize_time,start_time),
MS_TIME_DIFF(done_time,finalize_time));
}
+# elif !defined(SMALL_CONFIG) && !defined(GC_NO_FINALIZATION)
+ if (GC_print_stats)
+ GC_print_finalization_stats();
# endif
}
diff --git a/doc/README.macros b/doc/README.macros
index 191537fe..3e9f1798 100644
--- a/doc/README.macros
+++ b/doc/README.macros
@@ -179,6 +179,8 @@ SMALL_CONFIG Tries to tune the collector for small heap sizes,
statistic-printing code. Turns off some optimization algorithms (like data
prefetching in the mark routine).
+NO_CLOCK Do not use system clock. Disables some statistic printing.
+
GC_DISABLE_INCREMENTAL Turn off the incremental collection support.
NO_INCREMENTAL Causes the gctest program to not invoke the incremental
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index fba5166d..7fc977d7 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -404,6 +404,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
/* */
/*********************************/
+#ifndef NO_CLOCK
#ifdef BSD_TIME
# undef CLOCK_TYPE
# undef GET_TIME
@@ -453,6 +454,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
/* Avoid using double type since some targets (like ARM) might */
/* require -lm option for double-to-long conversion. */
#endif /* !BSD_TIME && !MSWIN32 */
+#endif /* !NO_CLOCK */
/* We use bzero and bcopy internally. They may not be available. */
# if defined(SPARC) && defined(SUNOS4)
@@ -2024,7 +2026,7 @@ GC_EXTERN GC_bool GC_have_errors; /* We saw a smashed or leaked object. */
/* without acquiring the lock. */
#define VERBOSE 2
-#ifndef SMALL_CONFIG
+#if !defined(NO_CLOCK) || !defined(SMALL_CONFIG)
/* GC_print_stats should be visible to extra/MacOS.c. */
extern int GC_print_stats; /* Nonzero generates basic GC log. */
/* VERBOSE generates add'l messages. */
diff --git a/misc.c b/misc.c
index d85286f7..290a3dd6 100644
--- a/misc.c
+++ b/misc.c
@@ -91,7 +91,7 @@ int GC_dont_precollect = FALSE;
GC_bool GC_quiet = 0; /* used also in pcr_interface.c */
-#ifndef SMALL_CONFIG
+#if !defined(NO_CLOCK) || !defined(SMALL_CONFIG)
int GC_print_stats = 0;
#endif
@@ -916,7 +916,7 @@ GC_API void GC_CALL GC_init(void)
# ifdef GC_READ_ENV_FILE
GC_envfile_init();
# endif
-# ifndef SMALL_CONFIG
+# if !defined(NO_CLOCK) || !defined(SMALL_CONFIG)
# ifdef GC_PRINT_VERBOSE_STATS
/* This is useful for debugging and profiling on platforms with */
/* missing getenv() (like WinCE). */
@@ -928,8 +928,9 @@ GC_API void GC_CALL GC_init(void)
GC_print_stats = 1;
}
# endif
-# if (defined(UNIX_LIKE) && !defined(GC_ANDROID_LOG)) \
- || defined(CYGWIN32) || defined(SYMBIAN)
+# endif
+# if ((defined(UNIX_LIKE) && !defined(GC_ANDROID_LOG)) \
+ || defined(CYGWIN32) || defined(SYMBIAN)) && !defined(SMALL_CONFIG)
{
char * file_name = TRUSTED_STRING(GETENV("GC_LOG_FILE"));
# ifdef GC_LOG_TO_FILE_ALWAYS
@@ -963,8 +964,7 @@ GC_API void GC_CALL GC_init(void)
}
}
}
-# endif
-# endif /* !SMALL_CONFIG */
+# endif
# if !defined(NO_DEBUGGING) && !defined(GC_DUMP_REGULARLY)
if (0 != GETENV("GC_DUMP_REGULARLY")) {
GC_dump_regularly = TRUE;
diff --git a/reclaim.c b/reclaim.c
index 5bd69979..ec20a17a 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -711,7 +711,7 @@ GC_INNER GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old)
struct obj_kind * ok;
struct hblk ** rlp;
struct hblk ** rlh;
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
CLOCK_TYPE start_time = 0; /* initialized to prevent warning. */
if (GC_print_stats == VERBOSE)
@@ -739,7 +739,7 @@ GC_INNER GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old)
}
}
}
-# ifndef SMALL_CONFIG
+# ifndef NO_CLOCK
if (GC_print_stats == VERBOSE) {
CLOCK_TYPE done_time;
diff --git a/tests/test.c b/tests/test.c
index 451bce3d..a4b1bd12 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -1252,9 +1252,11 @@ void run_one_test(void)
char **z;
char *y = (char *)(GC_word)fail_proc1;
# endif
- CLOCK_TYPE start_time;
- CLOCK_TYPE reverse_time;
- unsigned long time_diff;
+# ifndef NO_CLOCK
+ CLOCK_TYPE start_time;
+ CLOCK_TYPE reverse_time;
+ unsigned long time_diff;
+# endif
# ifndef NO_TEST_HANDLE_FORK
pid_t pid;
int wstatus;
@@ -1467,36 +1469,45 @@ void run_one_test(void)
}
# endif
/* Repeated list reversal test. */
+# ifndef NO_CLOCK
GET_TIME(start_time);
+# endif
reverse_test();
+# ifndef NO_CLOCK
if (print_stats) {
GET_TIME(reverse_time);
time_diff = MS_TIME_DIFF(reverse_time, start_time);
GC_log_printf("-------------Finished reverse_test at time %u (%p)\n",
(unsigned) time_diff, (void *)&start_time);
}
+# endif
# ifndef DBG_HDRS_ALL
typed_test();
- if (print_stats) {
- CLOCK_TYPE typed_time;
+# ifndef NO_CLOCK
+ if (print_stats) {
+ CLOCK_TYPE typed_time;
- GET_TIME(typed_time);
- time_diff = MS_TIME_DIFF(typed_time, start_time);
- GC_log_printf("-------------Finished typed_test at time %u (%p)\n",
- (unsigned) time_diff, (void *)&start_time);
- }
+ GET_TIME(typed_time);
+ time_diff = MS_TIME_DIFF(typed_time, start_time);
+ GC_log_printf("-------------Finished typed_test at time %u (%p)\n",
+ (unsigned) time_diff, (void *)&start_time);
+ }
+# endif
# endif /* DBG_HDRS_ALL */
tree_test();
- if (print_stats) {
- CLOCK_TYPE tree_time;
+# ifndef NO_CLOCK
+ if (print_stats) {
+ CLOCK_TYPE tree_time;
- GET_TIME(tree_time);
- time_diff = MS_TIME_DIFF(tree_time, start_time);
- GC_log_printf("-------------Finished tree_test at time %u (%p)\n",
- (unsigned) time_diff, (void *)&start_time);
- }
+ GET_TIME(tree_time);
+ time_diff = MS_TIME_DIFF(tree_time, start_time);
+ GC_log_printf("-------------Finished tree_test at time %u (%p)\n",
+ (unsigned) time_diff, (void *)&start_time);
+ }
+# endif
/* Run reverse_test a second time, so we hopefully notice corruption. */
- reverse_test();
+ reverse_test();
+# ifndef NO_CLOCK
if (print_stats) {
GET_TIME(reverse_time);
time_diff = MS_TIME_DIFF(reverse_time, start_time);
@@ -1504,11 +1515,14 @@ void run_one_test(void)
"-------------Finished second reverse_test at time %u (%p)\n",
(unsigned)time_diff, (void *)&start_time);
}
+# endif
/* GC_allocate_ml and GC_need_to_lock are no longer exported, and */
/* AO_fetch_and_add1() may be unavailable to update a counter. */
(void)GC_call_with_alloc_lock(inc_int_counter, &n_tests);
- if (print_stats)
- GC_log_printf("Finished %p\n", (void *)&start_time);
+# ifndef NO_CLOCK
+ if (print_stats)
+ GC_log_printf("Finished %p\n", (void *)&start_time);
+# endif
}
void GC_CALLBACK reachable_objs_counter(void *obj, size_t size,