1*e4b17023SJohn Marino /* Garbage collection for the GNU compiler. Internal definitions 2*e4b17023SJohn Marino for ggc-*.c and stringpool.c. 3*e4b17023SJohn Marino 4*e4b17023SJohn Marino Copyright (C) 2009, 2010 Free Software Foundation, Inc. 5*e4b17023SJohn Marino 6*e4b17023SJohn Marino This file is part of GCC. 7*e4b17023SJohn Marino 8*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under 9*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free 10*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later 11*e4b17023SJohn Marino version. 12*e4b17023SJohn Marino 13*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY 14*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or 15*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16*e4b17023SJohn Marino for more details. 17*e4b17023SJohn Marino 18*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 19*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 20*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 21*e4b17023SJohn Marino 22*e4b17023SJohn Marino #ifndef GCC_GGC_INTERNAL_H 23*e4b17023SJohn Marino #define GCC_GGC_INTERNAL_H 24*e4b17023SJohn Marino 25*e4b17023SJohn Marino #include "ggc.h" 26*e4b17023SJohn Marino 27*e4b17023SJohn Marino /* Call ggc_set_mark on all the roots. */ 28*e4b17023SJohn Marino extern void ggc_mark_roots (void); 29*e4b17023SJohn Marino 30*e4b17023SJohn Marino /* Stringpool. */ 31*e4b17023SJohn Marino 32*e4b17023SJohn Marino /* Mark the entries in the string pool. */ 33*e4b17023SJohn Marino extern void ggc_mark_stringpool (void); 34*e4b17023SJohn Marino 35*e4b17023SJohn Marino /* Purge the entries in the string pool. */ 36*e4b17023SJohn Marino extern void ggc_purge_stringpool (void); 37*e4b17023SJohn Marino 38*e4b17023SJohn Marino /* Save and restore the string pool entries for PCH. */ 39*e4b17023SJohn Marino 40*e4b17023SJohn Marino extern void gt_pch_save_stringpool (void); 41*e4b17023SJohn Marino extern void gt_pch_fixup_stringpool (void); 42*e4b17023SJohn Marino extern void gt_pch_restore_stringpool (void); 43*e4b17023SJohn Marino 44*e4b17023SJohn Marino /* PCH and GGC handling for strings, mostly trivial. */ 45*e4b17023SJohn Marino extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *); 46*e4b17023SJohn Marino 47*e4b17023SJohn Marino /* PCH. */ 48*e4b17023SJohn Marino 49*e4b17023SJohn Marino struct ggc_pch_data; 50*e4b17023SJohn Marino 51*e4b17023SJohn Marino /* Return a new ggc_pch_data structure. */ 52*e4b17023SJohn Marino extern struct ggc_pch_data *init_ggc_pch (void); 53*e4b17023SJohn Marino 54*e4b17023SJohn Marino /* The second parameter and third parameters give the address and size 55*e4b17023SJohn Marino of an object. Update the ggc_pch_data structure with as much of 56*e4b17023SJohn Marino that information as is necessary. The bool argument should be true 57*e4b17023SJohn Marino if the object is a string. */ 58*e4b17023SJohn Marino extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool, 59*e4b17023SJohn Marino enum gt_types_enum); 60*e4b17023SJohn Marino 61*e4b17023SJohn Marino /* Return the total size of the data to be written to hold all 62*e4b17023SJohn Marino the objects previously passed to ggc_pch_count_object. */ 63*e4b17023SJohn Marino extern size_t ggc_pch_total_size (struct ggc_pch_data *); 64*e4b17023SJohn Marino 65*e4b17023SJohn Marino /* The objects, when read, will most likely be at the address 66*e4b17023SJohn Marino in the second parameter. */ 67*e4b17023SJohn Marino extern void ggc_pch_this_base (struct ggc_pch_data *, void *); 68*e4b17023SJohn Marino 69*e4b17023SJohn Marino /* Assuming that the objects really do end up at the address 70*e4b17023SJohn Marino passed to ggc_pch_this_base, return the address of this object. 71*e4b17023SJohn Marino The bool argument should be true if the object is a string. */ 72*e4b17023SJohn Marino extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool, 73*e4b17023SJohn Marino enum gt_types_enum); 74*e4b17023SJohn Marino 75*e4b17023SJohn Marino /* Write out any initial information required. */ 76*e4b17023SJohn Marino extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *); 77*e4b17023SJohn Marino 78*e4b17023SJohn Marino /* Write out this object, including any padding. The last argument should be 79*e4b17023SJohn Marino true if the object is a string. */ 80*e4b17023SJohn Marino extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *, 81*e4b17023SJohn Marino void *, size_t, bool); 82*e4b17023SJohn Marino 83*e4b17023SJohn Marino /* All objects have been written, write out any final information 84*e4b17023SJohn Marino required. */ 85*e4b17023SJohn Marino extern void ggc_pch_finish (struct ggc_pch_data *, FILE *); 86*e4b17023SJohn Marino 87*e4b17023SJohn Marino /* A PCH file has just been read in at the address specified second 88*e4b17023SJohn Marino parameter. Set up the GC implementation for the new objects. */ 89*e4b17023SJohn Marino extern void ggc_pch_read (FILE *, void *); 90*e4b17023SJohn Marino 91*e4b17023SJohn Marino 92*e4b17023SJohn Marino /* Allocation and collection. */ 93*e4b17023SJohn Marino 94*e4b17023SJohn Marino /* When set, ggc_collect will do collection. */ 95*e4b17023SJohn Marino extern bool ggc_force_collect; 96*e4b17023SJohn Marino 97*e4b17023SJohn Marino extern void ggc_record_overhead (size_t, size_t, void * MEM_STAT_DECL); 98*e4b17023SJohn Marino 99*e4b17023SJohn Marino extern void ggc_free_overhead (void *); 100*e4b17023SJohn Marino 101*e4b17023SJohn Marino extern void ggc_prune_overhead_list (void); 102*e4b17023SJohn Marino 103*e4b17023SJohn Marino /* Return the number of bytes allocated at the indicated address. */ 104*e4b17023SJohn Marino extern size_t ggc_get_size (const void *); 105*e4b17023SJohn Marino 106*e4b17023SJohn Marino 107*e4b17023SJohn Marino /* Statistics. */ 108*e4b17023SJohn Marino 109*e4b17023SJohn Marino /* This structure contains the statistics common to all collectors. 110*e4b17023SJohn Marino Particular collectors can extend this structure. */ 111*e4b17023SJohn Marino typedef struct ggc_statistics 112*e4b17023SJohn Marino { 113*e4b17023SJohn Marino /* At present, we don't really gather any interesting statistics. */ 114*e4b17023SJohn Marino int unused; 115*e4b17023SJohn Marino } ggc_statistics; 116*e4b17023SJohn Marino 117*e4b17023SJohn Marino /* Used by the various collectors to gather and print statistics that 118*e4b17023SJohn Marino do not depend on the collector in use. */ 119*e4b17023SJohn Marino extern void ggc_print_common_statistics (FILE *, ggc_statistics *); 120*e4b17023SJohn Marino 121*e4b17023SJohn Marino #endif 122