Mercurial > hg > CbC > CbC_gcc
comparison gcc/ggc-zone.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
34 #include "flags.h" | 34 #include "flags.h" |
35 #include "ggc.h" | 35 #include "ggc.h" |
36 #include "timevar.h" | 36 #include "timevar.h" |
37 #include "params.h" | 37 #include "params.h" |
38 #include "bitmap.h" | 38 #include "bitmap.h" |
39 #include "plugin.h" | |
39 | 40 |
40 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a | 41 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a |
41 file open. Prefer either to valloc. */ | 42 file open. Prefer either to valloc. */ |
42 #ifdef HAVE_MMAP_ANON | 43 #ifdef HAVE_MMAP_ANON |
43 # undef HAVE_MMAP_DEV_ZERO | 44 # undef HAVE_MMAP_DEV_ZERO |
423 unsigned long long total_overhead; | 424 unsigned long long total_overhead; |
424 | 425 |
425 /* Total allocations and overhead for sizes less than 32, 64 and 128. | 426 /* Total allocations and overhead for sizes less than 32, 64 and 128. |
426 These sizes are interesting because they are typical cache line | 427 These sizes are interesting because they are typical cache line |
427 sizes. */ | 428 sizes. */ |
428 | 429 |
429 unsigned long long total_allocated_under32; | 430 unsigned long long total_allocated_under32; |
430 unsigned long long total_overhead_under32; | 431 unsigned long long total_overhead_under32; |
431 | 432 |
432 unsigned long long total_allocated_under64; | 433 unsigned long long total_allocated_under64; |
433 unsigned long long total_overhead_under64; | 434 unsigned long long total_overhead_under64; |
434 | 435 |
435 unsigned long long total_allocated_under128; | 436 unsigned long long total_allocated_under128; |
436 unsigned long long total_overhead_under128; | 437 unsigned long long total_overhead_under128; |
437 } stats; | 438 } stats; |
438 #endif | 439 #endif |
439 } main_zone; | 440 } main_zone; |
1312 VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (result, orig_size)); | 1313 VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (result, orig_size)); |
1313 | 1314 |
1314 /* Keep track of how many bytes are being allocated. This | 1315 /* Keep track of how many bytes are being allocated. This |
1315 information is used in deciding when to collect. */ | 1316 information is used in deciding when to collect. */ |
1316 zone->allocated += size; | 1317 zone->allocated += size; |
1317 | 1318 |
1318 timevar_ggc_mem_total += size; | 1319 timevar_ggc_mem_total += size; |
1319 | 1320 |
1320 #ifdef GATHER_STATISTICS | 1321 #ifdef GATHER_STATISTICS |
1321 ggc_record_overhead (orig_size, size - orig_size, result PASS_MEM_STAT); | 1322 ggc_record_overhead (orig_size, size - orig_size, result PASS_MEM_STAT); |
1322 | 1323 |
1518 { | 1519 { |
1519 size_t mark_word, mark_bit, offset; | 1520 size_t mark_word, mark_bit, offset; |
1520 offset = (ptr - pch_zone.page) / BYTES_PER_MARK_BIT; | 1521 offset = (ptr - pch_zone.page) / BYTES_PER_MARK_BIT; |
1521 mark_word = offset / (8 * sizeof (mark_type)); | 1522 mark_word = offset / (8 * sizeof (mark_type)); |
1522 mark_bit = offset % (8 * sizeof (mark_type)); | 1523 mark_bit = offset % (8 * sizeof (mark_type)); |
1523 | 1524 |
1524 if (pch_zone.mark_bits[mark_word] & (1 << mark_bit)) | 1525 if (pch_zone.mark_bits[mark_word] & (1 << mark_bit)) |
1525 return 1; | 1526 return 1; |
1526 pch_zone.mark_bits[mark_word] |= (1 << mark_bit); | 1527 pch_zone.mark_bits[mark_word] |= (1 << mark_bit); |
1527 } | 1528 } |
1528 else if (page->large_p) | 1529 else if (page->large_p) |
1568 { | 1569 { |
1569 size_t mark_word, mark_bit, offset; | 1570 size_t mark_word, mark_bit, offset; |
1570 offset = (ptr - pch_zone.page) / BYTES_PER_MARK_BIT; | 1571 offset = (ptr - pch_zone.page) / BYTES_PER_MARK_BIT; |
1571 mark_word = offset / (8 * sizeof (mark_type)); | 1572 mark_word = offset / (8 * sizeof (mark_type)); |
1572 mark_bit = offset % (8 * sizeof (mark_type)); | 1573 mark_bit = offset % (8 * sizeof (mark_type)); |
1573 | 1574 |
1574 return (pch_zone.mark_bits[mark_word] & (1 << mark_bit)) != 0; | 1575 return (pch_zone.mark_bits[mark_word] & (1 << mark_bit)) != 0; |
1575 } | 1576 } |
1576 | 1577 |
1577 if (page->large_p) | 1578 if (page->large_p) |
1578 { | 1579 { |
1960 ggc_mark_roots (); | 1961 ggc_mark_roots (); |
1961 #ifdef GATHER_STATISTICS | 1962 #ifdef GATHER_STATISTICS |
1962 ggc_prune_overhead_list (); | 1963 ggc_prune_overhead_list (); |
1963 #endif | 1964 #endif |
1964 } | 1965 } |
1965 | 1966 |
1966 sweep_pages (zone); | 1967 sweep_pages (zone); |
1967 zone->was_collected = true; | 1968 zone->was_collected = true; |
1968 zone->allocated_last_gc = zone->allocated; | 1969 zone->allocated_last_gc = zone->allocated; |
1969 | 1970 |
1970 if (!quiet_flag) | 1971 if (!quiet_flag) |
2026 { | 2027 { |
2027 timevar_pop (TV_GC); | 2028 timevar_pop (TV_GC); |
2028 return; | 2029 return; |
2029 } | 2030 } |
2030 } | 2031 } |
2032 | |
2033 invoke_plugin_callbacks (PLUGIN_GGC_START, NULL); | |
2031 | 2034 |
2032 /* Start by possibly collecting the main zone. */ | 2035 /* Start by possibly collecting the main zone. */ |
2033 main_zone.was_collected = false; | 2036 main_zone.was_collected = false; |
2034 marked |= ggc_collect_1 (&main_zone, true); | 2037 marked |= ggc_collect_1 (&main_zone, true); |
2035 | 2038 |
2091 release_pages (dead_zone); | 2094 release_pages (dead_zone); |
2092 free (dead_zone); | 2095 free (dead_zone); |
2093 } | 2096 } |
2094 } | 2097 } |
2095 | 2098 |
2099 invoke_plugin_callbacks (PLUGIN_GGC_END, NULL); | |
2100 | |
2096 timevar_pop (TV_GC); | 2101 timevar_pop (TV_GC); |
2097 } | 2102 } |
2098 | 2103 |
2099 /* Print allocation statistics. */ | 2104 /* Print allocation statistics. */ |
2100 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \ | 2105 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \ |
2171 { | 2176 { |
2172 in_use -= ggc_get_size (chunk); | 2177 in_use -= ggc_get_size (chunk); |
2173 chunk = chunk->next_free; | 2178 chunk = chunk->next_free; |
2174 } | 2179 } |
2175 } | 2180 } |
2176 | 2181 |
2177 fprintf (stderr, "%20s %10lu%c %10lu%c %10lu%c\n", | 2182 fprintf (stderr, "%20s %10lu%c %10lu%c %10lu%c\n", |
2178 zone->name, | 2183 zone->name, |
2179 SCALE (allocated), LABEL (allocated), | 2184 SCALE (allocated), LABEL (allocated), |
2180 SCALE (in_use), LABEL (in_use), | 2185 SCALE (in_use), LABEL (in_use), |
2181 SCALE (overhead), LABEL (overhead)); | 2186 SCALE (overhead), LABEL (overhead)); |
2214 fprintf (stderr, "%20s %10lu%c %10lu%c %10lu%c\n", "Total", | 2219 fprintf (stderr, "%20s %10lu%c %10lu%c %10lu%c\n", "Total", |
2215 SCALE (total_bytes_mapped), LABEL (total_bytes_mapped), | 2220 SCALE (total_bytes_mapped), LABEL (total_bytes_mapped), |
2216 SCALE (total_allocated), LABEL(total_allocated), | 2221 SCALE (total_allocated), LABEL(total_allocated), |
2217 SCALE (total_overhead), LABEL (total_overhead)); | 2222 SCALE (total_overhead), LABEL (total_overhead)); |
2218 | 2223 |
2219 #ifdef GATHER_STATISTICS | 2224 #ifdef GATHER_STATISTICS |
2220 { | 2225 { |
2221 unsigned long long all_overhead = 0, all_allocated = 0; | 2226 unsigned long long all_overhead = 0, all_allocated = 0; |
2222 unsigned long long all_overhead_under32 = 0, all_allocated_under32 = 0; | 2227 unsigned long long all_overhead_under32 = 0, all_allocated_under32 = 0; |
2223 unsigned long long all_overhead_under64 = 0, all_allocated_under64 = 0; | 2228 unsigned long long all_overhead_under64 = 0, all_allocated_under64 = 0; |
2224 unsigned long long all_overhead_under128 = 0, all_allocated_under128 = 0; | 2229 unsigned long long all_overhead_under128 = 0, all_allocated_under128 = 0; |
2233 all_allocated_under32 += zone->stats.total_allocated_under32; | 2238 all_allocated_under32 += zone->stats.total_allocated_under32; |
2234 all_overhead_under32 += zone->stats.total_overhead_under32; | 2239 all_overhead_under32 += zone->stats.total_overhead_under32; |
2235 | 2240 |
2236 all_allocated_under64 += zone->stats.total_allocated_under64; | 2241 all_allocated_under64 += zone->stats.total_allocated_under64; |
2237 all_overhead_under64 += zone->stats.total_overhead_under64; | 2242 all_overhead_under64 += zone->stats.total_overhead_under64; |
2238 | 2243 |
2239 all_allocated_under128 += zone->stats.total_allocated_under128; | 2244 all_allocated_under128 += zone->stats.total_allocated_under128; |
2240 all_overhead_under128 += zone->stats.total_overhead_under128; | 2245 all_overhead_under128 += zone->stats.total_overhead_under128; |
2241 | 2246 |
2242 fprintf (stderr, "%20s: %10lld\n", | 2247 fprintf (stderr, "%20s: %10lld\n", |
2243 zone->name, zone->stats.total_allocated); | 2248 zone->name, zone->stats.total_allocated); |