+2019-10-11 Jan Hubicka <hubicka@ucw.cz>
+
+ * ggc-page.c (release_pages): Output statistics when !quiet_flag.
+ (ggc_collect): Dump later to not interfere with release_page dump.
+ (ggc_trim): New function.
+ * ggc-none.c (ggc_trim): New.
+ * ggc.h (ggc_trim): Declare.
+
2019-10-11 Richard Biener <rguenther@suse.de>
PR tree-optimization/92066
#endif
static struct page_entry * alloc_page (unsigned);
static void free_page (struct page_entry *);
-static void release_pages (void);
static void clear_marks (void);
static void sweep_pages (void);
static void ggc_recalculate_in_use_p (page_entry *);
static void
release_pages (void)
{
+ size_t n1 = 0;
+ size_t n2 = 0;
#ifdef USING_MADVISE
page_entry *p, *start_p;
char *start;
else
G.free_pages = p;
G.bytes_mapped -= mapped_len;
+ n1 += len;
continue;
}
prev = newprev;
/* Don't count those pages as mapped to not touch the garbage collector
unnecessarily. */
G.bytes_mapped -= len;
+ n2 += len;
while (start_p != p)
{
start_p->discarded = true;
}
munmap (start, len);
+ n1 += len;
G.bytes_mapped -= len;
}
*gp = g->next;
G.bytes_mapped -= g->alloc_size;
free (g->allocation);
+ n1 += g->alloc_size;
}
else
gp = &g->next;
#endif
+ if (!quiet_flag && (n1 || n2))
+ {
+ fprintf (stderr, " {GC");
+ if (n1)
+ fprintf (stderr, " released %luk", (unsigned long)(n1 / 1024));
+ if (n2)
+ fprintf (stderr, " madv_dontneed %luk", (unsigned long)(n2 / 1024));
+ fprintf (stderr, "}");
+ }
}
/* This table provides a fast way to determine ceil(log_2(size)) for
return;
timevar_push (TV_GC);
- if (!quiet_flag)
- fprintf (stderr, " {GC %luk -> ", (unsigned long) G.allocated / 1024);
if (GGC_DEBUG_LEVEL >= 2)
fprintf (G.debug_file, "BEGIN COLLECTING\n");
/* Zero the total allocated bytes. This will be recalculated in the
sweep phase. */
+ size_t allocated = G.allocated;
G.allocated = 0;
/* Release the pages we freed the last time we collected, but didn't
reuse in the interim. */
release_pages ();
+ /* Output this later so we do not interfere with release_pages. */
+ if (!quiet_flag)
+ fprintf (stderr, " {GC %luk -> ", (unsigned long) allocated / 1024);
+
/* Indicate that we've seen collections at this context depth. */
G.context_depth_collections = ((unsigned long)1 << (G.context_depth + 1)) - 1;
fprintf (G.debug_file, "END COLLECTING\n");
}
-/* Assume that all GGC memory is reachable and grow the limits for next collection.
- With checking, trigger GGC so -Q compilation outputs how much of memory really is
- reachable. */
+/* Return free pages to the system. */
+
+void
+ggc_trim ()
+{
+ timevar_push (TV_GC);
+ G.allocated = 0;
+ sweep_pages ();
+ release_pages ();
+ if (!quiet_flag)
+ fprintf (stderr, " {GC trimmed to %luk, %luk mapped}",
+ (unsigned long) G.allocated / 1024,
+ (unsigned long) G.bytes_mapped / 1024);
+ timevar_pop (TV_GC);
+}
+
+/* Assume that all GGC memory is reachable and grow the limits for next
+ collection. With checking, trigger GGC so -Q compilation outputs how much
+ of memory really is reachable. */
void
ggc_grow (void)