[Git][cmucl/cmucl][issue-278-more-gencgc-debug-prints] Apply review suggestions
![](https://secure.gravatar.com/avatar/5634a99cd64dd70d4a6692c3031a1284.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-278-more-gencgc-debug-prints at cmucl / cmucl Commits: 0baf6aeb by Raymond Toy at 2024-03-07T08:27:59-08:00 Apply review suggestions Use `stderr` instead of `stdout` so we get unbuffered messages. For gcc and clang, define an `UNLIKELY` macro to give a hint that the `DPRINTF` condition is unlikely since `gencgc_verbose` is usually disabled. - - - - - 2 changed files: - src/lisp/gencgc.c - src/lisp/os.h Changes: ===================================== src/lisp/gencgc.c ===================================== @@ -6757,7 +6757,7 @@ scavenge_newspace_generation_one_scan(int generation) int i; DPRINTF(gencgc_verbose, - (stdout, "Starting one full scan of newspace generation %d\n", + (stderr, "Starting one full scan of newspace generation %d\n", generation)); for (i = 0; i < last_free_page; i++) { @@ -6865,7 +6865,7 @@ scavenge_newspace_generation_one_scan(int generation) } DPRINTF(gencgc_verbose, - (stdout, "Finished one full scan of newspace generation %d\n", + (stderr, "Finished one full scan of newspace generation %d\n", generation)); } @@ -6896,7 +6896,7 @@ scavenge_newspace_generation(int generation) int previous_new_areas_index; DPRINTF(gencgc_verbose, - (stdout, "Start scavenge_newspace_generation %d\n", generation)); + (stderr, "Start scavenge_newspace_generation %d\n", generation)); #define SC_NS_GEN_CK 0 #if SC_NS_GEN_CK @@ -7078,7 +7078,7 @@ scavenge_newspace_generation(int generation) #endif DPRINTF(gencgc_verbose, - (stdout, "Finished scavenge_newspace_generation %d\n", generation)); + (stderr, "Finished scavenge_newspace_generation %d\n", generation)); } @@ -7838,15 +7838,15 @@ garbage_collect_generation(int generation, int raise) #endif DPRINTF(gencgc_verbose, - (stdout, "Scavenging interrupt handlers ...\n")); + (stderr, "Scavenging interrupt handlers ...\n")); scavenge_interrupt_handlers(); DPRINTF(gencgc_verbose, - (stdout, "Done scavenging interrupt handlers\n")); + (stderr, "Done scavenging interrupt handlers\n")); DPRINTF(gencgc_verbose, - (stdout, "Scavenging the binding stack (%d bytes) ...\n", + (stderr, "Scavenging the binding stack (%d bytes) ...\n", ((lispobj *) get_binding_stack_pointer() - binding_stack) * sizeof(lispobj))); @@ -7855,7 +7855,7 @@ garbage_collect_generation(int generation, int raise) (lispobj *) get_binding_stack_pointer() - binding_stack); DPRINTF(gencgc_verbose, - (stdout, "Done scavenging the binding stack.\n")); + (stderr, "Done scavenging the binding stack.\n")); /* * Scavenge the scavenge_hooks in case this refers to a hook added @@ -7865,18 +7865,18 @@ garbage_collect_generation(int generation, int raise) */ DPRINTF(gencgc_verbose, - (stdout, "Scavenging the scavenger hooks ...\n")); + (stderr, "Scavenging the scavenger hooks ...\n")); scavenge(&scavenger_hooks, 1); DPRINTF(gencgc_verbose, - (stdout, "Done scavenging the scavenger hooks.\n")); + (stderr, "Done scavenging the scavenger hooks.\n")); static_space_size = (lispobj *) SymbolValue(STATIC_SPACE_FREE_POINTER) - static_space; DPRINTF(gencgc_verbose, - (stdout, "Scavenge static space: %ld bytes\n", + (stderr, "Scavenge static space: %ld bytes\n", static_space_size * sizeof(lispobj))); scavenge(static_space, static_space_size); ===================================== src/lisp/os.h ===================================== @@ -8,7 +8,13 @@ #include "lisp.h" -#define DPRINTF(t,a) { if (t) fprintf a; } +#if defined(__GNUC__) || defined(__clang__) +#define UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +#define UNLIKELY(x) (x) +#endif + +#define DPRINTF(t,a) { if (UNLIKELY(t)) fprintf a; } #ifdef DARWIN #include "Darwin-os.h" View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/0baf6aebd505f1182657b46a... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/0baf6aebd505f1182657b46a... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)