diff options
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r-- | gcc/ggc-page.c | 133 |
1 files changed, 64 insertions, 69 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index ff23092b1d7..d3d186d8d7f 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -432,7 +432,6 @@ static struct globals struct free_object *free_object_list; #endif -#ifdef GATHER_STATISTICS struct { /* Total GC-allocated memory. */ @@ -459,7 +458,6 @@ static struct globals /* The overhead for each of the allocation orders. */ unsigned long long total_overhead_per_order[NUM_ORDERS]; } stats; -#endif } G; /* The size in bytes required to maintain a bitmap for the objects @@ -1324,10 +1322,9 @@ ggc_internal_alloc_stat (size_t size MEM_STAT_DECL) /* Calculate the object's address. */ result = entry->page + object_offset; -#ifdef GATHER_STATISTICS - ggc_record_overhead (OBJECT_SIZE (order), OBJECT_SIZE (order) - size, - result PASS_MEM_STAT); -#endif + if (GATHER_STATISTICS) + ggc_record_overhead (OBJECT_SIZE (order), OBJECT_SIZE (order) - size, + result FINAL_PASS_MEM_STAT); #ifdef ENABLE_GC_CHECKING /* Keep poisoning-by-writing-0xaf the object, in an attempt to keep the @@ -1358,32 +1355,31 @@ ggc_internal_alloc_stat (size_t size MEM_STAT_DECL) /* For timevar statistics. */ timevar_ggc_mem_total += object_size; -#ifdef GATHER_STATISTICS - { - size_t overhead = object_size - size; + if (GATHER_STATISTICS) + { + size_t overhead = object_size - size; - G.stats.total_overhead += overhead; - G.stats.total_allocated += object_size; - G.stats.total_overhead_per_order[order] += overhead; - G.stats.total_allocated_per_order[order] += object_size; + G.stats.total_overhead += overhead; + G.stats.total_allocated += object_size; + G.stats.total_overhead_per_order[order] += overhead; + G.stats.total_allocated_per_order[order] += object_size; - if (size <= 32) - { - G.stats.total_overhead_under32 += overhead; - G.stats.total_allocated_under32 += object_size; - } - if (size <= 64) - { - G.stats.total_overhead_under64 += overhead; - G.stats.total_allocated_under64 += object_size; - } - if (size <= 128) - { - G.stats.total_overhead_under128 += overhead; - G.stats.total_allocated_under128 += object_size; - } - } -#endif + if (size <= 32) + { + G.stats.total_overhead_under32 += overhead; + G.stats.total_allocated_under32 += object_size; + } + if (size <= 64) + { + G.stats.total_overhead_under64 += overhead; + G.stats.total_allocated_under64 += object_size; + } + if (size <= 128) + { + G.stats.total_overhead_under128 += overhead; + G.stats.total_allocated_under128 += object_size; + } + } if (GGC_DEBUG_LEVEL >= 3) fprintf (G.debug_file, @@ -1524,9 +1520,8 @@ ggc_free (void *p) size_t order = pe->order; size_t size = OBJECT_SIZE (order); -#ifdef GATHER_STATISTICS - ggc_free_overhead (p); -#endif + if (GATHER_STATISTICS) + ggc_free_overhead (p); if (GGC_DEBUG_LEVEL >= 3) fprintf (G.debug_file, @@ -2070,9 +2065,10 @@ ggc_collect (void) clear_marks (); ggc_mark_roots (); -#ifdef GATHER_STATISTICS - ggc_prune_overhead_list (); -#endif + + if (GATHER_STATISTICS) + ggc_prune_overhead_list (); + poison_pages (); validate_free_objects (); sweep_pages (); @@ -2160,40 +2156,39 @@ ggc_print_statistics (void) SCALE (G.allocated), STAT_LABEL(G.allocated), SCALE (total_overhead), STAT_LABEL (total_overhead)); -#ifdef GATHER_STATISTICS - { - fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n"); - - fprintf (stderr, "Total Overhead: %10lld\n", - G.stats.total_overhead); - fprintf (stderr, "Total Allocated: %10lld\n", - G.stats.total_allocated); - - fprintf (stderr, "Total Overhead under 32B: %10lld\n", - G.stats.total_overhead_under32); - fprintf (stderr, "Total Allocated under 32B: %10lld\n", - G.stats.total_allocated_under32); - fprintf (stderr, "Total Overhead under 64B: %10lld\n", - G.stats.total_overhead_under64); - fprintf (stderr, "Total Allocated under 64B: %10lld\n", - G.stats.total_allocated_under64); - fprintf (stderr, "Total Overhead under 128B: %10lld\n", - G.stats.total_overhead_under128); - fprintf (stderr, "Total Allocated under 128B: %10lld\n", - G.stats.total_allocated_under128); - - for (i = 0; i < NUM_ORDERS; i++) - if (G.stats.total_allocated_per_order[i]) - { - fprintf (stderr, "Total Overhead page size %7lu: %10lld\n", - (unsigned long) OBJECT_SIZE (i), - G.stats.total_overhead_per_order[i]); - fprintf (stderr, "Total Allocated page size %7lu: %10lld\n", - (unsigned long) OBJECT_SIZE (i), - G.stats.total_allocated_per_order[i]); - } + if (GATHER_STATISTICS) + { + fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n"); + + fprintf (stderr, "Total Overhead: %10lld\n", + G.stats.total_overhead); + fprintf (stderr, "Total Allocated: %10lld\n", + G.stats.total_allocated); + + fprintf (stderr, "Total Overhead under 32B: %10lld\n", + G.stats.total_overhead_under32); + fprintf (stderr, "Total Allocated under 32B: %10lld\n", + G.stats.total_allocated_under32); + fprintf (stderr, "Total Overhead under 64B: %10lld\n", + G.stats.total_overhead_under64); + fprintf (stderr, "Total Allocated under 64B: %10lld\n", + G.stats.total_allocated_under64); + fprintf (stderr, "Total Overhead under 128B: %10lld\n", + G.stats.total_overhead_under128); + fprintf (stderr, "Total Allocated under 128B: %10lld\n", + G.stats.total_allocated_under128); + + for (i = 0; i < NUM_ORDERS; i++) + if (G.stats.total_allocated_per_order[i]) + { + fprintf (stderr, "Total Overhead page size %7lu: %10lld\n", + (unsigned long) OBJECT_SIZE (i), + G.stats.total_overhead_per_order[i]); + fprintf (stderr, "Total Allocated page size %7lu: %10lld\n", + (unsigned long) OBJECT_SIZE (i), + G.stats.total_allocated_per_order[i]); + } } -#endif } struct ggc_pch_ondisk |