aboutsummaryrefslogtreecommitdiff
path: root/gcc/ggc-zone.c
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2012-07-24 09:49:56 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2012-07-24 09:49:56 +0000
commit7aa6d18a7c51ff7b19149d1e03db839b6b1033dc (patch)
tree7524c306e4effe5958489e003d2bb147a0439144 /gcc/ggc-zone.c
parent38ad2d079800cafd77f35c32a335697f643fa1a3 (diff)
downloadgcc-7aa6d18a7c51ff7b19149d1e03db839b6b1033dc.zip
gcc-7aa6d18a7c51ff7b19149d1e03db839b6b1033dc.tar.gz
gcc-7aa6d18a7c51ff7b19149d1e03db839b6b1033dc.tar.bz2
sbitmap.h (SBITMAP_ELT_BITS): Use "1u" trick as for BITMAP_WORD_BITS.
gcc/ * sbitmap.h (SBITMAP_ELT_BITS): Use "1u" trick as for BITMAP_WORD_BITS. Move test to check that there is a popcount function for the the number of bits in SBITMAP_ELT_BITS to sbitmap.c. * sbitmap.c: Test SBITMAP_ELT_BITS, not HOST_BITS_PER_WIDEST_FAST_INT. MEM_STAT_INFO): Define in terms of their ALONE counterparts. * configure.ac (GATHER_STATISTICS): Always define, non-zero if enabled. * configure: Regenerate. * statistics.h (GATHER_STATISTICS): Error out if it is not defined. (GCC_MEM_STAT_ARGUMENTS): New define. (ALONE_MEM_STAT_DECL): Define in terms of GCC_MEM_STAT_ARGUMENTS. (ALONE_FINAL_MEM_STAT_DECL, ALONE_FINAL_PASS_MEM_STAT): New defines. (MEM_STAT_DECL, FINAL_MEM_STAT_DECL, PASS_MEM_STAT, FINAL_PASS_MEM_STAT, * ggc-internal.h (ggc_record_overhead): Use FINAL_MEM_STAT_DECL. * ggc.h (ggc_record_overhead, ggc_free_overhead, ggc_prune_overhead_list): Remove internal prototypes, they are defined already in ggc-internal.h. * ggc-common.c (struct loc_descriptor): Remove #ifdef GATHER_STATISTICS wrappers. (add_statistics): Likewise. (dump_ggc_loc_statistics): Likewise. Return if GATHER_STATISTICS is 0. * ggc-zone.c (struct page_entry): Remove #ifdef GATHER_STATISTICS wrappers around "survived" and "stats" members. (alloc_large_page): Always initialize survived. (ggc_internal_alloc_zone_stat): Likewise. Remove #ifdef GATHER_STATISTICS wrappers. Record overhead if GATHER_STATISTICS is non-0. (ggc_free): Convert #ifdef GATHER_STATISTICS to if-code. (sweep_pages): Always increase survived. (ggc_collect_1): Convert #ifdef GATHER_STATISTICS to if-code. (calculate_average_page_survival): Always define. (ggc_collect): Convert #ifdef GATHER_STATISTICS to if-code. (ggc_print_statistics): Likewise. (ggc_pch_read): Likewise. * ggc-page.c (struct globals): Always define "stats" member. (ggc_internal_alloc_stat): Convert #ifdef GATHER_STATISTICS to if-code. (ggc_free): Likewise. (ggc_collec): Likewise. (ggc_print_statistics): Likewise. * bitmap.h (struct bitmap_head_def): Always define "desc" member. (bitmap_initialize_stat): Convert #ifdef GATHER_STATISTICS to if-code. * gimple.h (enum gimple_alloc_kind): Always define. (gimple_alloc_kind): Likewise. * tree-flow.h (phinodes_print_statistics): Always define. (ssanames_print_statistics): Likewise. * vec.h (vec_heap_free): Always define. (VEC_stack_alloc): Define if GATHER_STATISTICS is non-0. * alloc-pool.c (alloc_pool_descriptor): Always define. (create_alloc_pool): Convert #ifdef GATHER_STATISTICS to if-code. (empty_alloc_pool): Likewise. (pool_alloc): Likewise. (pool_free): Likewise. (dump_alloc_pool_statistics): Likewise. (print_statistics): Always define. * bitmap.c (struct bitmap_descriptor): Always define. (bitmap_register): Pass ALONE_FINAL_PASS_MEM_STAT. (register_overhead): Always define. (bitmap_element_free): Convert #ifdef GATHER_STATISTICS to if-code. (bitmap_element_allocate): Likewise. (bitmap_elt_clear_from): Likewise. (bitmap_obstack_alloc_stat): Likewise. (bitmap_gc_alloc_stat): Likewise. (bitmap_obstack_free): Likewise. (bitmap_find_bit): Likewise. (bitmap_ior_and_into): Likewise. (bitmap_print): Likewise. (dump_bitmap_statistics): Likewise. Return if GATHER_STATISTICS is 0. * gimple.c (gimple_alloc_counts, gimple_alloc_sizes): Always define. (gimple_alloc_kind_names): Likewise. (gimple_alloc_stat): Convert #ifdef GATHER_STATISTICS to if-code. (dump_gimple_statistics): Likewise. Return if GATHER_STATISTICS is 0. * rtl.c (rtx_alloc_counts, rtx_alloc_sizes, rtvec_alloc_counts, rtvec_alloc_sizes): Always define. (rvec_alloc): Convert #ifdef GATHER_STATISTICS to if-code. (rtx_alloc_stat): Likewise. (dump_rtx_statistics): Likewise. Return if GATHER_STATISTICS is 0. * tree.c (_obstack_allocated_p, tree_code_counts, tree_node_counts, tree_node_sizes, tree_node_kind_names): Always define. (record_node_allocation_statistics): Convert #ifdef GATHER_STATISTICS to if-code. (type_hash_canon): Likewise. (dump_tree_statistics): Likewise. * tree-ssanames.c (ssa_name_nodes_reused, ssa_name_nodes_created): Always define. (ssanames_print_statistics): Likewise. (make_ssa_name_fn): Convert #ifdef GATHER_STATISTICS to if-code. * tree-phinodes.c (phi_nodes_reused, phi_nodes_created): Always define. (phinodes_print_statistics): Likewise. (allocate_phi_node): Convert #ifdef GATHER_STATISTICS to if-code. * vec.c (struct vec_descriptor): Always define. (hash_descriptor, eq_descriptor, ptr_hash_entry, hash_ptr, eq_ptr, vec_descriptor, rester_overhead, free_overhead): Likewise. (cmp_statistic): Likewise. (vec_heap_free): Convert #ifdef GATHER_STATISTICS to if-code. (vec_heap_o_reserve_1): Likewise. (dump_vec_loc_statistics): Likewise. cp/ * cp/class.c (n_vtables, n_vtable_entries, n_vtable_searches, n_vtable_elems, n_convert_harshness, n_compute_conversion_costs, n_inner_fields_searched): Always define. (build_primary_vtable): Convert #ifdef GATHER_STATISTICS to if-code. (print_class_statistics): Convert #ifdef GATHER_STATISTICS to if-code. * cp/tree.c (depth_reached): Always define global. (cxx_print_statistics): Convert #ifdef GATHER_STATISTICS to if-code. * cp/pt.c (depth_reached): Always define. (push_tinst_level): Convert #ifdef GATHER_STATISTICS to if-code. * cp/search.c (n_fields_searched, n_calls_lookup_field, n_calls_lookup_field_1, n_calls_lookup_fnfields, n_calls_lookup_fnfields_1, n_calls_get_base_type, n_outer_fields_searched, n_contexts_saved): Always define. (lookup_field_1): Convert #ifdef GATHER_STATISTICS to if-code. (lookup_member): Likewise. (lookup_fnfields_idx_nolazy): Likewise. (print_search_statistics): Likewise. (reinit_search_statistics): Unconditionally re-set counters. * cp/lex.c (retrofit_lang_decl): Convert #ifdef GATHER_STATISTICS to if-code. (cxx_dup_lang_specific_decl): Likewise. (copy_lang_type): Likewise. (cxx_make_type): Likewise. From-SVN: r189803
Diffstat (limited to 'gcc/ggc-zone.c')
-rw-r--r--gcc/ggc-zone.c128
1 files changed, 55 insertions, 73 deletions
diff --git a/gcc/ggc-zone.c b/gcc/ggc-zone.c
index 5257ada..baf8076 100644
--- a/gcc/ggc-zone.c
+++ b/gcc/ggc-zone.c
@@ -216,10 +216,8 @@ typedef struct page_entry
/* The zone that this page entry belongs to. */
struct alloc_zone *zone;
-#ifdef GATHER_STATISTICS
/* How many collections we've survived. */
size_t survived;
-#endif
/* Does this page contain small objects, or one large object? */
bool large_p;
@@ -403,7 +401,6 @@ struct alloc_zone
/* True if this zone should be destroyed after the next collection. */
bool dead;
-#ifdef GATHER_STATISTICS
struct
{
/* Total GC-allocated memory. */
@@ -424,7 +421,6 @@ struct alloc_zone
unsigned long long total_allocated_under128;
unsigned long long total_overhead_under128;
} stats;
-#endif
} main_zone;
/* Some default zones. */
@@ -931,9 +927,7 @@ alloc_large_page (size_t size, struct alloc_zone *zone)
entry->common.large_p = true;
entry->common.pch_p = false;
entry->common.zone = zone;
-#ifdef GATHER_STATISTICS
entry->common.survived = 0;
-#endif
entry->mark_p = false;
entry->bytes = size;
entry->prev = NULL;
@@ -1250,9 +1244,7 @@ ggc_internal_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
{
struct large_page_entry *entry = alloc_large_page (size, zone);
-#ifdef GATHER_STATISTICS
entry->common.survived = 0;
-#endif
entry->next = zone->large_pages;
if (zone->large_pages)
@@ -1315,8 +1307,8 @@ ggc_internal_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
timevar_ggc_mem_total += size;
-#ifdef GATHER_STATISTICS
- ggc_record_overhead (orig_size, size - orig_size, result PASS_MEM_STAT);
+ if (GATHER_STATISTICS)
+ ggc_record_overhead (orig_size, size - orig_size, result FINAL_PASS_MEM_STAT);
{
size_t object_size = size;
@@ -1413,9 +1405,8 @@ ggc_free (void *p)
{
struct page_entry *page;
-#ifdef GATHER_STATISTICS
- ggc_free_overhead (p);
-#endif
+ if (GATHER_STATISTICS)
+ ggc_free_overhead (p);
poison_region (p, ggc_get_size (p));
@@ -1753,10 +1744,8 @@ sweep_pages (struct alloc_zone *zone)
lnext = lp->next;
-#ifdef GATHER_STATISTICS
/* This page has now survived another collection. */
lp->common.survived++;
-#endif
if (lp->mark_p)
{
@@ -1791,10 +1780,8 @@ sweep_pages (struct alloc_zone *zone)
snext = sp->next;
-#ifdef GATHER_STATISTICS
/* This page has now survived another collection. */
sp->common.survived++;
-#endif
/* Step through all chunks, consolidate those that are free and
insert them into the free lists. Note that consolidation
@@ -1948,9 +1935,8 @@ ggc_collect_1 (struct alloc_zone *zone, bool need_marking)
{
zone_allocate_marks ();
ggc_mark_roots ();
-#ifdef GATHER_STATISTICS
- ggc_prune_overhead_list ();
-#endif
+ if (GATHER_STATISTICS)
+ ggc_prune_overhead_list ();
}
sweep_pages (zone);
@@ -1962,7 +1948,6 @@ ggc_collect_1 (struct alloc_zone *zone, bool need_marking)
return true;
}
-#ifdef GATHER_STATISTICS
/* Calculate the average page survival rate in terms of number of
collections. */
@@ -1985,7 +1970,6 @@ calculate_average_page_survival (struct alloc_zone *zone)
}
return survival/count;
}
-#endif
/* Top level collection routine. */
@@ -2047,9 +2031,8 @@ ggc_collect (void)
}
}
-#ifdef GATHER_STATISTICS
/* Print page survival stats, if someone wants them. */
- if (GGC_DEBUG_LEVEL >= 2)
+ if (GATHER_STATISTICS && GGC_DEBUG_LEVEL >= 2)
{
for (zone = G.zones; zone; zone = zone->next_zone)
{
@@ -2061,7 +2044,6 @@ ggc_collect (void)
}
}
}
-#endif
if (marked)
zone_free_marks ();
@@ -2210,54 +2192,53 @@ ggc_print_statistics (void)
SCALE (total_allocated), LABEL(total_allocated),
SCALE (total_overhead), LABEL (total_overhead));
-#ifdef GATHER_STATISTICS
- {
- unsigned long long all_overhead = 0, all_allocated = 0;
- unsigned long long all_overhead_under32 = 0, all_allocated_under32 = 0;
- unsigned long long all_overhead_under64 = 0, all_allocated_under64 = 0;
- unsigned long long all_overhead_under128 = 0, all_allocated_under128 = 0;
+ if (GATHER_STATISTICS)
+ {
+ unsigned long long all_overhead = 0, all_allocated = 0;
+ unsigned long long all_overhead_under32 = 0, all_allocated_under32 = 0;
+ unsigned long long all_overhead_under64 = 0, all_allocated_under64 = 0;
+ unsigned long long all_overhead_under128 = 0, all_allocated_under128 = 0;
- fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
+ fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
- for (zone = G.zones; zone; zone = zone->next_zone)
- {
- all_overhead += zone->stats.total_overhead;
- all_allocated += zone->stats.total_allocated;
+ for (zone = G.zones; zone; zone = zone->next_zone)
+ {
+ all_overhead += zone->stats.total_overhead;
+ all_allocated += zone->stats.total_allocated;
- all_allocated_under32 += zone->stats.total_allocated_under32;
- all_overhead_under32 += zone->stats.total_overhead_under32;
+ all_allocated_under32 += zone->stats.total_allocated_under32;
+ all_overhead_under32 += zone->stats.total_overhead_under32;
- all_allocated_under64 += zone->stats.total_allocated_under64;
- all_overhead_under64 += zone->stats.total_overhead_under64;
+ all_allocated_under64 += zone->stats.total_allocated_under64;
+ all_overhead_under64 += zone->stats.total_overhead_under64;
- all_allocated_under128 += zone->stats.total_allocated_under128;
- all_overhead_under128 += zone->stats.total_overhead_under128;
+ all_allocated_under128 += zone->stats.total_allocated_under128;
+ all_overhead_under128 += zone->stats.total_overhead_under128;
- fprintf (stderr, "%20s: %10lld\n",
- zone->name, zone->stats.total_allocated);
- }
+ fprintf (stderr, "%20s: %10lld\n",
+ zone->name, zone->stats.total_allocated);
+ }
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Total Overhead: %10lld\n",
- all_overhead);
- fprintf (stderr, "Total Allocated: %10lld\n",
- all_allocated);
-
- fprintf (stderr, "Total Overhead under 32B: %10lld\n",
- all_overhead_under32);
- fprintf (stderr, "Total Allocated under 32B: %10lld\n",
- all_allocated_under32);
- fprintf (stderr, "Total Overhead under 64B: %10lld\n",
- all_overhead_under64);
- fprintf (stderr, "Total Allocated under 64B: %10lld\n",
- all_allocated_under64);
- fprintf (stderr, "Total Overhead under 128B: %10lld\n",
- all_overhead_under128);
- fprintf (stderr, "Total Allocated under 128B: %10lld\n",
- all_allocated_under128);
- }
-#endif
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "Total Overhead: %10lld\n",
+ all_overhead);
+ fprintf (stderr, "Total Allocated: %10lld\n",
+ all_allocated);
+
+ fprintf (stderr, "Total Overhead under 32B: %10lld\n",
+ all_overhead_under32);
+ fprintf (stderr, "Total Allocated under 32B: %10lld\n",
+ all_allocated_under32);
+ fprintf (stderr, "Total Overhead under 64B: %10lld\n",
+ all_overhead_under64);
+ fprintf (stderr, "Total Allocated under 64B: %10lld\n",
+ all_allocated_under64);
+ fprintf (stderr, "Total Overhead under 128B: %10lld\n",
+ all_overhead_under128);
+ fprintf (stderr, "Total Allocated under 128B: %10lld\n",
+ all_allocated_under128);
+ }
}
/* Precompiled header support. */
@@ -2472,13 +2453,14 @@ ggc_pch_read (FILE *f, void *addr)
pch_zone.page = (char *) addr;
pch_zone.end = (char *) pch_zone.alloc_bits;
- /* We've just read in a PCH file. So, every object that used to be
- allocated is now free. */
-#ifdef GATHER_STATISTICS
- zone_allocate_marks ();
- ggc_prune_overhead_list ();
- zone_free_marks ();
-#endif
+ if (GATHER_STATISTICS)
+ {
+ /* We've just read in a PCH file. So, every object that used to be
+ allocated is now free. */
+ zone_allocate_marks ();
+ ggc_prune_overhead_list ();
+ zone_free_marks ();
+ }
for (zone = G.zones; zone; zone = zone->next_zone)
{